dialog pick-race-abil: print pc's name + add left/right arrows
This commit is contained in:
@@ -2,8 +2,12 @@
|
|||||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||||
<dialog defbtn='done'>
|
<dialog defbtn='done'>
|
||||||
<text size='large' top='9' left='55' width='181' height='16'>Special Characteristics:</text>
|
<text size='large' top='9' left='55' width='181' height='16'>Special Characteristics:</text>
|
||||||
|
<text name='name' size='large' top='9' left='240' width='174' height='16'/>
|
||||||
<pict type='dlog' num='7' top='6' left='6'/>
|
<pict type='dlog' num='7' top='6' left='6'/>
|
||||||
<button name='done' type='done' top='349' left='423'/>
|
<button name='left' type='left' def-key='left' top='349' left='360'/>
|
||||||
|
<button name='right' type='right' def-key='right' top='349' left='423'/>
|
||||||
|
<button name='cancel' type='regular' def-key='esc' top='370' left='360'>Cancel</button>
|
||||||
|
<button name='done' type='done' top='370' left='423'/>
|
||||||
<text size='large' top='30' left='55' width='65' height='18'>Species:</text>
|
<text size='large' top='30' left='55' width='65' height='18'>Species:</text>
|
||||||
<text name='xp' framed='true' top='352' left='254' width='50' height='16'/>
|
<text name='xp' framed='true' top='352' left='254' width='50' height='16'/>
|
||||||
<text name='info' framed='true' top='282' left='15' width='300' height='59'>Select species and traits.</text>
|
<text name='info' framed='true' top='282' left='15' width='300' height='59'>Select species and traits.</text>
|
||||||
|
@@ -1350,7 +1350,7 @@ static bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod)
|
|||||||
else pick_pc_name(which_pc,&me);
|
else pick_pc_name(which_pc,&me);
|
||||||
put_party_stats(me);
|
put_party_stats(me);
|
||||||
} else if(item_hit == "trait") {
|
} else if(item_hit == "trait") {
|
||||||
pick_race_abil(&univ.party[which_pc],0,&me);
|
pick_race_abil(which_pc,0,&me);
|
||||||
put_party_stats(me);
|
put_party_stats(me);
|
||||||
} else if(item_hit == "train") {
|
} else if(item_hit == "train") {
|
||||||
spend_xp(which_pc,0,&me);
|
spend_xp(which_pc,0,&me);
|
||||||
|
@@ -434,7 +434,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) {
|
static bool give_pc_extra_info(cDialog& me, std::string item_hit, const short pc) {
|
||||||
if(item_hit == "seemage") display_pc(pc,0,&me);
|
if(item_hit == "seemage") display_pc(pc,0,&me);
|
||||||
else if(item_hit == "seepriest") display_pc(pc,1,&me);
|
else if(item_hit == "seepriest") display_pc(pc,1,&me);
|
||||||
else if(item_hit == "trait") pick_race_abil(&univ.party[pc],1,&me);
|
else if(item_hit == "trait") pick_race_abil(pc,1,&me);
|
||||||
else if(item_hit == "seealch") display_alchemy(false,&me);
|
else if(item_hit == "seealch") display_alchemy(false,&me);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ void put_spec_item_info (short which_i);
|
|||||||
void put_quest_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
|
// These are defined in pc.editors.cpp since they are also used by the character editor
|
||||||
void pick_race_abil(cPlayer *pc,short mode,cDialog* parent = nullptr);
|
void pick_race_abil(short pc_num,short mode,cDialog* parent = nullptr);
|
||||||
void display_pc(short pc_num,short mode,cDialog* parent_num);
|
void display_pc(short pc_num,short mode,cDialog* parent_num);
|
||||||
void display_alchemy(bool allowEdit,cDialog* parent);
|
void display_alchemy(bool allowEdit,cDialog* parent);
|
||||||
|
|
||||||
|
@@ -219,7 +219,7 @@ bool create_pc(short spot,cDialog* parent) {
|
|||||||
if(spot == 6) return false;
|
if(spot == 6) return false;
|
||||||
univ.party.new_pc(spot);
|
univ.party.new_pc(spot);
|
||||||
|
|
||||||
pick_race_abil(&univ.party[spot],0,parent);
|
pick_race_abil(spot,0,parent);
|
||||||
|
|
||||||
still_ok = spend_xp(spot,0,parent);
|
still_ok = spend_xp(spot,0,parent);
|
||||||
if(!still_ok)
|
if(!still_ok)
|
||||||
|
@@ -54,7 +54,7 @@ bool handle_action(const sf::Event & event) {
|
|||||||
display_pc(current_active_pc,11,nullptr);
|
display_pc(current_active_pc,11,nullptr);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pick_race_abil(&univ.party[current_active_pc],0);
|
pick_race_abil(current_active_pc,0);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
spend_xp(current_active_pc,2,nullptr);
|
spend_xp(current_active_pc,2,nullptr);
|
||||||
|
@@ -46,7 +46,6 @@ extern bool current_file_has_maps;
|
|||||||
bool choice_active[6];
|
bool choice_active[6];
|
||||||
|
|
||||||
extern short which_pc_displayed;
|
extern short which_pc_displayed;
|
||||||
cPlayer *store_pc;
|
|
||||||
sf::Texture button_num_gworld;
|
sf::Texture button_num_gworld;
|
||||||
|
|
||||||
extern std::map<eSkill,short> skill_cost;
|
extern std::map<eSkill,short> skill_cost;
|
||||||
@@ -130,33 +129,62 @@ void display_pc(short pc_num,short mode, cDialog* parent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_traits_graphics(cDialog& me) {
|
// Start pick race dialog here
|
||||||
short store;
|
struct sTraitsState {
|
||||||
|
sTraitsState(cUniverse const &univ) : pc_num(-1)
|
||||||
if(store_pc->race <= eRace::VAHNATAI) {
|
{
|
||||||
std::string race = "race" + std::to_string(int(store_pc->race) + 1);
|
for (int i=0; i<6; ++i) {
|
||||||
|
auto const &pc=univ.party[i];
|
||||||
|
races[i]=pc.race;
|
||||||
|
for (int t=0; t<17; ++t) {
|
||||||
|
eTrait trait = eTrait(t);
|
||||||
|
if (pc.traits.find(trait)!=pc.traits.end())
|
||||||
|
traits[i][t]=pc.traits[trait];
|
||||||
|
else
|
||||||
|
traits[i][t]=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void save(cUniverse &univ) const {
|
||||||
|
for (int i=0; i<6; ++i) {
|
||||||
|
auto &pc=univ.party[i];
|
||||||
|
pc.race=races[i];
|
||||||
|
for (int t=0; t<17; ++t) {
|
||||||
|
eTrait trait = eTrait(t);
|
||||||
|
pc.traits[trait]=traits[i][t];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
short pc_num;
|
||||||
|
eRace races[6];
|
||||||
|
bool traits[6][17];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void display_traits_graphics(cDialog& me, sTraitsState const &state) {
|
||||||
|
int const pc_num=state.pc_num;
|
||||||
|
auto const &pc=univ.party[pc_num];
|
||||||
|
me["name"].setText(pc.name);
|
||||||
|
if(pc.race <= eRace::VAHNATAI) {
|
||||||
|
std::string race = "race" + std::to_string(int(state.races[pc_num]) + 1);
|
||||||
dynamic_cast<cLedGroup&>(me["race"]).setSelected(race);
|
dynamic_cast<cLedGroup&>(me["race"]).setSelected(race);
|
||||||
}
|
}
|
||||||
for(short i = 0; i < 10; i++) {
|
for(short i = 0; i < 10; i++) {
|
||||||
std::string id = "good" + std::to_string(i + 1);
|
std::string id = "good" + std::to_string(i + 1);
|
||||||
eTrait trait = eTrait(i);
|
dynamic_cast<cLed&>(me[id]).setState(state.traits[pc_num][i] ? led_red : led_off);
|
||||||
dynamic_cast<cLed&>(me[id]).setState(store_pc->traits[trait] ? led_red : led_off);
|
|
||||||
}
|
}
|
||||||
for(short i = 0; i < 7; i++) {
|
for(short i = 0; i < 7; i++) {
|
||||||
std::string id = "bad" + std::to_string(i + 1);
|
std::string id = "bad" + std::to_string(i + 1);
|
||||||
eTrait trait = eTrait(i + 10);
|
dynamic_cast<cLed&>(me[id]).setState(state.traits[pc_num][i+10] ? led_red : led_off);
|
||||||
dynamic_cast<cLed&>(me[id]).setState(store_pc->traits[trait] ? led_red : led_off);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
store = store_pc->get_tnl();
|
me["xp"].setTextToNum(pc.get_tnl());
|
||||||
me["xp"].setTextToNum(store);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool pick_race_select_led(cDialog& me, std::string item_hit, bool, const short store_trait_mode) {
|
static bool pick_race_select_led(cDialog& me, sTraitsState &state, std::string item_hit, bool, const short store_trait_mode) {
|
||||||
int abil_str = 0;
|
int abil_str = 0;
|
||||||
cPlayer *pc;
|
|
||||||
|
int const pc_num=state.pc_num;
|
||||||
pc = store_pc;
|
|
||||||
if(item_hit == "race") {
|
if(item_hit == "race") {
|
||||||
item_hit = dynamic_cast<cLedGroup&>(me["race"]).getSelected();
|
item_hit = dynamic_cast<cLedGroup&>(me["race"]).getSelected();
|
||||||
eRace race;
|
eRace race;
|
||||||
@@ -167,22 +195,20 @@ static bool pick_race_select_led(cDialog& me, std::string item_hit, bool, const
|
|||||||
case 3: race = eRace::VAHNATAI; break;
|
case 3: race = eRace::VAHNATAI; break;
|
||||||
}
|
}
|
||||||
if(store_trait_mode == 0)
|
if(store_trait_mode == 0)
|
||||||
pc->race = race;
|
state.races[pc_num] = race;
|
||||||
display_traits_graphics(me);
|
display_traits_graphics(me,state);
|
||||||
abil_str = 36 + int(race) * 2;
|
abil_str = 36 + int(race) * 2;
|
||||||
} else if(item_hit.substr(0,3) == "bad") {
|
} else if(item_hit.substr(0,3) == "bad") {
|
||||||
int hit = item_hit[3] - '1';
|
int hit = item_hit[3] - '1';
|
||||||
eTrait trait = eTrait(hit + 10);
|
|
||||||
if(store_trait_mode != 1)
|
if(store_trait_mode != 1)
|
||||||
pc->traits[trait] = !pc->traits[trait];
|
state.traits[pc_num][hit+10] = !state.traits[pc_num][hit+10];
|
||||||
display_traits_graphics(me);
|
display_traits_graphics(me,state);
|
||||||
abil_str = 22 + hit * 2;
|
abil_str = 22 + hit * 2;
|
||||||
} else if(item_hit.substr(0,4) == "good") {
|
} else if(item_hit.substr(0,4) == "good") {
|
||||||
int hit = boost::lexical_cast<int>(item_hit.substr(4)) - 1;
|
int hit = boost::lexical_cast<int>(item_hit.substr(4)) - 1;
|
||||||
eTrait trait = eTrait(hit);
|
|
||||||
if(store_trait_mode != 1)
|
if(store_trait_mode != 1)
|
||||||
pc->traits[trait] = !pc->traits[trait];
|
state.traits[pc_num][hit] = !state.traits[pc_num][hit];
|
||||||
display_traits_graphics(me);
|
display_traits_graphics(me,state);
|
||||||
abil_str = 2 + hit * 2;
|
abil_str = 2 + hit * 2;
|
||||||
}
|
}
|
||||||
if(abil_str > 0)
|
if(abil_str > 0)
|
||||||
@@ -190,28 +216,58 @@ static bool pick_race_select_led(cDialog& me, std::string item_hit, bool, const
|
|||||||
return store_trait_mode == 0;
|
return store_trait_mode == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OSNOLA2
|
||||||
|
static bool give_pick_race_event_filter(cDialog& me, std::string item_hit, sTraitsState &state) {
|
||||||
|
short &pc_num=state.pc_num;
|
||||||
|
if (item_hit == "cancel") {
|
||||||
|
me.toast(false);
|
||||||
|
me.setResult(false);
|
||||||
|
}
|
||||||
|
else if(item_hit == "done") {
|
||||||
|
me.setResult(true);
|
||||||
|
me.toast(true);
|
||||||
|
}
|
||||||
|
else if(item_hit == "left") {
|
||||||
|
do {
|
||||||
|
pc_num = (pc_num + 5) % 6;
|
||||||
|
} while(univ.party[pc_num].main_status != eMainStatus::ALIVE);
|
||||||
|
display_traits_graphics(me, state);
|
||||||
|
} else if(item_hit == "right") {
|
||||||
|
do {
|
||||||
|
pc_num = (pc_num + 1) % 6;
|
||||||
|
} while(univ.party[pc_num].main_status != eMainStatus::ALIVE);
|
||||||
|
display_traits_graphics(me, state);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//mode; // 0 - edit 1 - just display 2 - can't change race
|
//mode; // 0 - edit 1 - just display 2 - can't change race
|
||||||
void pick_race_abil(cPlayer *pc,short mode,cDialog* parent) {
|
void pick_race_abil(short pc_num,short mode,cDialog* parent) {
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
static const char*const start_str1 = "Click on button by name for description.";
|
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.";
|
static const char*const start_str2 = "Click on advantage button to add/remove.";
|
||||||
|
sTraitsState state(univ);
|
||||||
store_pc = pc;
|
state.pc_num = pc_num;
|
||||||
set_cursor(sword_curs);
|
set_cursor(sword_curs);
|
||||||
|
|
||||||
cDialog pickAbil("pick-race-abil",parent);
|
cDialog pickAbil("pick-race-abil",parent);
|
||||||
pickAbil["done"].attachClickHandler(std::bind(&cDialog::toast, &pickAbil, true));
|
pickAbil.attachClickHandlers(std::bind(give_pick_race_event_filter, _1, _2, std::ref(state)), {"done", "cancel", "left", "right"});
|
||||||
auto led_selector = std::bind(pick_race_select_led, _1, _2, _3, mode);
|
auto led_selector = std::bind(pick_race_select_led, _1, std::ref(state), _2, _3, mode);
|
||||||
pickAbil.attachFocusHandlers(led_selector, {"race", "bad1", "bad2", "bad3", "bad4", "bad5", "bad6", "bad7"});
|
pickAbil.attachFocusHandlers(led_selector, {"race", "bad1", "bad2", "bad3", "bad4", "bad5", "bad6", "bad7"});
|
||||||
pickAbil.attachFocusHandlers(led_selector, {"good1", "good2", "good3", "good4", "good5"});
|
pickAbil.attachFocusHandlers(led_selector, {"good1", "good2", "good3", "good4", "good5"});
|
||||||
pickAbil.attachFocusHandlers(led_selector, {"good6", "good7", "good8", "good9", "good10"});
|
pickAbil.attachFocusHandlers(led_selector, {"good6", "good7", "good8", "good9", "good10"});
|
||||||
|
|
||||||
display_traits_graphics(pickAbil);
|
display_traits_graphics(pickAbil, state);
|
||||||
if(mode == 1)
|
if(mode == 1) {
|
||||||
|
pickAbil["cancel"].hide();
|
||||||
pickAbil["info"].setText(start_str1);
|
pickAbil["info"].setText(start_str1);
|
||||||
else pickAbil["info"].setText(start_str2);
|
}
|
||||||
|
else
|
||||||
|
pickAbil["info"].setText(start_str2);
|
||||||
pickAbil.run();
|
pickAbil.run();
|
||||||
|
|
||||||
|
if (pickAbil.getResult<bool>() && mode!=1)
|
||||||
|
state.save(univ);;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern const short alch_difficulty[20] = {
|
extern const short alch_difficulty[20] = {
|
||||||
|
@@ -4,6 +4,6 @@ class cDialog;
|
|||||||
void give_gold(short amount,bool print_result);
|
void give_gold(short amount,bool print_result);
|
||||||
bool take_gold(short amount,bool print_result);
|
bool take_gold(short amount,bool print_result);
|
||||||
void give_spec_items();
|
void give_spec_items();
|
||||||
void pick_race_abil(cPlayer *pc,short mode,cDialog* parent = nullptr);
|
void pick_race_abil(short pc_num,short mode,cDialog* parent = nullptr);
|
||||||
void reset_boats();
|
void reset_boats();
|
||||||
void edit_stuff_done();
|
void edit_stuff_done();
|
||||||
|
@@ -404,7 +404,7 @@ void handle_menu_choice(eMenu item_hit) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eMenu::EDIT_TRAITS:
|
case eMenu::EDIT_TRAITS:
|
||||||
pick_race_abil(&univ.party[current_active_pc],0);
|
pick_race_abil(current_active_pc,0);
|
||||||
break;
|
break;
|
||||||
case eMenu::EDIT_SKILLS:
|
case eMenu::EDIT_SKILLS:
|
||||||
spend_xp(current_active_pc,2,0);
|
spend_xp(current_active_pc,2,0);
|
||||||
|
@@ -59,7 +59,7 @@ void cPlayer::import_legacy(legacy::pc_record_type old){
|
|||||||
direction = eDirection(old.direction);
|
direction = eDirection(old.direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
short cPlayer::get_tnl(){
|
short cPlayer::get_tnl() const {
|
||||||
short tnl = 100,store_per = 100;
|
short tnl = 100,store_per = 100;
|
||||||
// Omitting a race from this list gives it a value of 0, thanks to the defaulting implementation of operator[]
|
// Omitting a race from this list gives it a value of 0, thanks to the defaulting implementation of operator[]
|
||||||
static std::map<const eRace, const int> rp = {{eRace::NEPHIL,12},{eRace::SLITH,20},{eRace::VAHNATAI,18}};
|
static std::map<const eRace, const int> rp = {{eRace::NEPHIL,12},{eRace::SLITH,20},{eRace::VAHNATAI,18}};
|
||||||
|
@@ -171,7 +171,7 @@ public:
|
|||||||
void import_legacy(legacy::pc_record_type old);
|
void import_legacy(legacy::pc_record_type old);
|
||||||
cPlayer(cParty& party);
|
cPlayer(cParty& party);
|
||||||
cPlayer(cParty& party,ePartyPreset key,short slot);
|
cPlayer(cParty& party,ePartyPreset key,short slot);
|
||||||
short get_tnl();
|
short get_tnl() const;
|
||||||
void writeTo(std::ostream& file) const;
|
void writeTo(std::ostream& file) const;
|
||||||
void readFrom(std::istream& file);
|
void readFrom(std::istream& file);
|
||||||
virtual ~cPlayer() = default;
|
virtual ~cPlayer() = default;
|
||||||
|
Reference in New Issue
Block a user