|
2 | 2 |
|
3 | 3 | #include "building/building.h"
|
4 | 4 | #include "city/object_info.h"
|
| 5 | +#include "figure/figure.h" |
5 | 6 | #include "game/resource.h"
|
6 | 7 | #include "graphics/elements/panel.h"
|
7 | 8 | #include "graphics/view/view.h"
|
|
13 | 14 | #include "sound/sound_building.h"
|
14 | 15 | #include "game/game.h"
|
15 | 16 |
|
16 |
| -void building_tax_collector_draw_info(object_info* c) { |
17 |
| - painter ctx = game.painter(); |
18 |
| - c->help_id = e_text_building_tax_collector; |
19 |
| - window_building_play_sound(c, snd::get_building_info_sound("tax_collector")); |
20 |
| - outer_panel_draw(c->offset, c->width_blocks, c->height_blocks); |
21 |
| - lang_text_draw_centered(106, 0, c->offset.x, c->offset.y + 10, 16 * c->width_blocks, FONT_LARGE_BLACK_ON_LIGHT); |
22 |
| - ImageDraw::img_generic(ctx, image_id_resource_icon(RESOURCE_DEBEN), c->offset.x + 16, c->offset.y + 36); |
| 17 | +void building_tax_collector::window_info_background(object_info &c) { |
| 18 | + ui::begin_window(c.offset); |
23 | 19 |
|
24 |
| - building* b = building_get(c->building_id); |
25 |
| - int width = lang_text_draw(106, 2, c->offset.x + 44, c->offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
| 20 | + c.help_id = e_text_building_tax_collector; |
| 21 | + c.go_to_advisor.left_a = ADVISOR_RATINGS; |
| 22 | + c.go_to_advisor.left_b = ADVISOR_FINANCIAL; |
| 23 | + |
| 24 | + window_building_play_sound(&c, snd::get_building_info_sound("tax_collector")); |
| 25 | + |
| 26 | + { |
| 27 | + ui::panel(vec2i{0, 0}, {c.width_blocks, c.height_blocks}, UiFlags_PanelOuter); |
| 28 | + ui::label(106, 0, vec2i{0, 10}, 16 * c.width_blocks, FONT_LARGE_BLACK_ON_LIGHT, UiFlags_LabelCentered); |
| 29 | + ui::icon(vec2i{16, 36}, RESOURCE_DEBEN); |
| 30 | + } |
| 31 | + |
| 32 | + building* b = building_get(c.building_id); |
| 33 | + int width = lang_text_draw(106, 2, c.offset.x + 44, c.offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
26 | 34 | if (config_get(CONFIG_GP_CH_NEW_TAX_COLLECTION_SYSTEM)) {
|
27 |
| - lang_text_draw_amount(8, 0, b->deben_storage, c->offset.x + 44 + width, c->offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
| 35 | + lang_text_draw_amount(8, 0, b->deben_storage, c.offset.x + 44 + width, c.offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
28 | 36 | } else {
|
29 |
| - lang_text_draw_amount(8, 0, b->tax_income_or_storage, c->offset.x + 44 + width, c->offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
| 37 | + lang_text_draw_amount(8, 0, b->tax_income_or_storage, c.offset.x + 44 + width, c.offset.y + 43, FONT_NORMAL_BLACK_ON_LIGHT); |
30 | 38 | }
|
31 | 39 |
|
32 |
| - if (!c->has_road_access) { |
| 40 | + if (!c.has_road_access) { |
33 | 41 | window_building_draw_description(c, 69, 25);
|
34 | 42 | } else if (b->num_workers <= 0) {
|
35 | 43 | window_building_draw_description_at(c, 72, 106, 10);
|
36 |
| - } else if (c->worker_percentage >= 100) { |
| 44 | + } else if (c.worker_percentage >= 100) { |
37 | 45 | window_building_draw_description_at(c, 72, 106, 5);
|
38 |
| - } else if (c->worker_percentage >= 75) { |
| 46 | + } else if (c.worker_percentage >= 75) { |
39 | 47 | window_building_draw_description_at(c, 72, 106, 6);
|
40 |
| - } else if (c->worker_percentage >= 50) { |
| 48 | + } else if (c.worker_percentage >= 50) { |
41 | 49 | window_building_draw_description_at(c, 72, 106, 7);
|
42 |
| - } else if (c->worker_percentage >= 25) { |
| 50 | + } else if (c.worker_percentage >= 25) { |
43 | 51 | window_building_draw_description_at(c, 72, 106, 8);
|
44 | 52 | } else {
|
45 | 53 | window_building_draw_description_at(c, 72, 106, 9);
|
46 | 54 | }
|
47 | 55 |
|
48 |
| - inner_panel_draw(c->offset.x + 16, c->offset.y + 136, c->width_blocks - 2, 4); |
49 |
| - window_building_draw_employment(c, 142); |
| 56 | + inner_panel_draw(c.offset.x + 16, c.offset.y + 136, c.width_blocks - 2, 4); |
| 57 | + window_building_draw_employment(&c, 142); |
| 58 | +} |
| 59 | + |
| 60 | +void building_tax_collector::update_month() { |
| 61 | + if (!config_get(CONFIG_GP_CH_NEW_TAX_COLLECTION_SYSTEM)) { |
| 62 | + return; |
| 63 | + } |
| 64 | + |
| 65 | + if (base.has_figure_of_type(BUILDING_SLOT_CARTPUSHER, FIGURE_CART_PUSHER)) { |
| 66 | + return; |
| 67 | + } |
| 68 | + |
| 69 | + if (base.has_road_access && base.deben_storage > 100) { |
| 70 | + int may_send = std::min<int>((base.deben_storage / 100) * 100, 400); |
| 71 | + figure *f = base.create_cartpusher(RESOURCE_GOLD, may_send, FIGURE_ACTION_20_CARTPUSHER_INITIAL, BUILDING_SLOT_CARTPUSHER); |
| 72 | + base.deben_storage -= may_send; |
| 73 | + f->sender_building_id = base.id; |
| 74 | + } |
50 | 75 | }
|
0 commit comments