Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::map_updates_handler Class Reference

Records regions of the map that should be updated. More...

#include <map_updates_handler.h>

+ Inheritance diagram for freeciv::map_updates_handler:
+ Collaboration diagram for freeciv::map_updates_handler:

Public Types

enum class  update_type {
  tile_single = 0x01 , tile_full = 0x02 , unit = 0x04 , city_description = 0x08 ,
  city_map = 0x10 , tile_label = 0x20
}
 What kind of update should be performed. More...
 
- Public Types inherited from listener< map_updates_handler >
typedef map_updates_handler type_t
 

Signals

void repaint_needed ()
 

Public Member Functions

 map_updates_handler (QObject *parent=nullptr)
 Constructor. More...
 
virtual ~map_updates_handler ()=default
 
bool full () const
 Returns true if the whole map should be updated. More...
 
auto list () const
 Returns the list of pending updates. More...
 
void clear ()
 Clears all pending updates. More...
 
void update (const city *city, bool full)
 Registers a city for update. More...
 
void update (const tile *tile, bool full)
 Registers a tile for update. More...
 
void update (const unit *unit, bool full)
 Registers a unit for update. More...
 
void update_all ()
 Requests an update of the whole (visible) map. More...
 
void update_city_description (const city *city)
 Registers a city label for update. More...
 
void update_tile_label (const tile *tile)
 Registers a tile label for update. More...
 

Private Attributes

bool m_full_update = false
 
std::map< const tile *, updates > m_updates
 

Additional Inherited Members

- Static Public Member Functions inherited from listener< map_updates_handler >
static void invoke (_member_fct_ function, _args_ &&...args)
 
- Protected Member Functions inherited from listener< map_updates_handler >
 listener ()
 
virtual ~listener ()
 
void listen ()
 

Detailed Description

Records regions of the map that should be updated.

This class records a list of all regions on the map that need an update, and the extent of the necessary update (as a combination of update_type). It has nothing to do with tilesets and doesn't know about the map geometry, but some tilesets assumptions are hard-coded.

Definition at line 21 of file map_updates_handler.h.

Member Enumeration Documentation

◆ update_type

What kind of update should be performed.

Enumerator
tile_single 
tile_full 
unit 
city_description 
city_map 
tile_label 

Definition at line 29 of file map_updates_handler.h.

Constructor & Destructor Documentation

◆ map_updates_handler()

freeciv::map_updates_handler::map_updates_handler ( QObject *  parent = nullptr)
explicit

Constructor.

Definition at line 27 of file map_updates_handler.cpp.

◆ ~map_updates_handler()

virtual freeciv::map_updates_handler::~map_updates_handler ( )
virtualdefault

Member Function Documentation

◆ clear()

void freeciv::map_updates_handler::clear ( )

Clears all pending updates.

Definition at line 35 of file map_updates_handler.cpp.

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

◆ full()

bool freeciv::map_updates_handler::full ( ) const
inline

Returns true if the whole map should be updated.

Definition at line 43 of file map_updates_handler.h.

Referenced by freeciv::renderer::unqueue_updates(), and update().

◆ list()

auto freeciv::map_updates_handler::list ( ) const
inline

Returns the list of pending updates.

Definition at line 46 of file map_updates_handler.h.

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

◆ repaint_needed

void freeciv::map_updates_handler::repaint_needed ( )
signal

◆ update() [1/3]

void freeciv::map_updates_handler::update ( const city city,
bool  full 
)

Registers a city for update.

If full, also update the city label.

See also
update_city_description

Definition at line 45 of file map_updates_handler.cpp.

Referenced by refresh_city_mapcanvas(), refresh_tile_mapcanvas(), and refresh_unit_mapcanvas().

◆ update() [2/3]

void freeciv::map_updates_handler::update ( const tile tile,
bool  full 
)

Registers a tile for update.

If full, also update the neighboring area.

Definition at line 62 of file map_updates_handler.cpp.

◆ update() [3/3]

void freeciv::map_updates_handler::update ( const unit unit,
bool  full 
)

Registers a unit for update.

Definition at line 77 of file map_updates_handler.cpp.

◆ update_all()

void freeciv::map_updates_handler::update_all ( )

Requests an update of the whole (visible) map.

Definition at line 96 of file map_updates_handler.cpp.

Referenced by update(), and update_map_canvas_visible().

◆ update_city_description()

void freeciv::map_updates_handler::update_city_description ( const city city)

Registers a city label for update.

See also
update(const city *, bool)

Definition at line 107 of file map_updates_handler.cpp.

Referenced by update_city_description().

◆ update_tile_label()

void freeciv::map_updates_handler::update_tile_label ( const tile tile)

Registers a tile label for update.

Definition at line 118 of file map_updates_handler.cpp.

Referenced by update_tile_label().

Member Data Documentation

◆ m_full_update

bool freeciv::map_updates_handler::m_full_update = false
private

◆ m_updates

std::map<const tile *, updates> freeciv::map_updates_handler::m_updates
private