Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
mapview.cpp File Reference
#include <QMouseEvent>
#include <QPainter>
#include <QPixmap>
#include <QToolTip>
#include <QWheelEvent>
#include "log.h"
#include "support.h"
#include "calendar.h"
#include "game.h"
#include "map.h"
#include "research.h"
#include "climisc.h"
#include "mapctrl_common.h"
#include "menu.h"
#include "movement.h"
#include "overview_common.h"
#include "sprite.h"
#include "repodlgs.h"
#include "text.h"
#include "zoom.h"
#include "colors.h"
#include "fc_client.h"
#include "gui_main.h"
#include "mapview.h"
#include "qtg_cxxside.h"
#include "sidebar.h"

Go to the source code of this file.

Macros

#define MAX_DIRTY_RECTS   20
 

Functions

const charget_timeout_label_text ()
 
void destroy_city_dialog ()
 
bool is_point_in_area (int x, int y, int px, int py, int pxe, int pye)
 
void draw_calculated_trade_routes (QPainter *painter)
 
static void gui_to_overview (int *ovr_x, int *ovr_y, int gui_x, int gui_y)
 
void unscale_point (double scale_factor, int &x, int &y)
 
void update_info_label (void)
 
void update_unit_info_label (struct unit_list *punitlist)
 
void update_mouse_cursor (enum cursor_type new_cursor_type)
 
void qtg_update_timeout_label (void)
 
void update_turn_done_button (bool do_restore)
 
void set_indicator_icons (struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
 
struct canvasget_overview_window (void)
 
static void flush_mapcanvas (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
 
void dirty_rect (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
 
void dirty_all (void)
 
void flush_dirty (void)
 
void gui_flush (void)
 
void update_map_canvas_scrollbars (void)
 
void update_map_canvas_scrollbars_size (void)
 
void update_city_descriptions (void)
 
void pixmap_put_overlay_tile (int canvas_x, int canvas_y, struct sprite *ssprite)
 
void put_cross_overlay_tile (struct tile *ptile)
 
void draw_selection_rectangle (int canvas_x, int canvas_y, int w, int h)
 
void tileset_changed (void)
 
void get_overview_area_dimensions (int *width, int *height)
 
void overview_size_changed (void)
 
void update_overview_scroll_window_pos (int x, int y)
 
bool mapview_is_frozen (void)
 
void mapview_freeze (void)
 
void mapview_thaw (void)
 
void qtg_start_turn ()
 
void qtg_map_canvas_size_refresh (void)
 

Variables

static int mapview_frozen_level = 0
 
struct canvascanvas
 
static int num_dirty_rects = 0
 
static QRect dirty_rects [MAX_DIRTY_RECTS]
 
int last_center_enemy
 
int last_center_capital
 
int last_center_player_city
 
int last_center_enemy_city
 

Macro Definition Documentation

◆ MAX_DIRTY_RECTS

#define MAX_DIRTY_RECTS   20

Definition at line 59 of file mapview.cpp.

Function Documentation

◆ destroy_city_dialog()

void destroy_city_dialog ( )
extern

Closes city dialog

Definition at line 3835 of file citydlg.cpp.

Referenced by qtg_popdown_all_city_dialogs(), qtg_popdown_city_dialog(), city_dialog::refresh(), and tileset_changed().

◆ dirty_all()

void dirty_all ( void  )

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

Definition at line 1159 of file mapview.cpp.

Referenced by mapview_thaw().

◆ 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 1141 of file mapview.cpp.

◆ draw_calculated_trade_routes()

void draw_calculated_trade_routes ( QPainter painter)

Draws calculated trade routes

Definition at line 82 of file mapview.cpp.

Referenced by map_view::paint().

◆ draw_selection_rectangle()

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

Area Selection

Definition at line 1256 of file mapview.cpp.

◆ 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 1172 of file mapview.cpp.

◆ flush_mapcanvas()

static void flush_mapcanvas ( int  canvas_x,
int  canvas_y,
int  pixel_width,
int  pixel_height 
)
static

Flush the given part of the canvas buffer (if there is one) to the screen.

Definition at line 1131 of file mapview.cpp.

Referenced by flush_dirty().

◆ get_overview_area_dimensions()

void get_overview_area_dimensions ( int width,
int height 
)

Return the dimensions of the area (container widget; maximum size) for the overview.

Definition at line 1288 of file mapview.cpp.

◆ get_overview_window()

struct canvas * get_overview_window ( void  )

Return a canvas that is the overview window.

Definition at line 1121 of file mapview.cpp.

◆ get_timeout_label_text()

const char * get_timeout_label_text ( void  )

Get the text showing the timeout. This is generally displayed on the info panel.

Not re-entrant

Definition at line 1557 of file text.c.

Referenced by qtg_update_timeout_label(), and update_timeout_label().

◆ gui_flush()

void gui_flush ( void  )

Do any necessary synchronization to make sure the screen is up-to-date. The canvas should have already been flushed to screen via flush_dirty - all this function does is make sure the hardware has caught up.

Definition at line 1196 of file mapview.cpp.

◆ gui_to_overview()

static void gui_to_overview ( int ovr_x,
int ovr_y,
int  gui_x,
int  gui_y 
)
static

Converts gui to overview position.

Definition at line 590 of file mapview.cpp.

Referenced by minimap_view::draw_viewport(), minimap_view::scale_point(), and unscale_point().

◆ is_point_in_area()

bool is_point_in_area ( int  x,
int  y,
int  px,
int  py,
int  pxe,
int  pye 
)

Check if point x, y is in area (px -> pxe, py - pye)

Definition at line 71 of file mapview.cpp.

Referenced by map_view::find_place().

◆ mapview_freeze()

void mapview_freeze ( void  )

Freeze the drawing of the map.

Definition at line 1334 of file mapview.cpp.

◆ mapview_is_frozen()

bool mapview_is_frozen ( void  )

Return whether the map should be drawn or not.

Definition at line 1326 of file mapview.cpp.

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

◆ mapview_thaw()

void mapview_thaw ( void  )

Thaw the drawing of the map.

Definition at line 1342 of file mapview.cpp.

◆ overview_size_changed()

void overview_size_changed ( void  )

Called when the map size changes. This may be used to change the size of the GUI element holding the overview canvas. The overview.width and overview.height are updated if this function is called. It's used for first creation of overview only, later overview stays the same size, scaled by qt-specific function.

Definition at line 1302 of file mapview.cpp.

◆ pixmap_put_overlay_tile()

void pixmap_put_overlay_tile ( int  canvas_x,
int  canvas_y,
struct sprite ssprite 
)

Put overlay tile to pixmap

Definition at line 1229 of file mapview.cpp.

Referenced by put_cross_overlay_tile().

◆ put_cross_overlay_tile()

void put_cross_overlay_tile ( struct tile ptile)

Draw a cross-hair overlay on a tile.

Definition at line 1242 of file mapview.cpp.

◆ qtg_map_canvas_size_refresh()

void qtg_map_canvas_size_refresh ( void  )

Refresh map canvas size information

Definition at line 1459 of file mapview.cpp.

Referenced by setup_gui_funcs().

◆ qtg_start_turn()

void qtg_start_turn ( )

New turn callback

Definition at line 1447 of file mapview.cpp.

Referenced by setup_gui_funcs().

◆ qtg_update_timeout_label()

void qtg_update_timeout_label ( void  )

Update the timeout display. The timeout is the time until the turn ends, in seconds.

Definition at line 1086 of file mapview.cpp.

Referenced by setup_gui_funcs().

◆ set_indicator_icons()

void set_indicator_icons ( struct sprite bulb,
struct sprite sol,
struct sprite flake,
struct sprite gov 
)

Set information for the indicator icons typically shown in the main client window. The parameters tell which sprite to use for the indicator.

Definition at line 1112 of file mapview.cpp.

◆ tileset_changed()

void tileset_changed ( void  )

This function is called when the tileset is changed.

Definition at line 1264 of file mapview.cpp.

◆ unscale_point()

void unscale_point ( double  scale_factor,
int x,
int y 
)

Scales point from scaled overview coords to real overview coords.

Definition at line 713 of file mapview.cpp.

Referenced by minimap_view::mousePressEvent(), and minimap_thread::run().

◆ update_city_descriptions()

void update_city_descriptions ( void  )

Update (refresh) all city descriptions on the mapview.

Definition at line 1221 of file mapview.cpp.

◆ update_info_label()

void update_info_label ( void  )

Typically an info box is provided to tell the player about the state of their civilization. This function is called when the label is changed.

Definition at line 990 of file mapview.cpp.

◆ update_map_canvas_scrollbars()

void update_map_canvas_scrollbars ( void  )

Update (refresh) the locations of the mapview scrollbars (if it uses them).

Definition at line 1205 of file mapview.cpp.

◆ update_map_canvas_scrollbars_size()

void update_map_canvas_scrollbars_size ( void  )

Update the size of the sliders on the scrollbars.

Definition at line 1213 of file mapview.cpp.

◆ 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 1077 of file mapview.cpp.

◆ update_overview_scroll_window_pos()

void update_overview_scroll_window_pos ( int  x,
int  y 
)

Sets the position of the overview scroll window based on mapview position.

Definition at line 1318 of file mapview.cpp.

◆ 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 1098 of file mapview.cpp.

◆ update_unit_info_label()

void update_unit_info_label ( struct unit_list *  punitlist)

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 NULL.

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 1066 of file mapview.cpp.

Referenced by tileset_changed().

Variable Documentation

◆ canvas

struct canvas* canvas
extern

◆ dirty_rects

QRect dirty_rects[MAX_DIRTY_RECTS]
static

Definition at line 61 of file mapview.cpp.

Referenced by dirty_rect(), and flush_dirty().

◆ last_center_capital

int last_center_capital
extern

Definition at line 68 of file pages.cpp.

Referenced by qtg_start_turn().

◆ last_center_enemy

int last_center_enemy
extern

Definition at line 81 of file pages.cpp.

Referenced by cycle_enemy_units(), and qtg_start_turn().

◆ last_center_enemy_city

int last_center_enemy_city
extern

Definition at line 70 of file pages.cpp.

Referenced by center_next_enemy_city(), and qtg_start_turn().

◆ last_center_player_city

int last_center_player_city
extern

Definition at line 69 of file pages.cpp.

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

◆ mapview_frozen_level

int mapview_frozen_level = 0
static

Definition at line 55 of file mapview.cpp.

Referenced by mapview_freeze(), mapview_is_frozen(), and mapview_thaw().

◆ num_dirty_rects

int num_dirty_rects = 0
static

Definition at line 60 of file mapview.cpp.

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