@@ -55,6 +55,63 @@ struct mastaba_part {
55
55
building *b;
56
56
};
57
57
58
+ template <typename T>
59
+ void building_mastaba::static_params_t <T>::planer_setup_preview_graphics(build_planner &planer) const {
60
+ switch (city_view_orientation () / 2 ) {
61
+ case 0 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
62
+ case 1 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
63
+ case 2 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
64
+ case 3 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
65
+ }
66
+ }
67
+
68
+ template <class T >
69
+ void building_mastaba::static_params_t <T>::planer_ghost_preview(build_planner &planer, painter &ctx, tile2i start, tile2i end, vec2i pixel) const {
70
+ int image_id = anim[animkeys ().base ].first_img ();
71
+ auto get_image = [image_id] (tile2i tile, tile2i start, vec2i size) {
72
+ if (tile == start) {
73
+ return image_id;
74
+ }
75
+
76
+ if (tile == start.shifted (size.x - 1 , 0 )) {
77
+ return image_id - 2 ;
78
+ }
79
+
80
+ if (tile == start.shifted (size.x - 1 , size.y - 1 )) {
81
+ return image_id - 4 ;
82
+ }
83
+
84
+ if (tile == start.shifted (0 , size.y - 1 )) {
85
+ return image_id - 6 ;
86
+ }
87
+
88
+ if (tile.y () == start.y ()) { return image_id - 1 ; }
89
+ if (tile.y () == start.y () + size.y - 1 ) { return image_id - 5 ; }
90
+ if (tile.x () == start.x ()) { return image_id - 7 ; }
91
+ if (tile.x () == start.x () + size.x - 1 ) { return image_id - 3 ; }
92
+
93
+ return (image_id + 5 + (tile.x () + tile.y ()) % 7 );
94
+ };
95
+
96
+ vec2i size{ 1 , 1 };
97
+ vec2i size_b = init_tiles_size ();
98
+ switch (city_view_orientation () / 2 ) {
99
+ case 0 : size = { size_b.x , size_b.y }; break ;
100
+ case 1 : size = { size_b.y , size_b.x }; break ;
101
+ case 2 : size = { size_b.x , size_b.y }; break ;
102
+ case 3 : size = { size_b.y , size_b.x }; break ;
103
+ }
104
+
105
+ for (int i = 0 ; i < size.x ; ++i) {
106
+ for (int j = 0 ; j < size.y ; ++j) {
107
+ vec2i p = pixel + (vec2i (-30 , 15 ) * i) + (vec2i (30 , 15 ) * j);
108
+ int image_id = get_image (end.shifted (i, j), end, size);
109
+ ImageDraw::isometric_from_drawtile (ctx, image_id, p, COLOR_MASK_GREEN);
110
+ ImageDraw::isometric_from_drawtile_top (ctx, image_id, p, COLOR_MASK_GREEN, 1 .f );
111
+ }
112
+ }
113
+ }
114
+
58
115
void map_mastaba_tiles_add (int building_id, tile2i tile, int size, int image_id, int terrain) {
59
116
int x_leftmost, y_leftmost;
60
117
switch (city_view_orientation ()) {
@@ -147,28 +204,11 @@ void building_small_mastaba::update_day() {
147
204
return ;
148
205
}
149
206
150
- building_mastaba::update_day (init_tiles_size ());
207
+ building_mastaba::update_day (current_params (). init_tiles_size ());
151
208
}
152
209
153
210
bool building_small_mastaba::draw_ornaments_and_animations_flat (painter &ctx, vec2i point, tile2i tile, color mask) {
154
- return draw_ornaments_and_animations_flat_impl (base, ctx, point, tile, mask, init_tiles_size ());
155
- }
156
-
157
- void building_small_mastaba::ghost_preview (painter &ctx, e_building_type type, vec2i pixel, tile2i start, tile2i end) {
158
- building_mastaba::ghost_preview (ctx, type, pixel, start, end, init_tiles_size ());
159
- }
160
-
161
- vec2i building_small_mastaba::init_tiles_size () {
162
- return vec2i (10 , 4 );
163
- }
164
-
165
- void building_small_mastaba::static_params::planer_setup_preview_graphics (build_planner &planer) const {
166
- switch (city_view_orientation () / 2 ) {
167
- case 0 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
168
- case 1 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
169
- case 2 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
170
- case 3 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
171
- }
211
+ return draw_ornaments_and_animations_flat_impl (base, ctx, point, tile, mask, current_params ().init_tiles_size ());
172
212
}
173
213
174
214
int building_mastaba::get_image (int orientation, tile2i tile, tile2i start, tile2i end) {
@@ -237,51 +277,6 @@ int building_small_mastabe_get_bricks_image(int orientation, e_building_type typ
237
277
void building_mastaba::on_create (int orientation) {
238
278
}
239
279
240
- void building_mastaba::ghost_preview (painter &ctx, e_building_type type, vec2i pixel, tile2i start, tile2i end, const vec2i size_b) {
241
- int image_id = small_mastaba_m.anim [animkeys ().base ].first_img ();
242
- auto get_image = [image_id] (tile2i tile, tile2i start, vec2i size) {
243
- if (tile == start) {
244
- return image_id;
245
- }
246
-
247
- if (tile == start.shifted (size.x - 1 , 0 )) {
248
- return image_id - 2 ;
249
- }
250
-
251
- if (tile == start.shifted (size.x - 1 , size.y - 1 )) {
252
- return image_id - 4 ;
253
- }
254
-
255
- if (tile == start.shifted (0 , size.y - 1 )) {
256
- return image_id - 6 ;
257
- }
258
-
259
- if (tile.y () == start.y ()) { return image_id - 1 ; }
260
- if (tile.y () == start.y () + size.y - 1 ) { return image_id - 5 ; }
261
- if (tile.x () == start.x ()) { return image_id - 7 ; }
262
- if (tile.x () == start.x () + size.x - 1 ) { return image_id - 3 ; }
263
-
264
- return (image_id + 5 + (tile.x () + tile.y ()) % 7 );
265
- };
266
-
267
- vec2i size{ 1 , 1 };
268
- switch (city_view_orientation () / 2 ) {
269
- case 0 : size = { size_b.x , size_b.y }; break ;
270
- case 1 : size = { size_b.y , size_b.x }; break ;
271
- case 2 : size = { size_b.x , size_b.y }; break ;
272
- case 3 : size = { size_b.y , size_b.x }; break ;
273
- }
274
-
275
- for (int i = 0 ; i < size.x ; ++i) {
276
- for (int j = 0 ; j < size.y ; ++j) {
277
- vec2i p = pixel + (vec2i (-30 , 15 ) * i) + (vec2i (30 , 15 ) * j);
278
- int image_id = get_image (end.shifted (i, j), end, size);
279
- ImageDraw::isometric_from_drawtile (ctx, image_id, p, COLOR_MASK_GREEN);
280
- ImageDraw::isometric_from_drawtile_top (ctx, image_id, p, COLOR_MASK_GREEN, 1 .f );
281
- }
282
- }
283
- }
284
-
285
280
bool building_mastaba::draw_ornaments_and_animations_flat_impl (building &base, painter &ctx, vec2i point, tile2i tile, color color_mask, const vec2i tiles_size) {
286
281
if (building_monument_is_finished (&base)) {
287
282
return false ;
@@ -630,7 +625,7 @@ bool building_small_mastaba::draw_ornaments_and_animations_height(painter &ctx,
630
625
return false ;
631
626
}
632
627
633
- return draw_ornaments_and_animations_hight_impl (base, ctx, point, tile, color_mask, init_tiles_size ());
628
+ return draw_ornaments_and_animations_hight_impl (base, ctx, point, tile, color_mask, current_params (). init_tiles_size ());
634
629
}
635
630
636
631
void game_cheat_finish_phase (std::istream &, std::ostream &) {
@@ -655,16 +650,8 @@ void game_cheat_finish_phase(std::istream &, std::ostream &) {
655
650
});
656
651
}
657
652
658
- void building_medium_mastaba::ghost_preview (painter &ctx, e_building_type type, vec2i pixel, tile2i start, tile2i end) {
659
- building_mastaba::ghost_preview (ctx, type, pixel, start, end, vec2i{ 14 , 6 });
660
- }
661
-
662
- vec2i building_medium_mastaba::init_tiles_size () {
663
- return vec2i (14 , 6 );
664
- }
665
-
666
653
bool building_medium_mastaba::draw_ornaments_and_animations_flat (painter &ctx, vec2i point, tile2i tile, color mask) {
667
- return draw_ornaments_and_animations_flat_impl (base, ctx, point, tile, mask, init_tiles_size ());
654
+ return draw_ornaments_and_animations_flat_impl (base, ctx, point, tile, mask, current_params (). init_tiles_size ());
668
655
}
669
656
670
657
bool building_medium_mastaba::draw_ornaments_and_animations_height (painter &ctx, vec2i point, tile2i tile, color color_mask) {
@@ -676,7 +663,7 @@ bool building_medium_mastaba::draw_ornaments_and_animations_height(painter &ctx,
676
663
return false ;
677
664
}
678
665
679
- return draw_ornaments_and_animations_hight_impl (base, ctx, point, tile, color_mask, init_tiles_size ());
666
+ return draw_ornaments_and_animations_hight_impl (base, ctx, point, tile, color_mask, current_params (). init_tiles_size ());
680
667
}
681
668
682
669
void building_medium_mastaba::on_place (int orientation, int variant) {
@@ -767,14 +754,5 @@ void building_medium_mastaba::update_day() {
767
754
return ;
768
755
}
769
756
770
- building_mastaba::update_day (init_tiles_size ());
771
- }
772
-
773
- void building_medium_mastaba::static_params::planer_setup_preview_graphics (build_planner &planer) const {
774
- switch (city_view_orientation () / 2 ) {
775
- case 0 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
776
- case 1 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
777
- case 2 : planer.init_tiles (init_tiles_size ().y , init_tiles_size ().x ); break ;
778
- case 3 : planer.init_tiles (init_tiles_size ().x , init_tiles_size ().y ); break ;
779
- }
757
+ building_mastaba::update_day (current_params ().init_tiles_size ());
780
758
}
0 commit comments