Restore the done/help buttons in shop mode
This commit is contained in:
@@ -39,6 +39,7 @@ extern short stat_window;
|
||||
extern eGameMode overall_mode;
|
||||
extern bool play_sounds,give_intro_hint,show_startup_splash,changed_display_mode;
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern location ul;
|
||||
extern rectangle d_rects[80];
|
||||
extern short d_rect_index[80];
|
||||
extern short display_mode,current_pc;
|
||||
@@ -48,6 +49,7 @@ extern long ed_flag,ed_key;
|
||||
extern bool save_maps,give_delays;
|
||||
extern location center;
|
||||
extern std::shared_ptr<cScrollbar> text_sbar,item_sbar,shop_sbar;
|
||||
extern std::shared_ptr<cButton> done_btn, help_btn;
|
||||
extern bool map_visible;
|
||||
extern sf::RenderWindow mini_map;
|
||||
extern bool game_run_before,skip_boom_delay;
|
||||
@@ -151,6 +153,8 @@ void end_shop_mode() {
|
||||
// This would be a place to show the text box, if I add it (and if this is not an outdoor shop).
|
||||
|
||||
shop_sbar->hide();
|
||||
done_btn->hide();
|
||||
help_btn->hide();
|
||||
if(store_pre_shop_mode == 20) {
|
||||
strnum1 = strnum2 = oldstrnum1 = oldstrnum2 = 0;
|
||||
place_talk_str("You conclude your business.", "", 0, dummy_rect);
|
||||
@@ -175,21 +179,25 @@ void handle_shop_event(location p) {
|
||||
short i;
|
||||
unsigned long store_what_picked;
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
if(p.in(talk_help_rect)) {
|
||||
click_shop_rect(talk_help_rect);
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(!help_btn->handleClick(loc))
|
||||
return;
|
||||
univ.party.help_received[26] = 0;
|
||||
give_help(26,27);
|
||||
return;
|
||||
}
|
||||
|
||||
if(p.in(shop_done_rect)) {
|
||||
click_shop_rect(shop_done_rect);
|
||||
end_shop_mode();
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(done_btn->handleClick(loc))
|
||||
end_shop_mode();
|
||||
return;
|
||||
}
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
store_what_picked = i + shop_sbar->getPosition();
|
||||
if(store_what_picked >= active_shop.size()) break;
|
||||
@@ -464,6 +472,7 @@ void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short st
|
||||
store_talk_face_pic = store_face_pic; ////
|
||||
area_rect = talk_area_rect;
|
||||
talk_gworld.create(area_rect.width(), area_rect.height());
|
||||
help_btn->show();
|
||||
|
||||
// This would be the place to show the text box, if I add it.
|
||||
|
||||
@@ -500,6 +509,7 @@ void end_talk_mode() {
|
||||
center = univ.town.p_loc;
|
||||
update_explored(center);
|
||||
}
|
||||
help_btn->hide();
|
||||
stat_screen_mode = MODE_INVEN;
|
||||
put_item_screen(stat_window,0);
|
||||
put_pc_screen();
|
||||
@@ -514,15 +524,18 @@ void handle_talk_event(location p) {
|
||||
short a,b,c,d;
|
||||
eTalkNode ttype;
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
if(p.in(talk_help_rect)) {
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(!help_btn->handleClick(loc))
|
||||
return;
|
||||
univ.party.help_received[5] = 0;
|
||||
give_help(5,6);
|
||||
return;
|
||||
}
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
int which_talk_entry = TALK_DUNNO;
|
||||
for(word_rect_t& word : talk_words) {
|
||||
if(word.node == -1) continue;
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "graphtool.hpp"
|
||||
#include "soundtool.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
#include "boe.party.h"
|
||||
#include "boe.town.h"
|
||||
@@ -46,6 +47,7 @@ extern short num_targets_left;
|
||||
extern location spell_targets[8];
|
||||
extern short display_mode;
|
||||
extern std::shared_ptr<cScrollbar> text_sbar,item_sbar,shop_sbar;
|
||||
extern std::shared_ptr<cButton> done_btn, help_btn;
|
||||
extern sf::Texture bg_gworld;
|
||||
extern rectangle sbar_rect,item_sbar_rect,shop_sbar_rect,startup_top;
|
||||
extern rectangle talk_area_rect, word_place_rect;
|
||||
@@ -183,10 +185,12 @@ void adjust_window_mode() {
|
||||
r = windRect;
|
||||
}
|
||||
redraw_screen(REFRESH_NONE);
|
||||
if(text_sbar != NULL) {
|
||||
if(text_sbar) {
|
||||
text_sbar->relocate({ul.x + 546,ul.y + 283});
|
||||
item_sbar->relocate({ul.x + 546,ul.y + 146});
|
||||
shop_sbar->relocate({ul.x + 258,ul.y + 67});
|
||||
done_btn->relocate({ul.x + 217,ul.y + 393});
|
||||
help_btn->relocate({ul.x + 259,ul.y + 10});
|
||||
}
|
||||
init_menubar();
|
||||
showMenuBar();
|
||||
@@ -597,6 +601,8 @@ void redraw_screen(int refresh) {
|
||||
text_sbar->draw();
|
||||
item_sbar->draw();
|
||||
shop_sbar->draw();
|
||||
done_btn->draw();
|
||||
help_btn->draw();
|
||||
}
|
||||
mainPtr.display();
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "boe.menus.h"
|
||||
#include "cursors.hpp"
|
||||
#include "prefs.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
extern cursor_type arrow_curs[3][3];
|
||||
extern cursor_type current_cursor;
|
||||
@@ -40,6 +41,7 @@ bool first_startup_update = true;
|
||||
bool diff_depth_ok = false,first_sound_played = false,spell_forced = false,startup_loaded = false;
|
||||
bool save_maps = true,party_in_memory = false;
|
||||
std::shared_ptr<cScrollbar> text_sbar, item_sbar, shop_sbar;
|
||||
std::shared_ptr<cButton> done_btn, help_btn;
|
||||
rectangle sbar_rect = {283,546,421,562};
|
||||
rectangle shop_sbar_rect = {67,258,357,274};
|
||||
rectangle item_sbar_rect = {146,546,253,562};
|
||||
@@ -185,6 +187,12 @@ void Initialize(void) {
|
||||
shop_sbar->setMaximum(16);
|
||||
shop_sbar->setPageSize(8);
|
||||
shop_sbar->hide();
|
||||
done_btn.reset(new cButton(mainPtr));
|
||||
done_btn->setBtnType(BTN_DONE);
|
||||
done_btn->hide();
|
||||
help_btn.reset(new cButton(mainPtr));
|
||||
help_btn->setBtnType(BTN_HELP);
|
||||
help_btn->hide();
|
||||
adjust_window_mode();
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "location.h"
|
||||
#include "shop.hpp"
|
||||
#include "spell.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
short monsters_faces[190] = {
|
||||
0,1,2,3,4,5,6,7,8,9,
|
||||
@@ -57,6 +58,7 @@ extern sf::RenderTexture terrain_screen_gworld;
|
||||
extern sf::Texture bg_gworld;
|
||||
extern rectangle sbar_rect,item_sbar_rect,shop_sbar_rect;
|
||||
extern std::shared_ptr<cScrollbar> text_sbar,item_sbar,shop_sbar;
|
||||
extern std::shared_ptr<cButton> done_btn, help_btn;
|
||||
extern location center;
|
||||
extern location store_anim_ul;
|
||||
extern char light_area[13][13];
|
||||
@@ -78,7 +80,7 @@ extern short store_personality,store_personality_graphic,current_pc;
|
||||
extern sf::RenderTexture talk_gworld;
|
||||
extern bool talk_end_forced;
|
||||
extern std::string old_str1,old_str2,one_back1,one_back2;
|
||||
extern rectangle talk_area_rect, word_place_rect,talk_help_rect;
|
||||
extern rectangle talk_area_rect, word_place_rect;
|
||||
extern std::string title_string;
|
||||
extern mon_num_t store_monst_type;
|
||||
std::vector<word_rect_t> talk_words;
|
||||
@@ -751,19 +753,6 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
|
||||
}
|
||||
win_draw_string(talk_gworld,shopper_name,title.str(),eTextMode::LEFT_TOP,style);
|
||||
|
||||
// Place help and done buttons
|
||||
// TODO: Reimplement these with a cButton
|
||||
#if 0
|
||||
help_from = rectangle(dlg_buttons_gworld[3][0]); // help
|
||||
talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
|
||||
talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
|
||||
rect_draw_some_item(dlg_buttons_gworld[3][pressed],help_from,talk_gworld,talk_help_rect);
|
||||
help_from = rectangle(dlg_buttons_gworld[11][0]); // done
|
||||
//talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
|
||||
//talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
|
||||
rect_draw_some_item(dlg_buttons_gworld[11][pressed],help_from,talk_gworld,shop_done_rect);
|
||||
#endif
|
||||
|
||||
if(pressed)
|
||||
style.colour = c[4];
|
||||
else style.colour = sf::Color::Black;
|
||||
@@ -840,6 +829,7 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
|
||||
if(shop_sbar->getMaximum() > 1)
|
||||
shop_sbar->show();
|
||||
else shop_sbar->hide();
|
||||
done_btn->show();
|
||||
}
|
||||
|
||||
void refresh_shopping() {
|
||||
@@ -979,12 +969,6 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
|
||||
area_rect.inset(1,1);
|
||||
tileImage(talk_gworld, area_rect,bg[12]);
|
||||
|
||||
// Put help button
|
||||
// TODO: Reimplement this with a cButton
|
||||
talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
|
||||
talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
|
||||
rect_draw_some_item(invenbtn_gworld, help_from, talk_gworld, talk_help_rect, sf::BlendAlpha);
|
||||
|
||||
// Place name oftalkee
|
||||
style.colour = c[3];
|
||||
style.lineHeight = 18;
|
||||
|
@@ -35,11 +35,18 @@ bool cButton::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
|
||||
return false;
|
||||
}
|
||||
|
||||
cButton::cButton(cDialog* parent) :
|
||||
cControl(CTRL_BTN,*parent),
|
||||
cButton::cButton(sf::RenderWindow& parent) :
|
||||
cControl(CTRL_BTN,parent),
|
||||
wrapLabel(false),
|
||||
type(BTN_REG),
|
||||
textClr(parent->getDefTextClr()),
|
||||
textClr(sf::Color::Black),
|
||||
fromList("none") {}
|
||||
|
||||
cButton::cButton(cDialog& parent) :
|
||||
cControl(CTRL_BTN,parent),
|
||||
wrapLabel(false),
|
||||
type(BTN_REG),
|
||||
textClr(parent.getDefTextClr()),
|
||||
fromList("none") {}
|
||||
|
||||
cButton::cButton(cDialog* parent,eControlType t) :
|
||||
@@ -85,7 +92,7 @@ void cButton::draw(){
|
||||
// Others may need adjustments too, not sure
|
||||
// TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button?
|
||||
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
|
||||
}else{
|
||||
} else if(parent) {
|
||||
tileImage(*inWindow,frame,bg[parent->getBg()]);
|
||||
}
|
||||
}
|
||||
@@ -258,7 +265,7 @@ void cLed::draw(){
|
||||
to_rect.right = frame.right;
|
||||
to_rect.left = frame.left + 18; // Possibly could be 20
|
||||
win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style);
|
||||
}else{
|
||||
} else if(parent) {
|
||||
tileImage(*inWindow,frame,bg[parent->getBg()]);
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,10 @@ public:
|
||||
eBtnType getBtnType();
|
||||
/// Create a new button.
|
||||
/// @param parent The parent dialog.
|
||||
explicit cButton(cDialog* parent);
|
||||
explicit cButton(cDialog& parent);
|
||||
/// Create a button outside of a dialog
|
||||
/// @param parent The parent window
|
||||
explicit cButton(sf::RenderWindow& parent);
|
||||
bool isClickable();
|
||||
virtual ~cButton();
|
||||
void draw();
|
||||
|
@@ -351,7 +351,7 @@ template<> pair<string,cButton*> cDialog::parse(Element& who /*button*/){
|
||||
std::string keyMod, keyMain;
|
||||
int keyModRow, keyModCol, keyMainRow, keyMainCol;
|
||||
rectangle frame;
|
||||
p.second = new cButton(this);
|
||||
p.second = new cButton(*this);
|
||||
for(attr = attr.begin(&who); attr != attr.end(); attr++){
|
||||
attr->GetName(&name);
|
||||
if(name == "name")
|
||||
|
@@ -381,7 +381,7 @@ void cThreeChoice::init_buttons(cBasicButtonType btn1, cBasicButtonType btn2, cB
|
||||
if(!btns[i]) continue;
|
||||
std::ostringstream sout;
|
||||
sout << "btn" << i + 1;
|
||||
cButton* btn = new cButton(me);
|
||||
cButton* btn = new cButton(*me);
|
||||
btn->attachKey(btns[i]->defaultKey);
|
||||
btn->setText(btns[i]->label);
|
||||
btn->setBtnType(btns[i]->type);
|
||||
|
Reference in New Issue
Block a user