From 08236555f96260cc6086a443e1be85ec0bd477fb Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 16 Feb 2015 16:10:08 -0500 Subject: [PATCH] Fixes to traits dialog - Now updates properly (thanks to Erdos for helping to track down the cause of this) - No longer crashes if the PC has a monster race --- src/boe.dlgutil.cpp | 2 +- src/boe.infodlg.cpp | 2 +- src/boe.infodlg.h | 2 +- src/boe.party.cpp | 2 +- src/pcedit/pc.editors.cpp | 10 ++++++---- src/pcedit/pc.editors.h | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/boe.dlgutil.cpp b/src/boe.dlgutil.cpp index 1c27fe01..6db66d5f 100644 --- a/src/boe.dlgutil.cpp +++ b/src/boe.dlgutil.cpp @@ -1288,7 +1288,7 @@ static bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod) else pick_pc_name(which_pc,&me); put_party_stats(me); } else if(item_hit == "trait") { - pick_race_abil(&univ.party[which_pc],0); + pick_race_abil(&univ.party[which_pc],0,&me); put_party_stats(me); } else if(item_hit == "train") { spend_xp(which_pc,0,&me); diff --git a/src/boe.infodlg.cpp b/src/boe.infodlg.cpp index 25c396c8..e516ed54 100644 --- a/src/boe.infodlg.cpp +++ b/src/boe.infodlg.cpp @@ -605,7 +605,7 @@ static bool give_pc_info_event_filter(cDialog& me, std::string item_hit, short& static bool give_pc_extra_info(cDialog& me, std::string item_hit, const short pc) { if(item_hit == "seemage") display_pc(pc,0,&me); else if(item_hit == "seepriest") display_pc(pc,1,&me); - else if(item_hit == "trait") pick_race_abil(&univ.party[pc],1); + else if(item_hit == "trait") pick_race_abil(&univ.party[pc],1,&me); else if(item_hit == "alch") display_alchemy(false); return true; } diff --git a/src/boe.infodlg.h b/src/boe.infodlg.h index c1a6fa2d..11e58f7b 100644 --- a/src/boe.infodlg.h +++ b/src/boe.infodlg.h @@ -27,7 +27,7 @@ void put_spec_item_info (short which_i); void put_quest_info(short which_i); // These are defined in pc.editors.cpp since they are also used by the character editor -void pick_race_abil(cPlayer *pc,short mode); +void pick_race_abil(cPlayer *pc,short mode,cDialog* parent = nullptr); void display_pc(short pc_num,short mode,cDialog* parent_num); void display_alchemy(bool allowEdit); diff --git a/src/boe.party.cpp b/src/boe.party.cpp index 3366f521..9c8e8431 100644 --- a/src/boe.party.cpp +++ b/src/boe.party.cpp @@ -312,7 +312,7 @@ bool create_pc(short spot,cDialog* parent) { if(spot == 6) return false; univ.party.new_pc(spot); - pick_race_abil(&univ.party[spot],0); + pick_race_abil(&univ.party[spot],0,parent); still_ok = spend_xp(spot,0,parent); if(!still_ok) diff --git a/src/pcedit/pc.editors.cpp b/src/pcedit/pc.editors.cpp index 41f06ff5..497c7e83 100644 --- a/src/pcedit/pc.editors.cpp +++ b/src/pcedit/pc.editors.cpp @@ -126,8 +126,10 @@ void display_pc(short pc_num,short mode, cDialog* parent) { static void display_traits_graphics(cDialog& me) { short i,store; - std::string race = "race" + boost::lexical_cast(int(store_pc->race) + 1); - dynamic_cast(me["race"]).setSelected(race); + if(store_pc->race <= eRace::VAHNATAI) { + std::string race = "race" + boost::lexical_cast(int(store_pc->race) + 1); + dynamic_cast(me["race"]).setSelected(race); + } for(i = 0; i < 10; i++) { std::string id = "good" + boost::lexical_cast(i + 1); eTrait trait = eTrait(i); @@ -182,7 +184,7 @@ static bool pick_race_select_led(cDialog& me, std::string item_hit, bool, const } //mode; // 0 - edit 1 - just display 2 - can't change race -void pick_race_abil(cPlayer *pc,short mode) { +void pick_race_abil(cPlayer *pc,short mode,cDialog* parent) { using namespace std::placeholders; static const char*const start_str1 = "Click on button by name for description."; static const char*const start_str2 = "Click on advantage button to add/remove."; @@ -190,7 +192,7 @@ void pick_race_abil(cPlayer *pc,short mode) { store_pc = pc; make_cursor_sword(); - cDialog pickAbil("pick-race-abil"); + cDialog pickAbil("pick-race-abil",parent); 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", "bad6", "bad7"}); diff --git a/src/pcedit/pc.editors.h b/src/pcedit/pc.editors.h index 6c73e614..5fd0697a 100644 --- a/src/pcedit/pc.editors.h +++ b/src/pcedit/pc.editors.h @@ -1,8 +1,9 @@ +class cDialog; void give_gold(short amount,bool print_result); bool take_gold(short amount,bool print_result); void give_spec_items(); -void pick_race_abil(cPlayer *pc,short mode); +void pick_race_abil(cPlayer *pc,short mode,cDialog* parent = nullptr); void reset_boats(); void edit_stuff_done();