separate args to highlight text and item help button

This commit is contained in:
2025-02-04 12:29:52 -06:00
parent ddad32458e
commit 673de75c73
5 changed files with 21 additions and 19 deletions

View File

@@ -920,7 +920,7 @@ void handle_switch_pc_items(short which_pc, bool& need_redraw) {
set_stat_window_for_pc(which_pc);
if(overall_mode == MODE_SHOPPING) {
set_up_shop_array();
draw_shop_graphics(0,item_screen_button_rects[which_pc]); // rect is dummy
draw_shop_graphics(false,false,item_screen_button_rects[which_pc]); // rect is dummy
}
}
}
@@ -1623,7 +1623,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
put_item_screen(stat_window);
if(overall_mode == MODE_SHOPPING) {
set_up_shop_array();
draw_shop_graphics(0,pc_buttons[0][PCBTN_NAME]);
draw_shop_graphics(false,false,pc_buttons[0][PCBTN_NAME]);
}
}

View File

@@ -149,7 +149,7 @@ bool start_shop_mode(short which,short cost_adj,std::string store_name, bool can
put_background();
draw_shop_graphics(0,area_rect);
draw_shop_graphics(false,false,area_rect);
put_item_screen(stat_window);
give_help(26,27);
@@ -251,11 +251,11 @@ bool handle_shop_event(location p, cFramerateLimiter& fps_limiter) {
item_help_rect.offset(talk_gword_offset_x, talk_gword_offset_y);
if(p.in(active_rect)) {
click_shop_rect(visual_rect);
click_shop_rect(visual_rect, false);
handle_sale(what_picked);
return true;
} else if(p.in(item_help_rect)){
click_shop_rect(visual_item_help_rect);
click_shop_rect(visual_item_help_rect, true);
handle_info_request(what_picked);
return true;
}
@@ -421,14 +421,14 @@ void handle_sale(int i) {
}
// Maybe that was the last of that item, so re-init the shop array just in case.
set_up_shop_array();
draw_shop_graphics(0,dummy_rect);
draw_shop_graphics(false,false,dummy_rect);
print_buf();
put_pc_screen();
put_item_screen(stat_window);
// This looks to be redundant, but I'm just preserving the previous behavior of the code.
set_up_shop_array();
draw_shop_graphics(false, {});
draw_shop_graphics(false,false,{});
}

View File

@@ -521,7 +521,7 @@ void redraw_screen(int refresh) {
refresh_talking();
break;
case MODE_SHOPPING:
if(refresh & REFRESH_DLOG) draw_shop_graphics(0,{0,0,0,0});
if(refresh & REFRESH_DLOG) draw_shop_graphics(false,false,{0,0,0,0});
refresh_shopping();
break;
default:

View File

@@ -599,15 +599,15 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
store_booms[i].boom_type = -1;
}
void click_shop_rect(rectangle area_rect) {
void click_shop_rect(rectangle area_rect, bool item_help) {
if(recording){
record_action("click_shop_rect", boost::lexical_cast<std::string>(area_rect));
}
draw_shop_graphics(1,area_rect);
draw_shop_graphics(!item_help,item_help,area_rect);
mainPtr.display();
play_sound(37, time_in_ticks(5));
draw_shop_graphics(0,area_rect);
draw_shop_graphics(false,false,area_rect);
}
@@ -627,7 +627,7 @@ graf_pos calc_item_rect(int num,rectangle& to_rect) {
}
// mode 1 - drawing dark for button press
void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
void draw_shop_graphics(bool item_pressed, bool item_help_pressed, rectangle clip_area_rect) {
rectangle area_rect,item_info_from = {11,42,24,56};
rectangle face_rect = {6,6,38,38};
@@ -653,7 +653,7 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
area_rect = rectangle(talk_gworld);
talk_gworld.setActive(false);
// Only re-render on top of the item that is clicked:
if(pressed) {
if(item_pressed || item_help_pressed) {
clip_area_rect.offset(-area_rect.left, -area_rect.top);
clip_rect(talk_gworld, clip_area_rect);
} else {
@@ -664,8 +664,10 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
frame_rect(talk_gworld, shop_frame, Colours::BLACK);
}
// Place store icon
if(!pressed) {
// Place store icon:
// We can skip this when rendering for a button press, but it won't matter anyway
// because button press rendering is clipped anyway.
if(!item_pressed || item_help_pressed) {
rectangle from_rect = {0,0,32,32};
std::shared_ptr<const sf::Texture> from_gw;
int i = std::max<int>(0, active_shop.getFace());
@@ -719,7 +721,7 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
}
win_draw_string(talk_gworld,shopper_name,title.str(),eTextMode::LEFT_TOP,style);
if(pressed)
if(item_pressed)
style.colour = Colours::TITLE_BLUE;
else
style.colour = Colours::BLACK;
@@ -781,7 +783,7 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
rect_draw_some_item(invenbtn_gworld, {0, 29, 7, 36}, talk_gworld, cost_rect, sf::BlendAlpha);
style.pointSize = 10;
win_draw_string(talk_gworld,shopping_rects[i][SHOPRECT_ITEM_EXTRA],cur_info_str,eTextMode::WRAP,style);
rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][SHOPRECT_ITEM_HELP],pressed ? sf::BlendNone : sf::BlendAlpha);
rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][SHOPRECT_ITEM_HELP],item_help_pressed ? sf::BlendNone : sf::BlendAlpha);
}
// Finally, cost info and help strs

View File

@@ -59,8 +59,8 @@ void add_missile(location dest,miss_num_t missile_type,short path_type,short x_a
void add_explosion(location dest,short val_to_place,short place_type,short boom_type,short x_adj,short y_adj, bool use_unique_ran = false);
void do_missile_anim(short num_steps,location missile_origin,short sound_num) ;
void do_explosion_anim(short sound_num,short expand,short snd = -1);
void click_shop_rect(rectangle area_rect);
void draw_shop_graphics(bool pressed,rectangle clip_area_rect);
void click_shop_rect(rectangle area_rect, bool item_help = false);
void draw_shop_graphics(bool item_pressed, bool item_help_pressed, rectangle clip_area_rect);
void refresh_shopping();
void click_talk_rect(word_rect_t word);
void place_talk_str(std::string str_to_place,std::string str_to_place2,short color,rectangle c_rect);