Scenario picker handle names with first character numeric
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
<button name='x' def-key='x' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>X</button>
|
||||
<button name='y' def-key='y' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>Y</button>
|
||||
<button name='z' def-key='z' type='tiny' relative='pos pos-in' rel-anchor='prev' top='0' left='4'>Z</button>
|
||||
<button name='#' def-key='shift 3' type='tiny' relative='neg pos-in' anchor='j' top='0' left='32'>#</button>
|
||||
|
||||
<button name='cancel' type='regular' top='330' left='5'>Cancel</button>
|
||||
<button name='prev' type='left' def-key='left' relative='pos pos-in' rel-anchor='prev' top='0' left='14'/>
|
||||
|
@@ -1798,8 +1798,16 @@ class cChooseScenario {
|
||||
for(auto& hdr : scen_headers){
|
||||
// I just checked, and the scenario editor will let you name your scenario "" or " "!
|
||||
std::string name = name_alphabetical(hdr.name);
|
||||
if(!name.empty())
|
||||
me[name.substr(0, 1)].show();
|
||||
if(!name.empty()){
|
||||
// Starts with a letter:
|
||||
if(me.hasControl(name.substr(0, 1))){
|
||||
me[name.substr(0, 1)].show();
|
||||
}
|
||||
// Starts with a digit:
|
||||
else if(name[0] >= '0' && name[0] <= '9'){
|
||||
me["#"].show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1882,6 +1890,7 @@ public:
|
||||
stk.setPage(0);
|
||||
return true;
|
||||
});
|
||||
// Letter buttons scroll to an alphabetical position:
|
||||
for(int i = 0; i < 26; ++i){
|
||||
std::string letter(1, (char)('a' + i));
|
||||
me[letter].attachClickHandler([this](cDialog& me, std::string letter, eKeyMod) -> bool {
|
||||
@@ -1895,6 +1904,12 @@ public:
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// Number button scrolls to scenarios that start with symbols or digits:
|
||||
me["#"].attachClickHandler([this](cDialog& me, std::string letter, eKeyMod) -> bool {
|
||||
auto& stk = dynamic_cast<cStack&>(me["list"]);
|
||||
stk.setPage(1);
|
||||
return true;
|
||||
});
|
||||
|
||||
put_scen_info();
|
||||
|
||||
|
Reference in New Issue
Block a user