Freeciv21
Develop your civilization from humble roots to a global empire
gold_widget Class Reference

Top bar widget that shows the amount of gold owned by the current player, and their income. More...

#include <top_bar.h>

+ Inheritance diagram for gold_widget:
+ Collaboration diagram for gold_widget:

Public Types

enum class  warning { no_warning = 0 , losing_money = 1 , low_on_funds = 2 }
 Types of warnings displayed by gold_widget. More...
 

Public Member Functions

 gold_widget ()
 Constructor. More...
 
 ~gold_widget () override
 Destructor. More...
 
int income () const
 Returns the incom as currently shown. More...
 
void set_income (int income)
 Changes the gold amount shown by the widget. More...
 
int gold () const
 Returns the gold amount as currently shown. More...
 
void set_gold (int gold)
 Changes the gold amount shown by the widget. More...
 
warning current_warning () const
 Retrieves the current warning. More...
 
- Public Member Functions inherited from top_bar_widget
 top_bar_widget (const QString &label, const QString &pg, pfcn func)
 Sidewidget constructor. More...
 
 ~top_bar_widget () override
 Sidewidget destructor. More...
 
int getPriority ()
 
QPixmap * get_pixmap ()
 
void paint (QPainter *painter, QPaintEvent *event)
 
void setCustomLabels (const QString &)
 Sets custom text visible on top of sidewidget. More...
 
void setLabel (const QString &str)
 
void setLeftClick (pfcn func)
 Sets callback for mouse left click. More...
 
void setRightClick (pfcn func)
 Sets callback for mouse right click. More...
 
void setWheelDown (pfcn func)
 Sets callback for mouse wheel down. More...
 
void setWheelUp (pfcn func)
 Sets callback for mouse wheel up. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Renders the national budget widget. More...
 
- Protected Member Functions inherited from top_bar_widget
void mousePressEvent (QMouseEvent *event) override
 Mouse press event for sidewidget. More...
 
void paintEvent (QPaintEvent *event) override
 Paint event for top bar widget. More...
 
void wheelEvent (QWheelEvent *event) override
 Mouse wheel event. More...
 

Properties

warning current_warning
 

Private Member Functions

void update_contents ()
 Updates the displayed text after the gold or income changed. More...
 

Private Attributes

int m_gold = 0
 
int m_income = 0
 
warning m_warning = warning::no_warning
 

Additional Inherited Members

- Public Slots inherited from top_bar_widget
void sblink ()
 Blinks current top_bar widget. More...
 
void someSlot ()
 Miscelanous slot, helping observe players currently, and changing science extra functionality might be added, eg by setting properties. More...
 
- Public Attributes inherited from top_bar_widget
bool blink
 
bool keep_blinking
 
QString page
 

Detailed Description

Top bar widget that shows the amount of gold owned by the current player, and their income.

The top bar widget displays a warning when the player has negative income or will go bankrupt.

Definition at line 109 of file top_bar.h.

Member Enumeration Documentation

◆ warning

enum gold_widget::warning
strong

Types of warnings displayed by gold_widget.

Enumerator
no_warning 

Used when no warning is shown.

losing_money 

The current player has negative gold income.

low_on_funds 

The current player will soon go bankrupt.

Definition at line 115 of file top_bar.h.

Constructor & Destructor Documentation

◆ gold_widget()

gold_widget::gold_widget ( )

Constructor.

Definition at line 360 of file top_bar.cpp.

◆ ~gold_widget()

gold_widget::~gold_widget ( )
override

Destructor.

Definition at line 370 of file top_bar.cpp.

Member Function Documentation

◆ current_warning()

warning gold_widget::current_warning ( ) const
inline

Retrieves the current warning.

Definition at line 146 of file top_bar.h.

◆ gold()

int gold_widget::gold ( ) const
inline

Returns the gold amount as currently shown.

Definition at line 136 of file top_bar.h.

Referenced by set_gold().

◆ income()

int gold_widget::income ( ) const
inline

Returns the incom as currently shown.

Definition at line 126 of file top_bar.h.

Referenced by set_income(), and update_contents().

◆ paintEvent()

void gold_widget::paintEvent ( QPaintEvent *  event)
overrideprotected

Renders the national budget widget.

Definition at line 407 of file top_bar.cpp.

◆ set_gold()

void gold_widget::set_gold ( int  gold)
inline

Changes the gold amount shown by the widget.

Definition at line 139 of file top_bar.h.

Referenced by pageGame::updateInfoLabelTimeout().

◆ set_income()

void gold_widget::set_income ( int  income)
inline

Changes the gold amount shown by the widget.

Definition at line 129 of file top_bar.h.

Referenced by pageGame::updateInfoLabelTimeout().

◆ update_contents()

void gold_widget::update_contents ( )
private

Updates the displayed text after the gold or income changed.

Definition at line 375 of file top_bar.cpp.

Referenced by set_gold(), and set_income().

Member Data Documentation

◆ m_gold

int gold_widget::m_gold = 0
private

Definition at line 154 of file top_bar.h.

Referenced by gold(), income(), set_gold(), and update_contents().

◆ m_income

int gold_widget::m_income = 0
private

Definition at line 154 of file top_bar.h.

Referenced by set_income(), and update_contents().

◆ m_warning

warning gold_widget::m_warning = warning::no_warning
private

Definition at line 155 of file top_bar.h.

Referenced by current_warning(), and update_contents().

Property Documentation

◆ current_warning

warning gold_widget::current_warning
read

Definition at line 99 of file top_bar.h.