1
- #include " top_menu_game .h"
1
+ #include " widget_top_menu_game .h"
2
2
3
3
#include " game/game.h"
4
4
@@ -76,6 +76,7 @@ struct top_menu_data_t {
76
76
vec2i offset;
77
77
int item_height;
78
78
int spacing;
79
+ int sidebar_offset;
79
80
e_image_id background;
80
81
81
82
ui::widget headers;
@@ -144,6 +145,7 @@ void config_load_top_menu_bar() {
144
145
data.offset_population_basic = arch.r_int (" offset_population_basic" );
145
146
data.offset_date_basic = arch.r_int (" offset_date_basic" );
146
147
data.offset_rotate_basic = arch.r_int (" offset_rotate_basic" );
148
+ data.sidebar_offset = arch.r_int (" sidebar_offset" );
147
149
148
150
data.headers .load (arch, " headers" );
149
151
for (auto &header : data.headers .elements ) {
@@ -635,13 +637,13 @@ static void widget_top_menu_init() {
635
637
set_text_for_debug_render ();
636
638
}
637
639
638
- static void top_menu_draw_background () {
640
+ static void widget_sub_menu_draw_background () {
639
641
window_city_draw_panels ();
640
642
window_city_draw ();
641
643
widget_sidebar_city_draw_foreground ();
642
644
}
643
645
644
- static void top_menu_draw_foreground () {
646
+ static void widget_sub_menu_draw_foreground () {
645
647
auto & data = g_top_menu_data;
646
648
if (!data.open_sub_menu ) {
647
649
return ;
@@ -650,11 +652,11 @@ static void top_menu_draw_foreground() {
650
652
top_menu_menu_draw (data.open_sub_menu , data.focus_sub_menu_id );
651
653
}
652
654
653
- void widget_top_menu_show () {
655
+ void widget_sub_menu_show () {
654
656
static window_type window = {
655
657
WINDOW_TOP_MENU,
656
- top_menu_draw_background ,
657
- top_menu_draw_foreground ,
658
+ widget_sub_menu_draw_background ,
659
+ widget_sub_menu_draw_foreground ,
658
660
widget_top_menu_handle_input
659
661
};
660
662
widget_top_menu_init ();
@@ -666,18 +668,16 @@ int orientation_button_pressed = 0;
666
668
667
669
void wdiget_top_menu_draw_background () {
668
670
painter ctx = game.painter ();
669
- int block_width = 96 ;
670
- int s_width = screen_width ();
671
-
672
- int s_end = s_width - 1000 - 24 + city_view_is_sidebar_collapsed () * (162 - 18 );
673
- int s_start = s_end - ceil ((float )s_end / (float )block_width) * block_width;
674
671
675
672
int img_id = image_group (g_top_menu_data.background );
676
- for (int i = 0 ; s_start + i * block_width < s_end; i++) {
677
- ImageDraw::img_generic (ctx, img_id, s_start + (i * block_width), COLOR_MASK_NONE);
673
+ const image_t *img = image_get (img_id);
674
+ const int block_width = img->width ;
675
+
676
+ for (int x = -(screen_width () - widget_sidebar_city_offset_x ()); x < screen_width (); x += (block_width - g_top_menu_data.sidebar_offset )) {
677
+ ImageDraw::img_generic (ctx, img_id, x, 0 );
678
678
}
679
679
680
- ImageDraw::img_generic (ctx, img_id, s_end , 0 );
680
+ ImageDraw::img_generic (ctx, img_id, widget_sidebar_city_offset_x () - block_width + g_top_menu_data. sidebar_offset , 0 );
681
681
}
682
682
683
683
void widget_top_menu_draw (int force) {
@@ -818,7 +818,7 @@ static bool widget_top_menu_handle_mouse_menu(const mouse* m) {
818
818
xstring menu_id = top_menu_bar_handle_mouse (m);
819
819
if (!!menu_id && m->left .went_up ) {
820
820
data.open_sub_menu = menu_id;
821
- widget_top_menu_show ();
821
+ widget_sub_menu_show ();
822
822
return true ;
823
823
}
824
824
0 commit comments