Skip to content

Commit 85e85b3

Browse files
committed
ui: restored info window for courthouse
1 parent 58bad9e commit 85e85b3

File tree

2 files changed

+42
-31
lines changed

2 files changed

+42
-31
lines changed

src/building/building_courthouse.cpp

+41-30
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,60 @@
33
#include "window/building/common.h"
44
#include "widget/city/ornaments.h"
55
#include "graphics/elements/ui.h"
6+
#include "figure/figure.h"
7+
#include "window/window_building_info.h"
68

79
#include "graphics/animation.h"
810
#include "city/labor.h"
911
#include "js/js_game.h"
1012

1113
buildings::model_t<building_courthouse> courthouse_m;
1214

13-
ANK_REGISTER_CONFIG_ITERATOR(config_load_building_courthouse);
14-
void config_load_building_courthouse() {
15-
courthouse_m.load();
15+
struct info_window_courthouse : public building_info_window_t<info_window_courthouse> {
16+
virtual void init(object_info &c) override;
17+
virtual bool check(object_info &c) override {
18+
return c.building_get()->dcast_courthouse();
19+
}
20+
};
21+
22+
info_window_courthouse courthouse_infow;
23+
24+
void info_window_courthouse::init(object_info &c) {
25+
building_info_window::init(c);
26+
27+
building* b = c.building_get();
28+
std::pair<int, int> reason = { c.group_id, 0 };
29+
30+
if (!c.has_road_access) reason = { 69, 25 };
31+
else if (b->num_workers <= 0) reason.second = 2;
32+
else reason.second = approximate_value(c.worker_percentage / 100.f, make_array(4, 5, 6));
33+
ui["workers_desc"] = ui::str(reason.first, reason.second);
34+
35+
textid magistrate_state{58 ,51};
36+
if (b->num_workers > 0) {
37+
if (!b->get_figure(BUILDING_SLOT_SERVICE)->is_valid()) {
38+
magistrate_state = { c.group_id, 8 };
39+
} else {
40+
magistrate_state = { c.group_id, 7 };
41+
}
42+
}
43+
44+
ui["state"] = magistrate_state;
45+
46+
fill_employment_details(c);
47+
ui["warning_text"] = ui::str(c.group_id, 1);
1648
}
1749

1850
void building_courthouse::spawn_figure() {
1951
common_spawn_roamer(FIGURE_MAGISTRATE, 50, FIGURE_ACTION_125_ROAMING);
2052
}
2153

22-
void building_courthouse::window_info_background(object_info &c) {
23-
const int LANG_GROUP_ID = 176;
24-
c.help_id = 76;
25-
window_building_play_sound(&c, "Wavs/forum.wav");
26-
outer_panel_draw(c.offset, c.bgsize.x, c.bgsize.y);
27-
lang_text_draw_centered(LANG_GROUP_ID, 0, c.offset.x, c.offset.y + 10, 16 * c.bgsize.x, FONT_LARGE_BLACK_ON_LIGHT);
28-
29-
building* b = building_get(c.building_id);
30-
31-
if (!c.has_road_access)
32-
window_building_draw_description(c, 69, 25);
33-
else if (b->num_workers <= 0)
34-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 10);
35-
else if (c.worker_percentage >= 100)
36-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 5);
37-
else if (c.worker_percentage >= 75)
38-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 6);
39-
else if (c.worker_percentage >= 50)
40-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 7);
41-
else if (c.worker_percentage >= 25)
42-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 8);
43-
else {
44-
window_building_draw_description_at(c, 72, LANG_GROUP_ID, 9);
45-
}
46-
47-
inner_panel_draw(c.offset + vec2i{ 16, 136 }, { c.bgsize.x - 2, 4 });
48-
window_building_draw_employment(&c, 142);
54+
void building_courthouse::update_graphic() {
55+
const xstring &animkey = can_play_animation()
56+
? animkeys().work
57+
: animkeys().none;
58+
set_animation(animkey);
59+
building_impl::update_graphic();
4960
}
5061

5162
bool building_courthouse::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) {

src/building/building_courthouse.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class building_courthouse : public building_impl {
1313
virtual e_overlay get_overlay() const override { return OVERLAY_COUTHOUSE; }
1414
virtual bool is_administration() const override { return true; }
1515
virtual void spawn_figure() override;
16-
virtual void window_info_background(object_info &ctx) override;
16+
virtual void update_graphic() override;
1717
virtual bool draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) override;
1818
};

0 commit comments

Comments
 (0)