Skip to content

Commit 6415bd3

Browse files
committed
swars: Unified components positioning in World Map screen
1 parent db56ba5 commit 6415bd3

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/fedebrief.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,10 @@ void init_debrief_screen_boxes(void)
712712
// for that, add pixels for such border to the space.
713713
space_h = scr_h - start_y - world_city_info_box.Height + border;
714714

715-
world_city_info_box.Y = start_y + space_h / 2;
716-
715+
// Expect world_city_info_box to be already set
717716
debrief_mission_box.X = start_x;
718717
debrief_mission_box.Y = world_city_info_box.Y;
719718

720-
world_city_info_box.X = debrief_mission_box.X + debrief_mission_box.Width + space_w;
721-
722719
debrief_people_box.X = start_x;
723720
debrief_people_box.Y = world_city_info_box.Y + world_city_info_box.Height - debrief_people_box.Height;
724721
}

src/feworld.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,17 @@ ubyte show_worldmap_screen(void)
653653

654654
void init_world_screen_boxes(void)
655655
{
656-
short scr_w, start_x;
657-
658-
scr_w = lbDisplay.GraphicsWindowWidth;
656+
ScrCoord scr_h, start_x, start_y;
657+
short space_w, space_h, border;
658+
659+
// Border value represents how much the box background goes
660+
// out of the box area.
661+
border = 3;
662+
#ifdef EXPERIMENTAL_MENU_CENTER_H
663+
scr_h = global_apps_bar_box.Y;
664+
#else
665+
scr_h = 432;
666+
#endif
659667

660668
init_screen_box(&world_landmap_box, 7u, 72u, 518u, 354, 6);
661669
init_screen_text_box(&world_city_info_box, 534u, 72u, 99u, 354, 6, small_med_font, 3);
@@ -670,10 +678,22 @@ void init_world_screen_boxes(void)
670678
world_info_ACCEPT_button.CallBackFn = ac_do_unkn2_ACCEPT;
671679
world_landmap_box.SpecialDrawFn = show_world_landmap_box;
672680

673-
start_x = (scr_w - world_landmap_box.Width - world_city_info_box.Width - 23) / 2;
681+
// Reposition the components to current resolution
682+
683+
start_x = heading_box.X;
684+
// On the X axis, we're going for aligning below heading box, to both left and right
685+
space_w = heading_box.Width - world_landmap_box.Width - world_city_info_box.Width;
686+
687+
start_y = heading_box.Y + heading_box.Height;
688+
// On the top, we're aligning to spilled border of previous box; same goes inside.
689+
// But on the bottom, we're aligning to hard border, without spilling. To compensate
690+
// for that, add pixels for such border to the space.
691+
space_h = scr_h - start_y - world_city_info_box.Height + border;
674692

675-
world_landmap_box.X = start_x + 7;
676-
world_city_info_box.X = world_landmap_box.X + world_landmap_box.Width + 9;
693+
world_city_info_box.Y = start_y + space_h / 2;
694+
world_landmap_box.X = start_x;
695+
world_landmap_box.Y = world_city_info_box.Y;
696+
world_city_info_box.X = world_landmap_box.X + world_landmap_box.Width + space_w;
677697

678698
world_info_ACCEPT_button.X = world_city_info_box.X
679699
+ ((world_city_info_box.Width - world_info_ACCEPT_button.Width) >> 1);

0 commit comments

Comments
 (0)