Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
mapview_common.h File Reference
#include "support.h"
#include "fc_types.h"
#include "featured_text.h"
#include "map.h"
#include "colors_g.h"
#include "tilespec.h"

Go to the source code of this file.

Data Structures

struct  view
 

Macros

#define BORDER_WIDTH   2
 
#define GOTO_WIDTH   2
 
#define gui_rect_iterate(GRI_x0, GRI_y0, GRI_width, GRI_height, _t, _e, _c, _zoom)
 
#define gui_rect_iterate_end
 
#define gui_rect_iterate_coord(GRI_x0, GRI_y0, GRI_width, GRI_height, _t, _e, _c, _x, _y, _zoom)
 
#define gui_rect_iterate_coord_end    } gui_rect_iterate_end
 

Enumerations

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

Functions

void mapdeco_init (void)
 
void mapdeco_free (void)
 
void mapdeco_set_highlight (const struct tile *ptile, bool highlight)
 
bool mapdeco_is_highlight_set (const struct tile *ptile)
 
void mapdeco_clear_highlights (void)
 
void mapdeco_set_crosshair (const struct tile *ptile, bool crosshair)
 
bool mapdeco_is_crosshair_set (const struct tile *ptile)
 
void mapdeco_clear_crosshairs (void)
 
void mapdeco_set_gotoroute (const struct unit *punit)
 
void mapdeco_add_gotoline (const struct tile *ptile, enum direction8 dir)
 
void mapdeco_remove_gotoline (const struct tile *ptile, enum direction8 dir)
 
bool mapdeco_is_gotoline_set (const struct tile *ptile, enum direction8 dir)
 
void mapdeco_clear_gotoroutes (void)
 
struct tileclient_infratile (void)
 
void client_infratile_set (struct tile *ptile)
 
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 refresh_city_mapcanvas (struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
 
void unqueue_mapview_updates (bool write_to_screen)
 
void map_to_gui_vector (const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
 
bool tile_to_canvas_pos (float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile) fc__attribute((nonnull(1
 
bool struct tilecanvas_pos_to_tile (float canvas_x, float canvas_y, float zoom)
 
struct tilecanvas_pos_to_nearest_tile (float canvas_x, float canvas_y, float zoom)
 
void get_mapview_scroll_window (float *xmin, float *ymin, float *xmax, float *ymax, int *xsize, int *ysize)
 
void get_mapview_scroll_step (int *xstep, int *ystep)
 
void get_mapview_scroll_pos (int *scroll_x, int *scroll_y)
 
void set_mapview_scroll_pos (int scroll_x, int scroll_y, float zoom)
 
void set_mapview_origin (float gui_x0, float gui_y0, float zoom)
 
struct tileget_center_tile_mapcanvas (void)
 
void center_tile_mapcanvas (const struct tile *ptile) fc__attribute((nonnull(1)))
 
bool tile_visible_mapcanvas (struct tile *ptile)
 
bool tile_visible_and_not_on_border_mapcanvas (struct tile *ptile)
 
void put_unit (const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
 
void put_unittype (const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
 
void put_city (struct city *pcity, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
 
void put_terrain (struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
 
void put_unit_city_overlays (struct unit *punit, struct canvas *pcanvas, int canvas_x, int canvas_y, int *upkeep_cost, int happy_cost)
 
void toggle_city_color (struct city *pcity)
 
void toggle_unit_color (struct unit *punit)
 
void put_nuke_mushroom_pixmaps (struct tile *ptile)
 
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)
 
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 (int canvas_x, int canvas_y, int width, int height)
 
void update_map_canvas_visible (void)
 
void update_city_description (struct city *pcity)
 
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)
 
void show_tile_labels (int canvas_base_x, int canvas_base_y, int width_base, int height_base)
 
void draw_segment (struct tile *ptile, enum direction8 dir) fc__attribute((nonnull(1)))
 
void decrease_unit_hp_smooth (struct unit *punit0, int hp0, struct unit *punit1, int hp1)
 
void move_unit_map_canvas (struct unit *punit, struct tile *ptile, int dx, int dy)
 
struct cityfind_city_or_settler_near_tile (const struct tile *ptile, struct unit **punit)
 
struct cityfind_city_near_tile (const struct tile *ptile)
 
void get_city_mapview_production (struct city *pcity, char *buf, size_t buf_len)
 
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)
 
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)
 
bool map_canvas_resized (int width, int height)
 
void init_mapcanvas_and_overview (void)
 
void free_mapcanvas_and_overview (void)
 
void get_spaceship_dimensions (int *width, int *height)
 
void put_spaceship (struct canvas *pcanvas, int canvas_x, int canvas_y, const struct player *pplayer)
 
void link_marks_init (void)
 
void link_marks_free (void)
 
void link_marks_draw_all (void)
 
void link_marks_clear_all (void)
 
void link_marks_decrease_turn_counters (void)
 
void link_mark_add_new (enum text_link_type type, int id)
 
void link_mark_restore (enum text_link_type type, int id)
 
enum topo_comp_lvl tileset_map_topo_compatible (int topology_id, struct tileset *tset, int *tset_topo)
 
const chardescribe_topology (int topo)
 
void animations_init (void)
 
void animations_free (void)
 
void set_frame_by_frame_animation (void)
 
void update_animation (void)
 

Variables

struct view mapview
 
bool can_slide
 

Macro Definition Documentation

◆ BORDER_WIDTH

#define BORDER_WIDTH   2

Definition at line 71 of file mapview_common.h.

◆ GOTO_WIDTH

#define GOTO_WIDTH   2

Definition at line 72 of file mapview_common.h.

◆ gui_rect_iterate

#define gui_rect_iterate (   GRI_x0,
  GRI_y0,
  GRI_width,
  GRI_height,
  _t,
  _e,
  _c,
  _zoom 
)

Definition at line 97 of file mapview_common.h.

◆ gui_rect_iterate_coord

#define gui_rect_iterate_coord (   GRI_x0,
  GRI_y0,
  GRI_width,
  GRI_height,
  _t,
  _e,
  _c,
  _x,
  _y,
  _zoom 
)
Value:
_t, _e, _c, _zoom) { \
int _x, _y; \
\
_x = _t##_xi * _t##_w / _t##_r2 - _t##_w / 2; \
_y = _t##_yi * _t##_h / _t##_r2 - _t##_h / 2;
char * incite_cost
Definition comments.c:76
#define gui_rect_iterate(GRI_x0, GRI_y0, GRI_width, GRI_height, _t, _e, _c, _zoom)

Definition at line 230 of file mapview_common.h.

◆ gui_rect_iterate_coord_end

#define gui_rect_iterate_coord_end    } gui_rect_iterate_end

Definition at line 239 of file mapview_common.h.

◆ gui_rect_iterate_end

#define gui_rect_iterate_end
Value:
} \
} \
}

Definition at line 225 of file mapview_common.h.

Enumeration Type Documentation

◆ topo_comp_lvl

Enumerator
TOPO_COMPATIBLE 
TOPO_INCOMP_SOFT 
TOPO_INCOMP_HARD 

Definition at line 362 of file mapview_common.h.

Function Documentation

◆ animations_free()

void animations_free ( void  )

Clean up animations system.

Definition at line 188 of file mapview_common.c.

Referenced by client_game_free().

◆ animations_init()

void animations_init ( void  )

Initialize animations system.

Definition at line 180 of file mapview_common.c.

Referenced by client_game_init().

◆ canvas_pos_to_nearest_tile()

struct tile * canvas_pos_to_nearest_tile ( float  canvas_x,
float  canvas_y,
float  zoom 
)

Finds the tile corresponding to pixel coordinates. Returns that tile, or the one nearest is the position is off the map. Will never return NULL.

Definition at line 780 of file mapview_common.c.

Referenced by anchor_selection_rectangle(), get_center_tile_mapcanvas(), recenter_button_pressed(), and update_selection_rectangle().

◆ canvas_pos_to_tile()

bool struct tile * canvas_pos_to_tile ( float  canvas_x,
float  canvas_y,
float  zoom 
)

◆ center_tile_mapcanvas()

void center_tile_mapcanvas ( const struct tile ptile)

◆ client_infratile()

struct tile * client_infratile ( void  )

Return currently selected infratile, if any

Definition at line 4071 of file mapview_common.c.

Referenced by fill_sprite_array().

◆ client_infratile_set()

void client_infratile_set ( struct tile ptile)

Select specific infratile

Definition at line 4079 of file mapview_common.c.

Referenced by infra_placement_set_tile(), and infra_response_callback().

◆ 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 2519 of file mapview_common.c.

Referenced by handle_unit_combat_info().

◆ describe_topology()

const char * describe_topology ( int  topo)

Return string describing topology id.

Definition at line 4045 of file mapview_common.c.

Referenced by handle_map_info(), and tilespec_reread().

◆ draw_segment()

void draw_segment ( struct tile src_tile,
enum direction8  dir 
)

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 2481 of file mapview_common.c.

Referenced by update_map_canvas().

◆ find_city_near_tile()

struct city * find_city_near_tile ( const struct tile ptile)

Find the nearest/best city that owns the tile.

Definition at line 2865 of file mapview_common.c.

Referenced by adjust_workers_button_pressed().

◆ 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 NULL. 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 != NULL). f. If any settler could work it if they founded a city, choose the closest one (only if punit != NULL). g. If nobody can work it, return NULL.

Definition at line 2774 of file mapview_common.c.

Referenced by fill_city_overlays_sprite_array(), find_city_near_tile(), and key_city_overlay().

◆ free_mapcanvas_and_overview()

void free_mapcanvas_and_overview ( void  )

Frees resources allocated for mapview and overview.

Definition at line 3664 of file mapview_common.c.

Referenced by fc_client::fc_main(), ui_main(), and ui_main().

◆ get_center_tile_mapcanvas()

struct tile * get_center_tile_mapcanvas ( void  )

◆ get_city_mapview_name_and_growth()

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 
)

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 3157 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

◆ get_city_mapview_production()

void get_city_mapview_production ( struct city pcity,
char buffer,
size_t  buffer_len 
)

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

Definition at line 2894 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

◆ get_city_mapview_trade_routes()

void get_city_mapview_trade_routes ( struct 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-NULL.

Definition at line 2920 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

◆ 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 1206 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), scrollbar_jump_callback(), tile_visible_and_not_on_border_mapcanvas(), and update_map_canvas_scrollbars().

◆ get_mapview_scroll_step()

void get_mapview_scroll_step ( int xstep,
int ystep 
)

Find the scroll step for the mapview. This is the amount to scroll (in scroll coordinates) on each "step". See also get_mapview_scroll_window().

Definition at line 1192 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), and update_map_canvas_scrollbars_size().

◆ 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 1108 of file mapview_common.c.

Referenced by calc_mapview_origin(), tile_visible_and_not_on_border_mapcanvas(), and update_map_canvas_scrollbars_size().

◆ get_spaceship_dimensions()

void get_spaceship_dimensions ( int width,
int height 
)

Return the desired width of the spaceship canvas.

Definition at line 3673 of file mapview_common.c.

Referenced by create_spaceship_dialog(), and ss_report::ss_report().

◆ init_mapcanvas_and_overview()

void init_mapcanvas_and_overview ( void  )

Sets up data for the mapview and overview.

Definition at line 3655 of file mapview_common.c.

Referenced by activate_gui(), fc_client::init(), ui_main(), and ui_main().

◆ 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 3957 of file mapview_common.c.

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 3979 of file mapview_common.c.

Referenced by chatwdg::anchor_clicked(), event_after(), and event_after().

◆ link_marks_clear_all()

void link_marks_clear_all ( void  )

Clear all visible links.

Definition at line 3934 of file mapview_common.c.

Referenced by chatwdg::rm_links(), and setup_widgets().

◆ link_marks_decrease_turn_counters()

void link_marks_decrease_turn_counters ( void  )

Clear all visible links.

Definition at line 3943 of file mapview_common.c.

Referenced by handle_new_year().

◆ link_marks_draw_all()

void link_marks_draw_all ( void  )

Draw all link marks.

Definition at line 3924 of file mapview_common.c.

Referenced by update_map_canvas().

◆ link_marks_free()

void link_marks_free ( void  )

Free the link marks.

Definition at line 3911 of file mapview_common.c.

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

◆ link_marks_init()

void link_marks_init ( void  )

Initialize the link marks.

Definition at line 3899 of file mapview_common.c.

Referenced by client_game_init(), and client_game_reset().

◆ map_canvas_resized()

bool map_canvas_resized ( int  width,
int  height 
)

Called if the map in the GUI is resized.

Returns TRUE iff the canvas was redrawn.

Definition at line 3564 of file mapview_common.c.

Referenced by init_mapcanvas_and_overview(), map_canvas_configure(), map_canvas_size_refresh(), overview_size_changed(), real_resize_window_callback(), fc_game_tab_widget::resizeEvent(), mr_menu::save_image(), zoom_1_0(), and zoom_set().

◆ map_to_gui_vector()

void map_to_gui_vector ( const struct tileset t,
float  zoom,
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 563 of file mapview_common.c.

Referenced by city_to_canvas_pos(), 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 
)

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 3416 of file mapview_common.c.

Referenced by goto_path_redraw(), and mapdeco_set_gotoroute().

◆ mapdeco_clear_crosshairs()

void mapdeco_clear_crosshairs ( void  )

Clears all previous set tile crosshair decorations. Marks the affected tiles as needing a mapview update.

Definition at line 3398 of file mapview_common.c.

Referenced by fc_client::popdown_tile_info(), and popupinfo_popdown_callback().

◆ mapdeco_clear_gotoroutes()

void mapdeco_clear_gotoroutes ( void  )

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

Definition at line 3542 of file mapview_common.c.

Referenced by fc_client::popdown_tile_info(), and popupinfo_popdown_callback().

◆ mapdeco_clear_highlights()

void mapdeco_clear_highlights ( void  )

Clears all highlighting. Marks the previously highlighted tiles as needing a mapview update.

Definition at line 3347 of file mapview_common.c.

Referenced by cancel_tile_hiliting().

◆ mapdeco_free()

void mapdeco_free ( void  )

Free all memory used for map decorations.

Definition at line 3292 of file mapview_common.c.

Referenced by mapdeco_init().

◆ mapdeco_init()

void mapdeco_init ( void  )

Called when we receive map dimensions. It initialized the mapview decorations.

Definition at line 3278 of file mapview_common.c.

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 3386 of file mapview_common.c.

Referenced by fill_sprite_array().

◆ mapdeco_is_gotoline_set()

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

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

Definition at line 3521 of file mapview_common.c.

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 3335 of file mapview_common.c.

Referenced by fill_grid_sprite_array(), find_city_or_settler_near_tile(), is_city_hilited(), and toggle_tile_hilite().

◆ mapdeco_remove_gotoline()

void mapdeco_remove_gotoline ( const struct tile ptile,
enum direction8  dir 
)

Removes a goto line from the given tile 'ptile' going in the direction 'dir'. If this was the last line there, a mapview update is queued to erase the drawn line.

Definition at line 3450 of file mapview_common.c.

Referenced by goto_path_redraw(), and goto_path_undraw().

◆ 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 3363 of file mapview_common.c.

Referenced by popit(), popit(), and fc_client::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 3486 of file mapview_common.c.

Referenced by popit(), popit(), and fc_client::popup_tile_info().

◆ mapdeco_set_highlight()

void mapdeco_set_highlight ( const struct tile ptile,
bool  highlight 
)

Set the given tile's map decoration as either highlighted or not, depending on the value of 'highlight'.

Definition at line 3312 of file mapview_common.c.

Referenced by define_tiles_within_rectangle(), and toggle_tile_hilite().

◆ 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 2655 of file mapview_common.c.

Referenced by do_move_unit().

◆ put_city()

void put_city ( struct city pcity,
struct canvas pcanvas,
float  zoom,
int  canvas_x,
int  canvas_y 
)

Draw the given city onto the canvas store at the given location. The area of drawing is tileset_full_tile_height(tileset) x tileset_full_tile_width(tileset).

Definition at line 1418 of file mapview_common.c.

◆ put_drawn_sprites()

void put_drawn_sprites ( struct canvas pcanvas,
float  zoom,
int  canvas_x,
int  canvas_y,
int  count,
struct drawn_sprite pdrawn,
bool  fog 
)

◆ put_nuke_mushroom_pixmaps()

void put_nuke_mushroom_pixmaps ( struct tile ptile)

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

Definition at line 1525 of file mapview_common.c.

Referenced by handle_nuke_tile_info().

◆ put_one_element()

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 
)

Draw one layer of a tile, edge, corner, unit, and/or city onto the canvas at the given position.

Definition at line 1364 of file mapview_common.c.

Referenced by city_dialog_redraw_map(), create_pixbuf_from_layers(), put_city(), put_one_tile(), put_terrain(), put_unit(), put_unittype(), and update_map_canvas().

◆ put_spaceship()

void put_spaceship ( struct canvas pcanvas,
int  canvas_x,
int  canvas_y,
const struct player pplayer 
)

Draw the spaceship onto the canvas.

Definition at line 3686 of file mapview_common.c.

Referenced by spaceship_image_canvas_draw(), spaceship_image_canvas_expose(), and ss_report::update_report().

◆ put_terrain()

void put_terrain ( struct tile ptile,
struct canvas pcanvas,
float  zoom,
int  canvas_x,
int  canvas_y 
)

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 1435 of file mapview_common.c.

Referenced by get_terrain_surface(), and hud_units::update_actions().

◆ put_unit()

void put_unit ( const struct unit punit,
struct canvas pcanvas,
float  zoom,
int  canvas_x,
int  canvas_y 
)

◆ put_unit_city_overlays()

void put_unit_city_overlays ( struct unit punit,
struct canvas pcanvas,
int  canvas_x,
int  canvas_y,
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 1453 of file mapview_common.c.

Referenced by put_unit_image_city_overlays(), put_unit_picture_city_overlays(), and unit_item::unit_item().

◆ put_unittype()

void put_unittype ( const struct unit_type putype,
struct canvas pcanvas,
float  zoom,
int  canvas_x,
int  canvas_y 
)

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 1403 of file mapview_common.c.

Referenced by hud_unit_combat::init_images(), help_widget::set_topic_unit(), and usdlg_tab_append_utype().

◆ refresh_city_mapcanvas()

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

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 541 of file mapview_common.c.

Referenced by city_packet_common(), client_remove_city(), handle_unit_packet_common(), and toggle_city_color().

◆ refresh_tile_mapcanvas()

void refresh_tile_mapcanvas ( struct tile ptile,
bool  full_refresh,
bool  write_to_screen 
)

◆ refresh_unit_mapcanvas()

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

◆ set_frame_by_frame_animation()

void set_frame_by_frame_animation ( void  )

Set frame by frame animation mode on.

Definition at line 4063 of file mapview_common.c.

Referenced by ui_init().

◆ set_mapview_origin()

void set_mapview_origin ( float  gui_x0,
float  gui_y0,
float  zoom 
)

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

Definition at line 1008 of file mapview_common.c.

Referenced by center_tile_mapcanvas(), scroll_mapview(), and set_mapview_scroll_pos().

◆ set_mapview_scroll_pos()

void set_mapview_scroll_pos ( int  scroll_x,
int  scroll_y,
float  zoom 
)

Set the scroll position (origin) of the mapview, and update the GUI.

Definition at line 1215 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), and scrollbar_jump_callback().

◆ 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 2363 of file mapview_common.c.

Referenced by update_city_descriptions(), and 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 2437 of file mapview_common.c.

Referenced by update_map_canvas().

◆ tile_to_canvas_pos()

bool tile_to_canvas_pos ( float canvas_x,
float canvas_y,
float  zoom,
const struct tile ptile 
)

◆ 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 1282 of file mapview_common.c.

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 1264 of file mapview_common.c.

Referenced by 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,
int tset_topo 
)

Are the topology and tileset compatible?

Definition at line 3999 of file mapview_common.c.

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 1491 of file mapview_common.c.

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 1509 of file mapview_common.c.

Referenced by key_city_overlay().

◆ unqueue_mapview_updates()

void unqueue_mapview_updates ( bool  write_to_screen)

◆ update_animation()

void update_animation ( void  )

Progress current animation

Definition at line 439 of file mapview_common.c.

Referenced by animation_idle_cb(), and map_canvas_draw().

◆ update_city_description()

void update_city_description ( struct city pcity)

◆ 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 1736 of file mapview_common.c.

Referenced by advance_global_anim_state(), base_set_mapview_origin(), editor_end_selection_rectangle(), explosion_animation(), movement_animation(), unqueue_mapview_updates(), and update_animation().

◆ update_map_canvas_visible()

void update_map_canvas_visible ( void  )

◆ update_tile_label()

void update_tile_label ( struct tile ptile)

Update the label for the given tile

Definition at line 1888 of file mapview_common.c.

Referenced by show_tile_labels().

Variable Documentation

◆ can_slide

bool can_slide
extern

◆ mapview

struct view mapview
extern