9
9
#include " config/config.h"
10
10
#include " js/js_game.h"
11
11
12
- struct farm_info_window : public building_info_window {
12
+ struct info_window_farm : public building_info_window_t <info_window_farm> {
13
13
virtual void window_info_background (object_info &c) override ;
14
14
virtual bool check (object_info &c) override {
15
15
return c.building_get ()->dcast_farm ();
16
16
}
17
17
};
18
18
19
- farm_info_window farm_infow;
19
+ info_window_farm farm_infow;
20
20
21
- ANK_REGISTER_CONFIG_ITERATOR (config_load_farm_info_window);
22
- void config_load_farm_info_window () {
23
- farm_infow.load (" info_window_farm" );
24
- }
25
-
26
- void farm_info_window::window_info_background (object_info &c) {
21
+ void info_window_farm::window_info_background (object_info &c) {
27
22
building_info_window::window_info_background (c);
28
23
29
24
building *b = c.building_get ();
@@ -37,23 +32,19 @@ void farm_info_window::window_info_background(object_info &c) {
37
32
ui::str (c.group_id , 2 ), pct_grown, ui::str (c.group_id , 3 ),
38
33
ui::str (c.group_id , 12 ), pct_fertility, ui::str (c.group_id , 13 ));
39
34
40
- std::pair<int , int > reason = { c.group_id , 0 };
41
- if (!c.has_road_access ) { reason = { 69 , 25 }; }
42
- else if (city_resource_is_mothballed (b->output_resource_first_id )) { reason.second = 4 ; }
43
- else if (b->data .industry .curse_days_left > 4 ) { reason.second = 11 ; }
44
- else if (b->num_workers <= 0 ) { reason.second = 5 ; }
45
- else reason.second = approximate_value (c.worker_percentage / 100 .f , make_array (10 , 9 , 8 , 7 , 6 ));
46
-
47
- ui[" workers_text" ] = ui::str (reason.first , reason.second );
35
+ textid reason{ c.group_id , 0 };
36
+ if (!b->num_workers ) {
37
+ reason = { 177 , 5 };
38
+ } else {
39
+ if (!c.has_road_access ) { reason = { 69 , 25 }; }
40
+ else if (city_resource_is_mothballed (b->output_resource_first_id )) { reason.id = 4 ; }
41
+ else if (b->data .industry .curse_days_left > 4 ) { reason.id = 11 ; }
42
+ else if (b->num_workers <= 0 ) { reason.id = 5 ; }
43
+ else reason.id = approximate_value (c.worker_percentage / 100 .f , make_array (10 , 9 , 8 , 7 , 6 ));
44
+ }
45
+ ui[" workers_desc" ] = reason;
48
46
49
47
if (building_is_floodplain_farm (*b)) {
50
- int text_id = 5 ;
51
- if (b->num_workers >= model_get_building (b->type )->laborers ) {
52
- text_id = 6 ;
53
- }
54
-
55
- ui[" workers_desc" ] = ui::str (177 , text_id);
56
-
57
48
// next flood info
58
49
int month_id = 8 ; // TODO: fetch flood info
59
50
ui[" flood_info" ].text_var (" %s %s" , ui::str (177 , 2 ), ui::str (160 , month_id));
0 commit comments