Fix item name rect stealing clicks from ID button

This commit is contained in:
2025-05-06 15:29:30 -05:00
parent c8a2817987
commit 30e77633e4
3 changed files with 30 additions and 27 deletions

View File

@@ -163,21 +163,8 @@ static void init_shopping_rects() {
}
}
void init_screen_locs() {
init_shopping_rects();
rectangle startup_base = {281,1,329,302};
for(auto btn : startup_button.keys()) {
startup_button[btn] = startup_base;
startup_button[btn].offset(301 * (btn / 3), 48 * (btn % 3));
}
startup_top.top = 7;
startup_top.bottom = startup_button[STARTBTN_TUTORIAL].top;
startup_top.left = startup_base.left;
startup_top.right = startup_button[STARTBTN_NEW].right;
// icon, name, use, give, drip, info, sell/id each one 13 down
void init_inven_rects() {
// icon, name, use, give, drop, info, sell/id each one 13 down
item_buttons[0][ITEMBTN_ICON].top = 15;
item_buttons[0][ITEMBTN_ICON].bottom = item_buttons[0][ITEMBTN_ICON].top + 18;
item_buttons[0][ITEMBTN_ICON].left = 20;
@@ -205,25 +192,34 @@ void init_screen_locs() {
item_buttons[0][ITEMBTN_SPEC] = item_buttons[0][ITEMBTN_NAME];
item_buttons[0][ITEMBTN_SPEC].left = 173;
item_buttons[0][ITEMBTN_SPEC].right = 232;
// If extra buttons are visible on the item window, truncate the hitbox of the name, or else it will steal button clicks
if(stat_screen_mode >= MODE_IDENTIFY){
item_buttons[0][ITEMBTN_NAME].right = item_buttons[0][ITEMBTN_SPEC].left;
}
item_buttons[0][ITEMBTN_NAME].top += 3;
for(short i = 1; i < 8; i++)
for(auto j : item_buttons[i].keys()) {
item_buttons[i][j] = item_buttons[0][j];
item_buttons[i][j].offset(0,13 * i);
}
/* for(short i = 0; i < 8; i++) {
item_screen_button_rects[i] = bottom_base;
OffsetRect(&item_screen_button_rects[i],10 + i * 29,126);
}
void init_screen_locs() {
init_shopping_rects(true);
rectangle startup_base = {281,1,329,302};
for(auto btn : startup_button.keys()) {
startup_button[btn] = startup_base;
startup_button[btn].offset(301 * (btn / 3), 48 * (btn % 3));
}
item_screen_button_rects[6].left = 176;
item_screen_button_rects[6].right = 211;
item_screen_button_rects[7].left = 213;
item_screen_button_rects[7].right = 248;
item_screen_button_rects[8].top = 127;
item_screen_button_rects[8].bottom = 140;
item_screen_button_rects[8].left = 251;
item_screen_button_rects[8].right = 267; */
startup_top.top = 7;
startup_top.bottom = startup_button[STARTBTN_TUTORIAL].top;
startup_top.left = startup_base.left;
startup_top.right = startup_button[STARTBTN_NEW].right;
init_inven_rects();
// name, hp, sp, info, trade
pc_buttons[0][PCBTN_NAME].top = 18;

View File

@@ -14,6 +14,7 @@ struct key_action_t {
void (*action)();
};
void init_inven_rects();
void init_screen_locs();
location mouse_window_coords();
// If the mouse is in the terrain window, set the given location to the hovered tile.

View File

@@ -105,6 +105,8 @@ cShop active_shop;
short active_shop_num;
short store_cur_pc = -1;
extern void init_inven_rects();
// For healing shops, other PCs might be able to buy something if
// the active PC can't
static bool start_shop_mode_other_pc(bool allow_empty = false, bool already_started = false) {
@@ -256,6 +258,7 @@ void end_shop_mode() {
univ.party.store_limited_stock[active_shop_num][i] = left;
}
}
init_inven_rects();
}
bool handle_shop_event(location p, cFramerateLimiter& fps_limiter) {
@@ -731,6 +734,7 @@ void end_talk_mode() {
put_pc_screen();
// TODO: I suspect REFRESH_NONE will suffice here
redraw_screen(REFRESH_TERRAIN | REFRESH_BAR);
init_inven_rects();
}
static void fill_job_bank(cDialog& me, job_bank_t& bank, std::string) {
@@ -1214,6 +1218,8 @@ bool handle_talk_event(location p, cFramerateLimiter& fps_limiter) {
break;
}
handle_talk_node(which_talk_entry);
// Update hitboxes of the inventory in case sell/identify/recharge mode started
init_inven_rects();
return clicked_word || p.in(rectangle(talk_gworld()));
}