|
2 | 2 |
|
3 | 3 | #include "city/labor.h"
|
4 | 4 | #include "grid/water.h"
|
| 5 | +#include "grid/image.h" |
5 | 6 | #include "grid/building.h"
|
6 | 7 | #include "grid/building_tiles.h"
|
7 | 8 | #include "grid/routing/routing.h"
|
8 | 9 | #include "graphics/elements/ui.h"
|
9 | 10 |
|
10 | 11 | #include "io/gamefiles/lang.h"
|
11 | 12 |
|
12 |
| -#include "js/js_game.h" |
13 |
| - |
14 | 13 | buildings::model_t<building_ferry> ferry_m;
|
15 |
| - |
16 |
| -ANK_REGISTER_CONFIG_ITERATOR(config_load_building_ferry); |
17 |
| -void config_load_building_ferry() { |
18 |
| - ferry_m.load(); |
19 |
| -} |
| 14 | +info_window_ferry ferry_infow; |
20 | 15 |
|
21 | 16 | void building_ferry::on_create(int orientation) {
|
22 | 17 | data.industry.orientation = orientation;
|
23 | 18 | }
|
24 | 19 |
|
25 | 20 | void building_ferry::on_place_update_tiles(int orientation, int variant) {
|
26 |
| - int img_id = ferry_m.anim["base"].first_img() + orientation; |
27 |
| - map_water_add_building(id(), tile(), ferry_m.building_size, img_id); |
28 |
| - map_building_tiles_add(id(), tile(), ferry_m.building_size, img_id, TERRAIN_BUILDING|TERRAIN_ROAD|TERRAIN_FERRY_ROUTE); |
| 21 | + int img_id = ferry_m.anim[animkeys().base].first_img() + orientation; |
| 22 | + map_water_add_building(id(), tile(), size(), img_id); |
| 23 | + map_building_tiles_add(id(), tile(), size(), img_id, TERRAIN_BUILDING|TERRAIN_ROAD|TERRAIN_FERRY_ROUTE); |
29 | 24 | }
|
30 | 25 |
|
31 |
| -void building_ferry::window_info_background(object_info &c) { |
32 |
| - c.help_id = 85; |
33 |
| - window_building_play_sound(&c, "Wavs/gatehouse.wav"); |
34 |
| - outer_panel_draw(c.offset, c.bgsize.x, c.bgsize.y); |
35 |
| - lang_text_draw_centered(e_text_ferry_landing, 0, c.offset.x, c.offset.y + 10, 16 * c.bgsize.x, FONT_LARGE_BLACK_ON_LIGHT); |
36 |
| - building *ferry = building_get(c.building_id); |
37 |
| - if (!map_routing_ferry_has_routes(ferry)) { |
38 |
| - window_building_draw_description_at(c, 16 * c.bgsize.y - 158, e_text_ferry_landing, e_text_ferry_landing_no_routes); |
39 |
| - } else if (!ferry->has_road_access) { |
40 |
| - window_building_draw_description_at(c, 16 * c.bgsize.y - 158, e_text_ferry_landing, e_text_ferry_landing_no_roads); |
41 |
| - } else if (ferry->num_workers <= 0) { |
42 |
| - window_building_draw_description_at(c, 16 * c.bgsize.y - 158, e_text_ferry_landing, e_text_ferry_landing_no_workers); |
| 26 | +void building_ferry::update_map_orientation(int orientation) { |
| 27 | + int image_offset = city_view_relative_orientation(data.industry.orientation); |
| 28 | + int image_id = ferry_m.anim[animkeys().base].first_img() + image_offset; |
| 29 | + map_water_add_building(id(), tile(), size(), image_id); |
| 30 | +} |
| 31 | + |
| 32 | +bool building_ferry::force_draw_height_tile(painter &ctx, tile2i t, vec2i pixel, color mask) { |
| 33 | + if (this->main()->tile() == t) { |
| 34 | + int image_id = map_image_at(t); |
| 35 | + ImageDraw::isometric_from_drawtile_top(ctx, image_id, pixel + vec2i{-30, 15}, mask); |
| 36 | + |
| 37 | + return true; |
43 | 38 | }
|
| 39 | + |
| 40 | + return false; |
44 | 41 | }
|
45 | 42 |
|
46 |
| -void building_ferry::update_map_orientation(int orientation) { |
47 |
| - int image_offset = city_view_relative_orientation(data.industry.orientation); |
48 |
| - int image_id = ferry_m.anim["base"].first_img() + image_offset; |
49 |
| - map_water_add_building(id(), tile(), ferry_m.building_size, image_id); |
| 43 | +bool building_ferry::force_draw_top_tile(painter &ctx, tile2i t, vec2i pixel, color mask) { |
| 44 | + if (this->main()->tile() == t) { |
| 45 | + return true; |
| 46 | + } |
| 47 | + |
| 48 | + return false; |
50 | 49 | }
|
51 | 50 |
|
| 51 | + |
52 | 52 | void building_ferry::highlight_waypoints() {
|
53 | 53 | building_impl::highlight_waypoints();
|
54 | 54 |
|
55 | 55 | ferry_tiles fpoints = map_water_docking_points(base);
|
56 | 56 | map_highlight_set(fpoints.point_a, 3);
|
57 | 57 | map_highlight_set(fpoints.point_b, 3);
|
58 | 58 | }
|
| 59 | + |
| 60 | + |
| 61 | +bool info_window_ferry::check(object_info &c) { |
| 62 | + return c.building_get()->dcast_ferry(); |
| 63 | +} |
| 64 | + |
| 65 | +void info_window_ferry::init(object_info &c) { |
| 66 | + building_info_window::init(c); |
| 67 | + |
| 68 | + building *ferry = c.building_get(); |
| 69 | + |
| 70 | + textid reason{ 0, 0 }; |
| 71 | + if (!map_routing_ferry_has_routes(ferry)) { |
| 72 | + reason = { c.group_id, 1 }; |
| 73 | + } else if (!ferry->has_road_access) { |
| 74 | + reason = { c.group_id, 2 }; |
| 75 | + } else if (ferry->num_workers <= 0) { |
| 76 | + reason = { c.group_id, 3 }; |
| 77 | + } |
| 78 | + |
| 79 | + fill_employment_details(c); |
| 80 | + |
| 81 | + if (reason.id) { |
| 82 | + ui["warning_text"] = reason; |
| 83 | + } |
| 84 | +} |
0 commit comments