Skip to content

Commit e0e9af0

Browse files
committed
ui: button overlays logic moved to js config
1 parent 4b938b2 commit e0e9af0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/scripts/ui.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ mission_briefing_window = {
701701
goal_5 : { type : "label", pos:[288 + 16, 134 + 32], body : {w:15, h:1}, font : FONT_NORMAL_YELLOW, enabled: false },
702702
goal_immediate : { type : "label", pos : {x:32 + 16, y:134 + 32}, body : {w:31, h:1}, font : FONT_NORMAL_YELLOW, enabled: false },
703703
description_panel : { type : "inner_panel", pos : {x:32, y:200}, size: {w:33, h:14} },
704-
description_text : { type : "text", pos: [40, 216], size:[px(36), px(10)], wrap:px(34), font : FONT_NORMAL_WHITE_ON_DARK, link_font:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
704+
description_text : { type : "text", pos: [40, 216], size:[px(36), px(10)], wrap:px(34), font : FONT_NORMAL_WHITE_ON_DARK, font_link:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
705705
difficulty_label : { type : "label", pos:[105, 433], size:[31, 14], font : FONT_NORMAL_BLACK_ON_LIGHT },
706706
back : { type:"image_button", pos:[26, 428], size:[31, 20], pack:PACK_GENERAL, id:90, offset:8 },
707707
start_mission : { type:"image_button", pos:[516, 430], size:[27, 27], pack:PACK_GENERAL, id:90, offset:0 },
@@ -833,7 +833,7 @@ sidebar_window = {
833833
background : image({pos:[0, 30], size: [29, 22], pack:PACK_GENERAL, id:121}),
834834
build_image : image({pos:[11, 211]}),
835835

836-
overlay_text : text_center({pos:[15, 30], size:[117, 20]}),
836+
show_overlays : button({pos:[4, 30], size:[117, 20], border:false, font_hover:FONT_NORMAL_YELLOW }),
837837

838838
goto_problem : image_button({pos:[86, 434], pack:PACK_GENERAL, id:136, offset:56}),
839839
show_messages : image_button({pos:[46, 434], pack:PACK_GENERAL, id:136, offset:52}),
@@ -878,8 +878,8 @@ info_window_figure_animal = {
878878

879879
info_window_figure_caravan_donkey = {
880880
ui : __baseui(figure_info_window, {
881-
bought_items : { type : "text", pos: [40, 180], size:[px(29), px(10)], wrap:px(29), font : FONT_NORMAL_WHITE_ON_DARK, link_font:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
882-
sold_items : { type : "text", pos: [40, 210], size:[px(29), px(10)], wrap:px(29), font : FONT_NORMAL_WHITE_ON_DARK, link_font:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
881+
bought_items : { type : "text", pos: [40, 180], size:[px(29), px(10)], wrap:px(29), font : FONT_NORMAL_WHITE_ON_DARK, font_link:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
882+
sold_items : { type : "text", pos: [40, 210], size:[px(29), px(10)], wrap:px(29), font : FONT_NORMAL_WHITE_ON_DARK, font_link:FONT_NORMAL_YELLOW, rich:true, clip_area:true },
883883
})
884884
}
885885

src/widget/widget_sidebar.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#define MINIMAP_Y_OFFSET 59
3737

38-
static void button_overlay(int param1, int param2);
3938
static void button_collapse_expand(int param1, int param2);
4039
static void button_build(int submenu, int param2);
4140
static void button_undo(int param1, int param2);
@@ -48,7 +47,6 @@ static void button_rotate(int clockwise, int param2);
4847

4948
static image_button buttons_overlays_collapse_sidebar[2] = {
5049
{128, 0, 31, 20, IB_NORMAL, GROUP_SIDEBAR_UPPER_BUTTONS, 7, button_collapse_expand, button_none, 0, 0, 1},
51-
{4, 3, 117, 31, IB_NORMAL, GROUP_SIDEBAR_UPPER_BUTTONS, 0, button_overlay, button_help, 0, MESSAGE_DIALOG_OVERLAYS, 1}
5250
};
5351

5452
static image_button button_expand_sidebar[1] = {
@@ -111,13 +109,11 @@ static image_button buttons_top_expanded[3] = {
111109
ui::sidebar_window g_sidebar;
112110

113111
void ui::sidebar_window::draw_overlay_text() {
114-
const bool is_button_focused = buttons_overlays_collapse_sidebar[1].focused;
115-
e_font font = is_button_focused ? FONT_NORMAL_WHITE_ON_DARK : FONT_NORMAL_BLACK_ON_LIGHT;
116112
pcstr overlay_text = game.current_overlay
117113
? game_state_overlay_text(game.current_overlay)
118114
: ui::str(6, 4);
119115

120-
ui["overlay_text"].text(font, overlay_text);
116+
ui["show_overlays"] = overlay_text;
121117
}
122118

123119
static void draw_sidebar_remainder(int x_offset, bool is_collapsed) {
@@ -196,6 +192,10 @@ void ui::sidebar_window::init() {
196192
});
197193

198194
ui["show_messages"].onclick([] { window_message_list_show(); });
195+
196+
ui["show_overlays"]
197+
.onclick([] { window_overlay_menu_show(); })
198+
.onrclick([] { window_message_dialog_show(MESSAGE_DIALOG_OVERLAYS, -1, window_city_draw_all);; });
199199
}
200200

201201
void ui::sidebar_window::ui_draw_foreground() {
@@ -340,10 +340,6 @@ static void slide_finished() {
340340
window_draw(1);
341341
}
342342

343-
static void button_overlay(int param1, int param2) {
344-
window_overlay_menu_show();
345-
}
346-
347343
static void button_collapse_expand(int param1, int param2) {
348344
city_view_start_sidebar_toggle();
349345
auto draw_expanded_background = [] (int offset) { g_sidebar.x_offset = offset; };

0 commit comments

Comments
 (0)