14#ifndef FC__MAPVIEW_COMMON_H
15#define FC__MAPVIEW_COMMON_H
97#define gui_rect_iterate(GRI_x0, GRI_y0, GRI_width, GRI_height, \
100 int _x_##_0 = (GRI_x0), _y_##_0 = (GRI_y0); \
101 int _x_##_w = (GRI_width), _y_##_h = (GRI_height); \
104 _x_##_0 += _x_##_w; \
105 _x_##_w = -_x_##_w; \
108 _y_##_0 += _y_##_h; \
109 _y_##_h = -_y_##_h; \
111 if (_x_##_w > 0 && _y_##_h > 0) { \
112 struct tile_edge _t##_e; \
113 struct tile_corner _t##_c; \
114 int _t##_xi, _t##_yi, _t##_si, _t##_di; \
115 const int _t##_r1 = (tileset_is_isometric(tileset) ? 2 : 1); \
116 const int _t##_r2 = _t##_r1 * 2; \
117 const int _t##_w = tileset_tile_width(tileset) * _zoom; \
118 const int _t##_h = tileset_tile_height(tileset) * _zoom; \
120 const int _t##_x0 = DIVIDE(_x_##_0 * _t##_r2, _t##_w) - _t##_r1 / 2;\
121 const int _t##_y0 = DIVIDE(_y_##_0 * _t##_r2, _t##_h) - _t##_r1 / 2;\
122 const int _t##_x1 = DIVIDE((_x_##_0 + _x_##_w) * _t##_r2 + _t##_w - 1,\
124 const int _t##_y1 = DIVIDE((_y_##_0 + _y_##_h) * _t##_r2 + _t##_h - 1,\
126 const int _t##_count = (_t##_x1 - _t##_x0) * (_t##_y1 - _t##_y0); \
127 int _t##_index = 0; \
129 log_debug("Iterating over %d-%d x %d-%d rectangle.", \
130 _t##_x1, _t##_x0, _t##_y1, _t##_y0); \
131 for (; _t##_index < _t##_count; _t##_index++) { \
132 struct tile *_t = NULL; \
133 struct tile_edge *_e = NULL; \
134 struct tile_corner *_c = NULL; \
136 _t##_xi = _t##_x0 + (_t##_index % (_t##_x1 - _t##_x0)); \
137 _t##_yi = _t##_y0 + (_t##_index / (_t##_x1 - _t##_x0)); \
138 _t##_si = _t##_xi + _t##_yi; \
139 _t##_di = _t##_yi - _t##_xi; \
140 if (2 == _t##_r1 ) { \
141 if ((_t##_xi + _t##_yi) % 2 != 0) { \
144 if (_t##_xi % 2 == 0 && _t##_yi % 2 == 0) { \
145 if ((_t##_xi + _t##_yi) % 4 == 0) { \
147 _t = map_pos_to_tile(&(wld.map), _t##_si / 4 - 1, _t##_di / 4); \
151 _c->tile[0] = map_pos_to_tile(&(wld.map), (_t##_si - 6) / 4, \
152 (_t##_di - 2) / 4); \
153 _c->tile[1] = map_pos_to_tile(&(wld.map), (_t##_si - 2) / 4, \
154 (_t##_di - 2) / 4); \
155 _c->tile[2] = map_pos_to_tile(&(wld.map), (_t##_si - 2) / 4, \
156 (_t##_di + 2) / 4); \
157 _c->tile[3] = map_pos_to_tile(&(wld.map), (_t##_si - 6) / 4, \
158 (_t##_di + 2) / 4); \
159 if (tileset_hex_width(tileset) > 0) { \
161 _e->type = EDGE_UD; \
162 _e->tile[0] = _c->tile[0]; \
163 _e->tile[1] = _c->tile[2]; \
164 } else if (tileset_hex_height(tileset) > 0) { \
166 _e->type = EDGE_LR; \
167 _e->tile[0] = _c->tile[1]; \
168 _e->tile[1] = _c->tile[3]; \
174 if (_t##_si % 4 == 0) { \
175 _e->type = EDGE_NS; \
176 _e->tile[0] = map_pos_to_tile(&(wld.map), (_t##_si - 4) / 4, \
177 (_t##_di - 2) / 4); \
178 _e->tile[1] = map_pos_to_tile(&(wld.map), (_t##_si - 4) / 4, \
179 (_t##_di + 2) / 4); \
181 _e->type = EDGE_WE; \
182 _e->tile[0] = map_pos_to_tile(&(wld.map), (_t##_si - 6) / 4, \
184 _e->tile[1] = map_pos_to_tile(&(wld.map), (_t##_si - 2) / 4, \
189 if (_t##_si % 2 == 0) { \
190 if (_t##_xi % 2 == 0) { \
193 _c->tile[0] = map_pos_to_tile(&(wld.map), _t##_xi / 2 - 1, \
195 _c->tile[1] = map_pos_to_tile(&(wld.map), _t##_xi / 2, \
197 _c->tile[2] = map_pos_to_tile(&(wld.map), _t##_xi / 2, \
199 _c->tile[3] = map_pos_to_tile(&(wld.map), _t##_xi / 2 - 1, \
203 _t = map_pos_to_tile(&(wld.map), (_t##_xi - 1) / 2, \
204 (_t##_yi - 1) / 2); \
209 if (_t##_yi % 2 == 0) { \
210 _e->type = EDGE_NS; \
211 _e->tile[0] = map_pos_to_tile(&(wld.map), (_t##_xi - 1) / 2, \
213 _e->tile[1] = map_pos_to_tile(&(wld.map), (_t##_xi - 1) / 2, \
216 _e->type = EDGE_WE; \
217 _e->tile[0] = map_pos_to_tile(&(wld.map), _t##_xi / 2 - 1, \
218 (_t##_yi - 1) / 2); \
219 _e->tile[1] = map_pos_to_tile(&(wld.map), _t##_xi / 2, \
220 (_t##_yi - 1) / 2); \
225#define gui_rect_iterate_end \
230#define gui_rect_iterate_coord(GRI_x0, GRI_y0, GRI_width, GRI_height, \
231 _t, _e, _c, _x, _y, _zoom) \
232 gui_rect_iterate(GRI_x0, GRI_y0, GRI_width, GRI_height, \
233 _t, _e, _c, _zoom) { \
236 _x = _t##_xi * _t##_w / _t##_r2 - _t##_w / 2; \
237 _y = _t##_yi * _t##_h / _t##_r2 - _t##_h / 2;
239#define gui_rect_iterate_coord_end \
240 } gui_rect_iterate_end
254 const struct tile *ptile)
262 int *xsize,
int *ysize);
295 const struct tile *ptile,
324 struct tile *ptile,
int dx,
int dy);
350 const struct player *pplayer);
struct canvas int int struct sprite int int int int height
struct canvas int int canvas_y
struct canvas int canvas_x
struct canvas int int struct sprite int int int width
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
void mapdeco_set_highlight(const struct tile *ptile, bool highlight)
void link_mark_restore(enum text_link_type type, int id)
void put_nuke_mushroom_pixmaps(struct tile *ptile)
void init_mapcanvas_and_overview(void)
struct city * find_city_or_settler_near_tile(const struct tile *ptile, struct unit **punit)
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
void update_map_canvas_visible(void)
bool tile_visible_mapcanvas(struct tile *ptile)
void set_mapview_origin(float gui_x0, float gui_y0, float zoom)
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void map_to_gui_vector(const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
void update_tile_label(struct tile *ptile)
void mapdeco_set_crosshair(const struct tile *ptile, bool crosshair)
enum topo_comp_lvl tileset_map_topo_compatible(int topology_id, struct tileset *tset, int *tset_topo)
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
void put_city(struct city *pcity, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
struct tile * get_center_tile_mapcanvas(void)
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void draw_segment(struct tile *ptile, enum direction8 dir) fc__attribute((nonnull(1)))
struct city * find_city_near_tile(const struct tile *ptile)
void free_mapcanvas_and_overview(void)
void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
bool mapdeco_is_highlight_set(const struct tile *ptile)
void center_tile_mapcanvas(const struct tile *ptile) fc__attribute((nonnull(1)))
void get_mapview_scroll_window(float *xmin, float *ymin, float *xmax, float *ymax, int *xsize, int *ysize)
void move_unit_map_canvas(struct unit *punit, struct tile *ptile, int dx, int dy)
void mapdeco_set_gotoroute(const struct unit *punit)
void unqueue_mapview_updates(bool write_to_screen)
void get_mapview_scroll_step(int *xstep, int *ystep)
void get_city_mapview_trade_routes(struct city *pcity, char *trade_routes_buffer, size_t trade_routes_buffer_len, enum color_std *trade_routes_color)
void get_city_mapview_production(struct city *pcity, char *buf, size_t buf_len)
void show_city_descriptions(int canvas_base_x, int canvas_base_y, int width_base, int height_base)
void set_mapview_scroll_pos(int scroll_x, int scroll_y, float zoom)
void client_infratile_set(struct tile *ptile)
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void mapdeco_clear_gotoroutes(void)
void put_unit_city_overlays(struct unit *punit, struct canvas *pcanvas, int canvas_x, int canvas_y, int *upkeep_cost, int happy_cost)
void put_one_element(struct canvas *pcanvas, float zoom, enum mapview_layer layer, const struct tile *ptile, const struct tile_edge *pedge, const struct tile_corner *pcorner, const struct unit *punit, const struct city *pcity, int canvas_x, int canvas_y, const struct city *citymode, const struct unit_type *putype)
bool mapdeco_is_gotoline_set(const struct tile *ptile, enum direction8 dir)
void animations_init(void)
void update_animation(void)
void toggle_city_color(struct city *pcity)
struct tile * canvas_pos_to_nearest_tile(float canvas_x, float canvas_y, float zoom)
void mapdeco_add_gotoline(const struct tile *ptile, enum direction8 dir)
void update_map_canvas(int canvas_x, int canvas_y, int width, int height)
void link_marks_decrease_turn_counters(void)
void mapdeco_clear_crosshairs(void)
void link_marks_draw_all(void)
void update_city_description(struct city *pcity)
void link_marks_init(void)
struct tile * client_infratile(void)
void set_frame_by_frame_animation(void)
void mapdeco_clear_highlights(void)
void link_marks_clear_all(void)
const char * describe_topology(int topo)
void toggle_unit_color(struct unit *punit)
void animations_free(void)
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile) fc__attribute((nonnull(1
bool map_canvas_resized(int width, int height)
void link_mark_add_new(enum text_link_type type, int id)
void refresh_tile_mapcanvas(struct tile *ptile, bool full_refresh, bool write_to_screen)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
void get_spaceship_dimensions(int *width, int *height)
void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1)
void get_city_mapview_name_and_growth(struct city *pcity, char *name_buffer, size_t name_buffer_len, char *growth_buffer, size_t growth_buffer_len, enum color_std *growth_color, enum color_std *production_color)
bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile)
void put_spaceship(struct canvas *pcanvas, int canvas_x, int canvas_y, const struct player *pplayer)
bool struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void mapdeco_remove_gotoline(const struct tile *ptile, enum direction8 dir)
bool mapdeco_is_crosshair_set(const struct tile *ptile)
void link_marks_free(void)
void show_tile_labels(int canvas_base_x, int canvas_base_y, int width_base, int height_base)
bool can_do_cached_drawing
struct canvas * tmp_store