Editor[food,gold]: make the windows widder,
Editor[xp]: add a cancel button, Editor[spell]: save spells when the user clicks on next/previous pc Shop: implements the clipping correctly when a user buys an item/spell/...
This commit is contained in:
@@ -432,8 +432,8 @@ 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);
|
||||
if(item_hit == "seemage") display_pc(pc,0,false,&me);
|
||||
else if(item_hit == "seepriest") display_pc(pc,1,false,&me);
|
||||
else if(item_hit == "trait") pick_race_abil(pc,1,&me);
|
||||
else if(item_hit == "seealch") display_alchemy(false,&me);
|
||||
return true;
|
||||
|
@@ -27,7 +27,7 @@ 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(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,bool edit, cDialog* parent_num);
|
||||
void display_alchemy(bool allowEdit,cDialog* parent);
|
||||
|
||||
// Callback for recording encounter strings
|
||||
|
@@ -603,12 +603,13 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
|
||||
}
|
||||
|
||||
void click_shop_rect(rectangle area_rect) {
|
||||
|
||||
draw_shop_graphics(1,area_rect);
|
||||
// fixme: offset probably because we have offset the position in shop_mode
|
||||
// seems easier to only redraw the shop string here
|
||||
area_rect.offset(-9,-9);
|
||||
draw_shop_graphics(true,area_rect);
|
||||
mainPtr.display();
|
||||
play_sound(37, time_in_ticks(5));
|
||||
draw_shop_graphics(0,area_rect);
|
||||
|
||||
draw_shop_graphics(false,area_rect);
|
||||
}
|
||||
|
||||
Texture_pos calc_item_rect(int num,rectangle& to_rect) {
|
||||
@@ -651,16 +652,14 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
|
||||
style.pointSize = 18;
|
||||
|
||||
talk_gworld.setActive(false);
|
||||
if(pressed) {
|
||||
clip_rect(talk_gworld, clip_area_rect);
|
||||
}
|
||||
|
||||
area_rect = rectangle(0,0,talk_area_rect.height(),talk_area_rect.width());
|
||||
frame_rect(talk_gworld, area_rect, Colours::BLACK);
|
||||
area_rect.inset(1,1);
|
||||
tileImage(talk_gworld, area_rect,bg[12]);
|
||||
|
||||
frame_rect(talk_gworld, shop_frame, Colours::BLACK);
|
||||
tileImage(talk_gworld, pressed ? clip_area_rect : area_rect, bg[12]);
|
||||
if(pressed)
|
||||
clip_rect(talk_gworld, clip_area_rect);
|
||||
frame_rect(talk_gworld, shop_frame, Colours::BLACK);
|
||||
|
||||
// Place store icon
|
||||
if(!pressed) {
|
||||
|
@@ -17,7 +17,7 @@ extern sf::RenderWindow mainPtr;
|
||||
extern fs::path file_in_mem;
|
||||
extern sf::Texture pc_gworld;
|
||||
|
||||
short which_pc_displayed,store_pc_trait_mode,store_which_to_edit;
|
||||
short store_pc_trait_mode,store_which_to_edit;
|
||||
extern short current_active_pc;
|
||||
extern rectangle pc_area_buttons[6][4] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later
|
||||
extern rectangle item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 -
|
||||
@@ -48,10 +48,10 @@ bool handle_action(const sf::Event & event) {
|
||||
do_button_action(0,i + 10);
|
||||
switch(i) {
|
||||
case 0:
|
||||
display_pc(current_active_pc,10,nullptr);
|
||||
display_pc(current_active_pc,0,true,nullptr);
|
||||
break;
|
||||
case 1:
|
||||
display_pc(current_active_pc,11,nullptr);
|
||||
display_pc(current_active_pc,1,true,nullptr);
|
||||
break;
|
||||
case 2:
|
||||
pick_race_abil(current_active_pc,0);
|
||||
@@ -154,6 +154,7 @@ void edit_xp(cPlayer *pc) {
|
||||
set_cursor(sword_curs);
|
||||
|
||||
cDialog dlog("edit-xp");
|
||||
dlog.attachClickHandlers(get_num_event_filter, {"okay", "cancel"});
|
||||
dlog["okay"].attachClickHandler(get_num_event_filter);
|
||||
|
||||
dlog["number"].setTextToNum(pc->experience);
|
||||
@@ -161,9 +162,8 @@ void edit_xp(cPlayer *pc) {
|
||||
|
||||
dlog.run();
|
||||
|
||||
int dialog_answer = minmax(0,10000,abs(dlog.getResult<long long>()));
|
||||
|
||||
pc->experience = dialog_answer;
|
||||
if (dlog.accepted())
|
||||
pc->experience = minmax(0,10000,abs(dlog.getResult<long long>()));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -5,7 +5,8 @@
|
||||
bool handle_action(const sf::Event&);
|
||||
void flash_rect(rectangle to_flash);
|
||||
void edit_gold_or_food(short which_to_edit);
|
||||
void display_pc(short pc_num,short mode,cDialog* parent);
|
||||
// mode=0 : mage, mode=1 : priest
|
||||
void display_pc(short pc_num,short mode,bool edit, cDialog* parent);
|
||||
void display_alchemy(bool allowEdit,cDialog* parent);
|
||||
bool spend_xp(short pc_num, short mode, cDialog* parent);
|
||||
void edit_day();
|
||||
|
@@ -25,7 +25,7 @@
|
||||
* For the game's purposes, these are declared in
|
||||
* boe.infodlg.h and boe.party.h.
|
||||
*/
|
||||
void display_pc(short pc_num,short mode,cDialog* parent);
|
||||
void display_pc(short pc_num,short mode,bool edit, cDialog* parent);
|
||||
void display_alchemy(bool allowEdit,cDialog* parent);
|
||||
bool spend_xp(short pc_num, short mode, cDialog* parent);
|
||||
// TODO: There's probably a more logical way of arranging this
|
||||
@@ -45,88 +45,83 @@ extern short d_rect_index[80];
|
||||
extern bool current_file_has_maps;
|
||||
bool choice_active[6];
|
||||
|
||||
extern short which_pc_displayed;
|
||||
sf::Texture button_num_gworld;
|
||||
|
||||
extern std::map<eSkill,short> skill_cost;
|
||||
extern std::map<eSkill,short> skill_max;
|
||||
extern std::map<eSkill,short> skill_g_cost;
|
||||
|
||||
static void put_pc_spells(cDialog& me, short store_trait_mode) {
|
||||
store_trait_mode %= 10;
|
||||
|
||||
// display pc spells
|
||||
static void put_pc_spells(cDialog& me, short pc_num, short mode) {
|
||||
for(short i = 0; i < 62; i++) {
|
||||
std::string id = "spell" + std::to_string(i + 1);
|
||||
cLed& cur = dynamic_cast<cLed&>(me[id]);
|
||||
if(((store_trait_mode == 0) && univ.party[which_pc_displayed].mage_spells[i]) ||
|
||||
((store_trait_mode == 1) && univ.party[which_pc_displayed].priest_spells[i]))
|
||||
if((mode == 0 && univ.party[pc_num].mage_spells[i]) ||
|
||||
(mode == 1 && univ.party[pc_num].priest_spells[i]))
|
||||
cur.setState(led_red);
|
||||
else cur.setState(led_off);
|
||||
}
|
||||
|
||||
me["who"].setText(univ.party[which_pc_displayed].name.c_str());
|
||||
me["who"].setText(univ.party[pc_num].name.c_str());
|
||||
}
|
||||
|
||||
static bool display_pc_event_filter(cDialog& me, std::string item_hit, const short trait_mode) {
|
||||
short pc_num;
|
||||
|
||||
pc_num = which_pc_displayed;
|
||||
if(item_hit == "done") {
|
||||
me.toast(true);
|
||||
} else if(item_hit == "left") {
|
||||
do {
|
||||
pc_num = (pc_num == 0) ? 5 : pc_num - 1;
|
||||
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
|
||||
which_pc_displayed = pc_num;
|
||||
put_pc_spells(me, trait_mode);
|
||||
} else if(item_hit == "right") {
|
||||
do {
|
||||
pc_num = (pc_num == 5) ? 0 : pc_num + 1;
|
||||
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
|
||||
which_pc_displayed = pc_num;
|
||||
put_pc_spells(me, trait_mode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void display_pc(short pc_num,short mode, cDialog* parent) {
|
||||
using namespace std::placeholders;
|
||||
std::string label_str;
|
||||
|
||||
if(univ.party[pc_num].main_status == eMainStatus::ABSENT) {
|
||||
for(pc_num = 0; pc_num < 6; pc_num++)
|
||||
if(univ.party[pc_num].main_status == eMainStatus::ALIVE)
|
||||
break;
|
||||
}
|
||||
which_pc_displayed = pc_num;
|
||||
|
||||
set_cursor(sword_curs);
|
||||
|
||||
cDialog pcInfo("pc-spell-info", parent);
|
||||
pcInfo.attachClickHandlers(std::bind(display_pc_event_filter, _1, _2, mode),{"done","left","right"});
|
||||
|
||||
for(short i = 0; i < 62; i++) {
|
||||
std::string id = "spell" + std::to_string(i + 1);
|
||||
label_str = get_str("magic-names", i + (mode % 10 == 0 ? 1 : 101));
|
||||
pcInfo[id].setText(label_str);
|
||||
if(mode < 10)
|
||||
pcInfo[id].attachClickHandler(&cLed::noAction);
|
||||
}
|
||||
put_pc_spells(pcInfo, mode);
|
||||
|
||||
dynamic_cast<cPict&>(pcInfo["pic"]).setPict(14 + mode,PIC_DLOG);
|
||||
|
||||
pcInfo.run();
|
||||
|
||||
if(mode >= 10) {
|
||||
mode %= 10;
|
||||
static bool display_pc_event_filter(cDialog& me, std::string item_hit, short &pc_num, const short mode, bool edit) {
|
||||
if (edit) {
|
||||
for(short i = 0; i < 62; i++) {
|
||||
std::string id = "spell" + std::to_string(i + 1);
|
||||
bool set = dynamic_cast<cLed&>(pcInfo[id]).getState() != led_off;
|
||||
bool set = dynamic_cast<cLed&>(me[id]).getState() != led_off;
|
||||
if(mode == 0) univ.party[pc_num].mage_spells[i] = set;
|
||||
else if(mode == 1) univ.party[pc_num].priest_spells[i] = set;
|
||||
}
|
||||
}
|
||||
if(item_hit == "done")
|
||||
me.toast(true);
|
||||
else if(item_hit == "left") {
|
||||
do {
|
||||
pc_num = (pc_num == 0) ? 5 : pc_num - 1;
|
||||
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
|
||||
put_pc_spells(me, pc_num, mode);
|
||||
} else if(item_hit == "right") {
|
||||
do {
|
||||
pc_num = (pc_num == 5) ? 0 : pc_num + 1;
|
||||
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
|
||||
put_pc_spells(me, pc_num, mode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void display_pc(short pc_num, short mode, bool edit, cDialog* parent) {
|
||||
using namespace std::placeholders;
|
||||
std::string label_str;
|
||||
|
||||
short current_pc = pc_num;
|
||||
if(current_pc<0 || current_pc>=6 || univ.party[current_pc].main_status == eMainStatus::ABSENT) {
|
||||
for(current_pc = 0; current_pc < 6; current_pc++)
|
||||
if(univ.party[current_pc].main_status == eMainStatus::ALIVE)
|
||||
break;
|
||||
if (current_pc>=6) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
set_cursor(sword_curs);
|
||||
|
||||
cDialog pcInfo("pc-spell-info", parent);
|
||||
pcInfo.attachClickHandlers(std::bind(display_pc_event_filter, _1, _2, std::ref(current_pc), mode, edit),{"done","left","right"});
|
||||
|
||||
for(short i = 0; i < 62; i++) {
|
||||
std::string id = "spell" + std::to_string(i + 1);
|
||||
label_str = get_str("magic-names", i + (mode == 0 ? 1 : 101));
|
||||
pcInfo[id].setText(label_str);
|
||||
if(!edit)
|
||||
pcInfo[id].attachClickHandler(&cLed::noAction);
|
||||
}
|
||||
put_pc_spells(pcInfo, pc_num, mode);
|
||||
|
||||
dynamic_cast<cPict&>(pcInfo["pic"]).setPict(14 + mode + (edit ? 10 : 0),PIC_DLOG);
|
||||
|
||||
pcInfo.run();
|
||||
}
|
||||
|
||||
// Start pick race dialog here
|
||||
|
@@ -389,10 +389,10 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
m.set();
|
||||
break;
|
||||
case eMenu::EDIT_MAGE:
|
||||
display_pc(current_active_pc,10,0);
|
||||
display_pc(current_active_pc,0,true,nullptr);
|
||||
break;
|
||||
case eMenu::EDIT_PRIEST:
|
||||
display_pc(current_active_pc,11,0);
|
||||
display_pc(current_active_pc,1,true,nullptr);
|
||||
break;
|
||||
case eMenu::EDIT_ITEM:
|
||||
if(scen_items_loaded) {
|
||||
|
Reference in New Issue
Block a user