diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index ad656b16..80355885 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -1086,10 +1086,10 @@ static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) if(id == "okay") { done_yet = true; - me.toast(); + me.toast(true); } else if(id == "cancel") { done_yet = true; - me.toast(); + me.toast(false); did_cancel = true; } @@ -1236,7 +1236,7 @@ static void put_party_stats(cDialog& me) static bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod) { if(item_hit == "done") { - me.toast(); + me.toast(true); } else if(item_hit == "help") { univ.party.help_received[22] = 0; give_help(222,23,me); @@ -1328,7 +1328,7 @@ static bool tip_of_day_event_filter(cDialog& me, std::string item_hit, eKeyMod) std::string place_str; if(item_hit == "done") { - me.toast(); + me.toast(true); } else if(item_hit == "next") { store_tip_page_on++; if (store_tip_page_on == NUM_HINTS) @@ -1401,7 +1401,7 @@ static static bool pick_a_scen_event_filter(cDialog& me, std::string item_hit, e { if(item_hit == "cancel") { me.setResult(-1); - me.toast(); + me.toast(false); } else if(item_hit == "next") { if (store_scen_page_on == 0) store_scen_page_on = (store_num_scen - 1) / 3; @@ -1415,7 +1415,7 @@ static static bool pick_a_scen_event_filter(cDialog& me, std::string item_hit, e } else if(item_hit.substr(0,item_hit.length()-1) == "start") { int scen_hit = item_hit[item_hit.length()-1] - '1'; me.setResult(scen_hit + store_scen_page_on * 3); - me.toast(); + me.toast(true); } return true; } diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index 379c32fc..162f1eb4 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -100,7 +100,7 @@ static void put_spell_info(cDialog& me, short display_mode) static bool display_spells_event_filter(cDialog& me, std::string item_hit, short display_mode) { short store; if(item_hit == "done") { - me.toast(); + me.toast(true); } else { store = (display_mode == 0) ? mage_spell_pos : priest_spell_pos; if(item_hit == "left") { @@ -163,7 +163,7 @@ static void put_skill_info(cDialog& me) static bool display_skills_event_filter(cDialog& me, std::string item_hit, eKeyMod) { if(item_hit == "done") { - me.toast(); + me.toast(true); } else { if(item_hit == "left") { skill_pos = (skill_pos == 0) ? 18 : skill_pos - 1; @@ -309,7 +309,7 @@ static void put_item_info(cDialog& me,const cItemRec& s_i) { static bool display_pc_item_event_filter(cDialog& me, std::string item_hit, cItemRec& store_i, short& item, const short pc_num) { if(item_hit == "done") { - me.toast(); + me.toast(true); } else if(item_hit == "left") { do { item = (item == 0) ? 23 : item - 1; @@ -443,7 +443,7 @@ static bool display_monst_event_filter(cDialog& me, std::string item_hit, cCreat short i,dummy = 0; if(item_hit == "done") { - me.toast(); + me.toast(true); } else if(item_hit == "left") { if (position == 0) { for (i = 255; on_monst_menu[i] < 0 && i > 0; i--) @@ -536,7 +536,7 @@ static bool display_alchemy_event_filter(cDialog& me, std::string item_hit, eKey std::string get_text; if(item_hit == "done") { - me.toast(); + me.toast(true); return true; } else if(item_hit == "left") { cur_entry = (cur_entry == 3) ? num_entries + 2 : cur_entry - 1; @@ -661,7 +661,7 @@ static void display_pc_info(cDialog& me, const short pc) { } static bool give_pc_info_event_filter(cDialog& me, std::string item_hit, short& store_pc_num) { - if(item_hit == "done") me.toast(); + if(item_hit == "done") me.toast(true); else if(item_hit == "left") { // TODO: Put braces on these do-whiles... o.O do @@ -713,7 +713,7 @@ static bool adventure_notes_event_filter(cDialog& me, std::string item_hit, eKey std::string place_str; char temp_str[256]; - if(item_hit == "done") me.toast(); + if(item_hit == "done") me.toast(true); else if(item_hit == "left") { if (store_page_on == 0) store_page_on = (store_num_i - 1) / 3; @@ -871,7 +871,7 @@ static void put_talk(cDialog& me) } static bool talk_notes_event_filter(cDialog& me, std::string item_hit, eKeyMod) { - if(item_hit == "done") me.toast(); + if(item_hit == "done") me.toast(true); else if(item_hit == "left") { if (store_page_on == 0) store_page_on = store_num_i - 1; @@ -922,7 +922,7 @@ static bool journal_event_filter(cDialog& me, std::string item_hit, eKeyMod) { short i; char place_str[256]; - if(item_hit == "done") me.toast(); + if(item_hit == "done") me.toast(true); else if(item_hit == "left") { if (store_page_on == 0) store_page_on = (store_num_i - 1) / 3; diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 3ef996df..0057a027 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -967,7 +967,7 @@ static bool display_item_event_filter(cDialog& me, std::string id, eKeyMod) { cItemRec item; if(id == "done") { - me.toast(); + me.toast(true); } else if(id == "up") { if(first_item_shown > 0) { first_item_shown -= 8; @@ -1430,7 +1430,7 @@ void refresh_store_items() static bool get_text_response_event_filter(cDialog& me, std::string, eKeyMod) { - me.toast(); + me.toast(true); me.setResult(me["response"].getText()); return true; } diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 6b3d563e..31b4874c 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -2287,7 +2287,7 @@ static bool finish_pick_spell(cDialog& me, bool spell_toast, const short store_s if (store_situation == 0) store_last_cast_mage = pc_casting; else store_last_cast_priest = pc_casting; - me.toast(); + me.toast(false); me.setResult(70); return true; } @@ -2298,21 +2298,21 @@ static bool finish_pick_spell(cDialog& me, bool spell_toast, const short store_s store_mage = store_mage_store; store_priest = store_priest_store; store_spell_target = store_store_target ; - me.toast(); + me.toast(false); me.setResult(70); return true; } if ((store_situation == 0) && (mage_need_select[store_mage] == 0)) { store_last_cast_mage = pc_casting; pc_last_cast[store_situation][pc_casting] = store_mage; - me.toast(); + me.toast(false); me.setResult(store_mage); return true; } if ((store_situation == 1) && (priest_need_select[store_priest] == 0)) { store_last_cast_priest = pc_casting; pc_last_cast[store_situation][pc_casting] = store_priest; - me.toast(); + me.toast(false); me.setResult(store_priest); return true; } @@ -2321,7 +2321,7 @@ static bool finish_pick_spell(cDialog& me, bool spell_toast, const short store_s store_mage = store_mage_store; store_priest = store_priest_store; store_spell_target = store_store_target ; - me.toast(); + me.toast(false); give_help(39,0,me); me.setResult(70); return true; @@ -2331,7 +2331,7 @@ static bool finish_pick_spell(cDialog& me, bool spell_toast, const short store_s store_last_cast_mage = pc_casting; else store_last_cast_priest = pc_casting; pc_last_cast[store_situation][pc_casting] = ((store_situation == 0) ? store_mage : store_priest); - me.toast(); + me.toast(true); return true; } @@ -2612,7 +2612,7 @@ static bool alch_choice_event_filter(cDialog& me, std::string item_hit, eKeyMod) else { me.setResult(item_hit[6] - '1'); } - me.toast(); + me.toast(true); return true; } @@ -2687,7 +2687,7 @@ static bool pc_name_event_filter(cDialog& me, short store_train_pc) { else { // TODO: This was originally truncated to 18 characters; is that really necessary? univ.party[store_train_pc].name = pcName; - me.toast(); + me.toast(true); } return true; } diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index 74097336..c53aa171 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -841,11 +841,11 @@ void cDialog::loadFromFile(std::string path){ winRect = RECT(); recalcRect(); ctrlIter iter = controls.begin(); - currentFocus = NULL; + currentFocus = ""; while(iter != controls.end()){ if(typeid(iter->second) == typeid(cTextField*)){ - cTextField* fld = (cTextField*) iter->second; - if(currentFocus == NULL) currentFocus = fld; + if(currentFocus.empty()) currentFocus = iter->first; + break; } iter++; } @@ -1080,23 +1080,25 @@ void cDialog::run(){ set_cursor(former_curs); } -template void cDialog::handleTabOrder(string itemHit, Iter begin, Iter end) { +template void cDialog::handleTabOrder(string& itemHit, Iter begin, Iter end) { auto cur = find_if(begin, end, [&itemHit](pair& a) { return a.first == itemHit; }); if(cur == end) return; // Unlikely, but let's be safe if(!cur->second->triggerFocusHandler(*this,itemHit,true)) return; - cTextField* wasFocus = currentFocus; + string wasFocus = currentFocus; auto iter = std::next(cur); if(iter == end) iter = begin; while(iter != cur){ // If tab order is explicitly specified for all fields, gaps are possible if(iter->second == nullptr) continue; - if((currentFocus = dynamic_cast(iter->second))){ - if(currentFocus->triggerFocusHandler(*this,iter->first,false)){ + if(iter->second->getType() == CTRL_FIELD){ + if(iter->second->triggerFocusHandler(*this,iter->first,false)){ + currentFocus = iter->first; + } else { itemHit = ""; - break; } + break; } iter++; if(iter == end) iter = begin; @@ -1121,7 +1123,10 @@ sf::Color cDialog::getDefTextClr() { return defTextClr; } -bool cDialog::toast(){ +bool cDialog::toast(bool triggerFocus){ + if(triggerFocus && !currentFocus.empty()) { + if(!this->getControl(currentFocus).triggerFocusHandler(*this, currentFocus, true)) return false; + } dialogNotToast = false; return true; } diff --git a/osx/dialogxml/dialog.h b/osx/dialogxml/dialog.h index 1a97eede..92a47d97 100644 --- a/osx/dialogxml/dialog.h +++ b/osx/dialogxml/dialog.h @@ -37,10 +37,10 @@ class cDialog { sf::Color parseColor(std::string what); cKey parseKey(std::string what); sf::RenderWindow win; - cTextField* currentFocus; + std::string currentFocus; cDialog* parent; void loadFromFile(std::string path); - template void handleTabOrder(std::string itemHit, Iter begin, Iter end); + template void handleTabOrder(std::string& itemHit, Iter begin, Iter end); std::vector> tabOrder; public: static void init(); @@ -61,7 +61,7 @@ public: void setDefTextClr(sf::Color clr); void setDefBtn(std::string defBtn); sf::Color getDefTextClr(); - bool toast(); + bool toast(bool triggerFocus); cControl& getControl(std::string id); cControl& operator[](std::string id); void recalcRect(); diff --git a/osx/dialogxml/dlogutil.cpp b/osx/dialogxml/dlogutil.cpp index 276b98d0..0f05bb48 100644 --- a/osx/dialogxml/dlogutil.cpp +++ b/osx/dialogxml/dlogutil.cpp @@ -114,13 +114,13 @@ bool cPictChoice::onRight(){ } bool cPictChoice::onCancel(){ - dlg.toast(); + dlg.toast(false); return true; } bool cPictChoice::onOkay(){ dlg.setResult(picts[cur].first); - dlg.toast(); + dlg.toast(true); return true; } @@ -207,13 +207,13 @@ bool cStringChoice::onRight(){ } bool cStringChoice::onCancel(cDialog& me){ - me.toast(); + me.toast(false); return true; } bool cStringChoice::onOkay(cDialog& me){ dlg.setResult(cur); - me.toast(); + me.toast(true); return true; } @@ -250,7 +250,7 @@ std::string cChoiceDlog::show(){ bool cChoiceDlog::onClick(cDialog& me, std::string id){ me.setResult(id); - me.toast(); + me.toast(true); return true; } @@ -479,7 +479,7 @@ bool cStrDlog::onRecord(std::string id){ } bool cStrDlog::onDismiss(){ - dlg.toast(); + dlg.toast(true); return true; } diff --git a/osx/pcedit/pc.action.cpp b/osx/pcedit/pc.action.cpp index ff62d9bd..879ad445 100644 --- a/osx/pcedit/pc.action.cpp +++ b/osx/pcedit/pc.action.cpp @@ -122,9 +122,9 @@ void flash_rect(RECT /*to_flash*/) sf::sleep(time_in_ticks(5)); } -static bool get_num_event_filter(cDialog& me, std::string, eKeyMod) +static bool get_num_event_filter(cDialog& me, std::string id, eKeyMod) { - me.toast(); + me.toast(id == "okay"); me.setResult(me["number"].getTextAsNum()); return true; } diff --git a/osx/pcedit/pc.editors.cpp b/osx/pcedit/pc.editors.cpp index db90117b..ec1cd9c1 100644 --- a/osx/pcedit/pc.editors.cpp +++ b/osx/pcedit/pc.editors.cpp @@ -81,7 +81,7 @@ long store_g; short store_train_mode,store_train_pc; static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod) { - me.toast(); + me.toast(true); if(item_hit != "cancel") { short which_pc = item_hit[item_hit.length() - 1] - '1'; me.setResult(which_pc); @@ -159,7 +159,7 @@ static bool display_pc_event_filter(cDialog& me, std::string item_hit, const sho pc_num = which_pc_displayed; if(item_hit == "done") { - me.toast(); + me.toast(true); } else if(item_hit == "left") { do { pc_num = (pc_num == 0) ? 5 : pc_num - 1; @@ -224,11 +224,6 @@ static void display_traits_graphics(cDialog& me) me["xp"].setTextToNum(store); } -static bool pick_race_abil_event_filter(cDialog& me, std::string, eKeyMod) { - me.toast(); - return true; -} - static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing, const short store_trait_mode) { if(losing) return true; std::string abil_str; @@ -277,7 +272,7 @@ void pick_race_abil(cPlayer *pc,short mode) make_cursor_sword(); cDialog pickAbil("pick-race-abil.xml"); - pickAbil["done"].attachClickHandler(pick_race_abil_event_filter); + pickAbil["done"].attachClickHandler(std::bind(&cDialog::toast, &pickAbil, true)); auto led_selector = std::bind(pick_race_select_led, _1, _2, _3, mode); pickAbil.attachFocusHandlers(led_selector, {"race", "bad1", "bad2", "bad3", "bad4", "bad5"}); pickAbil.attachFocusHandlers(led_selector, {"good1", "good2", "good3", "good4", "good5"}); @@ -451,7 +446,7 @@ static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod) } store_train_pc = pc_num; if (talk_done == true) { - me.toast(); + me.toast(item_hit == "keep"); } return true; } diff --git a/osx/scenedit/scen.core.cpp b/osx/scenedit/scen.core.cpp index b63f6360..dc58e46e 100644 --- a/osx/scenedit/scen.core.cpp +++ b/osx/scenedit/scen.core.cpp @@ -396,7 +396,7 @@ static void fill_ter_info(cDialog& me, short ter){ static bool finish_editing_ter(cDialog& me, std::string id, ter_num_t& which_ter) { if(!save_ter_info(me, scenario.ter_types[which_ter])) return true; - if(id == "done") me.toast(); + if(id == "done") me.toast(true); else if(id == "left") { // TODO: Use size() once ter_types becomes a vector if(which_ter == 0) which_ter = 255; @@ -423,7 +423,7 @@ short edit_ter_type(ter_num_t which_ter) { ter_dlg["trimter"].attachFocusHandler(std::bind(check_range,_1,_2,_3,0,255,"trim terrain")); ter_dlg["trim"].attachFocusHandler(std::bind(check_range,_1,_2,_3,0,18,"trim type")); ter_dlg["prop"].attachFocusHandler(fill_ter_flag_info); - ter_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &ter_dlg)); + ter_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &ter_dlg, false)); ter_dlg["arena"].attachFocusHandler(std::bind(check_range,_1,_2,_3,0,299,"ground type")); // TODO: Add focus handler for key // TODO: Add click handler for object @@ -574,7 +574,7 @@ static bool edit_monst_type_event_filter(cDialog& me,std::string item_hit,cMonst if(item_hit == "okay") { if(save_monst_info(me,store_monst)) { scenario.scen_monsters[which_monst] = store_monst; - me.toast(); + me.toast(true); } } else if(item_hit == "abils") { if(!save_monst_info(me,store_monst)) return false; @@ -637,7 +637,7 @@ short edit_monst_type(short which_monst) { cDialog monst_dlg("edit-monster.xml"); monst_dlg["pickicon"].attachClickHandler(std::bind(pick_picture,PIC_MONST,_1,"pic","icon",0)); monst_dlg["picktalk"].attachClickHandler(std::bind(pick_picture,PIC_TALK,_1,"talk","",0)); - monst_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &monst_dlg)); + monst_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &monst_dlg, false)); monst_dlg["pic"].attachFocusHandler(std::bind(check_monst_pic, _1, _2, _3, std::ref(store_monst))); monst_dlg["level"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 40, "level")); monst_dlg["health"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 2500, "health")); @@ -732,10 +732,10 @@ static bool edit_monst_abil_event_filter(cDialog& me,std::string item_hit,cMonst if(item_hit == "cancel") { store_monst.level = 255; - me.toast(); + me.toast(false); } else if(item_hit == "okay") { if(save_monst_abils(me, store_monst)) - me.toast(); + me.toast(true); } else if(item_hit == "abils") { if(!save_monst_abils(me, store_monst)) return true; i = choose_text_res("monster-abilities", 1, 38, store_monst.spec_skill + 1, &me, "Choose Monster Ability:"); @@ -974,9 +974,9 @@ static bool edit_item_type_event_filter(cDialog& me, std::string item_hit, cItem cItemRec temp_item; if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "okay") { - if(save_item_info(me, store_item, store_which_item)) me.toast(); + if(save_item_info(me, store_item, store_which_item)) me.toast(true); } else if(item_hit == "prev") { if(!save_item_info(me, store_item, store_which_item)) return true; store_which_item--; @@ -1067,11 +1067,11 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string item_hit, cItem if(item_hit == "cancel") { store_item.ability = ITEM_NO_ABILITY; - me.toast(); + me.toast(false); return true; } else if(item_hit == "okay") { if(save_item_abils(me, store_item)) { - me.toast(); + me.toast(true); return true; } } else if(item_hit == "weapon") { @@ -1193,9 +1193,9 @@ static bool save_spec_item(cDialog& me, cSpecItem& store_item, short which_item) static bool edit_spec_item_event_filter(cDialog& me, std::string item_hit, cSpecItem& store_item, short which_item) { if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "okay") { - if(save_spec_item(me, store_item, which_item)) me.toast(); + if(save_spec_item(me, store_item, which_item)) me.toast(true); } else if(item_hit == "left") { if(!save_spec_item(me, store_item, which_item)) return true; which_item--; @@ -1289,10 +1289,10 @@ static bool save_save_rects(cDialog& me) { static bool edit_save_rects_event_filter(cDialog& me, std::string item_hit) { if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "okay") { if(save_save_rects(me)) - me.toast(); + me.toast(true); } return true; } @@ -1344,7 +1344,7 @@ static bool edit_vehicles_event_filter(cDialog& me, std::string item_hit, cVehic if(item_hit == "okay") { if(save_vehicles(me, vehicles, page)) - me.toast(); + me.toast(true); } else if(item_hit == "left") { if(!save_vehicles(me, vehicles, page)) return true; page--; @@ -1415,7 +1415,7 @@ static void put_add_town_in_dlog(cDialog& me) { static bool edit_add_town_event_filter(cDialog& me, std::string item_hit) { if(item_hit == "okay") { if(save_add_town(me)) - me.toast(); + me.toast(true); } return true; } @@ -1469,9 +1469,9 @@ static bool edit_item_placement_event_filter(cDialog& me, std::string item_hit, if(item_hit == "okay") { if(save_item_placement(me, store_storage, cur_shortcut)) - me.toast(); + me.toast(true); } else if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "left") { if(!save_item_placement(me, store_storage, cur_shortcut)) return true; cur_shortcut--; diff --git a/osx/scenedit/scen.keydlgs.cpp b/osx/scenedit/scen.keydlgs.cpp index 7e27059c..754e2856 100644 --- a/osx/scenedit/scen.keydlgs.cpp +++ b/osx/scenedit/scen.keydlgs.cpp @@ -240,7 +240,7 @@ static bool edit_text_event_filter(cDialog& me, std::string item_hit, short& whi strcpy(current_terrain.out_strs(which_str), newVal.c_str()); if (str_mode == 2) strcpy(town->town_strs(which_str), newVal.c_str()); - if(item_hit == "okay") me.toast(); + if(item_hit == "okay") me.toast(true); else if(item_hit == "left" || item_hit == "right") { if(item_hit[0] == 'l') which_str--; @@ -279,14 +279,14 @@ void edit_text_str(short which_str,short mode) { static bool edit_area_rect_event_filter(cDialog& me, std::string item_hit, short which_str, short str_mode) { if(item_hit == "okay") { me.setResult(true); - me.toast(); + me.toast(true); std::string str = me["area"].getText(); if(str_mode == 0) sprintf(current_terrain.out_strs(which_str + 1),"%-29.29s",str.c_str()); else sprintf(town->town_strs(which_str + 1),"%-29.29s",str.c_str()); } else if(item_hit == "cancel") { me.setResult(false); - me.toast(); + me.toast(false); } return true; } @@ -517,7 +517,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& if(item_hit == "okay") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + me.toast(true); } else if(item_hit == "back") { if(!save_spec_enc(me, which_mode, which_node)) return true; @@ -531,7 +531,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& "Press the Go Back button until it disappears.",&me); return true; } - me.toast(); + me.toast(false); } else if(me[item_hit].getText() == "Create/Edit") { if(!save_spec_enc(me, which_mode, which_node)) return true; @@ -614,7 +614,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& me["x2a"].setTextToNum(store_spec_node.ex2a); } else if(item_hit == "msg2-edit") { // TODO: What about msg1-edit? if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; if ((edit_spec_mess_mess[store_spec_node.type] == 2) || (edit_spec_mess_mess[store_spec_node.type] == 4) || (edit_spec_mess_mess[store_spec_node.type] == 5)) { @@ -629,7 +629,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& } } else if(item_hit == "pict-edit") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = -1; switch (edit_pict_mess[store_spec_node.type]) { case 1: @@ -648,7 +648,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& } } else if(item_hit == "general") { if(save_spec_enc(me, which_mode, which_node) == true) - me.toast(); + return true; i = choose_text_res("special-node-names",1,28,store_spec_node.type + 1,&me,"Choose General Use Special:"); if (i >= 0) { store_spec_node.type = i - 1; @@ -656,7 +656,7 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& put_spec_enc_in_dlog(me, which_node); } else if(item_hit == "oneshot") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = choose_text_res("special-node-names",51,64,store_spec_node.type + 1,&me,"Choose One-Shot Special:"); if (i >= 0) { store_spec_node.type = i - 1; @@ -668,13 +668,13 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& put_spec_enc_in_dlog(me, which_node); } else if(item_hit == "affectpc") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = choose_text_res("special-node-names",81,107,store_spec_node.type + 1,&me,"Choose Affect Party Special:"); if (i >= 0) store_spec_node.type = i - 1; put_spec_enc_in_dlog(me, which_node); } else if(item_hit == "ifthen") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = choose_text_res("special-node-names",131,156,store_spec_node.type + 1,&me,"Choose If-Then Special:"); if (i >= 0) { store_spec_node.type = i - 1; @@ -682,13 +682,13 @@ static bool edit_spec_enc_event_filter(cDialog& me, std::string item_hit, short& put_spec_enc_in_dlog(me, which_node); } else if(item_hit == "town") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = choose_text_res("special-node-names",171,219,store_spec_node.type + 1,&me,"Choose Town Special:"); if (i >= 0) store_spec_node.type = i - 1; put_spec_enc_in_dlog(me, which_node); } else if(item_hit == "out") { if(save_spec_enc(me, which_mode, which_node)) - me.toast(); + return true; i = choose_text_res("special-node-names",226,230,store_spec_node.type + 1,&me,"Choose Outdoor Special:"); if (i >= 0) store_spec_node.type = i - 1; put_spec_enc_in_dlog(me, which_node); @@ -767,8 +767,6 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short std::string str; short i; - me.toast(); - if(item_hit == "okay") { str = me["str1"].getText(); if(!str.empty()) { @@ -865,7 +863,8 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short } } } - } + me.toast(true); + } else me.toast(false); return true; } @@ -904,8 +903,6 @@ static bool edit_dialog_text_event_filter(cDialog& me, std::string item_hit, sho std::string str; short i; - me.toast(); - if(item_hit == "okay") { for (i = 0; i < 6; i++) { std::string id = "str" + std::to_string(i + 1); @@ -923,7 +920,8 @@ static bool edit_dialog_text_event_filter(cDialog& me, std::string item_hit, sho break; } } - } + me.toast(true); + } else me.toast(false); return true; } @@ -1017,8 +1015,6 @@ void edit_dialog_text(short mode,short *str1,cDialog* parent) { static bool edit_special_num_event_filter(cDialog& me, std::string item_hit, short spec_mode) { short i; - me.toast(); - if(item_hit == "cancel") me.setResult(-1); else if(item_hit == "okay") { i = me["num"].getTextAsNum(); @@ -1026,7 +1022,8 @@ static bool edit_special_num_event_filter(cDialog& me, std::string item_hit, sho giveError("There is no special node with that number. Legal ranges are 0 to 255 for scenario specials, 0 to 59 for outdoor specials, and 0 to 99 for town specials.","",&me); } me.setResult(i); - } + me.toast(true); + } me.toast(false); return true; } @@ -1056,9 +1053,9 @@ static bool edit_scen_intro_event_filter(cDialog& me, std::string item_hit, eKey std::string id = "str" + std::to_string(i + 1); strcpy(scenario.scen_strs(4 + i), me[id].getText().c_str()); } - me.toast(); + me.toast(true); } else if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "choose") { i = me["picnum"].getTextAsNum(); i = choose_graphic(i,PIC_SCEN,&me); diff --git a/osx/scenedit/scen.townout.cpp b/osx/scenedit/scen.townout.cpp index 2f9d6a59..58aa108c 100644 --- a/osx/scenedit/scen.townout.cpp +++ b/osx/scenedit/scen.townout.cpp @@ -133,9 +133,9 @@ static bool edit_placed_monst_event_filter(cDialog& me, std::string item_hit, eK if(item_hit == "okay") { if(!get_placed_monst_in_dlog(me)) return true; - me.toast(); + me.toast(true); } else if(item_hit == "cancel") { - me.toast(); + me.toast(false); } else if(item_hit == "type-edit") { if(!get_placed_monst_in_dlog(me)) return true; i = choose_text(STRT_MONST,store_placed_monst.number,&me,"Choose Which Monster:"); @@ -210,10 +210,10 @@ static bool get_placed_monst_adv_in_dlog(cDialog& me) { static bool edit_placed_monst_adv_event_filter(cDialog& me, std::string item_hit, eKeyMod) { if(item_hit == "okay") { if(!get_placed_monst_adv_in_dlog(me)) return true; - me.toast(); + me.toast(true); } else if(item_hit == "cancel") { store_placed_monst2.number = 0; - me.toast(); + me.toast(false); } return true; }