Freeciv21
Develop your civilization from humble roots to a global empire
view_map_common.h File Reference
#include "featured_text.h"
#include "map.h"
#include "colors_g.h"
#include "map_updates_handler.h"
#include "tileset/tilespec.h"
+ Include dependency graph for view_map_common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  view
 

Macros

#define GOTO_WIDTH   2
 

Enumerations

enum  topo_comp_lvl { TOPO_COMPATIBLE = 0 , TOPO_INCOMP_SOFT = 1 , TOPO_INCOMP_HARD = 2 }
 

Functions

void mapdeco_init ()
 Called when we receive map dimensions. More...
 
void mapdeco_free ()
 Free all memory used for map decorations. More...
 
bool mapdeco_is_highlight_set (const struct tile *ptile)
 Return TRUE if the given tile is highlighted. More...
 
void mapdeco_set_crosshair (const struct tile *ptile, bool crosshair)
 Marks the given tile as having a "crosshair" map decoration. More...
 
bool mapdeco_is_crosshair_set (const struct tile *ptile)
 Returns TRUE if there is a "crosshair" decoration set at the given tile. More...
 
void mapdeco_clear_crosshairs ()
 Clears all previous set tile crosshair decorations. More...
 
void mapdeco_set_gotoroute (const struct unit *punit)
 Set the map decorations for the given unit's goto route. More...
 
void mapdeco_add_gotoline (const struct tile *ptile, enum direction8 dir, bool safe)
 Add a goto line from the given tile 'ptile' in the direction 'dir'. More...
 
bool mapdeco_is_gotoline_set (const struct tile *ptile, enum direction8 dir, bool *safe)
 Returns TRUE if a goto line should be drawn from the given tile in the given direction. More...
 
void mapdeco_clear_gotoroutes ()
 Clear all goto line map decorations and queues mapview updates for the affected tiles. More...
 
void refresh_tile_mapcanvas (const tile *ptile, bool full_refresh)
 Refreshes a single tile on the map canvas. More...
 
void refresh_unit_mapcanvas (struct unit *punit, struct tile *ptile, bool full_refresh)
 Refreshes a single unit on the map canvas. More...
 
void refresh_city_mapcanvas (struct city *pcity, struct tile *ptile, bool full_refresh)
 Refreshes a single city on the map canvas. More...
 
std::map< freeciv::map_updates_handler::update_type, QRectF > update_rects ()
 Calculates the area covered by each update type. More...
 
void unqueue_mapview_updates ()
 See comment in update_map_canvas_visible(). More...
 
void map_to_gui_vector (const struct tileset *t, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
 Translate from a cartesian system to the GUI system. More...
 
void map_to_gui_pos (const struct tileset *t, float *gui_x, float *gui_y, int map_x, int map_y)
 Translate from map to gui coordinate systems. More...
 
bool tile_to_canvas_pos (float *canvas_x, float *canvas_y, const tile *ptile)
 Finds the canvas coordinates for a map position. More...
 
struct tilecanvas_pos_to_tile (float canvas_x, float canvas_y)
 Finds the tile corresponding to pixel coordinates. More...
 
struct tilecanvas_pos_to_nearest_tile (float canvas_x, float canvas_y)
 Finds the tile corresponding to pixel coordinates. More...
 
void gui_distance_vector (const struct tileset *t, float *gui_dx, float *gui_dy, float gui_x0, float gui_y0, float gui_x1, float gui_y1)
 Find the vector with minimum "real" distance between two GUI positions. More...
 
void get_mapview_scroll_window (float *xmin, float *ymin, float *xmax, float *ymax, int *xsize, int *ysize)
 Return the scroll dimensions of the clipping window for the mapview window. More...
 
void get_mapview_scroll_pos (int *scroll_x, int *scroll_y)
 Find the current scroll position (origin) of the mapview. More...
 
void set_mapview_origin (float gui_x0, float gui_y0)
 Change the mapview origin, clip it, and update everything. More...
 
struct tileget_center_tile_mapcanvas ()
 Finds the current center tile of the mapcanvas. More...
 
bool tile_visible_mapcanvas (struct tile *ptile)
 Return TRUE iff the given map position has a tile visible on the map canvas. More...
 
bool tile_visible_and_not_on_border_mapcanvas (struct tile *ptile)
 Return TRUE iff the given map position has a tile visible within the interior of the map canvas. More...
 
void put_unit (const struct unit *punit, QPixmap *pcanvas, const QPoint &canvas_loc)
 Draw the given unit onto the canvas store at the given location. More...
 
void put_terrain (struct tile *ptile, QPixmap *pcanvas, const QPoint &canvas_loc)
 Draw the given tile terrain onto the canvas store at the given location. More...
 
void put_unit_city_overlays (const unit *punit, QPixmap *pcanvas, int canvas_x, int canvas_y, const int *upkeep_cost, int happy_cost)
 Draw food, gold, and shield upkeep values on the unit. More...
 
void toggle_city_color (struct city *pcity)
 Toggle the city color. More...
 
void toggle_unit_color (struct unit *punit)
 Toggle the unit color. More...
 
void put_nuke_mushroom_pixmaps (struct tile *ptile)
 Animate the nuke explosion at map(x, y). More...
 
void put_drawn_sprites (QPixmap *pcanvas, const QPoint &canvas_loc, const std::vector< drawn_sprite > &sprites, bool fog, bool city_unit=false)
 Draw an array of drawn sprites onto the canvas. More...
 
void update_map_canvas (int canvas_x, int canvas_y, int width, int height)
 Update (refresh) the map canvas starting at the given tile (in map coordinates) and with the given dimensions (also in map coordinates). More...
 
void update_map_canvas_visible ()
 Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update(). More...
 
void update_city_description (struct city *pcity)
 Update the city description for the given city. More...
 
void update_tile_label (struct tile *ptile)
 
void show_city_descriptions (int canvas_base_x, int canvas_base_y, int width_base, int height_base)
 Show descriptions for all cities visible on the map canvas. More...
 
void show_tile_labels (int canvas_base_x, int canvas_base_y, int width_base, int height_base)
 Show labels for all tiles visible on the map canvas. More...
 
void draw_segment (const tile *ptile, enum direction8 dir, bool safe)
 Draw a goto line at the given location and direction. More...
 
void decrease_unit_hp_smooth (struct unit *punit0, int hp0, struct unit *punit1, int hp1)
 This function is called to decrease a unit's HP smoothly in battle when combat_animation is turned on. More...
 
void animate_unit_explosion (const tile *location)
 Draws an explosion animation on the given sprite. More...
 
void move_unit_map_canvas (struct unit *punit, struct tile *ptile, int dx, int dy)
 Animates punit's "smooth" move from (x0, y0) to (x0+dx, y0+dy). More...
 
struct cityfind_city_or_settler_near_tile (const struct tile *ptile, struct unit **punit)
 Find the "best" city/settlers to associate with the selected tile. More...
 
void get_city_mapview_production (const city *pcity, char *buf, size_t buf_len)
 Find the mapview city production text for the given city, and place it into the buffer. More...
 
void get_city_mapview_name_and_growth (const 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)
 Fill the two buffers which information about the city which is shown below it. More...
 
void get_city_mapview_trade_routes (const city *pcity, char *trade_routes_buffer, size_t trade_routes_buffer_len, enum color_std *trade_routes_color)
 Find the mapview city trade routes text for the given city, and place it into the buffer. More...
 
void map_canvas_resized (int width, int height)
 Called if the map in the GUI is resized. More...
 
void init_mapcanvas_and_overview ()
 Sets up data for the mapview and overview. More...
 
void free_mapcanvas_and_overview ()
 Frees resources allocated for mapview and overview. More...
 
void link_marks_init ()
 Initialize the link marks. More...
 
void link_marks_free ()
 Free the link marks. More...
 
void link_marks_draw_all ()
 Draw all link marks. More...
 
void link_marks_clear_all ()
 Clear all visible links. More...
 
void link_marks_decrease_turn_counters ()
 Clear all visible links. More...
 
void link_mark_add_new (enum text_link_type type, int id)
 Add a visible link for 2 turns. More...
 
void link_mark_restore (enum text_link_type type, int id)
 Add a visible link for 1 turn. More...
 
enum topo_comp_lvl tileset_map_topo_compatible (int topology_id, struct tileset *tset)
 Are the topology and tileset compatible? More...
 

Variables

struct view mapview
 

Macro Definition Documentation

◆ GOTO_WIDTH

#define GOTO_WIDTH   2

Definition at line 45 of file view_map_common.h.

Enumeration Type Documentation

◆ topo_comp_lvl

Enumerator
TOPO_COMPATIBLE 
TOPO_INCOMP_SOFT 
TOPO_INCOMP_HARD 

Definition at line 142 of file view_map_common.h.

Function Documentation

◆ animate_unit_explosion()

void animate_unit_explosion ( const tile location)

Draws an explosion animation on the given sprite.

Definition at line 1518 of file view_map_common.cpp.

Referenced by decrease_unit_hp_smooth(), and handle_unit_bombard_info().

◆ canvas_pos_to_nearest_tile()

struct tile* canvas_pos_to_nearest_tile ( float  canvas_x,
float  canvas_y 
)

Finds the tile corresponding to pixel coordinates.

Returns that tile, or the one nearest is the position is off the map. Will never return nullptr.

Definition at line 360 of file view_map_common.cpp.

Referenced by get_center_tile_mapcanvas(), and recenter_button_pressed().

◆ canvas_pos_to_tile()

struct tile* canvas_pos_to_tile ( float  canvas_x,
float  canvas_y 
)

◆ decrease_unit_hp_smooth()

void decrease_unit_hp_smooth ( struct unit punit0,
int  hp0,
struct unit punit1,
int  hp1 
)

This function is called to decrease a unit's HP smoothly in battle when combat_animation is turned on.

Definition at line 1477 of file view_map_common.cpp.

Referenced by handle_unit_combat_info().

◆ draw_segment()

void draw_segment ( const tile src_tile,
enum direction8  dir,
bool  safe 
)

Draw a goto line at the given location and direction.

The line goes from the source tile to the adjacent tile in the given direction.

Definition at line 1438 of file view_map_common.cpp.

Referenced by update_map_canvas().

◆ find_city_or_settler_near_tile()

struct city* find_city_or_settler_near_tile ( const struct tile ptile,
struct unit **  punit 
)

Find the "best" city/settlers to associate with the selected tile.

a. If a visible city is working the tile, return that city. b. If another player's city is working the tile, return nullptr. c. If any selected cities are within range, return the closest one. d. If any cities are within range, return the closest one. e. If any active (with color) settler could work it if they founded a city, choose the closest one (only if punit != nullptr). f. If any settler could work it if they founded a city, choose the closest one (only if punit != nullptr). g. If nobody can work it, return nullptr.

Definition at line 1670 of file view_map_common.cpp.

Referenced by adjust_workers_button_pressed(), freeciv::layer_overlays::fill_sprite_array(), and key_city_overlay().

◆ free_mapcanvas_and_overview()

void free_mapcanvas_and_overview ( )

Frees resources allocated for mapview and overview.

Definition at line 2320 of file view_map_common.cpp.

Referenced by fc_client::fc_main().

◆ get_center_tile_mapcanvas()

struct tile* get_center_tile_mapcanvas ( )

◆ get_city_mapview_name_and_growth()

void get_city_mapview_name_and_growth ( const 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 
)

Fill the two buffers which information about the city which is shown below it.

It does not take draw_city_names/draw_city_growth into account.

Definition at line 1919 of file view_map_common.cpp.

Referenced by simple_citybar_painter::paint(), traditional_citybar_painter::paint(), and polished_citybar_painter::paint().

◆ get_city_mapview_production()

void get_city_mapview_production ( const city pcity,
char *  buf,
size_t  buf_len 
)

Find the mapview city production text for the given city, and place it into the buffer.

Definition at line 1792 of file view_map_common.cpp.

Referenced by simple_citybar_painter::paint(), and traditional_citybar_painter::paint().

◆ get_city_mapview_trade_routes()

void get_city_mapview_trade_routes ( const city pcity,
char *  trade_routes_buffer,
size_t  trade_routes_buffer_len,
enum color_std *  pcolor 
)

Find the mapview city trade routes text for the given city, and place it into the buffer.

Sets 'pcolor' to the preferred color the text should be drawn in if it is non-nullptr.

Definition at line 1818 of file view_map_common.cpp.

Referenced by simple_citybar_painter::paint(), traditional_citybar_painter::paint(), and polished_citybar_painter::paint().

◆ get_mapview_scroll_pos()

void get_mapview_scroll_pos ( int *  scroll_x,
int *  scroll_y 
)

Find the current scroll position (origin) of the mapview.

Definition at line 690 of file view_map_common.cpp.

Referenced by tile_visible_and_not_on_border_mapcanvas().

◆ get_mapview_scroll_window()

void get_mapview_scroll_window ( float *  xmin,
float *  ymin,
float *  xmax,
float *  ymax,
int *  xsize,
int *  ysize 
)

Return the scroll dimensions of the clipping window for the mapview window.

Imagine the entire map in scroll coordinates. It is a rectangle. Now imagine the mapview "window" sliding around through this rectangle. How far can it slide? In most cases it has to be able to slide past the ends of the map rectangle so that it's capable of reaching the whole area.

This function gives constraints on how far the window is allowed to slide. xmin and ymin are the minimum values for the window origin. xsize and ysize give the scroll dimensions of the mapview window. xmax and ymax give the maximum values that the bottom/left ends of the window may reach. The constraints, therefore, are that:

get_mapview_scroll_pos(&scroll_x, &scroll_y); xmin <= scroll_x < xmax - xsize ymin <= scroll_y < ymax - ysize

This function should be used anywhere and everywhere that scrolling is constrained.

Note that scroll coordinates, not map coordinates, are used. Currently these correspond to native coordinates.

Definition at line 608 of file view_map_common.cpp.

Referenced by calc_mapview_origin(), and tile_visible_and_not_on_border_mapcanvas().

◆ gui_distance_vector()

void gui_distance_vector ( const struct tileset t,
float *  gui_dx,
float *  gui_dy,
float  gui_x0,
float  gui_y0,
float  gui_x1,
float  gui_y1 
)

Find the vector with minimum "real" distance between two GUI positions.

This corresponds to map_to_distance_vector but works for GUI coordinates.

Definition at line 408 of file view_map_common.cpp.

Referenced by base_set_mapview_origin(), and map_view::center_on_tile().

◆ init_mapcanvas_and_overview()

void init_mapcanvas_and_overview ( )

Sets up data for the mapview and overview.

Definition at line 2310 of file view_map_common.cpp.

Referenced by fc_client::fc_client().

◆ link_mark_add_new()

void link_mark_add_new ( enum text_link_type  type,
int  id 
)

Add a visible link for 2 turns.

Definition at line 2522 of file view_map_common.cpp.

Referenced by handle_event().

◆ link_mark_restore()

void link_mark_restore ( enum text_link_type  type,
int  id 
)

Add a visible link for 1 turn.

Definition at line 2544 of file view_map_common.cpp.

Referenced by chat_widget::anchor_clicked().

◆ link_marks_clear_all()

void link_marks_clear_all ( )

Clear all visible links.

Definition at line 2497 of file view_map_common.cpp.

Referenced by chat_widget::rm_links().

◆ link_marks_decrease_turn_counters()

void link_marks_decrease_turn_counters ( )

Clear all visible links.

Definition at line 2506 of file view_map_common.cpp.

Referenced by handle_new_year().

◆ link_marks_draw_all()

void link_marks_draw_all ( )

Draw all link marks.

Definition at line 2488 of file view_map_common.cpp.

Referenced by update_map_canvas().

◆ link_marks_free()

void link_marks_free ( )

Free the link marks.

Definition at line 2475 of file view_map_common.cpp.

Referenced by client_game_free(), client_game_reset(), and link_marks_init().

◆ link_marks_init()

void link_marks_init ( )

Initialize the link marks.

Definition at line 2463 of file view_map_common.cpp.

Referenced by client_game_init(), and client_game_reset().

◆ map_canvas_resized()

void map_canvas_resized ( int  width,
int  height 
)

Called if the map in the GUI is resized.

Definition at line 2242 of file view_map_common.cpp.

Referenced by init_mapcanvas_and_overview(), mr_menu::save_image(), freeciv::renderer::set_scale(), and freeciv::renderer::set_viewport_size().

◆ map_to_gui_pos()

void map_to_gui_pos ( const struct tileset t,
float *  gui_x,
float *  gui_y,
int  map_x,
int  map_y 
)

Translate from map to gui coordinate systems.

GUI coordinates are comparable to canvas coordinates but extend in all directions. gui(0,0) == map(0,0).

Definition at line 174 of file view_map_common.cpp.

Referenced by map_view::center_on_tile(), get_mapview_scroll_window(), gui_distance_vector(), map_canvas_resized(), normalize_gui_pos(), tile_to_canvas_pos(), and trade_route_to_canvas_lines().

◆ map_to_gui_vector()

void map_to_gui_vector ( const struct tileset t,
float *  gui_dx,
float *  gui_dy,
int  map_dx,
int  map_dy 
)

Translate from a cartesian system to the GUI system.

This function works on vectors, meaning it can be passed a (dx,dy) pair and will return the change in GUI coordinates corresponding to this vector. It is thus more general than map_to_gui_pos.

Note that a gui_to_map_vector function is not possible, since the resulting map vector may differ based on the origin of the gui vector.

Definition at line 145 of file view_map_common.cpp.

Referenced by draw_calculated_trade_routes(), draw_segment(), generate_citydlg_dimensions(), map_to_gui_pos(), and move_unit_map_canvas().

◆ mapdeco_add_gotoline()

void mapdeco_add_gotoline ( const struct tile ptile,
enum direction8  dir,
bool  safe 
)

Add a goto line from the given tile 'ptile' in the direction 'dir'.

If there was no previously drawn line there, a mapview update is queued for the source and destination tiles.

Definition at line 2121 of file view_map_common.cpp.

Referenced by is_valid_goto_draw_line(), and mapdeco_set_gotoroute().

◆ mapdeco_clear_crosshairs()

void mapdeco_clear_crosshairs ( )

Clears all previous set tile crosshair decorations.

Marks the affected tiles as needing a mapview update.

Definition at line 2108 of file view_map_common.cpp.

Referenced by popdown_tile_info().

◆ mapdeco_clear_gotoroutes()

void mapdeco_clear_gotoroutes ( )

Clear all goto line map decorations and queues mapview updates for the affected tiles.

Definition at line 2220 of file view_map_common.cpp.

Referenced by exit_goto_state(), is_valid_goto_draw_line(), and popdown_tile_info().

◆ mapdeco_free()

void mapdeco_free ( )

Free all memory used for map decorations.

Definition at line 2050 of file view_map_common.cpp.

Referenced by mapdeco_clear_gotoroutes(), and mapdeco_init().

◆ mapdeco_init()

void mapdeco_init ( )

Called when we receive map dimensions.

It initialized the mapview decorations.

Definition at line 2038 of file view_map_common.cpp.

Referenced by handle_map_info().

◆ mapdeco_is_crosshair_set()

bool mapdeco_is_crosshair_set ( const struct tile ptile)

Returns TRUE if there is a "crosshair" decoration set at the given tile.

Definition at line 2096 of file view_map_common.cpp.

Referenced by freeciv::layer_overlays::fill_sprite_array().

◆ mapdeco_is_gotoline_set()

bool mapdeco_is_gotoline_set ( const struct tile ptile,
enum direction8  dir,
bool *  safe 
)

Returns TRUE if a goto line should be drawn from the given tile in the given direction.

Definition at line 2199 of file view_map_common.cpp.

Referenced by update_map_canvas().

◆ mapdeco_is_highlight_set()

bool mapdeco_is_highlight_set ( const struct tile ptile)

Return TRUE if the given tile is highlighted.

Definition at line 2061 of file view_map_common.cpp.

Referenced by freeciv::layer_grid::fill_sprite_array(), and find_city_or_settler_near_tile().

◆ mapdeco_set_crosshair()

void mapdeco_set_crosshair ( const struct tile ptile,
bool  crosshair 
)

Marks the given tile as having a "crosshair" map decoration.

Definition at line 2072 of file view_map_common.cpp.

Referenced by popup_tile_info().

◆ mapdeco_set_gotoroute()

void mapdeco_set_gotoroute ( const struct unit punit)

Set the map decorations for the given unit's goto route.

A goto route consists of one or more goto lines, with each line being from the center of one tile to the center of another tile.

Definition at line 2160 of file view_map_common.cpp.

Referenced by popup_tile_info().

◆ move_unit_map_canvas()

void move_unit_map_canvas ( struct unit punit,
struct tile src_tile,
int  dx,
int  dy 
)

Animates punit's "smooth" move from (x0, y0) to (x0+dx, y0+dy).

Note: Works only for adjacent-tile moves.

Definition at line 1573 of file view_map_common.cpp.

Referenced by do_move_unit().

◆ put_drawn_sprites()

void put_drawn_sprites ( QPixmap *  pcanvas,
const QPoint &  canvas_loc,
const std::vector< drawn_sprite > &  sprites,
bool  fog,
bool  city_unit = false 
)

Draw an array of drawn sprites onto the canvas.

Definition at line 776 of file view_map_common.cpp.

Referenced by put_one_element(), and terrain_canvas().

◆ put_nuke_mushroom_pixmaps()

void put_nuke_mushroom_pixmaps ( struct tile ptile)

Animate the nuke explosion at map(x, y).

Definition at line 952 of file view_map_common.cpp.

Referenced by handle_nuke_tile_info().

◆ put_terrain()

void put_terrain ( struct tile ptile,
QPixmap *  pcanvas,
const QPoint &  canvas_loc 
)

Draw the given tile terrain onto the canvas store at the given location.

The area of drawing is tileset_full_tile_height(tileset) x tileset_full_tile_width(tileset) (even though most tiles are not this tall).

Definition at line 858 of file view_map_common.cpp.

Referenced by hud_units::update_actions().

◆ put_unit()

void put_unit ( const struct unit punit,
QPixmap *  pcanvas,
const QPoint &  canvas_loc 
)

Draw the given unit onto the canvas store at the given location.

The area of drawing is tileset_unit_height(tileset) x tileset_unit_width(tileset).

Definition at line 842 of file view_map_common.cpp.

Referenced by units_select::create_pixmap(), unit_list_widget::create_unit_image(), hud_unit_combat::init_images(), move_unit_map_canvas(), choice_dialog::next_unit(), choice_dialog::prev_unit(), freeciv::upkeep_widget::refresh(), choice_dialog::set_layout(), and hud_units::update_actions().

◆ put_unit_city_overlays()

void put_unit_city_overlays ( const unit punit,
QPixmap *  pcanvas,
int  canvas_x,
int  canvas_y,
const int *  upkeep_cost,
int  happy_cost 
)

Draw food, gold, and shield upkeep values on the unit.

The proper way to do this is probably something like what Civ II does (one sprite drawn N times on top of itself), but we just use separate sprites (limiting the number of combinations).

Definition at line 876 of file view_map_common.cpp.

Referenced by unit_list_widget::create_unit_image(), and freeciv::upkeep_widget::refresh().

◆ refresh_city_mapcanvas()

void refresh_city_mapcanvas ( struct city pcity,
struct tile ptile,
bool  full_refresh 
)

Refreshes a single city on the map canvas.

If full_refresh is given then the citymap area and the city text will also be refreshed. Otherwise only the base city sprite is refreshed.

Definition at line 128 of file view_map_common.cpp.

Referenced by city_packet_common(), client_remove_city(), handle_unit_packet_common(), city_dialog::setup_ui(), and toggle_city_color().

◆ refresh_tile_mapcanvas()

◆ refresh_unit_mapcanvas()

void refresh_unit_mapcanvas ( struct unit punit,
struct tile ptile,
bool  full_refresh 
)

◆ set_mapview_origin()

void set_mapview_origin ( float  gui_x0,
float  gui_y0 
)

Change the mapview origin, clip it, and update everything.

Definition at line 573 of file view_map_common.cpp.

Referenced by freeciv::renderer::set_origin().

◆ show_city_descriptions()

void show_city_descriptions ( int  canvas_base_x,
int  canvas_base_y,
int  width_base,
int  height_base 
)

Show descriptions for all cities visible on the map canvas.

Definition at line 1335 of file view_map_common.cpp.

Referenced by update_map_canvas().

◆ show_tile_labels()

void show_tile_labels ( int  canvas_base_x,
int  canvas_base_y,
int  width_base,
int  height_base 
)

Show labels for all tiles visible on the map canvas.

Definition at line 1398 of file view_map_common.cpp.

Referenced by update_map_canvas().

◆ tile_to_canvas_pos()

bool tile_to_canvas_pos ( float *  canvas_x,
float *  canvas_y,
const tile ptile 
)

Finds the canvas coordinates for a map position.

Beside setting the results in canvas_x, canvas_y it returns whether the tile is inside the visible mapview canvas.

The result represents the upper left pixel (origin) of the bounding box of the tile. Note that in iso-view this origin is not a part of the tile itself - so to make the operation reversible you would have to call canvas_to_map_pos on the center of the tile, not the origin.

The center of a tile is defined as: { tile_to_canvas_pos(&canvas_x, &canvas_y, ptile); canvas_x += tileset_tile_width(tileset) / 2; canvas_y += tileset_tile_height(tileset) / 2; }

This pixel is one position closer to the lower right, which may be important to remember when doing some round-off operations. Other parts of the code assume tileset_tile_width(tileset) and tileset_tile_height(tileset) to be even numbers.

Definition at line 289 of file view_map_common.cpp.

Referenced by animate_unit_explosion(), info_tile::calc_size(), draw_calculated_trade_routes(), draw_segment(), link_mark_draw(), move_unit_map_canvas(), put_cross_overlay_tile(), put_nuke_mushroom_pixmaps(), tile_visible_and_not_on_border_mapcanvas(), tile_visible_mapcanvas(), trade_route_to_canvas_lines(), and freeciv::renderer::unqueue_updates().

◆ tile_visible_and_not_on_border_mapcanvas()

bool tile_visible_and_not_on_border_mapcanvas ( struct tile ptile)

Return TRUE iff the given map position has a tile visible within the interior of the map canvas.

This information is used to determine when we need to recenter the map canvas.

The logic of this function is simple: if a tile is within 1.5 tiles of a border of the canvas and that border is not aligned with the edge of the map, then the tile is on the "border" of the map canvas.

This function is only correct for the current topology.

Definition at line 726 of file view_map_common.cpp.

Referenced by auto_center_on_focus_unit(), do_move_unit(), and unit_focus_advance().

◆ tile_visible_mapcanvas()

bool tile_visible_mapcanvas ( struct tile ptile)

Return TRUE iff the given map position has a tile visible on the map canvas.

Definition at line 708 of file view_map_common.cpp.

Referenced by handle_unit_bombard_info(), handle_unit_combat_info(), link_mark_add_new(), link_mark_restore(), and move_unit_map_canvas().

◆ tileset_map_topo_compatible()

enum topo_comp_lvl tileset_map_topo_compatible ( int  topology_id,
struct tileset tset 
)

Are the topology and tileset compatible?

Definition at line 2544 of file view_map_common.cpp.

Referenced by handle_map_info(), handle_set_topology(), and tilespec_reread().

◆ toggle_city_color()

void toggle_city_color ( struct city pcity)

Toggle the city color.

This cycles through the possible colors for the citymap as shown on the mapview. These colors are listed in the city_colors array; above.

Definition at line 918 of file view_map_common.cpp.

Referenced by key_city_overlay().

◆ toggle_unit_color()

void toggle_unit_color ( struct unit punit)

Toggle the unit color.

This cycles through the possible colors for the citymap as shown on the mapview. These colors are listed in the city_colors array; above.

Definition at line 936 of file view_map_common.cpp.

Referenced by key_city_overlay().

◆ unqueue_mapview_updates()

◆ update_city_description()

void update_city_description ( struct city pcity)

Update the city description for the given city.

Definition at line 1284 of file view_map_common.cpp.

Referenced by do_move_unit(), handle_city_info(), handle_city_short_info(), handle_traderoute_info(), handle_unit_packet_common(), and show_city_descriptions().

◆ update_map_canvas()

void update_map_canvas ( int  canvas_x,
int  canvas_y,
int  width,
int  height 
)

Update (refresh) the map canvas starting at the given tile (in map coordinates) and with the given dimensions (also in map coordinates).

In non-iso view, this is easy. In iso view, we have to use the Painter's Algorithm to draw the tiles in back first. When we draw a tile, we tell the GUI which part of the tile to draw - which is necessary unless we have an extra buffering step.

After refreshing the backing store tile-by-tile, we write the store out to the display if write_to_screen is specified.

x, y, width, and height are in map coordinates; they need not be normalized or even real.

Definition at line 1129 of file view_map_common.cpp.

Referenced by base_set_mapview_origin(), editor_end_selection_rectangle(), and freeciv::renderer::unqueue_updates().

◆ update_map_canvas_visible()

◆ update_rects()

std::map<freeciv::map_updates_handler::update_type, QRectF> update_rects ( )

Calculates the area covered by each update type.

The area array gives the offset from the tile origin as well as the width and height of the area to be updated. This is initialized each time when entering the function from the existing tileset variables.

A TILE update covers the base tile (width x height) plus a half-tile in each direction (for edge/corner graphics), making its area 2 width x 2 height.

A UNIT update covers a unit_width x unit_height area. This is centered horizontally over the tile but extends up above the tile (e.g., units in iso-view).

A CITYMAP update covers the whole citymap of a tile. This includes the citymap area itself plus an extra half-tile in each direction (for edge/corner graphics).

Definition at line 1875 of file view_map_common.cpp.

Referenced by freeciv::renderer::unqueue_updates().

◆ update_tile_label()

void update_tile_label ( struct tile ptile)

Variable Documentation

◆ mapview