Freeciv21
Develop your civilization from humble roots to a global empire
citybar_painter Class Referenceabstract

Abstraction for city bars of various styles. More...

#include <citybar.h>

+ Inheritance diagram for citybar_painter:
+ Collaboration diagram for citybar_painter:

Public Member Functions

virtual ~citybar_painter ()=default
 
virtual QRect paint (QPainter &painter, const QPointF &position, const city *pcity) const =0
 Draws a city bar under the given position. More...
 
virtual bool has_flag () const
 Returns whether the flag is shown in the bar. More...
 
virtual bool has_units () const
 Returns whether the units inside are shown in the bar. More...
 
virtual bool has_size () const
 Returns whether the city size is shown in the bar. More...
 

Static Public Member Functions

static QStringList available ()
 Returns the list of all available city bar styles. More...
 
static const QVector< QString > * available_vector (const option *)
 Returns the list of all available city bar styles. More...
 
static void option_changed (option *opt)
 Called by the option code when the option has changed. More...
 
static citybar_paintercurrent ()
 Returns the current painter (never null). More...
 

Static Private Member Functions

static void set_current (const QString &name)
 Sets the current city bar style. More...
 

Static Private Attributes

static std::unique_ptr< citybar_painters_current = nullptr
 Pointer to the city bar painter currently in use. More...
 

Detailed Description

Abstraction for city bars of various styles.

Definition at line 32 of file citybar.h.

Constructor & Destructor Documentation

◆ ~citybar_painter()

virtual citybar_painter::~citybar_painter ( )
virtualdefault

Member Function Documentation

◆ available()

QStringList citybar_painter::available ( )
static

Returns the list of all available city bar styles.

The strings are not translated.

Definition at line 261 of file citybar.cpp.

Referenced by available_vector(), and set_current().

◆ available_vector()

const QVector< QString > * citybar_painter::available_vector ( const option )
static

Returns the list of all available city bar styles.

For compatibility with the option code.

Definition at line 271 of file citybar.cpp.

Referenced by init_client_options(), and mr_menu::setup_menus().

◆ current()

citybar_painter * citybar_painter::current ( )
static

Returns the current painter (never null).

Definition at line 295 of file citybar.cpp.

Referenced by freeciv::layer_city::fill_sprite_array(), freeciv::layer_city_size::fill_sprite_array(), polished_citybar_painter::paint(), and show_city_desc().

◆ has_flag()

virtual bool citybar_painter::has_flag ( ) const
inlinevirtual

Returns whether the flag is shown in the bar.

Reimplemented in simple_citybar_painter.

Definition at line 46 of file citybar.h.

◆ has_size()

virtual bool citybar_painter::has_size ( ) const
inlinevirtual

Returns whether the city size is shown in the bar.

Reimplemented in simple_citybar_painter.

Definition at line 56 of file citybar.h.

Referenced by freeciv::layer_city_size::fill_sprite_array().

◆ has_units()

virtual bool citybar_painter::has_units ( ) const
inlinevirtual

Returns whether the units inside are shown in the bar.

Reimplemented in simple_citybar_painter.

Definition at line 51 of file citybar.h.

◆ option_changed()

void citybar_painter::option_changed ( option opt)
static

Called by the option code when the option has changed.

Sets the current painter and refreshes the map.

Definition at line 286 of file citybar.cpp.

Referenced by init_client_options(), and mr_menu::slot_set_citybar().

◆ paint()

virtual QRect citybar_painter::paint ( QPainter &  painter,
const QPointF &  position,
const city pcity 
) const
pure virtual

Draws a city bar under the given position.

Returns the bounding box of the touched area.

Implemented in polished_citybar_painter, traditional_citybar_painter, and simple_citybar_painter.

◆ set_current()

void citybar_painter::set_current ( const QString &  name)
staticprivate

Sets the current city bar style.

The name should not be translated. Returns true on success.

Definition at line 307 of file citybar.cpp.

Referenced by current(), and option_changed().

Member Data Documentation

◆ s_current

std::unique_ptr< citybar_painter > citybar_painter::s_current = nullptr
staticprivate

Pointer to the city bar painter currently in use.

Definition at line 66 of file citybar.h.

Referenced by current(), and set_current().