Freeciv21
Develop your civilization from humble roots to a global empire
view_map.cpp File Reference
#include <memory>
#include <QCommandLinkButton>
#include <QMouseEvent>
#include <QPainter>
#include "log.h"
#include "citybar.h"
#include "citydlg_g.h"
#include "client_main.h"
#include "climap.h"
#include "climisc.h"
#include "colors_common.h"
#include "fc_client.h"
#include "fonts.h"
#include "hudwidget.h"
#include "mapctrl_common.h"
#include "mapview_g.h"
#include "messagewin.h"
#include "minimap_panel.h"
#include "page_game.h"
#include "qtg_cxxside.h"
#include "renderer.h"
#include "text.h"
#include "tileset/sprite.h"
#include "tileset/tilespec.h"
#include "top_bar.h"
#include "views/view_map.h"
#include "views/view_map_common.h"
#include "views/view_research.h"
#include "widgets/decorations.h"
+ Include dependency graph for view_map.cpp:

Go to the source code of this file.

Functions

void destroy_city_dialog ()
 
void draw_calculated_trade_routes (QPainter *painter)
 Draws calculated trade routes. More...
 
void update_unit_info_label (const std::vector< unit * > &unit_list)
 Update the information label which gives info on the current unit and the tile under the current unit, for specified unit. More...
 
void update_mouse_cursor (enum cursor_type new_cursor_type)
 Update the mouse cursor. More...
 
void update_turn_done_button (bool do_restore)
 If do_restore is false it should change the turn button style (to draw the user's attention to it). More...
 
void dirty_rect (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
 Mark the rectangular region as "dirty" so that we know to flush it later. More...
 
void dirty_all (void)
 Mark the entire screen area as "dirty" so that we can flush it later. More...
 
void flush_dirty ()
 Flush all regions that have been previously marked as dirty. More...
 
void pixmap_put_overlay_tile (int canvas_x, int canvas_y, const QPixmap *ssprite)
 Put overlay tile to pixmap. More...
 
void put_cross_overlay_tile (struct tile *ptile)
 Draw a cross-hair overlay on a tile. More...
 
void draw_selection_rectangle (int canvas_x, int canvas_y, int w, int h)
 Area Selection. More...
 
void tileset_changed (void)
 This function is called when the tileset is changed. More...
 
bool mapview_is_frozen ()
 Return whether the map should be drawn or not. More...
 
void popup_tile_info (struct tile *ptile)
 Popups information label tile. More...
 
void popdown_tile_info ()
 Popdowns information label tile. More...
 
void start_turn ()
 New turn callback. More...
 
void show_city_desc (QPixmap *pcanvas, int canvas_x, int canvas_y, struct city *pcity, int *width, int *height)
 Draw a description for the given city. More...
 
void debug_tile (tile *tile)
 Callback to set the tile being debugged. More...
 

Variables

static int mapview_frozen_level = 0
 
QPixmap * canvas
 
static QRegion dirty
 
int last_center_enemy
 
int last_center_capital
 
int last_center_player_city
 
int last_center_enemy_city
 

Function Documentation

◆ debug_tile()

void debug_tile ( tile tile)

Callback to set the tile being debugged.

Definition at line 757 of file view_map.cpp.

Referenced by do_map_click().

◆ destroy_city_dialog()

void destroy_city_dialog ( )

◆ dirty_all()

void dirty_all ( void  )

Mark the entire screen area as "dirty" so that we can flush it later.

Definition at line 494 of file view_map.cpp.

Referenced by base_set_mapview_origin().

◆ dirty_rect()

void dirty_rect ( int  canvas_x,
int  canvas_y,
int  pixel_width,
int  pixel_height 
)

Mark the rectangular region as "dirty" so that we know to flush it later.

Definition at line 480 of file view_map.cpp.

Referenced by animate_unit_explosion(), draw_segment(), move_unit_map_canvas(), put_nuke_mushroom_pixmaps(), and update_map_canvas().

◆ draw_calculated_trade_routes()

void draw_calculated_trade_routes ( QPainter *  painter)

Draws calculated trade routes.

Definition at line 65 of file view_map.cpp.

Referenced by map_view::paintEvent().

◆ draw_selection_rectangle()

void draw_selection_rectangle ( int  canvas_x,
int  canvas_y,
int  w,
int  h 
)

Area Selection.

Definition at line 546 of file view_map.cpp.

Referenced by cancel_selection_rectangle(), and editor_draw_selrect().

◆ flush_dirty()

void flush_dirty ( void  )

Flush all regions that have been previously marked as dirty.

See dirty_rect and dirty_all. This function is generally called after we've processed a batch of drawing operations.

Definition at line 507 of file view_map.cpp.

Referenced by animate_unit_explosion(), editor_end_selection_rectangle(), move_unit_map_canvas(), and put_nuke_mushroom_pixmaps().

◆ mapview_is_frozen()

bool mapview_is_frozen ( )

Return whether the map should be drawn or not.

Definition at line 607 of file view_map.cpp.

Referenced by dirty_all(), dirty_rect(), and flush_dirty().

◆ pixmap_put_overlay_tile()

void pixmap_put_overlay_tile ( int  canvas_x,
int  canvas_y,
const QPixmap *  ssprite 
)

Put overlay tile to pixmap.

Definition at line 520 of file view_map.cpp.

Referenced by put_cross_overlay_tile().

◆ popdown_tile_info()

void popdown_tile_info ( )

Popdowns information label tile.

Definition at line 702 of file view_map.cpp.

Referenced by map_view::shortcut_released().

◆ popup_tile_info()

void popup_tile_info ( struct tile ptile)

Popups information label tile.

Definition at line 682 of file view_map.cpp.

Referenced by map_view::shortcut_pressed().

◆ put_cross_overlay_tile()

void put_cross_overlay_tile ( struct tile ptile)

Draw a cross-hair overlay on a tile.

Definition at line 533 of file view_map.cpp.

Referenced by center_next_player_capital(), key_center_capital(), and unit_focus_set_and_select().

◆ show_city_desc()

void show_city_desc ( QPixmap *  pcanvas,
int  canvas_x,
int  canvas_y,
struct city pcity,
int *  width,
int *  height 
)

Draw a description for the given city.

This description may include the name, turns-to-grow, production, and city turns-to-build (depending on client options).

(canvas_x, canvas_y) gives the location on the given canvas at which to draw the description. This is the location of the city itself so the text must be drawn underneath it. pcity gives the city to be drawn, while (*width, *height) should be set by show_city_desc to contain the width and height of the text block (centered directly underneath the city's tile).

Definition at line 733 of file view_map.cpp.

Referenced by show_city_descriptions().

◆ start_turn()

void start_turn ( )

New turn callback.

Definition at line 712 of file view_map.cpp.

Referenced by handle_new_year().

◆ tileset_changed()

void tileset_changed ( void  )

This function is called when the tileset is changed.

Definition at line 554 of file view_map.cpp.

Referenced by fc_client::current_page(), and tilespec_reread().

◆ update_mouse_cursor()

void update_mouse_cursor ( enum cursor_type  new_cursor_type)

Update the mouse cursor.

Cursor type depends on what user is doing and pointing.

Definition at line 457 of file view_map.cpp.

Referenced by control_mouse_cursor().

◆ update_turn_done_button()

void update_turn_done_button ( bool  do_restore)

If do_restore is false it should change the turn button style (to draw the user's attention to it).

If called regularly from a timer this will give a blinking turn done button. If do_restore is true this should reset the turn done button to the default style.

Definition at line 468 of file view_map.cpp.

Referenced by blink_turn_done_button(), and update_turn_done_button_state().

◆ update_unit_info_label()

void update_unit_info_label ( const std::vector< unit * > &  unit_list)

Update the information label which gives info on the current unit and the tile under the current unit, for specified unit.

Note that in practice punit is always the focus unit.

Clears label if punit is nullptr.

Typically also updates the cursor for the map_canvas (this is related because the info label may includes "select destination" prompt etc). And it may call update_unit_pix_label() to update the icons for units on this tile.

Definition at line 446 of file view_map.cpp.

Referenced by client_remove_unit(), client_state(), do_map_click(), do_move_unit(), focus_units_changed(), handle_city_info(), handle_new_year(), handle_unit_packet_common(), is_valid_goto_draw_line(), key_cancel_action(), key_unit_action_select_tgt(), release_goto_button(), request_unit_connect(), request_unit_goto(), request_unit_paradrop(), request_unit_patrol(), and tileset_changed().

Variable Documentation

◆ canvas

QPixmap* canvas
extern

◆ dirty

QRegion dirty
static

Definition at line 54 of file view_map.cpp.

Referenced by dirty_all(), dirty_rect(), and flush_dirty().

◆ last_center_capital

int last_center_capital
extern

Definition at line 52 of file page_game.cpp.

Referenced by start_turn().

◆ last_center_enemy

int last_center_enemy
extern

Definition at line 55 of file page_game.cpp.

Referenced by cycle_enemy_units(), and start_turn().

◆ last_center_enemy_city

int last_center_enemy_city
extern

Definition at line 54 of file page_game.cpp.

Referenced by center_next_enemy_city(), and start_turn().

◆ last_center_player_city

int last_center_player_city
extern

Definition at line 53 of file page_game.cpp.

Referenced by center_next_player_capital(), center_next_player_city(), and start_turn().

◆ mapview_frozen_level

int mapview_frozen_level = 0
static

Definition at line 51 of file view_map.cpp.

Referenced by mapview_is_frozen().