1 #include "building_info.h"
2
3 #include "building/barracks.h"
4 #include "building/culture.h"
5 #include "building/house_evolution.h"
6 #include "building/industry.h"
7 #include "building/model.h"
8 #include "building/monument.h"
9 #include "building/warehouse.h"
10 #include "city/map.h"
11 #include "city/view.h"
12 #include "core/calc.h"
13 #include "core/image_group.h"
14 #include "figure/figure.h"
15 #include "figure/formation_legion.h"
16 #include "figure/phrase.h"
17 #include "graphics/generic_button.h"
18 #include "graphics/image.h"
19 #include "graphics/image_button.h"
20 #include "graphics/lang_text.h"
21 #include "graphics/panel.h"
22 #include "graphics/screen.h"
23 #include "graphics/text.h"
24 #include "graphics/window.h"
25 #include "input/input.h"
26 #include "map/aqueduct.h"
27 #include "map/building.h"
28 #include "map/figure.h"
29 #include "map/grid.h"
30 #include "map/image.h"
31 #include "map/property.h"
32 #include "map/sprite.h"
33 #include "map/terrain.h"
34 #include "window/advisors.h"
35 #include "window/city.h"
36 #include "window/message_dialog.h"
37 #include "window/building/distribution.h"
38 #include "window/building/figures.h"
39 #include "window/building/government.h"
40 #include "window/building/house.h"
41 #include "window/building/military.h"
42 #include "window/building/terrain.h"
43 #include "window/building/utility.h"
44
45 #define OFFSET(x,y) (x + GRID_SIZE * y)
46
47 static void button_help(int param1, int param2);
48 static void button_close(int param1, int param2);
49 static void button_advisor(int advisor, int param2);
50 static void button_mothball(int mothball, int param2);
51 static void button_monument_construction(int param1, int param2);
52
53 static image_button image_buttons_help_close[] = {
54 {14, 0, 27, 27, IB_NORMAL, GROUP_CONTEXT_ICONS, 0, button_help, button_none, 0, 0, 1},
55 {424, 3, 24, 24, IB_NORMAL, GROUP_CONTEXT_ICONS, 4, button_close, button_none, 0, 0, 1}
56 };
57
58 static image_button image_buttons_advisor[] = {
59 {350, -38, 28, 28, IB_NORMAL, GROUP_MESSAGE_ADVISOR_BUTTONS, 9, button_advisor, button_none, ADVISOR_RATINGS, 0, 1}
60 };
61
62 static image_button image_button_mothball[] = {
63 {400, 3, 24, 24, IB_NORMAL, 0, 0, button_mothball, button_none, 0, 0, 1, "UI_Elements", "Mothball_1"},
64 {400, 3, 24, 24, IB_NORMAL, 0, 0, button_mothball, button_none, 0, 0, 1, "UI_Elements", "Unmothball_1"}
65 };
66
67 static generic_button generic_button_monument_construction[] = {
68 {80, 3, 304, 24, button_monument_construction, button_none, 0, 0}
69 };
70
71 static building_info_context context;
72 static int focus_image_button_id;
73 static int focus_mothball_image_button_id;
74 static int focus_monument_construction_button_id;
75
get_height_id(void)76 static int get_height_id(void)
77 {
78 if (context.type == BUILDING_INFO_TERRAIN) {
79 switch (context.terrain_type) {
80 case TERRAIN_INFO_AQUEDUCT:
81 return 4;
82 case TERRAIN_INFO_RUBBLE:
83 case TERRAIN_INFO_WALL:
84 case TERRAIN_INFO_GARDEN:
85 return 1;
86 default:
87 return 5;
88 }
89 } else if (context.type == BUILDING_INFO_LEGION) {
90 return 7;
91 } else if (context.type == BUILDING_INFO_BUILDING) {
92 const building *b = building_get(context.building_id);
93 if (building_is_house(b->type) && b->house_population <= 0) {
94 return 5;
95 }
96 if (building_is_house(b->type) && b->house_population > 0) {
97 return 7;
98 }
99
100 if (b->type >= BUILDING_SMALL_POND && b->type <= BUILDING_SMALL_STATUE_ALT_B) {
101 return 1;
102 }
103
104 switch (b->type) {
105 case BUILDING_SMALL_TEMPLE_CERES:
106 case BUILDING_SMALL_TEMPLE_NEPTUNE:
107 case BUILDING_SMALL_TEMPLE_MERCURY:
108 case BUILDING_SMALL_TEMPLE_MARS:
109 case BUILDING_SMALL_TEMPLE_VENUS:
110 case BUILDING_SMALL_STATUE:
111 case BUILDING_MEDIUM_STATUE:
112 case BUILDING_LARGE_STATUE:
113 case BUILDING_LEGION_STATUE:
114 case BUILDING_DECORATIVE_COLUMN:
115 case BUILDING_HORSE_STATUE:
116 case BUILDING_GLADIATOR_SCHOOL:
117 case BUILDING_LION_HOUSE:
118 case BUILDING_ACTOR_COLONY:
119 case BUILDING_CHARIOT_MAKER:
120 case BUILDING_BURNING_RUIN:
121 case BUILDING_RESERVOIR:
122 case BUILDING_NATIVE_HUT:
123 case BUILDING_NATIVE_MEETING:
124 case BUILDING_NATIVE_CROPS:
125 case BUILDING_MISSION_POST:
126 case BUILDING_PREFECTURE:
127 case BUILDING_ENGINEERS_POST:
128 case BUILDING_GATEHOUSE:
129 case BUILDING_TOWER:
130 case BUILDING_FORT:
131 case BUILDING_MILITARY_ACADEMY:
132 case BUILDING_MARKET:
133 case BUILDING_SHIPYARD:
134 case BUILDING_WHARF:
135 case BUILDING_GOVERNORS_HOUSE:
136 case BUILDING_GOVERNORS_VILLA:
137 case BUILDING_GOVERNORS_PALACE:
138 case BUILDING_FORUM:
139 case BUILDING_ROADBLOCK:
140 case BUILDING_FORUM_UPGRADED:
141 case BUILDING_WORKCAMP:
142 case BUILDING_ARCHITECT_GUILD:
143 case BUILDING_OBELISK:
144 case BUILDING_HEDGE_DARK:
145 case BUILDING_HEDGE_LIGHT:
146 case BUILDING_LARARIUM:
147 case BUILDING_COLONNADE:
148 case BUILDING_GARDEN_PATH:
149 case BUILDING_WATCHTOWER:
150 case BUILDING_GARDEN_WALL:
151 case BUILDING_ROOFED_GARDEN_WALL:
152 case BUILDING_GARDEN_WALL_GATE:
153 case BUILDING_PALISADE:
154 return 1;
155
156 case BUILDING_SENATE:
157 case BUILDING_SENATE_UPGRADED:
158 case BUILDING_FOUNTAIN:
159 return 2;
160
161 case BUILDING_BARRACKS:
162 case BUILDING_LARGE_TEMPLE_CERES:
163 case BUILDING_LARGE_TEMPLE_NEPTUNE:
164 case BUILDING_LARGE_TEMPLE_MERCURY:
165 case BUILDING_LARGE_TEMPLE_MARS:
166 case BUILDING_LARGE_TEMPLE_VENUS:
167 case BUILDING_ORACLE:
168 case BUILDING_NYMPHAEUM:
169 case BUILDING_SMALL_MAUSOLEUM:
170 case BUILDING_LARGE_MAUSOLEUM:
171 return 3;
172
173 case BUILDING_WELL:
174 return 4;
175
176 case BUILDING_DOCK:
177 case BUILDING_LIGHTHOUSE:
178 case BUILDING_CARAVANSERAI:
179 return 6;
180
181 case BUILDING_MESS_HALL:
182 return 7;
183
184 case BUILDING_GRAND_TEMPLE_CERES:
185 case BUILDING_GRAND_TEMPLE_NEPTUNE:
186 case BUILDING_GRAND_TEMPLE_MERCURY:
187 case BUILDING_GRAND_TEMPLE_MARS:
188 case BUILDING_GRAND_TEMPLE_VENUS:
189 case BUILDING_PANTHEON:
190 case BUILDING_HIPPODROME:
191 case BUILDING_COLOSSEUM:
192 return 8;
193
194 case BUILDING_GRANARY:
195 return 9;
196
197 default:
198 return 0;
199 }
200 }
201 return 0;
202 }
203
draw_mothball_button(int x,int y)204 static void draw_mothball_button(int x, int y)
205 {
206 building *b = building_get(context.building_id);
207 if (b->state == BUILDING_STATE_MOTHBALLED) {
208 image_buttons_draw(x, y, image_button_mothball, 2);
209 } else {
210 image_buttons_draw(x, y, image_button_mothball, 1);
211 }
212 }
213
draw_halt_monument_construction_button(int x,int y,int focused,building * monument)214 static void draw_halt_monument_construction_button(int x, int y, int focused, building *monument)
215 {
216 int width = BLOCK_SIZE * (context.width_blocks - 10);
217 button_border_draw(x, y, width, 20, focused ? 1 : 0);
218 if (monument->state != BUILDING_STATE_MOTHBALLED) {
219 text_draw_centered(translation_for(TR_BUTTON_HALT_MONUMENT_CONSTRUCTION), x, y + 4, width, FONT_NORMAL_BLACK, 0);
220 } else {
221 text_draw_centered(translation_for(TR_BUTTON_RESUME_MONUMENT_CONSTRUCTION), x, y + 4, width, FONT_NORMAL_BLACK, 0);
222 }
223 }
224
center_in_city(int element_width_pixels)225 static int center_in_city(int element_width_pixels)
226 {
227 int x, y, width, height;
228 city_view_get_unscaled_viewport(&x, &y, &width, &height);
229 int margin = (width - element_width_pixels) / 2;
230 return x + margin;
231 }
232
highlight_waypoints(building * b)233 void highlight_waypoints(building *b) // highlight the 4 routing tiles for roams from this building
234 {
235 map_clear_highlights();
236 if (b->type == BUILDING_FORT || b->house_size) { // building doesn't send roamers
237 return;
238 }
239 int hx, hy, roadx, roady;
240 hx = b->x; hy = b->y - 8;
241 map_grid_bound(&hx, &hy);
242 if (map_closest_road_within_radius(hx, hy, 1, 6, &roadx, &roady)) {
243 map_highlight_set(map_grid_offset(roadx, roady));
244 }
245 hx = b->x + 8; hy = b->y;
246 map_grid_bound(&hx, &hy);
247 if (map_closest_road_within_radius(hx, hy, 1, 6, &roadx, &roady)) {
248 map_highlight_set(map_grid_offset(roadx, roady));
249 }
250 hx = b->x; hy = b->y + 8;
251 map_grid_bound(&hx, &hy);
252 if (map_closest_road_within_radius(hx, hy, 1, 6, &roadx, &roady)) {
253 map_highlight_set(map_grid_offset(roadx, roady));
254 }
255 hx = b->x - 8; hy = b->y;
256 map_grid_bound(&hx, &hy);
257 if (map_closest_road_within_radius(hx, hy, 1, 6, &roadx, &roady)) {
258 map_highlight_set(map_grid_offset(roadx, roady));
259 }
260 window_invalidate();
261 }
262
init(int grid_offset)263 static void init(int grid_offset)
264 {
265 context.can_play_sound = 1;
266 context.storage_show_special_orders = 0;
267 context.can_go_to_advisor = 0;
268 context.building_id = map_building_at(grid_offset);
269 context.rubble_building_type = map_rubble_building_type(grid_offset);
270 context.has_reservoir_pipes = map_terrain_is(grid_offset, TERRAIN_RESERVOIR_RANGE);
271 context.aqueduct_has_water = map_aqueduct_at(grid_offset)
272 && map_image_at(grid_offset) - image_group(GROUP_BUILDING_AQUEDUCT) < 15;
273
274 city_resource_determine_available();
275 context.type = BUILDING_INFO_TERRAIN;
276 context.figure.drawn = 0;
277 if (!context.building_id && map_sprite_bridge_at(grid_offset) > 0) {
278 if (map_terrain_is(grid_offset, TERRAIN_WATER)) {
279 context.terrain_type = TERRAIN_INFO_BRIDGE;
280 } else {
281 context.terrain_type = TERRAIN_INFO_EMPTY;
282 }
283 } else if (map_property_is_plaza_or_earthquake(grid_offset)) {
284 if (map_terrain_is(grid_offset, TERRAIN_ROAD)) {
285 context.terrain_type = TERRAIN_INFO_PLAZA;
286 }
287 if (map_terrain_is(grid_offset, TERRAIN_ROCK)) {
288 context.terrain_type = TERRAIN_INFO_EARTHQUAKE;
289 }
290 } else if (map_terrain_is(grid_offset, TERRAIN_TREE)) {
291 context.terrain_type = TERRAIN_INFO_TREE;
292 } else if (map_terrain_is(grid_offset, TERRAIN_ROCK)) {
293 if (grid_offset == city_map_entry_flag()->grid_offset) {
294 context.terrain_type = TERRAIN_INFO_ENTRY_FLAG;
295 } else if (grid_offset == city_map_exit_flag()->grid_offset) {
296 context.terrain_type = TERRAIN_INFO_EXIT_FLAG;
297 } else {
298 context.terrain_type = TERRAIN_INFO_ROCK;
299 }
300 } else if ((map_terrain_get(grid_offset) & (TERRAIN_WATER | TERRAIN_BUILDING)) == TERRAIN_WATER) {
301 context.terrain_type = TERRAIN_INFO_WATER;
302 } else if (map_terrain_is(grid_offset, TERRAIN_SHRUB)) {
303 context.terrain_type = TERRAIN_INFO_SHRUB;
304 } else if (map_terrain_is(grid_offset, TERRAIN_GARDEN)) {
305 context.terrain_type = TERRAIN_INFO_GARDEN;
306 } else if ((map_terrain_get(grid_offset) & (TERRAIN_ROAD | TERRAIN_BUILDING)) == TERRAIN_ROAD) {
307 context.terrain_type = TERRAIN_INFO_ROAD;
308 } else if (map_terrain_is(grid_offset, TERRAIN_AQUEDUCT)) {
309 context.terrain_type = TERRAIN_INFO_AQUEDUCT;
310 } else if (map_terrain_is(grid_offset, TERRAIN_RUBBLE)) {
311 context.terrain_type = TERRAIN_INFO_RUBBLE;
312 } else if (map_terrain_is(grid_offset, TERRAIN_WALL)) {
313 context.terrain_type = TERRAIN_INFO_WALL;
314 } else if (!context.building_id) {
315 context.terrain_type = TERRAIN_INFO_EMPTY;
316 } else {
317 building *b = building_get(context.building_id);
318 context.type = BUILDING_INFO_BUILDING;
319 context.worker_percentage = calc_percentage(b->num_workers, model_get_building(b->type)->laborers);
320 highlight_waypoints(b);
321
322 switch (b->type) {
323 case BUILDING_FORT_GROUND:
324 context.building_id = b->prev_part_building_id;
325 // fallthrough
326 case BUILDING_FORT:
327 context.formation_id = b->formation_id;
328 break;
329 case BUILDING_WAREHOUSE_SPACE:
330 case BUILDING_HIPPODROME:
331 b = building_main(b);
332 context.building_id = b->id;
333 break;
334 case BUILDING_BARRACKS:
335 context.barracks_soldiers_requested = formation_legion_recruits_needed();
336 context.barracks_soldiers_requested += building_barracks_has_tower_sentry_request();
337 break;
338 default:
339 if (b->house_size) {
340 context.worst_desirability_building_id = building_house_determine_worst_desirability_building(b);
341 building_house_determine_evolve_text(b, context.worst_desirability_building_id);
342 }
343 break;
344 }
345 context.has_road_access = 0;
346 switch (b->type) {
347 case BUILDING_GRANARY:
348 if (map_has_road_access_granary(b->x, b->y, 0)) {
349 context.has_road_access = 1;
350 }
351 break;
352 case BUILDING_HIPPODROME:
353 if (map_has_road_access_hippodrome_rotation(b->x, b->y, 0, b->subtype.orientation)) {
354 context.has_road_access = 1;
355 }
356 break;
357 case BUILDING_WAREHOUSE:
358 if (map_has_road_access_rotation(b->subtype.orientation, b->x, b->y, 3, 0)) {
359 context.has_road_access = 1;
360 }
361 context.warehouse_space_text = building_warehouse_get_space_info(b);
362 break;
363 case BUILDING_GRAND_TEMPLE_CERES:
364 case BUILDING_GRAND_TEMPLE_NEPTUNE:
365 case BUILDING_GRAND_TEMPLE_MERCURY:
366 case BUILDING_GRAND_TEMPLE_MARS:
367 case BUILDING_GRAND_TEMPLE_VENUS:
368 case BUILDING_PANTHEON:
369 if (map_has_road_access_monument_size7(b->x, b->y, 0)) {
370 context.has_road_access = 1;
371 }
372 break;
373 case BUILDING_COLOSSEUM:
374 if (map_has_road_access_monument_size5(b->x, b->y, 0)) {
375 context.has_road_access = 1;
376 }
377 break;
378 case BUILDING_LIGHTHOUSE:
379 case BUILDING_LARGE_TEMPLE_CERES:
380 case BUILDING_LARGE_TEMPLE_MARS:
381 case BUILDING_LARGE_TEMPLE_MERCURY:
382 case BUILDING_LARGE_TEMPLE_NEPTUNE:
383 case BUILDING_LARGE_TEMPLE_VENUS:
384 if (map_has_road_access_monument_size3(b->x, b->y, 0)) {
385 context.has_road_access = 1;
386 }
387 break;
388 case BUILDING_CARAVANSERAI:
389 if (map_has_road_access_monument_size4(b->x, b->y, 0)) {
390 context.has_road_access = 1;
391 }
392 break;
393 default:
394 if (map_has_road_access(b->x, b->y, b->size, 0)) {
395 context.has_road_access = 1;
396 }
397 break;
398 }
399 }
400 // figures
401 context.figure.selected_index = 0;
402 context.figure.count = 0;
403 for (int i = 0; i < 7; i++) {
404 context.figure.figure_ids[i] = 0;
405 }
406 static const int FIGURE_OFFSETS[] = {
407 OFFSET(0,0), OFFSET(0,-1), OFFSET(0,1), OFFSET(1,0), OFFSET(-1,0),
408 OFFSET(-1,-1), OFFSET(1,-1), OFFSET(-1,1), OFFSET(1,1)
409 };
410 for (int i = 0; i < 9 && context.figure.count < 7; i++) {
411 int figure_id = map_figure_at(grid_offset + FIGURE_OFFSETS[i]);
412 while (figure_id > 0 && context.figure.count < 7) {
413 figure *f = figure_get(figure_id);
414 if (f->state != FIGURE_STATE_DEAD &&
415 f->action_state != FIGURE_ACTION_149_CORPSE) {
416 switch (f->type) {
417 case FIGURE_NONE:
418 case FIGURE_EXPLOSION:
419 case FIGURE_MAP_FLAG:
420 case FIGURE_FLOTSAM:
421 case FIGURE_ARROW:
422 case FIGURE_JAVELIN:
423 case FIGURE_BOLT:
424 case FIGURE_BALLISTA:
425 case FIGURE_CREATURE:
426 case FIGURE_FISH_GULLS:
427 case FIGURE_SPEAR:
428 case FIGURE_HIPPODROME_HORSES:
429 case FIGURE_FRIENDLY_ARROW:
430 case FIGURE_WATCHTOWER_ARCHER:
431 break;
432 default:
433 context.figure.figure_ids[context.figure.count++] = figure_id;
434 figure_phrase_determine(f);
435 break;
436 }
437 }
438 figure_id = f->next_figure_id_on_same_tile;
439 }
440 }
441 // check for legion figures
442 for (int i = 0; i < 7; i++) {
443 int figure_id = context.figure.figure_ids[i];
444 if (figure_id <= 0) {
445 continue;
446 }
447 figure *f = figure_get(figure_id);
448 if (f->type == FIGURE_FORT_STANDARD || figure_is_legion(f)) {
449 context.type = BUILDING_INFO_LEGION;
450 context.formation_id = f->formation_id;
451 const formation *m = formation_get(context.formation_id);
452 if (m->figure_type != FIGURE_FORT_LEGIONARY) {
453 context.formation_types = 5;
454 } else if (m->has_military_training) {
455 context.formation_types = 4;
456 } else {
457 context.formation_types = 3;
458 }
459 break;
460 }
461 }
462 // dialog size
463 context.width_blocks = 29;
464
465 switch (get_height_id()) {
466 case 1: context.height_blocks = 16; break;
467 case 2: context.height_blocks = 18; break;
468 case 3: context.height_blocks = 19; break;
469 case 4: context.height_blocks = 14; break;
470 case 5: context.height_blocks = 24; break;
471 case 6: context.height_blocks = 38; break;
472 case 7: context.height_blocks = 26; break;
473 case 8: context.height_blocks = 40; context.width_blocks = 30; break;
474 case 9: context.height_blocks = 20; break;
475 default: context.height_blocks = 22; break;
476 }
477 if (screen_height() <= 600) {
478 context.height_blocks = calc_bound(context.height_blocks, 0, 26);
479 }
480 // dialog placement
481 int s_width = screen_width();
482 int s_height = screen_height();
483 context.x_offset = center_in_city(BLOCK_SIZE * context.width_blocks);
484 if (s_width >= 1024 && s_height >= 768) {
485 context.x_offset = mouse_get()->x;
486 context.y_offset = mouse_get()->y;
487 window_building_set_possible_position(&context.x_offset, &context.y_offset,
488 context.width_blocks, context.height_blocks);
489 } else if (s_height >= 600 && mouse_get()->y <= (s_height - 24) / 2 + 24) {
490 context.y_offset = s_height - BLOCK_SIZE * context.height_blocks - MARGIN_POSITION;
491 } else {
492 context.y_offset = MIN_Y_POSITION;
493 }
494 }
495
draw_background(void)496 static void draw_background(void)
497 {
498 window_city_draw_panels();
499 window_city_draw();
500 if (context.type == BUILDING_INFO_NONE) {
501 window_building_draw_no_people(&context);
502 } else if (context.type == BUILDING_INFO_TERRAIN) {
503 window_building_draw_terrain(&context);
504 } else if (context.type == BUILDING_INFO_BUILDING) {
505 int btype = building_get(context.building_id)->type;
506 if (building_is_house(btype)) {
507 window_building_draw_house(&context);
508 } else if (btype == BUILDING_WHEAT_FARM) {
509 window_building_draw_wheat_farm(&context);
510 } else if (btype == BUILDING_VEGETABLE_FARM) {
511 window_building_draw_vegetable_farm(&context);
512 } else if (btype == BUILDING_FRUIT_FARM) {
513 window_building_draw_fruit_farm(&context);
514 } else if (btype == BUILDING_OLIVE_FARM) {
515 window_building_draw_olive_farm(&context);
516 } else if (btype == BUILDING_VINES_FARM) {
517 window_building_draw_vines_farm(&context);
518 } else if (btype == BUILDING_PIG_FARM) {
519 window_building_draw_pig_farm(&context);
520 } else if (btype == BUILDING_MARBLE_QUARRY) {
521 window_building_draw_marble_quarry(&context);
522 } else if (btype == BUILDING_IRON_MINE) {
523 window_building_draw_iron_mine(&context);
524 } else if (btype == BUILDING_TIMBER_YARD) {
525 window_building_draw_timber_yard(&context);
526 } else if (btype == BUILDING_CLAY_PIT) {
527 window_building_draw_clay_pit(&context);
528 } else if (btype == BUILDING_WINE_WORKSHOP) {
529 window_building_draw_wine_workshop(&context);
530 } else if (btype == BUILDING_OIL_WORKSHOP) {
531 window_building_draw_oil_workshop(&context);
532 } else if (btype == BUILDING_WEAPONS_WORKSHOP) {
533 window_building_draw_weapons_workshop(&context);
534 } else if (btype == BUILDING_FURNITURE_WORKSHOP) {
535 window_building_draw_furniture_workshop(&context);
536 } else if (btype == BUILDING_POTTERY_WORKSHOP) {
537 window_building_draw_pottery_workshop(&context);
538 } else if (btype == BUILDING_MARKET) {
539 if (context.storage_show_special_orders) {
540 window_building_draw_supplier_orders(&context, translation_for(TR_MARKET_SPECIAL_ORDERS_HEADER));
541 } else {
542 window_building_draw_market(&context);
543 }
544 } else if (btype == BUILDING_MESS_HALL) {
545 if (context.storage_show_special_orders) {
546 window_building_draw_supplier_orders(&context, translation_for(TR_MESS_HALL_SPECIAL_ORDERS_HEADER));
547 } else {
548 window_building_draw_mess_hall(&context);
549 }
550 } else if (btype == BUILDING_GRANARY) {
551 if (context.storage_show_special_orders) {
552 window_building_draw_granary_orders(&context);
553 } else {
554 window_building_draw_granary(&context);
555 }
556 } else if (btype == BUILDING_WAREHOUSE) {
557 if (context.storage_show_special_orders) {
558 window_building_draw_warehouse_orders(&context);
559 } else {
560 window_building_draw_warehouse(&context);
561 }
562 } else if (btype == BUILDING_AMPHITHEATER) {
563 window_building_draw_amphitheater(&context);
564 } else if (btype == BUILDING_THEATER) {
565 window_building_draw_theater(&context);
566 } else if (btype == BUILDING_HIPPODROME) {
567 window_building_draw_hippodrome_background(&context);
568 } else if (btype == BUILDING_COLOSSEUM) {
569 window_building_draw_colosseum_background(&context);
570 } else if (btype == BUILDING_ARENA) {
571 window_building_draw_arena(&context);
572 } else if (btype == BUILDING_GLADIATOR_SCHOOL) {
573 window_building_draw_gladiator_school(&context);
574 } else if (btype == BUILDING_LION_HOUSE) {
575 window_building_draw_lion_house(&context);
576 } else if (btype == BUILDING_ACTOR_COLONY) {
577 window_building_draw_actor_colony(&context);
578 } else if (btype == BUILDING_CHARIOT_MAKER) {
579 window_building_draw_chariot_maker(&context);
580 } else if (btype == BUILDING_DOCTOR) {
581 window_building_draw_clinic(&context);
582 } else if (btype == BUILDING_HOSPITAL) {
583 window_building_draw_hospital(&context);
584 } else if (btype == BUILDING_BATHHOUSE) {
585 window_building_draw_bathhouse(&context);
586 } else if (btype == BUILDING_BARBER) {
587 window_building_draw_barber(&context);
588 } else if (btype == BUILDING_SCHOOL) {
589 window_building_draw_school(&context);
590 } else if (btype == BUILDING_ACADEMY) {
591 window_building_draw_academy(&context);
592 } else if (btype == BUILDING_LIBRARY) {
593 window_building_draw_library(&context);
594 } else if (btype == BUILDING_SMALL_TEMPLE_CERES || btype == BUILDING_LARGE_TEMPLE_CERES) {
595 if (context.storage_show_special_orders) {
596 window_building_draw_supplier_orders(&context, translation_for(TR_TEMPLE_SPECIAL_ORDERS_HEADER));
597 } else {
598 window_building_draw_temple_ceres(&context);
599 }
600 } else if (btype == BUILDING_SMALL_TEMPLE_NEPTUNE || btype == BUILDING_LARGE_TEMPLE_NEPTUNE) {
601 window_building_draw_temple_neptune(&context);
602 } else if (btype == BUILDING_SMALL_TEMPLE_MERCURY || btype == BUILDING_LARGE_TEMPLE_MERCURY) {
603 window_building_draw_temple_mercury(&context);
604 } else if (btype == BUILDING_SMALL_TEMPLE_MARS || btype == BUILDING_LARGE_TEMPLE_MARS) {
605 window_building_draw_temple_mars(&context);
606 } else if (btype == BUILDING_SMALL_TEMPLE_VENUS || btype == BUILDING_LARGE_TEMPLE_VENUS) {
607 if (context.storage_show_special_orders) {
608 window_building_draw_supplier_orders(&context, translation_for(TR_TEMPLE_SPECIAL_ORDERS_HEADER));
609 } else {
610 window_building_draw_temple_venus(&context);
611 }
612 } else if (btype == BUILDING_ORACLE) {
613 window_building_draw_oracle(&context);
614 } else if (btype == BUILDING_LARARIUM) {
615 window_building_draw_lararium(&context);
616 } else if (btype == BUILDING_NYMPHAEUM) {
617 window_building_draw_nymphaeum(&context);
618 } else if (btype == BUILDING_SMALL_MAUSOLEUM) {
619 window_building_draw_small_mausoleum(&context);
620 } else if (btype == BUILDING_LARGE_MAUSOLEUM) {
621 window_building_draw_large_mausoleum(&context);
622 } else if (btype == BUILDING_WORKCAMP) {
623 window_building_draw_work_camp(&context);
624 } else if (btype == BUILDING_ARCHITECT_GUILD) {
625 window_building_draw_architect_guild(&context);
626 } else if (btype == BUILDING_MESS_HALL) {
627 window_building_draw_mess_hall(&context);
628 } else if (btype == BUILDING_TAVERN) {
629 if (context.storage_show_special_orders) {
630 window_building_draw_supplier_orders(&context, translation_for(TR_TAVERN_SPECIAL_ORDERS_HEADER));
631 } else {
632 window_building_draw_tavern(&context);
633 }
634 } else if (btype == BUILDING_GRAND_TEMPLE_CERES) {
635 window_building_draw_grand_temple_ceres(&context);
636 } else if (btype == BUILDING_GRAND_TEMPLE_NEPTUNE) {
637 window_building_draw_grand_temple_neptune(&context);
638 } else if (btype == BUILDING_GRAND_TEMPLE_MERCURY) {
639 window_building_draw_grand_temple_mercury(&context);
640 } else if (btype == BUILDING_GRAND_TEMPLE_MARS) {
641 window_building_draw_grand_temple_mars(&context);
642 } else if (btype == BUILDING_GRAND_TEMPLE_VENUS) {
643 window_building_draw_grand_temple_venus(&context);
644 } else if (btype == BUILDING_PANTHEON) {
645 window_building_draw_pantheon(&context);
646 } else if (btype == BUILDING_LIGHTHOUSE) {
647 window_building_draw_lighthouse(&context);
648 } else if (btype == BUILDING_GOVERNORS_HOUSE || btype == BUILDING_GOVERNORS_VILLA ||
649 btype == BUILDING_GOVERNORS_PALACE) {
650 window_building_draw_governor_home(&context);
651 } else if (btype == BUILDING_FORUM || btype == BUILDING_FORUM_UPGRADED) {
652 window_building_draw_forum(&context);
653 } else if (btype == BUILDING_SENATE || btype == BUILDING_SENATE_UPGRADED) {
654 window_building_draw_senate(&context);
655 } else if (btype == BUILDING_ENGINEERS_POST) {
656 window_building_draw_engineers_post(&context);
657 } else if (btype == BUILDING_SHIPYARD) {
658 window_building_draw_shipyard(&context);
659 } else if (btype == BUILDING_DOCK) {
660 if (context.storage_show_special_orders) {
661 window_building_draw_dock_orders(&context);
662 } else {
663 window_building_draw_dock(&context);
664 }
665 } else if (btype == BUILDING_WHARF) {
666 window_building_draw_wharf(&context);
667 } else if (btype == BUILDING_RESERVOIR) {
668 window_building_draw_reservoir(&context);
669 } else if (btype == BUILDING_FOUNTAIN) {
670 window_building_draw_fountain(&context);
671 } else if (btype == BUILDING_WELL) {
672 window_building_draw_well(&context);
673 } else if (btype == BUILDING_SMALL_STATUE ||
674 btype == BUILDING_MEDIUM_STATUE ||
675 btype == BUILDING_SMALL_STATUE_ALT ||
676 btype == BUILDING_SMALL_STATUE_ALT_B ||
677 btype == BUILDING_LEGION_STATUE ||
678 btype == BUILDING_DECORATIVE_COLUMN ||
679 btype == BUILDING_HORSE_STATUE) {
680 window_building_draw_statue(&context);
681 } else if (btype == BUILDING_LARGE_STATUE) {
682 window_building_draw_large_statue(&context);
683 } else if (btype == BUILDING_SMALL_POND || btype == BUILDING_LARGE_POND) {
684 window_building_draw_pond(&context);
685 } else if ((btype >= BUILDING_PINE_TREE && btype <= BUILDING_PAVILION_GREEN) ||
686 (btype >= BUILDING_HEDGE_DARK && btype <= BUILDING_HEDGE_LIGHT) ||
687 btype == BUILDING_COLONNADE || btype == BUILDING_GARDEN_PATH || btype == BUILDING_GARDEN_WALL ||
688 btype == BUILDING_ROOFED_GARDEN_WALL) {
689 window_building_draw_garden(&context);
690 } else if (btype == BUILDING_TRIUMPHAL_ARCH) {
691 window_building_draw_triumphal_arch(&context);
692 } else if (btype == BUILDING_PREFECTURE) {
693 window_building_draw_prefect(&context);
694 } else if (btype == BUILDING_OBELISK) {
695 window_building_draw_obelisk(&context);
696 } else if (btype == BUILDING_ROADBLOCK) {
697 if (context.storage_show_special_orders) {
698 window_building_draw_roadblock_orders(&context);
699 } else {
700 window_building_draw_roadblock(&context);
701 }
702 } else if (btype == BUILDING_GATEHOUSE) {
703 window_building_draw_gatehouse(&context);
704 } else if (btype == BUILDING_TOWER) {
705 window_building_draw_tower(&context);
706 } else if (btype == BUILDING_MILITARY_ACADEMY) {
707 window_building_draw_military_academy(&context);
708 } else if (btype == BUILDING_BARRACKS) {
709 window_building_draw_barracks(&context);
710 } else if (btype == BUILDING_FORT) {
711 window_building_draw_fort(&context);
712 } else if (btype == BUILDING_BURNING_RUIN) {
713 window_building_draw_burning_ruin(&context);
714 } else if (btype == BUILDING_NATIVE_HUT) {
715 window_building_draw_native_hut(&context);
716 } else if (btype == BUILDING_NATIVE_MEETING) {
717 window_building_draw_native_meeting(&context);
718 } else if (btype == BUILDING_NATIVE_CROPS) {
719 window_building_draw_native_crops(&context);
720 } else if (btype == BUILDING_MISSION_POST) {
721 window_building_draw_mission_post(&context);
722 } else if (btype == BUILDING_WATCHTOWER) {
723 window_building_draw_watchtower(&context);
724 } else if (btype == BUILDING_CARAVANSERAI) {
725 if (context.storage_show_special_orders) {
726 window_building_draw_supplier_orders(&context, translation_for(TR_CARAVANSERAI_SPECIAL_ORDERS_HEADER));
727 } else {
728 window_building_draw_caravanserai(&context);
729 }
730 } else if (btype == BUILDING_GARDEN_WALL_GATE) {
731 if (context.storage_show_special_orders) {
732 window_building_draw_roadblock_orders(&context);
733 } else {
734 window_building_draw_garden_gate(&context);
735 }
736 } else if (btype == BUILDING_PALISADE) {
737 window_building_draw_palisade(&context);
738 }
739 } else if (context.type == BUILDING_INFO_LEGION) {
740 window_building_draw_legion_info(&context);
741 }
742 }
743
draw_foreground(void)744 static void draw_foreground(void)
745 {
746 building *b = building_get(context.building_id);
747 // building-specific buttons
748 if (context.type == BUILDING_INFO_BUILDING) {
749 int btype = building_get(context.building_id)->type;
750
751 if (building_is_primary_product_producer(btype)) {
752 window_building_draw_primary_product_stockpiling(&context);
753 }
754
755 if (btype == BUILDING_LIGHTHOUSE && b->data.monument.phase == MONUMENT_FINISHED) {
756 window_building_draw_lighthouse_foreground(&context);
757 } else if (btype == BUILDING_GRANARY) {
758 if (context.storage_show_special_orders) {
759 window_building_draw_granary_orders_foreground(&context);
760 } else {
761 window_building_draw_granary_foreground(&context);
762 }
763 } else if (btype == BUILDING_WAREHOUSE) {
764 if (context.storage_show_special_orders) {
765 window_building_draw_warehouse_orders_foreground(&context);
766 } else {
767 window_building_draw_warehouse_foreground(&context);
768 }
769 } else if (btype == BUILDING_MARKET) {
770 if (context.storage_show_special_orders) {
771 window_building_draw_supplier_orders_foreground(&context);
772 } else {
773 window_building_supplier_draw_foreground(&context);
774 }
775 } else if (btype == BUILDING_TAVERN) {
776 if (context.storage_show_special_orders) {
777 window_building_draw_supplier_orders_foreground(&context);
778 } else {
779 window_building_supplier_draw_foreground(&context);
780 }
781 } else if (btype == BUILDING_MESS_HALL) {
782 if (context.storage_show_special_orders) {
783 window_building_draw_supplier_orders_foreground(&context);
784 } else {
785 window_building_supplier_draw_foreground(&context);
786 }
787 } else if (building_is_venus_temple(btype) && b->data.monument.phase <= 0 &&
788 building_monument_gt_module_is_active(VENUS_MODULE_1_DISTRIBUTE_WINE)) {
789 if (context.storage_show_special_orders) {
790 window_building_draw_supplier_orders_foreground(&context);
791 } else {
792 window_building_supplier_draw_foreground(&context);
793 }
794 } else if (building_is_ceres_temple(btype) && b->data.monument.phase <= 0 &&
795 building_monument_gt_module_is_active(CERES_MODULE_2_DISTRIBUTE_FOOD)) {
796 if (context.storage_show_special_orders) {
797 window_building_draw_supplier_orders_foreground(&context);
798 } else {
799 window_building_supplier_draw_foreground(&context);
800 }
801 } else if (btype == BUILDING_ROADBLOCK) {
802 if (context.storage_show_special_orders) {
803 window_building_draw_roadblock_orders_foreground(&context);
804 } else {
805 window_building_draw_roadblock_foreground(&context);
806 }
807 } else if (btype == BUILDING_DOCK) {
808 if (context.storage_show_special_orders) {
809 window_building_draw_dock_orders_foreground(&context);
810 } else {
811 window_building_draw_dock_foreground(&context);
812 }
813 } else if (btype == BUILDING_BARRACKS) {
814 window_building_draw_barracks_foreground(&context);
815 } else if ((btype >= BUILDING_GRAND_TEMPLE_CERES && btype <= BUILDING_GRAND_TEMPLE_VENUS) ||
816 btype == BUILDING_PANTHEON) {
817 window_building_draw_grand_temple_foreground(&context);
818 } else if (btype == BUILDING_CARAVANSERAI &&
819 b->data.monument.phase == MONUMENT_FINISHED) {
820 if (context.storage_show_special_orders) {
821 window_building_draw_supplier_orders_foreground(&context);
822 } else {
823 window_building_supplier_draw_foreground(&context);
824 window_building_draw_caravanserai_foreground(&context);
825 }
826 } else if (btype == BUILDING_COLOSSEUM) {
827 window_building_draw_colosseum_foreground(&context);
828 } else if (btype == BUILDING_HIPPODROME) {
829 window_building_draw_hippodrome_foreground(&context);
830 } else if (btype == BUILDING_GARDEN_WALL_GATE) {
831 if (context.storage_show_special_orders) {
832 window_building_draw_roadblock_orders_foreground(&context);
833 } else {
834 window_building_draw_garden_gate_foreground(&context);
835 }
836 }
837
838 if (building_monument_is_unfinished_monument(b)) {
839 draw_halt_monument_construction_button(context.x_offset + 80,
840 context.y_offset + 3 + BLOCK_SIZE * context.height_blocks - 40,
841 focus_monument_construction_button_id, b);
842 }
843 } else if (context.type == BUILDING_INFO_LEGION) {
844 window_building_draw_legion_info_foreground(&context);
845 }
846 // general buttons
847 if (context.storage_show_special_orders) {
848 int y_offset = window_building_get_vertical_offset(&context, 28);
849 image_buttons_draw(context.x_offset, y_offset + 400, image_buttons_help_close, 2);
850 } else {
851 image_buttons_draw(context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
852 image_buttons_help_close, 2);
853 }
854 if (context.can_go_to_advisor) {
855 image_buttons_draw(context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
856 image_buttons_advisor, 1);
857 }
858 if (!context.storage_show_special_orders && !building_monument_is_unfinished_monument(b)) {
859 int workers_needed = model_get_building(building_get(context.building_id)->type)->laborers;
860 if (workers_needed) {
861 draw_mothball_button(context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40);
862 }
863 }
864 }
865
handle_specific_building_info_mouse(const mouse * m)866 static int handle_specific_building_info_mouse(const mouse *m)
867 {
868 // building-specific buttons
869 if (context.type == BUILDING_INFO_NONE) {
870 return 0;
871 }
872
873 if (context.type == BUILDING_INFO_LEGION) {
874 return window_building_handle_mouse_legion_info(m, &context);
875 } else if (context.figure.drawn) {
876 return window_building_handle_mouse_figure_list(m, &context);
877 } else if (context.type == BUILDING_INFO_BUILDING) {
878 int btype = building_get(context.building_id)->type;
879
880 if (building_has_supplier_inventory(btype)) {
881 if (context.storage_show_special_orders) {
882 window_building_handle_mouse_supplier_orders(m, &context);
883 } else {
884 if (btype == BUILDING_CARAVANSERAI) {
885 window_building_handle_mouse_caravanserai(m, &context);
886 }
887 window_building_handle_mouse_supplier(m, &context);
888 }
889 } else if (btype == BUILDING_ROADBLOCK) {
890 if (context.storage_show_special_orders) {
891 return window_building_handle_mouse_roadblock_orders(m, &context);
892 } else {
893 return window_building_handle_mouse_roadblock(m, &context);
894 }
895 } else if (btype == BUILDING_DOCK) {
896 if (context.storage_show_special_orders) {
897 return window_building_handle_mouse_dock_orders(m, &context);
898 } else {
899 return window_building_handle_mouse_dock(m, &context);
900 }
901 } else if (btype == BUILDING_BARRACKS) {
902 return window_building_handle_mouse_barracks(m, &context);
903 } else if (btype == BUILDING_GRAND_TEMPLE_MARS) {
904 window_building_handle_mouse_grand_temple_mars(m, &context);
905 } else if (btype == BUILDING_GRANARY) {
906 if (context.storage_show_special_orders) {
907 return window_building_handle_mouse_granary_orders(m, &context);
908 } else {
909 return window_building_handle_mouse_granary(m, &context);
910 }
911 } else if (btype == BUILDING_WAREHOUSE) {
912 if (context.storage_show_special_orders) {
913 window_building_handle_mouse_warehouse_orders(m, &context);
914 } else {
915 window_building_handle_mouse_warehouse(m, &context);
916 }
917 } else if ((btype >= BUILDING_GRAND_TEMPLE_CERES && btype <= BUILDING_GRAND_TEMPLE_VENUS) || btype == BUILDING_PANTHEON) {
918 window_building_handle_mouse_grand_temple(m, &context);
919 } else if (btype == BUILDING_LIGHTHOUSE) {
920 window_building_handle_mouse_lighthouse(m, &context);
921 } else if (btype == BUILDING_COLOSSEUM) {
922 window_building_handle_mouse_colosseum(m, &context);
923 } else if (btype == BUILDING_HIPPODROME) {
924 window_building_handle_mouse_hippodrome(m, &context);
925 } else if (btype == BUILDING_GARDEN_WALL_GATE) {
926 if (context.storage_show_special_orders) {
927 return window_building_handle_mouse_roadblock_orders(m, &context);
928 } else {
929 return window_building_handle_mouse_garden_gate(m, &context);
930 }
931 } else if (building_is_primary_product_producer(btype)) {
932 window_building_handle_mouse_primary_product_producer(m, &context);
933 }
934 }
935 return 0;
936 }
937
handle_input(const mouse * m,const hotkeys * h)938 static void handle_input(const mouse *m, const hotkeys *h)
939 {
940 int handled = 0;
941 // general buttons
942 if (context.storage_show_special_orders) {
943 int y_offset = window_building_get_vertical_offset(&context, 28);
944 handled |= image_buttons_handle_mouse(m, context.x_offset, y_offset + 400,
945 image_buttons_help_close, 2, &focus_image_button_id);
946 } else {
947 handled |= image_buttons_handle_mouse(
948 m, context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
949 image_buttons_help_close, 2, &focus_image_button_id);
950 building *b = building_get(context.building_id);
951 if (building_monument_is_unfinished_monument(b)) {
952 handled = generic_buttons_handle_mouse(
953 m, context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
954 generic_button_monument_construction, 1, &focus_monument_construction_button_id);
955 } else {
956 if (b->state == BUILDING_STATE_MOTHBALLED) {
957 handled |= image_buttons_handle_mouse(m, context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
958 image_button_mothball, 2, &focus_mothball_image_button_id);
959 } else {
960 handled |= image_buttons_handle_mouse(m, context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
961 image_button_mothball, 1, &focus_mothball_image_button_id);
962 }
963 }
964 }
965 if (context.can_go_to_advisor) {
966 handled |= image_buttons_handle_mouse(
967 m, context.x_offset, context.y_offset + BLOCK_SIZE * context.height_blocks - 40,
968 image_buttons_advisor, 1, 0);
969 }
970
971 if (!handled) {
972 handled |= handle_specific_building_info_mouse(m);
973 }
974 if (!handled && input_go_back_requested(m, h)) {
975 window_city_show();
976 }
977 }
978
get_tooltip(tooltip_context * c)979 static void get_tooltip(tooltip_context *c)
980 {
981 int text_id = 0, group_id = 0, translation = 0;
982 building *b = building_get(context.building_id);
983 int btype = b->type;
984 if (focus_image_button_id) {
985 text_id = focus_image_button_id;
986 } else if (focus_mothball_image_button_id) {
987 if (!building_monument_is_unfinished_monument(b)) {
988 if (building_get(context.building_id)->state == BUILDING_STATE_MOTHBALLED) {
989 translation = TR_TOOLTIP_BUTTON_MOTHBALL_OFF;
990 } else {
991 translation = TR_TOOLTIP_BUTTON_MOTHBALL_ON;
992 }
993 }
994 } else if (building_is_primary_product_producer(btype)) {
995 window_building_primary_product_producer_stockpiling_tooltip(&translation);
996 } else if (context.type == BUILDING_INFO_LEGION) {
997 text_id = window_building_get_legion_info_tooltip_text(&context);
998 } else if (context.type == BUILDING_INFO_BUILDING && context.storage_show_special_orders) {
999 if (btype == BUILDING_GRANARY) {
1000 window_building_get_tooltip_granary_orders(&group_id, &text_id, &translation);
1001 } else if (btype == BUILDING_WAREHOUSE) {
1002 window_building_get_tooltip_warehouse_orders(&group_id, &text_id, &translation);
1003 } else if (btype == BUILDING_ROADBLOCK || btype == BUILDING_GARDEN_WALL_GATE) {
1004 window_building_roadblock_get_tooltip_walker_permissions(&translation);
1005 }
1006 } else if (btype == BUILDING_GRANARY) {
1007 window_building_granary_get_tooltip_distribution_permissions(&translation);
1008 } else if (btype == BUILDING_WAREHOUSE) {
1009 window_building_warehouse_get_tooltip_distribution_permissions(&translation);
1010 }
1011 if (text_id || group_id || translation) {
1012 c->type = TOOLTIP_BUTTON;
1013 c->text_id = text_id;
1014 c->translation_key = translation;
1015 if (group_id) {
1016 c->text_group = group_id;
1017 }
1018 }
1019 }
1020
button_help(int param1,int param2)1021 static void button_help(int param1, int param2)
1022 {
1023 if (context.help_id > 0) {
1024 window_message_dialog_show(context.help_id, window_city_draw_all);
1025 } else {
1026 window_message_dialog_show(MESSAGE_DIALOG_HELP, window_city_draw_all);
1027 }
1028 window_invalidate();
1029 }
1030
button_close(int param1,int param2)1031 static void button_close(int param1, int param2)
1032 {
1033 if (context.storage_show_special_orders) {
1034 context.storage_show_special_orders = 0;
1035 window_invalidate();
1036 } else {
1037 window_city_show();
1038 }
1039 }
1040
button_advisor(int advisor,int param2)1041 static void button_advisor(int advisor, int param2)
1042 {
1043 window_advisors_show_advisor(advisor);
1044 }
1045
button_mothball(int mothball,int param2)1046 static void button_mothball(int mothball, int param2)
1047 {
1048 building *b = building_get(context.building_id);
1049 int workers_needed = model_get_building(b->type)->laborers;
1050 if (workers_needed) {
1051 building_mothball_toggle(b);
1052 window_invalidate();
1053 }
1054 }
1055
button_monument_construction(int param1,int param2)1056 static void button_monument_construction(int param1, int param2)
1057 {
1058 building *b = building_get(context.building_id);
1059 building_monument_toggle_construction_halted(b);
1060 window_invalidate();
1061 }
1062
window_building_info_show(int grid_offset)1063 void window_building_info_show(int grid_offset)
1064 {
1065 window_type window = {
1066 WINDOW_BUILDING_INFO,
1067 draw_background,
1068 draw_foreground,
1069 handle_input,
1070 get_tooltip
1071 };
1072 init(grid_offset);
1073 window_show(&window);
1074 }
1075
window_building_info_get_building_type(void)1076 int window_building_info_get_building_type(void)
1077 {
1078 if (context.type == BUILDING_INFO_BUILDING) {
1079 return building_get(context.building_id)->type;
1080 }
1081 return BUILDING_NONE;
1082 }
1083
window_building_info_show_storage_orders(void)1084 void window_building_info_show_storage_orders(void)
1085 {
1086 context.storage_show_special_orders = 1;
1087 window_invalidate();
1088 }
1089