Skip to content

Commit 2eee087

Browse files
committed
ui: window empire mouse handle moved to class
1 parent 807fe3c commit 2eee087

File tree

4 files changed

+140
-132
lines changed

4 files changed

+140
-132
lines changed

src/graphics/elements/ui.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ void ui::element::load(archive arch, element *parent, element::items &items) {
544544
margin.left = m.r_int("left", recti::nomargin);
545545
margin.right = m.r_int("right", recti::nomargin);
546546
margin.top = m.r_int("top", recti::nomargin);
547+
margin.centerx = m.r_int("centerx", recti::nomargin);
547548
});
548549

549550
load_elements(arch, "ui", this, items);
@@ -558,6 +559,7 @@ void ui::element::update_pos(const recti &r) {
558559
if (margin.bottom > recti::nomargin) { pos.y = r.bottom + margin.bottom; }
559560
if (margin.right > recti::nomargin) { pos.x = r.right + margin.right; }
560561
if (margin.top > recti::nomargin) { pos.y = r.top + margin.top; }
562+
if (margin.centerx > recti::nomargin) { pos.x = (r.right - r.left) / 2 + margin.centerx; }
561563
}
562564

563565
vec2i ui::element::screen_pos() const {

src/graphics/elements/ui.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct recti {
9696
int top = 0;
9797
int right = 0;
9898
int bottom = 0;
99+
int centerx = 0;
99100
};
100101

101102
struct element {
@@ -105,7 +106,7 @@ struct element {
105106
xstring id;
106107
vec2i pos;
107108
vec2i size;
108-
recti margin = { recti::nomargin, recti::nomargin, recti::nomargin, recti::nomargin };
109+
recti margin = { recti::nomargin, recti::nomargin, recti::nomargin, recti::nomargin, recti::nomargin };
109110
bool readonly = false;
110111
bool enabled = true;
111112
bool grayed = false;

src/scripts/ui.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,6 @@ empire_window = {
13981398
info_y_sells : 30,
13991399
info_y_buys : 52,
14001400
info_y_footer_1 : 78,
1401-
info_y_city_name : 120,
14021401
info_y_city_desc : 28,
14031402
text_group_old_names : 195,
14041403
text_group_new_names : 21,
@@ -1415,8 +1414,9 @@ empire_window = {
14151414
cross_bar : {pack:PACK_GENERAL, id:172, offset:2},
14161415

14171416
ui : {
1418-
1419-
1417+
background : dummy({size:[sw(0), sh(0)]}),
1418+
city_name : header({pos:[0, -1], margin:{bottom:-120}, size:[sw(0), 20], align:"center"}),
1419+
button_help : help_button({margin:{centerx:575, bottom:-120}}),
14201420
}
14211421
}
14221422

0 commit comments

Comments
 (0)