From 5762c2bb906436801cdd02eea6042a61bfb763be Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 14 Aug 2015 23:30:07 -0400 Subject: [PATCH] Tweak to error dialogs and add separate warning dialogs (Also some error messages tweaked) --- src/boe.dlgutil.cpp | 16 ++--- src/boe.fileio.cpp | 2 +- src/boe.items.cpp | 2 +- src/boe.main.cpp | 6 +- src/boe.party.cpp | 4 +- src/boe.specials.cpp | 122 +++++++++++++++++----------------- src/boe.town.cpp | 4 +- src/classes/party.cpp | 2 +- src/classes/special.cpp | 4 +- src/dialogxml/dlogutil.cpp | 28 ++++++-- src/dialogxml/dlogutil.hpp | 28 ++++++-- src/dialogxml/field.cpp | 2 +- src/pcedit/pc.main.cpp | 10 +-- src/scenedit/scen.actions.cpp | 20 +++--- src/scenedit/scen.core.cpp | 56 ++++++++-------- src/scenedit/scen.keydlgs.cpp | 18 ++--- src/scenedit/scen.main.cpp | 22 +++--- src/scenedit/scen.townout.cpp | 8 +-- src/tools/fileio_party.cpp | 18 ++--- src/tools/fileio_scen.cpp | 42 ++++++------ src/tools/qdpict.cpp | 26 ++++---- 21 files changed, 240 insertions(+), 200 deletions(-) diff --git a/src/boe.dlgutil.cpp b/src/boe.dlgutil.cpp index 5756bee6..5c374546 100644 --- a/src/boe.dlgutil.cpp +++ b/src/boe.dlgutil.cpp @@ -107,7 +107,7 @@ short active_shop_num; void start_shop_mode(short which,short cost_adj,std::string store_name) { rectangle area_rect; if(which < 0 || which >= univ.scenario.shops.size()) { - giveError("The scenario tried to place you in a nonexistent shop!"); + showError("The scenario tried to place you in a nonexistent shop!"); return; } @@ -333,7 +333,7 @@ void handle_sale(cShopItem item, int i) { case eShopItemType::MAGE_SPELL: if((base_item.item_level < 0) || (base_item.item_level > 61)) { beep(); - giveError("Error: The scenario tried to sell you an invalid mage spell!"); + showError("The scenario tried to sell you an invalid mage spell!"); break; } if(univ.party[current_pc].mage_spells[base_item.item_level]) @@ -351,7 +351,7 @@ void handle_sale(cShopItem item, int i) { case eShopItemType::PRIEST_SPELL: if((base_item.item_level < 0) || (base_item.item_level > 61)) { beep(); - giveError("Error: The scenario tried to sell you an invalid priest spell!"); + showError("The scenario tried to sell you an invalid priest spell!"); break; } if(univ.party[current_pc].priest_spells[base_item.item_level]) @@ -381,7 +381,7 @@ void handle_sale(cShopItem item, int i) { case eShopItemType::SKILL: if(base_item.item_level < 0 || base_item.item_level > 18) { beep(); - giveError("Error: The scenario tried to sell you an invalid skill!"); + showError("The scenario tried to sell you an invalid skill!"); break; } eSkill skill = eSkill(base_item.item_level); @@ -842,7 +842,7 @@ void handle_talk_event(location p) { case eTalkNode::SHOP: if(d < 0 || d > 11) { - giveError("Invalid shop type!"); + showError("Invalid shop type!"); return; } start_shop_mode(b,a,save_talk_str1); @@ -906,7 +906,7 @@ void handle_talk_event(location p) { put_pc_screen(); if(univ.party.sd_legit(b,c)) PSD[b][c] = d; - else giveError("Invalid Stuff Done flag called in conversation."); + else showError("Invalid Stuff Done flag called in conversation."); } save_talk_str2 = ""; break; @@ -971,7 +971,7 @@ void handle_talk_event(location p) { break; case eTalkNode::RECEIVE_QUEST: if(a < 0 || a >= univ.scenario.quests.size()) { - giveError("Tried to give a nonexistent quest!"); + showError("Tried to give a nonexistent quest!"); return; } switch(univ.party.quest_status[a]) { @@ -1128,7 +1128,7 @@ void save_prefs(bool resetHelp){ bool success = sync_prefs(); if(!success){ - giveError("There was a problem writing to the preferences file. When the game is next run the preferences will revert to their previously set values.","Should you manage to resolve the problem without closing the program, simply open the preferences screen and click \"OK\" to try again."); + showWarning("There was a problem writing to the preferences file. When the game is next run the preferences will revert to their previously set values.","Should you manage to resolve the problem without closing the program, simply open the preferences screen and click \"OK\" to try again."); } } diff --git a/src/boe.fileio.cpp b/src/boe.fileio.cpp index 7075ff65..97df1f12 100644 --- a/src/boe.fileio.cpp +++ b/src/boe.fileio.cpp @@ -279,7 +279,7 @@ void position_party(short out_x,short out_y,short pc_pos_x,short pc_pos_y) { if((pc_pos_x != minmax(0,47,pc_pos_x)) || (pc_pos_y != minmax(0,47,pc_pos_y)) || (out_x != minmax(0,univ.scenario.outdoors.width() - 1,out_x)) || (out_y != minmax(0,univ.scenario.outdoors.height() - 1,out_y))) { - giveError("The scenario has tried to place you in an out of bounds outdoor location."); + showError("The scenario has tried to place you in an out of bounds outdoor location."); return; } diff --git a/src/boe.items.cpp b/src/boe.items.cpp index dfa1f33c..72869381 100644 --- a/src/boe.items.cpp +++ b/src/boe.items.cpp @@ -989,7 +989,7 @@ short get_num_response(short min, short max, std::string prompt) { if(!losing) return true; int val = me["number"].getTextAsNum(); if(val < min || val > max) { - giveError("Number out of range!"); + showError("Number out of range!"); return false; } return true; diff --git a/src/boe.main.cpp b/src/boe.main.cpp index e8652cce..0336f297 100644 --- a/src/boe.main.cpp +++ b/src/boe.main.cpp @@ -161,13 +161,13 @@ int main(int argc, char* argv[]) { close_program(); return 0; } catch(std::exception& x) { - giveError(x.what()); + showFatalError(x.what()); throw; } catch(std::string& x) { - giveError(x); + showFatalError(x); throw; } catch(...) { - giveError("An unknown error occurred!"); + showFatalError("An unknown error occurred!"); throw; } } diff --git a/src/boe.party.cpp b/src/boe.party.cpp index 6caa05e9..28c16c27 100644 --- a/src/boe.party.cpp +++ b/src/boe.party.cpp @@ -280,7 +280,7 @@ void put_party_in_scen(std::string scen_name) { fs::path path = locate_scenario(scen_name); if(path.empty()) { - giveError("Could not find scenario!"); + showError("Could not find scenario!"); return; } if(!load_scenario(path, univ.scenario)) @@ -656,7 +656,7 @@ void give_party_spell(short which) { bool sound_done = false; if((which < 0) || (which > 161) || ((which > 61) && (which < 100))) { - giveError("The scenario has tried to give you a non-existant spell."); + showError("The scenario has tried to give you a non-existant spell."); return;} // TODO: This seems like the wrong sounds diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 73d2351e..d624234a 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -1388,7 +1388,7 @@ void change_level(short town_num,short x,short y) { location l(x,y); if((town_num < 0) || (town_num >= univ.scenario.towns.size())) { - giveError("The scenario special encounter tried to put you into a town that doesn't exist."); + showError("The scenario special encounter tried to put you into a town that doesn't exist."); return; } @@ -2108,21 +2108,21 @@ cSpecial get_node(short cur_spec,short cur_spec_type) { dummy_node.type = eSpecType::INVALID; if(cur_spec_type == 0) { if(cur_spec != minmax(0,univ.scenario.scen_specials.size() - 1,cur_spec)) { - giveError("The scenario called a scenario special node out of range."); + showError("The scenario called a scenario special node out of range."); return dummy_node; } return univ.scenario.scen_specials[cur_spec]; } if(cur_spec_type == 1) { if(cur_spec != minmax(0,univ.out->specials.size() - 1,cur_spec)) { - giveError("The scenario called an outdoor special node out of range."); + showError("The scenario called an outdoor special node out of range."); return dummy_node; } return univ.out->specials[cur_spec]; } if(cur_spec_type == 2) { if(cur_spec != minmax(0,univ.town->specials.size() - 1,cur_spec)) { - giveError("The scenario called a town special node out of range."); + showError("The scenario called a town special node out of range."); return dummy_node; } return univ.town->specials[cur_spec]; @@ -2200,26 +2200,26 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::CHANGE_HORSE_OWNER: check_mess = true; if(spec.ex1a != minmax(0,univ.party.horses.size() - 1,spec.ex1a)) - giveError("Horse out of range."); + showError("Horse out of range."); else univ.party.horses[spec.ex1a].property = (spec.ex2a == 0) ? 1 : 0; break; case eSpecType::CHANGE_BOAT_OWNER: check_mess = true; if(spec.ex1a != minmax(0,univ.party.boats.size() - 1,spec.ex1a)) - giveError("Boat out of range."); + showError("Boat out of range."); else univ.party.boats[spec.ex1a].property = (spec.ex2a == 0) ? 1 : 0; break; case eSpecType::SET_TOWN_VISIBILITY: check_mess = true; if(spec.ex1a != minmax(0,univ.scenario.towns.size() - 1,spec.ex1a)) - giveError("Town out of range."); + showError("Town out of range."); else univ.party.can_find_town[spec.ex1a] = spec.ex2a; *redraw = true; break; case eSpecType::MAJOR_EVENT_OCCURRED: check_mess = true; if(spec.ex1a != minmax(1,10,spec.ex1a)) - giveError("Event code out of range."); + showError("Event code out of range."); else if(univ.party.key_times.count(spec.ex1a) == 0) univ.party.key_times[spec.ex1a] = univ.party.calc_day(); break; @@ -2246,12 +2246,12 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::SET_SDF_ROW: if(spec.sd1 != minmax(0,299,spec.sd1)) - giveError("Stuff Done flag out of range."); + showError("Stuff Done flag out of range."); else for(i = 0; i < 50; i++) PSD[spec.sd1][i] = spec.ex1a; break; case eSpecType::COPY_SDF: if(!univ.party.sd_legit(spec.sd1,spec.sd2) || !univ.party.sd_legit(spec.ex1a,spec.ex1b)) - giveError("Stuff Done flag out of range."); + showError("Stuff Done flag out of range."); else PSD[spec.sd1][spec.sd2] = PSD[spec.ex1a][spec.ex1b]; break; case eSpecType::REST: @@ -2263,18 +2263,18 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::SET_POINTER: if(spec.ex1a < 0) - giveError("Attempted to assign a pointer out of range (100..199)"); + showError("Attempted to assign a pointer out of range (100..199)"); else try { if(spec.sd1 < 0 && spec.sd2 < 0) univ.party.clear_ptr(spec.ex1a); else univ.party.set_ptr(spec.ex1a,spec.sd1,spec.sd2); } catch(std::range_error x) { - giveError(x.what()); + showError(x.what()); } break; case eSpecType::SET_CAMP_FLAG: if(!univ.party.sd_legit(spec.sd1,spec.sd2)) - giveError("Stuff Done flag out of range (x - 0..299, y - 0..49)."); + showError("Stuff Done flag out of range (x - 0..299, y - 0..49)."); else { set_campaign_flag(spec.sd1,spec.sd2,spec.ex1a,spec.ex1b,spec.m1,spec.ex2a); } @@ -2446,11 +2446,11 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::UPDATE_QUEST: check_mess = true; if(spec.ex1a < 0 || spec.ex1a >= univ.scenario.quests.size()) { - giveError("The scenario tried to update a non-existent quest."); + showError("The scenario tried to update a non-existent quest."); break; } if(spec.ex1b < 0 || spec.ex1b > 3) { - giveError("Invalid quest status (range 0 .. 3)."); + showError("Invalid quest status (range 0 .. 3)."); break; } if(spec.ex1b == int(eQuestStatus::STARTED) && univ.party.quest_status[spec.ex1a] != eQuestStatus::STARTED) { @@ -2481,7 +2481,7 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } if(check_mess) { @@ -2542,7 +2542,7 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::ONCE_GIVE_SPEC_ITEM: if(spec.ex1a != minmax(0,49,spec.ex1a)) { - giveError("Special item is out of range."); + showError("Special item is out of range."); set_sd = false; } else if(spec.ex1b == 0) @@ -2577,7 +2577,7 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, buttons[1] = spec.ex2a; } if((buttons[0] < 0) && (buttons[1] < 0)) { - giveError("Dialog box ended up with no buttons."); + showError("Dialog box ended up with no buttons."); break; } i = custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons); @@ -2626,7 +2626,7 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::ONCE_OUT_ENCOUNTER: if(spec.ex1a != minmax(0,3,spec.ex1a)) { - giveError("Special outdoor enc. is out of range. Must be 0-3."); + showError("Special outdoor enc. is out of range. Must be 0-3."); set_sd = false; } else { @@ -2670,7 +2670,7 @@ void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::ONCE_DISPLAY_MSG: break; // Nothing to do here, but need to include it to prevent the below error from showing. default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } if(check_mess) { @@ -3032,7 +3032,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_STAT: if(pc_num >= 100) break; if(spec.ex2a != minmax(0,20,spec.ex2a)) { - giveError("Skill is out of range."); + showError("Skill is out of range."); break; } for(i = 0; i < 6; i++) @@ -3069,7 +3069,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_MONST_ATT: if(pc_num < 100) break; if(spec.ex1a < 0 || spec.ex1a > 2) { - giveError("Invalid monster attack (0-2)"); + showError("Invalid monster attack (0-2)"); break; } if(spec.ex2a == 0) { @@ -3083,7 +3083,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_MONST_STAT: if(pc_num < 100) break; if(spec.ex2a < 0 || spec.ex2a > 7) { - giveError("Invalid monster stat (0-7)"); + showError("Invalid monster stat (0-7)"); break; } i = spec.ex1a; @@ -3102,7 +3102,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_MAGE_SPELL: if(pc_num >= 100) break; if(spec.ex1a != minmax(0,61,spec.ex1a)) { - giveError("Mage spell is out of range (0 - 61). See docs."); + showError("Mage spell is out of range (0 - 61). See docs."); break; } for(i = 0; i < 6; i++) @@ -3112,7 +3112,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_PRIEST_SPELL: if(pc_num >= 100) break; if(spec.ex1a != minmax(0,61,spec.ex1a)) { - giveError("Priest spell is out of range (0 - 61). See docs."); + showError("Priest spell is out of range (0 - 61). See docs."); break; } for(i = 0; i < 6; i++) @@ -3135,7 +3135,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::AFFECT_ALCHEMY: if(spec.ex1a != minmax(0,19,spec.ex1a)) { - giveError("Alchemy is out of range."); + showError("Alchemy is out of range."); break; } univ.party.alchemy[spec.ex1a] = true; @@ -3164,7 +3164,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_TRAITS: if(pc_num >= 100) break; if(spec.ex1a < 0 || spec.ex1a > 15) { - giveError("Trait is out of range (0 - 15)."); + showError("Trait is out of range (0 - 15)."); break; } for(i = 0; i < 6; i++) @@ -3201,7 +3201,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::CREATE_NEW_PC: if(spec.ex1c < 0 || spec.ex1c > 19) { - giveError("Race out of range (0 - 19)."); + showError("Race out of range (0 - 19)."); break; } pc_num = univ.party.free_space(); @@ -3238,7 +3238,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::UNSTORE_PC: if(spec.ex1a < 1000) spec.ex1a += 1000; if(univ.stored_pcs.find(spec.ex1a) == univ.stored_pcs.end()) { - giveError("Scenario tried to unstore a nonexistent PC!"); + showError("Scenario tried to unstore a nonexistent PC!"); break; } pc_num = univ.party.free_space(); @@ -3288,7 +3288,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } if(check_mess) { @@ -3340,7 +3340,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_HAVE_SPECIAL_ITEM: if(spec.ex1a != minmax(0,49,spec.ex1a)) { - giveError("Special item is out of range."); + showError("Special item is out of range."); } else if(univ.party.spec_items.count(spec.ex1a) > 0) *next_spec = spec.ex1b; @@ -3350,7 +3350,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, if(PSD[spec.ex1a][spec.ex1b] < PSD[spec.sd1][spec.sd2]) *next_spec = spec.ex2b; } - else giveError("A Stuff Done flag is out of range."); + else showError("A Stuff Done flag is out of range."); break; case eSpecType::IF_TER_TYPE: l.x = spec.ex1a; l.y = spec.ex1b; @@ -3412,7 +3412,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::IF_FIELDS: if(is_out()) break; if(!isValidField(spec.m1, false)) { - giveError("Scenario tried to check for invalid field type (1...24)"); + showError("Scenario tried to check for invalid field type (1...24)"); break; } i = 0; @@ -3470,7 +3470,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_SPECIES: if(spec.ex1a < 0 || spec.ex1a > 21) { - giveError("Species out of range (0-21)"); + showError("Species out of range (0-21)"); break; } i = 0; @@ -3486,7 +3486,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_TRAIT: if(spec.ex1a < 0 || spec.ex1a > 15) { - giveError("Invalid trait (0...15)"); + showError("Invalid trait (0...15)"); break; } j = min(spec.ex2a,party_size(true)); @@ -3501,11 +3501,11 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_STATISTIC: if((spec.ex2a < 0 || spec.ex2a > 20) && (spec.ex2a < 100 || spec.ex2a > 104)) { - giveError("Attempted to check an invalid statistic (0...20 or 100...104)."); + showError("Attempted to check an invalid statistic (0...20 or 100...104)."); break; } if(spec.ex2b < -1 || spec.ex2b > 3) { - giveError("Invalid statistic-checking mode (-1...3); will fall back to cumulative check."); + showError("Invalid statistic-checking mode (-1...3); will fall back to cumulative check."); spec.ex2b = 0; } @@ -3671,7 +3671,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_RECIPE: if(spec.ex1a < 0 || spec.ex1a >= 20) { - giveError("Alchemy recipe out of range (0 - 19)."); + showError("Alchemy recipe out of range (0 - 19)."); break; } if(univ.party.alchemy[spec.ex1a]) @@ -3679,7 +3679,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_STATUS: if(spec.ex1a < 0 || spec.ex1a > 14) { - giveError("Invalid status effect (0...14)"); + showError("Invalid status effect (0...14)"); break; } if(dynamic_cast(current_pc_picked_in_spec_enc)) { @@ -3711,11 +3711,11 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::IF_QUEST: if(spec.ex1a < 0 || spec.ex1a >= univ.scenario.quests.size()) { - giveError("The scenario tried to update a non-existent quest."); + showError("The scenario tried to update a non-existent quest."); break; } if(spec.ex1b < 0 || spec.ex1b > 3) { - giveError("Invalid quest status (range 0 .. 3)."); + showError("Invalid quest status (range 0 .. 3)."); break; } if(univ.party.quest_status[spec.ex1a] == eQuestStatus(spec.ex1b)) @@ -3757,7 +3757,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, *next_spec = spec.ex1c; break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } if(check_mess) { @@ -3793,7 +3793,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, switch(cur_node.type) { case eSpecType::MAKE_TOWN_HOSTILE: if(spec.ex2a < 0 || spec.ex2a > 3){ - giveError("Invalid attitude (0-Friendly Docile, 1-Hostile A, 2-Friendly Will Fight, 3-Hostile B)."); + showError("Invalid attitude (0-Friendly Docile, 1-Hostile A, 2-Friendly Will Fight, 3-Hostile B)."); break; } set_town_attitude(spec.ex1a,spec.ex1b,eAttitude(spec.ex2a)); @@ -4148,11 +4148,11 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::TOWN_SET_ATTITUDE: if((spec.ex1a < 0) || (spec.ex1a > 59)){ - giveError("Tried to change the attitude of a nonexistent monster (should be 0...59)."); + showError("Tried to change the attitude of a nonexistent monster (should be 0...59)."); break; } if(spec.ex1b < 0 || spec.ex1b > 3){ - giveError("Invalid attitude (0-Friendly Docile, 1-Hostile A, 2-Friendly Will Fight, 3-Hostile B)."); + showError("Invalid attitude (0-Friendly Docile, 1-Hostile A, 2-Friendly Will Fight, 3-Hostile B)."); break; } univ.town.monst[spec.ex1a].attitude = eAttitude(spec.ex1b); @@ -4205,7 +4205,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::TOWN_START_TARGETING: *next_spec = -1; if(spec.ex1a < 0 || spec.ex1a > 7) { - giveError("Invalid spell pattern (0 - 7)."); + showError("Invalid spell pattern (0 - 7)."); break; } if(spec.ex1c > 1 && !is_combat()) { @@ -4230,11 +4230,11 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::TOWN_SPELL_PAT_FIELD: if(spec.ex1c < -1 || spec.ex1c > 14) { - giveError("Invalid spell pattern (-1 - 14)."); + showError("Invalid spell pattern (-1 - 14)."); break; } if((spec.ex2a < 1 || spec.ex2a == 9 || spec.ex2a > 24) && spec.ex2a != 32 && spec.ex2a != 33) { - giveError("Invalid field type (see docs)."); + showError("Invalid field type (see docs)."); break; } switch(spec.ex1c) { @@ -4252,11 +4252,11 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::TOWN_SPELL_PAT_BOOM: if(spec.ex1c < -1 || spec.ex1c > 14) { - giveError("Invalid spell pattern (-1 - 14)."); + showError("Invalid spell pattern (-1 - 14)."); break; } if(spec.ex2a < 0 || spec.ex2a > 7) { - giveError("Invalid damage type (0 - 7)."); + showError("Invalid damage type (0 - 7)."); break; } switch(spec.ex1c) { @@ -4279,7 +4279,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::TOWN_RELOCATE_CREATURE: if(spec.ex2b > 5) { - giveError("Invalid positioning mode (0-5)"); + showError("Invalid positioning mode (0-5)"); break; } if(spec.ex2a < 0) @@ -4333,7 +4333,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, univ.town.monst[i].cur_loc.y += l.y; } } else { - giveError("Invalid positioning target!"); + showError("Invalid positioning target!"); break; } redraw_screen(REFRESH_TERRAIN); @@ -4353,7 +4353,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, else if(l.x >= 100 && l.x - 100 < univ.town.monst.size()) l = univ.town.monst[l.x - 100].cur_loc; else { - giveError("Invalid label target!"); + showError("Invalid label target!"); break; } } @@ -4364,7 +4364,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, sf::sleep(sf::seconds(spec.ex2b)); break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } if(check_mess) { @@ -4395,7 +4395,7 @@ void rect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, if(is_out()) return; if(!isValidField(spec.sd2, true)) { - giveError("Scenario tried to place an invalid field type (1...24)"); + showError("Scenario tried to place an invalid field type (1...24)"); goto END; // Break out of the switch AND both loops, but still handle messages } if(spec.sd2 == FIELD_DISPEL || get_ran(1,1,100) <= spec.sd1) @@ -4503,7 +4503,7 @@ void rect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, else take_explored(l.x, l.y); break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } } @@ -4533,7 +4533,7 @@ void outdoor_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::OUT_PLACE_ENCOUNTER: if(spec.ex1a != minmax(0,3,spec.ex1a)) { - giveError("Special outdoor enc. is out of range. Must be 0-3."); + showError("Special outdoor enc. is out of range. Must be 0-3."); //set_sd = false; } else { @@ -4560,7 +4560,7 @@ void outdoor_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, start_town_mode(spec.ex1a, i); break; default: - giveError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); + showError("Special node type \"" + (*cur_node.type).name() + "\" is either miscategorized or unimplemented!"); break; } @@ -4571,7 +4571,7 @@ void outdoor_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, void setsd(short a,short b,short val) { if(!univ.party.sd_legit(a,b)) { - giveError("The scenario attempted to change an out of range Stuff Done flag."); + showError("The scenario attempted to change an out of range Stuff Done flag."); return; } PSD[a][b] = val; @@ -4625,7 +4625,7 @@ void get_strs(std::string& str1,std::string& str2,short cur_type,short which_str if(((which_str1 >= 0) && (which_str1 != minmax(0,num_strs,which_str1))) || ((which_str2 >= 0) && (which_str2 != minmax(0,num_strs,which_str2)))) { - giveError("The scenario attempted to access a message out of range."); + showError("The scenario attempted to access a message out of range."); return; } switch(cur_type) { @@ -4673,6 +4673,6 @@ void set_campaign_flag(short sdf_a, short sdf_b, short cpf_a, short cpf_b, short univ.party.cpn_flag(cpf_a, cpf_b) = univ.party.stuff_done[sdf_a][sdf_b]; } } catch(std::range_error x) { - giveError(x.what()); + showError(x.what()); } } diff --git a/src/boe.town.cpp b/src/boe.town.cpp index d5aa0030..2f93863a 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -115,7 +115,7 @@ void start_town_mode(short which_town, short entry_dir) { former_town = town_number = which_town; if(town_number < 0 || town_number >= univ.scenario.towns.size()) { - giveError("The scenario tried to put you into a town that doesn't exist.", + showError("The scenario tried to put you into a town that doesn't exist.", "Requested town: " + std::to_string(town_number) + "|Max town: " + std::to_string(univ.scenario.towns.size())); return; } @@ -139,7 +139,7 @@ void start_town_mode(short which_town, short entry_dir) { if(town_number < 0 || town_number >= univ.scenario.towns.size()) { - giveError("The scenario tried to put you into a town that doesn't exist.", + showError("The scenario tried to put you into a town that doesn't exist.", "Requested town: " + std::to_string(former_town) + "|Adjusted town: " + std::to_string(town_number) + "|Max town: " + std::to_string(univ.scenario.towns.size())); return; } diff --git a/src/classes/party.cpp b/src/classes/party.cpp index ecd535c3..191562c0 100644 --- a/src/classes/party.cpp +++ b/src/classes/party.cpp @@ -758,7 +758,7 @@ void cParty::readFrom(std::istream& file){ unsigned long long version; sin >> std::hex >> version >> std::dec; if(version > OBOE_CURRENT_VERSION) { - giveError("Warning: this game appears to have been created with a newer version of Blades of Exile than you are running. Exile will do its best to load the saved game anyway, but there may be loss of information."); + showWarning("This game appears to have been created with a newer version of Blades of Exile than you are running. Exile will do its best to load the saved game anyway, but there may be loss of information."); } } else if(cur == "POINTER") { int i,j,k; diff --git a/src/classes/special.cpp b/src/classes/special.cpp index 5db78346..01bcdc2c 100644 --- a/src/classes/special.cpp +++ b/src/classes/special.cpp @@ -432,7 +432,7 @@ void cSpecial::append(legacy::special_node_type& old){ // These are ones that were added in the Windows version but only recently added to the Mac version. case 28: type = eSpecType::DISPLAY_PICTURE; - giveError("Warning: This scenario contains a Display Picture special node created by the 'Classic Windows' version of the game. Although this version of the game also supports a Display Picture node, the format is incompatible, and automatic conversion is impossible.", "If this is not your scenario, consider contacting the scenario designer to get this fixed."); + showWarning("This scenario contains a Display Picture special node created by the 'Classic Windows' version of the game. Although this version of the game also supports a Display Picture node, the format is incompatible, and automatic conversion is impossible.", "If this is not your scenario, consider contacting the scenario designer to get this fixed."); ex1a = 0; break; case 29: @@ -451,7 +451,7 @@ void cSpecial::append(legacy::special_node_type& old){ break; default: if(old.type >= 0 && old.type < 255) - giveError("Unrecognized node type found: " + std::to_string(old.type)); + showError("Unrecognized node type found: " + std::to_string(old.type)); else std::cout << "Unrecognized node type found: " + std::to_string(old.type) << "\n\tNote: This could indicate corruption in the scenario, but more likely is just a result of garbage data in unused nodes or in the memory structures they were read into. The unrecognized node type has been replaced with invalid type -1."; } diff --git a/src/dialogxml/dlogutil.cpp b/src/dialogxml/dlogutil.cpp index b50614ba..78052ed8 100644 --- a/src/dialogxml/dlogutil.cpp +++ b/src/dialogxml/dlogutil.cpp @@ -522,8 +522,8 @@ void cStrDlog::show(){ dlg.run(); } -void giveError(std::string str1, std::string str2, cDialog* parent){ - cStrDlog error(str1,str2,"Error!!!",25,PIC_DLOG,parent); +static void giveError(pic_num_t pic, std::string title, std::string str1, std::string str2, cDialog* parent) { + cStrDlog error(str1,str2,title,pic,PIC_DLOG,parent); error->getControl("record").setText("Copy"); error.setRecordHandler([](cDialog& me) { std::string error = me["str1"].getText(); @@ -539,6 +539,26 @@ void giveError(std::string str1, std::string str2, cDialog* parent){ error.show(); } -void giveError(std::string str1, cDialog* parent) { - giveError(str1, "", parent); +void showError(std::string str1, cDialog* parent) { + showError(str1, "", parent); +} + +void showError(std::string str1, std::string str2, cDialog* parent) { + giveError(25, "Error", str1, str2, parent); +} + +void showWarning(std::string str1, cDialog* parent) { + showWarning(str1, "", parent); +} + +void showWarning(std::string str1, std::string str2, cDialog* parent) { + giveError(24, "Warning", str1, str2, parent); +} + +void showFatalError(std::string str1, cDialog* parent) { + showFatalError(str1, "", parent); +} + +void showFatalError(std::string str1, std::string str2, cDialog* parent) { + giveError(25, "Error!!!", str1, str2, parent); } diff --git a/src/dialogxml/dlogutil.hpp b/src/dialogxml/dlogutil.hpp index da62cba8..9f433738 100644 --- a/src/dialogxml/dlogutil.hpp +++ b/src/dialogxml/dlogutil.hpp @@ -255,12 +255,32 @@ public: }; #endif -/// Shows a simple error dialog. +/// Shows a simple error dialog for an unrecoverable condition. /// @param str1 The first string in the error dialog. /// @param str2 The second string in the error dialog. /// @param parent Optionally, a parent dialog. -void giveError(std::string str1, std::string str2, cDialog* parent = NULL); -/// Shows a simple error dialog. +void showFatalError(std::string str1, std::string str2, cDialog* parent = NULL); +/// Shows a simple error dialog for an unrecoverable condition. /// @param str1 The string in the error dialog. /// @param parent Optionally, a parent dialog. -void giveError(std::string str1, cDialog* parent = NULL); +void showFatalError(std::string str1, cDialog* parent = NULL); + +/// Shows a simple error dialog for a recoverable condition. +/// @param str1 The first string in the error dialog. +/// @param str2 The second string in the error dialog. +/// @param parent Optionally, a parent dialog. +void showError(std::string str1, std::string str2, cDialog* parent = NULL); +/// Shows a simple error dialog for a recoverable condition. +/// @param str1 The string in the error dialog. +/// @param parent Optionally, a parent dialog. +void showError(std::string str1, cDialog* parent = NULL); + +/// Shows a simple warning message dialog. +/// @param str1 The first string in the warning dialog. +/// @param str2 The second string in the warning dialog. +/// @param parent Optionally, a parent dialog. +void showWarning(std::string str1, std::string str2, cDialog* parent = NULL); +/// Shows a simple warning message dialog. +/// @param str1 The string in the warning dialog. +/// @param parent Optionally, a parent dialog. +void showWarning(std::string str1, cDialog* parent = NULL); diff --git a/src/dialogxml/field.cpp b/src/dialogxml/field.cpp index 0b913602..707e2cc6 100644 --- a/src/dialogxml/field.cpp +++ b/src/dialogxml/field.cpp @@ -47,7 +47,7 @@ bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFoc {FLD_UINT, "a positive integer"}, {FLD_REAL, "a number"}, }; - giveError("You need to enter " + typeNames.at(field_type) + "!","",parent); + showError("You need to enter " + typeNames.at(field_type) + "!","",parent); return false; } } diff --git a/src/pcedit/pc.main.cpp b/src/pcedit/pc.main.cpp index 5ab94f90..47e6970c 100644 --- a/src/pcedit/pc.main.cpp +++ b/src/pcedit/pc.main.cpp @@ -85,13 +85,13 @@ int main(int argc, char* argv[]) { Handle_One_Event(); return 0; } catch(std::exception& x) { - giveError(x.what()); + showFatalError(x.what()); throw; } catch(std::string& x) { - giveError(x); + showFatalError(x); throw; } catch(...) { - giveError("An unknown error occurred!"); + showFatalError("An unknown error occurred!"); throw; } } @@ -220,7 +220,7 @@ void handle_menu_choice(eMenu item_hit) { } if(univ.party.left_in != size_t(-1) && univ.party.left_in != univ.town.num) { std::string need_town = univ.scenario.towns[univ.party.left_in]->town_name; - giveError("You can't reunite your party when you're in a different town than you split up in.", "Return to the following town in-game and then try again: " + need_town); + showError("You can't reunite your party when you're in a different town than you split up in.", "Return to the following town in-game and then try again: " + need_town); break; } cChoiceDlog("reunited").show(); @@ -323,7 +323,7 @@ void handle_item_menu(int item_hit) { store_i = univ.scenario.scen_items[item_hit]; store_i.ident = true; if(!univ.party[current_active_pc].give_item(store_i,GIVE_ALLOW_OVERLOAD)) - giveError("Sorry, that PC has no free inventory slots left! You'll have to either drop something or give it to a different PC."); + showError("Sorry, that PC has no free inventory slots left! You'll have to either drop something or give it to a different PC."); } bool verify_restore_quit(std::string dlog) { diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index 85555038..23f6154d 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -188,11 +188,11 @@ static bool handle_lb_action(location the_point) { break; case LB_NEW_TOWN: if(change_made) { - giveError("You need to save the changes made to your scenario before you can add a new town."); + showError("You need to save the changes made to your scenario before you can add a new town."); return true; } if(scenario.towns.size() >= 200) { - giveError("You have reached the limit of 200 towns you can have in one scenario."); + showError("You have reached the limit of 200 towns you can have in one scenario."); return true; } if(new_town(scenario.towns.size())) @@ -822,7 +822,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) { break; case MODE_PLACE_SAME_CREATURE: if(last_placed_monst.number == 0) { - giveError("Either no monster has been placed, or the last time you tried to place a monster the operation failed."); + showError("Either no monster has been placed, or the last time you tried to place a monster the operation failed."); break; } for(i = 0; i < town->creatures.size(); i++) @@ -920,7 +920,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) { break; case MODE_PLACE_SAME_ITEM: if(store_place_item.code < 0) { - giveError("Either no item has been placed, or the last time you tried to place an item the operation failed."); + showError("Either no item has been placed, or the last time you tried to place an item the operation failed."); break; } for(x = 0; x < town->preset_items.size(); x++) @@ -996,13 +996,13 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) { } } if(x != -1) - giveError("There wasn't a special on that spot."); + showError("There wasn't a special on that spot."); set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PASTE_SPECIAL: //paste special if(copied_spec < 0) { - giveError("You need to select a special to copy first."); + showError("You need to select a special to copy first."); break; } if(editing_town) { @@ -1090,7 +1090,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) { if(cChoiceDlog("set-out-start-confirm", {"okay", "cancel"}).show() == "cancel") break; if((spot_hit.x != minmax(4,43,spot_hit.x)) || (spot_hit.y != minmax(4,43,spot_hit.y))) { - giveError("You can't put the starting location this close to the edge of an outdoor section. It has to be at least 4 spaces away."); + showError("You can't put the starting location this close to the edge of an outdoor section. It has to be at least 4 spaces away."); break; } scenario.out_sec_start.x = cur_out.x; @@ -1188,7 +1188,7 @@ static bool handle_terpal_action(location cur_point, bool option_hit) { if(k >= scenario.scen_items.size()) break; if(scenario.scen_items[k].variety == eItemType::NO_ITEM) { - giveError("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type."); + showError("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type."); break; } overall_mode = MODE_PLACE_ITEM; @@ -2222,7 +2222,7 @@ void place_items_in_town() { } } if(place_failed) - giveError("Not all of the random items could be placed. The preset item per town limit of 64 was reached."); + showError("Not all of the random items could be placed. The preset item per town limit of 64 was reached."); draw_terrain(); } @@ -2339,7 +2339,7 @@ void town_entry(location spot_hit) { ter = current_terrain->terrain[spot_hit.x][spot_hit.y]; if(scenario.ter_types[ter].special != eTerSpec::TOWN_ENTRANCE) { - giveError("This space isn't a town entrance. Town entrances are marked by a small brown castle icon."); + showError("This space isn't a town entrance. Town entrances are marked by a small brown castle icon."); return; } // clean up old town entries diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 440d9011..8e519a85 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -92,7 +92,7 @@ static bool save_ter_info(cDialog& me, cTerrain& ter) { case eTerSpec::CALL_SPECIAL: case eTerSpec::CALL_SPECIAL_WHEN_USED: if(spec_type < 0 || spec_type > 1) { - giveError("Special type must be either 0 or 1.", &me); + showError("Special type must be either 0 or 1.", &me); return false; } if(!check_range(me, "flag1", true, 0, (spec_type == 0 ? num_glob : num_loc) - 1, "Special to call")) return false; @@ -157,7 +157,7 @@ bool check_range_msg(cDialog& me,std::string id,bool losing,long min_val,long ma std::ostringstream sout; sout << fld_name << " must be from " << min_val << " to " << max_val; if(!xtra.empty()) sout << ' ' << '(' << xtra << ')'; - giveError(sout.str(), "", &me); + showError(sout.str(), "", &me); return false; } return true; @@ -455,10 +455,10 @@ static bool edit_ter_obj(cDialog& me, ter_num_t which_ter) { if(fld != "id") { int i = me[fld].getTextAsNum(); if(i > 4 || (i == 4 && (fld == "x" || fld == "y"))) { - giveError("Terrain objects cannot be larger than 4x4 tiles.", &me); + showError("Terrain objects cannot be larger than 4x4 tiles.", &me); return false; } else if(id > 0 && i == 0 && (fld == "w" || fld == "h")) { - giveError("Width and height cannot be zero.", &me); + showError("Width and height cannot be zero.", &me); return false; } } else { @@ -490,7 +490,7 @@ static bool edit_ter_obj(cDialog& me, ter_num_t which_ter) { int x = me["x"].getTextAsNum(), y = me["y"].getTextAsNum(); int w = me["w"].getTextAsNum(), h = me["h"].getTextAsNum(); if(x >= w || y >= h) { - giveError("X and Y must be less than width and height, respectively.", &me); + showError("X and Y must be less than width and height, respectively.", &me); me.untoast(); return true; } @@ -1162,7 +1162,7 @@ static bool edit_monst_abil_detail(cDialog& me, std::string hit, cMonster& monst iter = monst.addAbil(tmpl, param); // Normally it'll never return end(), but if a new template was added and not implemented, it would. if(iter == monst.abil.end()) { - giveError("Failed to add the new ability. When reporting this, mention which ability you tried to add.", &me); + showError("Failed to add the new ability because the ability was not implemented. When reporting this, mention which ability you tried to add.", &me); return true; } if(save_abils.find(iter->first) != save_abils.end() && save_abils[iter->first].active) { @@ -1559,7 +1559,7 @@ static void save_item_info(cDialog& me, cItem& item) { if((cat == eItemAbilCat::USABLE || cat == eItemAbilCat::REAGENT) && item.charges == 0) item.charges = 1; if(was_charges != item.charges) - giveError("Due to either the selected special ability or the presence of a type flag, this item's charges have been set to 1.", &me); + showError("Due to either the selected special ability or the presence of a type flag, this item's charges have been set to 1.", &me); } static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& item, short& which) { @@ -1569,7 +1569,7 @@ static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& ite bool valid = true; if(variety.substr(0,6) == "unused") valid = false; if(!valid && hit != "cancel" && hit.substr(0,6) != "choose") { - giveError("The Unused item varieties are reserved for later expansions, and can't be used now.","",&me); + showError("The Unused item varieties are reserved for later expansions, and can't be used now.","",&me); return true; } @@ -1622,11 +1622,11 @@ static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& ite } else if(hit == "abils") { save_item_info(me, item); if(item.variety == eItemType::NO_ITEM) { - giveError("You must give the item a type (weapon, armor, etc.) before you can choose its abilities.","",&me); + showError("You must give the item a type (weapon, armor, etc.) before you can choose its abilities.","",&me); return true; } if(item.variety == eItemType::GOLD || item.variety == eItemType::FOOD || item.variety == eItemType::SPECIAL || item.variety == eItemType::QUEST) { - giveError("Gold, Food, Quests, and Special Items cannot be given special abilities.","",&me); + showError("Gold, Food, Quests, and Special Items cannot be given special abilities.","",&me); return true; } temp_item = edit_item_abil(item,which,me); @@ -1859,7 +1859,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite } else if(hit == "weapon") { save_item_abils(me, item); if(!isWeaponType(item.variety)) { - giveError("You can only give an ability of this sort to a weapon.","",&me); + showError("You can only give an ability of this sort to a weapon.","",&me); return true; } i = choose_text_res("item-abilities", 1, 14, int(item.ability), &me, "Choose Weapon Ability (inherent)"); @@ -1868,7 +1868,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite if(abil >= eItemAbil::RETURNING_MISSILE && abil <= eItemAbil::SEEKING_MISSILE) { if(item.variety != eItemType::THROWN_MISSILE && item.variety != eItemType::ARROW && item.variety != eItemType::BOLTS && item.variety != eItemType::MISSILE_NO_AMMO) { - giveError("You can only give this ability to a missile.",&me); + showError("You can only give this ability to a missile.",&me); return true; } } @@ -1877,7 +1877,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite } else if(hit == "general") { save_item_abils(me, item); if(equippable.count(item.variety) == 0 || item.variety == eItemType::ARROW || item.variety == eItemType::THROWN_MISSILE || item.variety == eItemType::BOLTS){ - giveError("You can only give an ability of this sort to an non-missile item which can be equipped (like armor, or a ring).",&me); + showError("You can only give an ability of this sort to an non-missile item which can be equipped (like armor, or a ring).",&me); return true; } i = choose_text_res("item-abilities", 30, 60, int(item.ability), &me, "Choose General Ability (inherent)"); @@ -1887,7 +1887,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite } else if(hit == "usable") { save_item_abils(me, item); if((item.variety == eItemType::ARROW) || (item.variety == eItemType::THROWN_MISSILE) || (item.variety == eItemType::BOLTS)){ - giveError("You can't give an ability of this sort to a missile.",&me); + showError("You can't give an ability of this sort to a missile.",&me); return true; } i = choose_text_res("item-abilities", 70, 84, int(item.ability), &me, "Choose Usable Ability"); @@ -1897,7 +1897,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite } else if(hit == "reagent") { save_item_abils(me, item); if(item.variety != eItemType::NON_USE_OBJECT){ - giveError("You can only give an ability of this sort to an item of type Non-Use Object.",&me); + showError("You can only give an ability of this sort to an item of type Non-Use Object.",&me); return true; } i = choose_text_res("item-abilities", 150, 160, int(item.ability), &me, "Choose Reagent Ability"); @@ -2339,7 +2339,7 @@ static bool delete_shop_entry(cDialog& me, std::string which, cShop& shop, size_ static bool add_shop_entry(cDialog& me, std::string type, cShop& shop, size_t which_shop) { if(shop.size() == 30) { - giveError("There is no more room in this shop to add another item. Each shop can only have up to 30 items.", &me); + showError("There is no more room in this shop to add another item. Each shop can only have up to 30 items.", &me); return true; } if(type == "item" || type == "opt") { @@ -2465,7 +2465,7 @@ static bool save_save_rects(cDialog& me) { scenario.store_item_rects[i].right = me["right" + id].getTextAsNum(); scenario.store_item_towns[i] = me["town" + id].getTextAsNum(); if((scenario.store_item_towns[i] < -1) || (scenario.store_item_towns[i] >= 200)) { - giveError("Towns must be in 0 to 200 range (or -1 for no save items rectangle).","",&me); + showError("Towns must be in 0 to 200 range (or -1 for no save items rectangle).","",&me); return false; } } @@ -2478,7 +2478,7 @@ static bool save_save_rects(cDialog& me) { ((scenario.store_item_towns[2] == scenario.store_item_towns[0]) && (scenario.store_item_towns[2] >= 0) && (scenario.store_item_towns[0] >= 0)) ) { - giveError("The three towns towns with saved item rectangles must be different.","",&me); + showError("The three towns towns with saved item rectangles must be different.","",&me); return false; } return true; @@ -2827,12 +2827,12 @@ static bool make_scen_check_out(cDialog& me, std::string which, bool losing) { else if(which == "out-h") error << "height"; error << " must be between 1 and 50."; - giveError(error.str(), &me); + showError(error.str(), &me); return false; } int total = w * h; if(total < 1 || total > 50) { - giveError("The total number of outdoor sections (width times height) must be between 1 and 100.", &me); + showError("The total number of outdoor sections (width times height) must be between 1 and 100.", &me); return false; } return true; @@ -2851,13 +2851,13 @@ static bool make_scen_check_towns(cDialog& me, std::string which, bool losing) { else if(which == "town-l") error << "large"; error << " must be between 0 and 200"; - giveError(error.str(), &me); + showError(error.str(), &me); return false; } // TODO: Shouldn't this only be checked when exiting the dialog? At least for the case of no towns. int total = sm + med + lg; if(total < 1 || total > 200) { - giveError("The total number of towns must be from 1 to 200 (you must have at least 1 town).", &me); + showError("The total number of towns must be from 1 to 200 (you must have at least 1 town).", &me); return false; } return true; @@ -2872,7 +2872,7 @@ bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m, new_dlog["warrior-grove"].attachFocusHandler([](cDialog& me, std::string, bool losing) -> bool { if(losing) return true; if(me["town-m"].getTextAsNum() < 1) { - giveError("Warrior's Grove replaces your first medium town. As such, you must have at least one medium town in order to use it.", &me); + showError("Warrior's Grove replaces your first medium town. As such, you must have at least one medium town in order to use it.", &me); return false; } return true; @@ -2912,7 +2912,7 @@ bool build_scenario() { fs::path basePath = progDir/"Scenario Editor"/"Blades of Exile Base"/"bladbase.exs"; if(!fs::exists(basePath)) { - giveError("Blades of Exile Base could not be found."); + showError("Blades of Exile Base could not be found."); return false; } cScenario base; @@ -3097,7 +3097,7 @@ static bool check_location_bounds(cDialog& me, std::string id, bool losing) { short town_num = me["town-num"].getTextAsNum(); short dim = me[id].getTextAsNum(); if(dim < 0 || dim >= scenario.towns[town_num]->max_dim()) { - giveError("This coordinate is not inside the bounds of the town."); + showError("This coordinate is not inside the bounds of the town."); return false; } return true; @@ -3145,7 +3145,7 @@ static bool check_scenario_timer_time(cDialog& me, std::string id, bool losing) if(!losing) return true; int val = me[id].getTextAsNum(); if(val > 0 && val % 10 != 0) { - giveError("All scenario event times must be multiples of 10 (e.g. 100, 150, 1000, etc.)."); + showError("All scenario event times must be multiples of 10 (e.g. 100, 150, 1000, etc.)."); return false; } return true; @@ -3312,7 +3312,7 @@ static bool change_pics_page(cDialog& me, std::string hit, std::vector void edit_custom_pics_types() { if(spec_scen_g.count() == 0) { - giveError("You don't have any custom graphics to classify!"); + showError("You don't have any custom graphics to classify!"); return; } using namespace std::placeholders; @@ -3479,7 +3479,7 @@ void edit_custom_sheets() { } else { auto iter = std::lower_bound(all_pics.begin(), all_pics.end(), newSheet); if(*iter == newSheet) { - giveError("Sorry, but that sheet already exists! Try creating a sheet with a different number.", "Sheet number: " + std::to_string(newSheet), &me); + showError("Sorry, but that sheet already exists! Try creating a sheet with a different number.", "Sheet number: " + std::to_string(newSheet), &me); return true; } iter = all_pics.insert(iter, newSheet); diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index 2d2e948a..33036653 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -106,7 +106,7 @@ static std::string str_info(eStrMode str_mode, size_t which) { //cre = check range error bool cre(short val,short min,short max,std::string text1,std::string text2,cDialog* parent) { if((val < min) || (val > max)) { - giveError(text1,text2,parent); + showError(text1,text2,parent); return true; } return false; @@ -178,7 +178,7 @@ pic_num_t choose_graphic(short cur_choice,ePicType g_type,cDialog* parent) { case PIC_TER_MAP: total_pics = 977; break; case PIC_FULL: if(!fs::is_directory(tempDir/scenario_temp_dir_name/"graphics")) { - giveError("You have no custom graphics, so it's not possible to select this kind of picture!",parent); + showError("You have no custom graphics, so it's not possible to select this kind of picture!",parent); return NO_PIC; } for(fs::directory_iterator iter(tempDir/scenario_temp_dir_name/"graphics"); iter != fs::directory_iterator(); iter++) { @@ -917,7 +917,7 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& default: choose_string = false; store = val; - giveError("Whoops! Unknown edit type! (" + (btn + std::string(")")), "", &me); + showError("Whoops! Unknown edit type! (" + (btn + std::string(")")), "", &me); break; } if(choose_string) @@ -934,7 +934,7 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) { if(mode == 0) { if(which_node >= scenario.scen_specials.size()) { - giveError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); + showError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); return false; } if(scenario.scen_specials[which_node].pic < 0) @@ -942,7 +942,7 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) { the_node = scenario.scen_specials[which_node]; } else if(mode == 1) { if(which_node >= current_terrain->specials.size()) { - giveError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); + showError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); return false; } if(current_terrain->specials[which_node].pic < 0) @@ -950,7 +950,7 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) { the_node = current_terrain->specials[which_node]; } else if(mode == 2) { if(which_node >= town->specials.size()) { - giveError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); + showError("That special node does not exist. You can create a new node by setting the field to -1 and trying again.", parent); return false; } if(town->specials[which_node].pic < 0) @@ -1105,7 +1105,7 @@ void edit_dialog_text(eStrMode mode,short *str1,cDialog* parent) { fetch_str(mode, i).clear(); } if(*str1 < 0) { - giveError("To create a dialog, you need 6 consecutive unused messages. To free up 6 messages, select Edit Out/Town/Scenario Text from the menus.","",parent); + showError("To create a dialog, you need 6 consecutive unused messages. To free up 6 messages, select Edit Out/Town/Scenario Text from the menus.","",parent); return; } @@ -1136,7 +1136,7 @@ static bool edit_special_num_event_filter(cDialog& me, std::string item_hit, sho else if(item_hit == "okay") { i = me["num"].getTextAsNum(); if(i < 0 || i >= num_specs) { - giveError("There is no special node with that number. The available range is 0 to " + std::to_string(num_specs - 1) + ".",&me); + showWarning("There is no special node with that number. The available range is 0 to " + std::to_string(num_specs - 1) + ".","The node has been set anyway. To create it, select Edit Special Nodes from the menu, scroll to the bottom, and select Create new Node.",&me); } me.setResult(i); me.toast(true); @@ -1163,7 +1163,7 @@ static bool edit_scen_intro_event_filter(cDialog& me, std::string item_hit, eKey if(item_hit == "okay") { scenario.intro_pic = me["picnum"].getTextAsNum(); if(scenario.intro_pic > 29) { - giveError("Intro picture number is out of range.","",&me); + showError("Intro picture number is out of range.","",&me); return true; } for(i = 0; i < 6; i++) { diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 1d820ec0..b78f4e1b 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -107,13 +107,13 @@ int main(int argc, char* argv[]) { close_program(); return 0; } catch(std::exception& x) { - giveError(x.what()); + showFatalError(x.what()); throw; } catch(std::string& x) { - giveError(x); + showFatalError(x); throw; } catch(...) { - giveError("An unknown error occurred!"); + showFatalError("An unknown error occurred!"); throw; } } @@ -281,11 +281,11 @@ void handle_menu_choice(eMenu item_hit) { break; case eMenu::TOWN_CREATE: if(change_made) { - giveError("You need to save the changes made to your scenario before you can add a new town."); + showError("You need to save the changes made to your scenario before you can add a new town."); return; } if(scenario.towns.size() >= 200) { - giveError("You have reached the limit of 200 towns you can have in one scenario."); + showError("You have reached the limit of 200 towns you can have in one scenario."); return; } if(new_town(scenario.towns.size())) @@ -336,7 +336,7 @@ void handle_menu_choice(eMenu item_hit) { break; case eMenu::TOWN_IMPORT: if(change_made) { - giveError("You need to save the changes made to your scenario before you can import a town."); + showError("You need to save the changes made to your scenario before you can import a town."); return; } if(cTown* town = pick_import_town()) { @@ -350,7 +350,7 @@ void handle_menu_choice(eMenu item_hit) { break; case eMenu::OUT_IMPORT: if(change_made) { - giveError("You need to save the changes made to your scenario before you can import a sector."); + showError("You need to save the changes made to your scenario before you can import a sector."); return; } if(cOutdoors* out = pick_import_out()) { @@ -387,19 +387,19 @@ void handle_menu_choice(eMenu item_hit) { break; case eMenu::TOWN_DELETE: if(change_made) { - giveError("You need to save the changes made to your scenario before you can delete a town."); + showError("You need to save the changes made to your scenario before you can delete a town."); return; } if(scenario.towns.size() == 1) { - giveError("You can't delete the last town in a scenario. All scenarios must have at least 1 town."); + showError("You can't delete the last town in a scenario. All scenarios must have at least 1 town."); return; } if(scenario.towns.size() - 1 == cur_town) { - giveError("You can't delete the last town in a scenario while you're working on it. Load a different town, and try this again."); + showError("You can't delete the last town in a scenario while you're working on it. Load a different town, and try this again."); return; } if(scenario.towns.size() - 1 == scenario.which_town_start) { - giveError("You can't delete the last town in a scenario while it's the town the party starts the scenario in. Change the parties starting point and try this again."); + showError("You can't delete the last town in a scenario while it's the town the party starts the scenario in. Change the parties starting point and try this again."); return; } if(cChoiceDlog("delete-town-confirm", {"okay", "cancel"}).show() == "okay") diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index 2764f9d5..b5ff147b 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -260,14 +260,14 @@ static bool get_placed_item_in_dlog(cDialog& me, cTown::cItem& item, const short item.charges = me["charges"].getTextAsNum(); if(item.charges < -1 || item.charges > 2500) { - giveError("Number of charges/amount of gold or food must be from 0 to 2500.", + showError("Number of charges/amount of gold or food must be from 0 to 2500.", "If an item with charges (not gold or food) leave this at -1 for the item to have the default number of charges.",&me); return true; } eItemType type = scenario.scen_items[item.code].variety; if(item.charges == 0 && (type == eItemType::GOLD || type == eItemType::FOOD)) { - giveError("You must assign gold or food an amount of at least 1.","",&me); + showError("You must assign gold or food an amount of at least 1.","",&me); return false; } @@ -911,7 +911,7 @@ static bool check_talk_personality(cDialog& me, std::string item_hit, bool losin std::ostringstream message; message << "The legal range for personalities in this town is from "; message << cur_town * 10 << " to " << cur_town * 10 + 9 << "."; - giveError("Personalities in talk nodes must be -1 (for unused node), -2 (all personalities use) or in the legal range of personalities in this town.", message.str(), &me); + showError("Personalities in talk nodes must be -1 (for unused node), -2 (all personalities use) or in the legal range of personalities in this town.", message.str(), &me); return false; } return true; @@ -927,7 +927,7 @@ static bool check_talk_key(cDialog& me, std::string item_hit, bool losing) { passes = false; } if(!passes) { - giveError("The words this node is the response to must be 4 characters long, and all characters must be lower case letters.", &me); + showError("The words this node is the response to must be 4 characters long, and all characters must be lower case letters.", &me); return false; } return true; diff --git a/src/tools/fileio_party.cpp b/src/tools/fileio_party.cpp index 6bec2de4..3fb8dae1 100644 --- a/src/tools/fileio_party.cpp +++ b/src/tools/fileio_party.cpp @@ -54,7 +54,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){ // the three flags still follow that. FILE* file_id = fopen(file_to_load.string().c_str(), "rb"); if(file_id == NULL) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } @@ -63,7 +63,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){ n = fread(&flags, len, 1, file_id); if(n < 1) { fclose(file_id); - giveError("This is not a Blades of Exile save file."); + showError("This is not a Blades of Exile save file."); return false; } @@ -142,7 +142,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){ case new_oboe: return load_party_v2(file_to_load, univ, town_restore, in_scen, maps_there); case unknown: - giveError("This is not a Blades of Exile save file."); + showError("This is not a Blades of Exile save file."); return false; } @@ -306,7 +306,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo { // Load main party data first std::istream& fin = partyIn.getFile("save/party.txt"); if(!fin) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } univ.party.readFrom(fin); @@ -315,7 +315,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo { // Then the "setup" array std::istream& fin = partyIn.getFile("save/setup.dat"); if(!fin) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } uint16_t magic; @@ -334,7 +334,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo fname[7] = i + '1'; std::istream& fin = partyIn.getFile(fname); if(!fin) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } univ.party[i].readFrom(fin); @@ -363,7 +363,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo // Load town data std::istream& fin = partyIn.getFile("save/town.txt"); if(!fin) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } univ.town.readFrom(fin); @@ -382,7 +382,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo // Load outdoors data std::istream& fin = partyIn.getFile("save/out.txt"); if(!fin) { - giveError("Loading Blades of Exile save file failed."); + showError("Loading Blades of Exile save file failed."); return false; } univ.out.readFrom(fin); @@ -406,7 +406,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo spec_scen_g.party_sheet.reset(new sf::Texture); spec_scen_g.party_sheet->create(party_sheet.getSize().x, party_sheet.getSize().y); spec_scen_g.party_sheet->update(party_sheet); - } else giveError("There was an error loading the party custom graphics."); + } else showWarning("There was an error loading the party custom graphics."); } return true; diff --git a/src/tools/fileio_scen.cpp b/src/tools/fileio_scen.cpp index b46d0df2..e2926cf2 100644 --- a/src/tools/fileio_scen.cpp +++ b/src/tools/fileio_scen.cpp @@ -77,10 +77,10 @@ bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header) else if(fname.substr(dot) == ".exs") return load_scenario_v1(file_to_load, scenario, only_header); } catch(std::exception& x) { - giveError("There was an error loading the scenario. The details of the error are given below; you may be able to decompress the scenario package, fix the error, and repack it.", x.what()); + showError("There was an error loading the scenario. The details of the error are given below; you may be able to decompress the scenario package, fix the error, and repack it.", x.what()); return false; } - giveError("That is not a Blades of Exile scenario."); + showError("That is not a Blades of Exile scenario."); return false; } @@ -115,7 +115,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head // TODO: Convert this (and all the others in this file) to use C++ streams FILE* file_id = fopen(file_to_load.string().c_str(),"rb"); if(file_id == NULL) { - giveError(err_prefix + "Could not open file.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not open file.", boost::lexical_cast(std_fmterr)); return false; } @@ -123,7 +123,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head if(fread(&scenario.format, len, 1, file_id) < 1){ fclose(file_id); - giveError(err_prefix + "Failed to read scenario header.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Failed to read scenario header.", boost::lexical_cast(std_fmterr)); return false; } @@ -142,7 +142,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head } if(!file_ok) { fclose(file_id); - giveError("This is not a legitimate Blades of Exile scenario."); + showError("This is not a legitimate Blades of Exile scenario."); return false; } @@ -150,7 +150,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head n = fread(temp_scenario, len, 1, file_id); if(n < 1){ fclose(file_id); - giveError(err_prefix + "Failed to read scenario data.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Failed to read scenario data.", boost::lexical_cast(std_fmterr)); return false; } port_scenario(temp_scenario); @@ -158,7 +158,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head n = fread(item_data, len, 1, file_id); if(n < 1){ fclose(file_id); - giveError(err_prefix + "Failed to read scenario items.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Failed to read scenario items.", boost::lexical_cast(std_fmterr)); return false; } port_item_list(item_data); @@ -629,7 +629,7 @@ static void initialXmlRead(ticpp::Document& data, std::string root_tag, int& maj if(name == "boes") { std::tie(maj, min, rev) = parse_version(val); if(maj < 2) { - giveError("This scenario specifies an invalid format version. Loading will be attempted as if it were version 2.0.0, but there is a possibility that there could be errors."); + showError("This scenario specifies an invalid format version. Loading will be attempted as if it were version 2.0.0, but there is a possibility that there could be errors."); maj = 2; min = rev = 0; } @@ -1970,7 +1970,7 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario, bool only_head tarball pack; std::ifstream fin; if(!fs::exists(file_to_load)) { - giveError("The scenario could not be found."); + showError("The scenario could not be found."); return false; } if(fs::is_directory(file_to_load)) { // Unpacked @@ -1979,7 +1979,7 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario, bool only_head igzstream gzin(file_to_load.string().c_str()); pack.readFrom(gzin); if(gzin.bad()) { - giveError("There was an error loading the scenario."); + showError("There was an error loading the scenario."); return false; } } @@ -2155,7 +2155,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy: FILE* file_id = fopen(scen_file.string().c_str(), "rb"); if(file_id == NULL) { - giveError(err_prefix + "Could not open file for reading town data.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not open file for reading town data.", boost::lexical_cast(std_fmterr)); return false; } @@ -2163,7 +2163,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy: n = fseek(file_id, len_to_jump, SEEK_SET); if(n != 0) { fclose(file_id); - giveError(err_prefix + "Failure seeking to town record.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Failure seeking to town record.", boost::lexical_cast(std_fmterr)); return false; } @@ -2171,7 +2171,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy: n = fread(&store_town, len, 1, file_id); if(n < 1) { fclose(file_id); - giveError(err_prefix + "Could not read town record.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not read town record.", boost::lexical_cast(std_fmterr)); return false; } port_town(&store_town); @@ -2224,7 +2224,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy: n = fread(&store_talk, len, 1, file_id); if(n < 1) { fclose(file_id); - giveError(err_prefix + "Could not read dialogue record.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not read dialogue record.", boost::lexical_cast(std_fmterr)); return false; } port_talk_nodes(&store_talk); @@ -2259,7 +2259,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy: n = fclose(file_id); if(n != 0) { - giveError(err_prefix + "An error occurred while closing the file.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "An error occurred while closing the file.", boost::lexical_cast(std_fmterr)); } return true; @@ -2293,7 +2293,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out, FILE* file_id = fopen(scen_file.string().c_str(), "rb"); if(file_id == NULL) { - giveError(err_prefix + "Could not open file for reading outdoor data.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not open file for reading outdoor data.", boost::lexical_cast(std_fmterr)); return false; } @@ -2301,7 +2301,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out, n = fseek(file_id, len_to_jump, SEEK_SET); if(n != 0) { fclose(file_id); - giveError(err_prefix + "Failure seeking to outdoor record.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Failure seeking to outdoor record.", boost::lexical_cast(std_fmterr)); return false; } @@ -2309,7 +2309,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out, n = fread(&store_out, len, 1, file_id); if(n < 1) { fclose(file_id); - giveError(err_prefix + "Could not read outdoor record.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Could not read outdoor record.", boost::lexical_cast(std_fmterr)); return false; } @@ -2335,7 +2335,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out, n = fclose(file_id); if(n != 0) { - giveError(err_prefix + "Something went wrong when closing the file.", boost::lexical_cast(std_fmterr)); + showError(err_prefix + "Something went wrong when closing the file.", boost::lexical_cast(std_fmterr)); } return true; } @@ -2367,7 +2367,7 @@ void load_spec_graphics_v1(fs::path scen_file) { if(fs::exists(gpath)) { if(graphics_store.loadFromFile(gpath.string())) foundGraphics = true; - else giveError("An old-style .bmp graphics file was found, but there was an error reading from the file.",noGraphics); + else showWarning("An old-style .bmp graphics file was found, but there was an error reading from the file.",noGraphics); } } if(foundGraphics) { @@ -2378,7 +2378,7 @@ void load_spec_graphics_v1(fs::path scen_file) { spec_scen_g.sheets = new sf::Texture[1]; spec_scen_g.numSheets = 1; if(!spec_scen_g.sheets[0].loadFromImage(graphics_store)) { - giveError("An error occurred while converting old-style graphics into the new format.",noGraphics); + showWarning("An error occurred while converting old-style graphics into the new format.",noGraphics); spec_scen_g.is_old = false; spec_scen_g.numSheets = 0; delete[] spec_scen_g.sheets; diff --git a/src/tools/qdpict.cpp b/src/tools/qdpict.cpp index 6fc7d0c1..b2f816d4 100644 --- a/src/tools/qdpict.cpp +++ b/src/tools/qdpict.cpp @@ -45,7 +45,7 @@ template class ptr_guard { void boundcheck() { if(the_ptr > guard) { std::string overflow = std::to_string(the_ptr - guard); - giveError(err_prefix + "read pointer reached end of buffer", overflow); + showError(err_prefix + "read pointer reached end of buffer", overflow); throw std::runtime_error(overflow); } } @@ -71,7 +71,7 @@ public: T& operator[](size_t i) { if(the_ptr + i > guard) { std::string overflow = std::to_string(i - (guard - the_ptr)); - giveError(err_prefix + "attempt to index beyond buffer", overflow); + showError(err_prefix + "attempt to index beyond buffer", overflow); throw std::runtime_error(overflow); } return the_ptr[i]; @@ -86,7 +86,7 @@ static void loadColourTable(ptr_guard& picData, sf::Color(& clut)[256], in while(numColours >= 0) { int i = extract_word(picData); if(i > 256) { - giveError(err_prefix + " Found too many colours in 'clut'", std::to_string(i)); + showError(err_prefix + " Found too many colours in 'clut'", std::to_string(i)); throw std::runtime_error(std::to_string(i)); } picData += 2; @@ -164,7 +164,7 @@ static legacy::Rect loadPixMapData(ptr_guard& picData, ptr_guard& picData, ptr_guard= 256) { - giveError(err_prefix + "More than 256 colours found."); + showError(err_prefix + "More than 256 colours found."); throw std::runtime_error(std::to_string(numColours)); } picData += 2; @@ -206,12 +206,12 @@ static rectangle loadFromPictResource(Handle resHandle, unsigned char*& pixelSto picFrame.bottom = extract_word(picData); picData += 2; picFrame.right = extract_word(picData); picData += 2; if(strncmp(picData, "\0\x11\x02\xff", 4) != 0) { // QuickDraw version code (version 2) - giveError("Missing QuickDraw 2 version code"); + showError("Missing QuickDraw 2 version code"); throw std::runtime_error("QD2 version"); } picData += 4; // Skip version field if(strncmp(picData, "\x0c\0", 2) != 0) { // Header opcode - giveError("Missing QuickDraw 2 header opcode"); + showError("Missing QuickDraw 2 header opcode"); throw std::runtime_error("QD2 header"); } picData += 2 + 24; // Skip header opcode and payload @@ -466,25 +466,25 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) { err = FSGetResourceForkName(&rsrc); err = FSOpenResourceFile(&file, rsrc.length, rsrc.unicode, fsRdPerm, &custRef); if(err != noErr) { - giveError("An old-style .meg graphics file was found, but neither data nor resource fork could be read.",noGraphics); + showError("An old-style .meg graphics file was found, but neither data nor resource fork could be read.",noGraphics); return false; } } int nPicts = Count1Resources('PICT'); if(nPicts < 1) { CloseResFile(custRef); - giveError("An old-style .meg graphics file was found, but it did not contain any PICT resources.",noGraphics); + showError("An old-style .meg graphics file was found, but it did not contain any PICT resources.",noGraphics); return false; } Handle resHandle = Get1Resource('PICT', 1); if(ResError() == resNotFound) { CloseResFile(custRef); - giveError("An old-style .meg graphics file was found, but it did not contain a PICT resource of ID 1.",noGraphics); + showError("An old-style .meg graphics file was found, but it did not contain a PICT resource of ID 1.",noGraphics); return false; } if(resHandle == NULL) { CloseResFile(custRef); - giveError("An old-style .meg graphics file was found, but an error occurred while fetching the PICT resource of ID 1.",noGraphics); + showError("An old-style .meg graphics file was found, but an error occurred while fetching the PICT resource of ID 1.",noGraphics); return false; } unsigned char* data = NULL; @@ -495,13 +495,13 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) { } catch(std::runtime_error&) { CloseResFile(custRef); if(data != NULL) delete[] data; - giveError("An old-style .meg graphics file was found, but an error occurred while loading the PICT resource of ID 1.",noGraphics); + showError("An old-style .meg graphics file was found, but an error occurred while loading the PICT resource of ID 1.",noGraphics); return false; } CloseResFile(custRef); if(picFrame.width() <= 0 || picFrame.height() <= 0) { if(data != NULL) delete[] data; - giveError("An old-style .meg graphics file was found, but an error occurred while reading it: " + errStrings[error],noGraphics); + showError("An old-style .meg graphics file was found, but an error occurred while reading it: " + errStrings[error],noGraphics); return false; } graphics_store.create(picFrame.width(), picFrame.height(), data);