|
3 | 3 | #include "window/building/common.h"
|
4 | 4 | #include "widget/city/ornaments.h"
|
5 | 5 | #include "graphics/elements/ui.h"
|
| 6 | +#include "figure/figure.h" |
| 7 | +#include "window/window_building_info.h" |
6 | 8 |
|
7 | 9 | #include "graphics/animation.h"
|
8 | 10 | #include "city/labor.h"
|
9 | 11 | #include "js/js_game.h"
|
10 | 12 |
|
11 | 13 | buildings::model_t<building_courthouse> courthouse_m;
|
12 | 14 |
|
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); |
16 | 48 | }
|
17 | 49 |
|
18 | 50 | void building_courthouse::spawn_figure() {
|
19 | 51 | common_spawn_roamer(FIGURE_MAGISTRATE, 50, FIGURE_ACTION_125_ROAMING);
|
20 | 52 | }
|
21 | 53 |
|
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(); |
49 | 60 | }
|
50 | 61 |
|
51 | 62 | bool building_courthouse::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) {
|
|
0 commit comments