more convenient has_next_action()

This commit is contained in:
2024-08-31 16:25:16 -05:00
committed by Celtic Minstrel
parent 9573b47e70
commit 20bb7e4322
3 changed files with 9 additions and 6 deletions

View File

@@ -538,17 +538,17 @@ void cDialog::handle_events() {
cFramerateLimiter fps_limiter;
while(dialogNotToast) {
if(replaying && has_next_action() && next_action_type() == "control_click"){
if(replaying && has_next_action("control_click")){
Element& next_action = pop_next_action();
auto info = info_from_action(next_action);
if(info["id"].empty()) continue;
eKeyMod mods = static_cast<eKeyMod>(std::stoi(info["mods"]));
controls[info["id"]]->triggerClickHandler(*this, info["id"], mods);
}else if(replaying && has_next_action() && next_action_type() == "field_input"){
}else if(replaying && has_next_action("field_input")){
Element& next_action = pop_next_action();
cKey key = key_from_action(next_action);
dynamic_cast<cTextField&>(getControl(currentFocus)).handleInput(key);
}else if(replaying && has_next_action() && next_action_type() == "handleTab"){
}else if(replaying && has_next_action("handleTab")){
Element& next_action = pop_next_action();
handleTab(boost::lexical_cast<bool>(next_action.GetText()));
}else{

View File

@@ -121,8 +121,11 @@ void record_field_input(cKey key) {
record_action("field_input", info);
}
bool has_next_action() {
return next_action != nullptr;
bool has_next_action(std::string type) {
if(type.empty())
return next_action != nullptr;
else
return has_next_action() && next_action_type() == type;
}
std::string next_action_type() {

View File

@@ -22,7 +22,7 @@ extern bool init_action_log(std::string command, std::string file);
extern void record_action(std::string action_type, std::string inner_text, bool cdata = false);
extern void record_action(std::string action_type, std::map<std::string,std::string> info);
extern void record_field_input(cKey key);
extern bool has_next_action();
extern bool has_next_action(std::string type = "");
extern std::string next_action_type();
extern Element& pop_next_action(std::string expected_action_type="");
extern std::map<std::string,std::string> info_from_action(Element& action);