Freeciv21
Develop your civilization from humble roots to a global empire
overview_common.cpp File Reference
#include <cmath>
#include "log.h"
#include "client_main.h"
#include "climap.h"
#include "control.h"
#include "mapview_g.h"
#include "options.h"
#include "overview_common.h"
#include <QPainter>
#include <QPixmap>
#include <qnamespace.h>
+ Include dependency graph for overview_common.cpp:

Go to the source code of this file.

Functions

static void overview_update_tile (const tile *ptile)
 Redraw the given map position in the overview canvas. More...
 
void gui_to_natural_pos (const struct tileset *t, double *ntl_x, double *ntl_y, int gui_x, int gui_y)
 Translate from gui to natural coordinate systems. More...
 
void gui_to_overview_pos (const struct tileset *t, int *ovr_x, int *ovr_y, int gui_x, int gui_y)
 Translate from gui to overview coordinate systems. More...
 
static QColor overview_tile_color (const tile *ptile)
 Return color for overview map tile. More...
 
static void redraw_overview ()
 Copies the overview image from the backing store to the window and draws the viewrect on top of it. More...
 
static void dirty_overview ()
 Mark the overview as "dirty" so that it will be redrawn soon. More...
 
void flush_dirty_overview ()
 Redraw the overview if it is "dirty". More...
 
void overview_to_map_pos (int *map_x, int *map_y, int overview_x, int overview_y)
 Finds the map coordinates for a given overview (canvas) position. More...
 
void refresh_overview_canvas ()
 Redraw the entire backing store for the overview minimap. More...
 
static void put_overview_tile_area (QPixmap *pcanvas, const tile *ptile, int x, int y, int w, int h)
 Draws the color for this tile onto the given rectangle of the canvas. More...
 
void calculate_overview_dimensions ()
 Called if the map size is know or changes. More...
 
void overview_init ()
 Allocates overview resources. More...
 
void overview_free ()
 Free overview resources. More...
 
void overview_redraw_callback (struct option *option)
 Callback to be called when an overview option is changed. More...
 

Variables

int OVERVIEW_TILE_SIZE = 2
 

Function Documentation

◆ calculate_overview_dimensions()

void calculate_overview_dimensions ( )

Called if the map size is know or changes.

Definition at line 357 of file overview_common.cpp.

Referenced by handle_map_info().

◆ dirty_overview()

static void dirty_overview ( )
static

Mark the overview as "dirty" so that it will be redrawn soon.

Definition at line 244 of file overview_common.cpp.

Referenced by overview_update_tile().

◆ flush_dirty_overview()

void flush_dirty_overview ( )

Redraw the overview if it is "dirty".

This module contains various general - mostly highlevel - functions used throughout the client.

Definition at line 249 of file overview_common.cpp.

Referenced by client_remove_unit(), decrease_unit_hp_smooth(), do_move_unit(), handle_unit_bombard_info(), map_canvas_resized(), and unit_focus_set().

◆ gui_to_natural_pos()

void gui_to_natural_pos ( const struct tileset t,
double *  ntl_x,
double *  ntl_y,
int  gui_x,
int  gui_y 
)

Translate from gui to natural coordinate systems.

This provides natural coordinates as a floating-point value so there is no loss of information in the resulting values.

Definition at line 64 of file overview_common.cpp.

Referenced by gui_to_overview_pos().

◆ gui_to_overview_pos()

void gui_to_overview_pos ( const struct tileset t,
int *  ovr_x,
int *  ovr_y,
int  gui_x,
int  gui_y 
)

Translate from gui to overview coordinate systems.

Definition at line 91 of file overview_common.cpp.

Referenced by redraw_overview().

◆ overview_free()

void overview_free ( )

Free overview resources.

Definition at line 445 of file overview_common.cpp.

Referenced by client_exit().

◆ overview_init()

void overview_init ( )

Allocates overview resources.

Definition at line 434 of file overview_common.cpp.

Referenced by init_mapcanvas_and_overview().

◆ overview_redraw_callback()

void overview_redraw_callback ( struct option option)

Callback to be called when an overview option is changed.

Definition at line 459 of file overview_common.cpp.

Referenced by init_client_options().

◆ overview_tile_color()

static QColor overview_tile_color ( const tile ptile)
static

Return color for overview map tile.

Definition at line 125 of file overview_common.cpp.

Referenced by put_overview_tile_area().

◆ overview_to_map_pos()

void overview_to_map_pos ( int *  map_x,
int *  map_y,
int  overview_x,
int  overview_y 
)

Finds the map coordinates for a given overview (canvas) position.

Definition at line 261 of file overview_common.cpp.

Referenced by minimap_view::mousePressEvent().

◆ overview_update_tile()

static void overview_update_tile ( const tile ptile)
static

Redraw the given map position in the overview canvas.

Definition at line 312 of file overview_common.cpp.

Referenced by refresh_overview_canvas().

◆ put_overview_tile_area()

static void put_overview_tile_area ( QPixmap *  pcanvas,
const tile ptile,
int  x,
int  y,
int  w,
int  h 
)
static

Draws the color for this tile onto the given rectangle of the canvas.

This is just a simple helper function for overview_update_tile, since sometimes a tile may cover more than one rectangle.

Definition at line 297 of file overview_common.cpp.

Referenced by overview_update_tile().

◆ redraw_overview()

static void redraw_overview ( )
static

Copies the overview image from the backing store to the window and draws the viewrect on top of it.

Definition at line 192 of file overview_common.cpp.

Referenced by flush_dirty_overview(), and refresh_overview_canvas().

◆ refresh_overview_canvas()

void refresh_overview_canvas ( )

Redraw the entire backing store for the overview minimap.

Definition at line 281 of file overview_common.cpp.

Referenced by calculate_overview_dimensions(), client_state(), overview_redraw_callback(), and minimap_panel::setup_minimap_menu().

Variable Documentation

◆ OVERVIEW_TILE_SIZE