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

#include <hudwidget.h>

+ Inheritance diagram for hud_unit_combat:
+ Collaboration diagram for hud_unit_combat:

Public Member Functions

 hud_unit_combat (int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran, float scale, QWidget *parent)
 Hud unit combat contructor, prepares images to show as result. More...
 
 ~hud_unit_combat () override
 Hud unit combat destructor. More...
 
bool get_focus ()
 Returns true if widget has focus (used to prevent hiding parent) More...
 
void set_fading (float fade)
 Sets widget fading. More...
 
void set_scale (float scale)
 Sets scale for images. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Paint event for hud_unit combat. More...
 
void mousePressEvent (QMouseEvent *e) override
 Mouse press event, centers on highlighted combat. More...
 
void leaveEvent (QEvent *event) override
 Leave event for hud unit combat. More...
 
void enterEvent (QEvent *event) override
 Leave event for hud unit combat. More...
 

Private Member Functions

void init_images (bool redraw=false)
 Draws images of units to pixmaps for later use. More...
 

Private Attributes

int att_hp = 0
 
int def_hp = 0
 
int att_hp_loss = 0
 
int def_hp_loss = 0
 
bool att_veteran = false
 
bool def_veteran = false
 
struct unitattacker = nullptr
 
struct unitdefender = nullptr
 
const struct unit_typetype_attacker = nullptr
 
const struct unit_typetype_defender = nullptr
 
struct tilecenter_tile = nullptr
 
bool focus = false
 
float fading = 0.0f
 
float hud_scale
 
QImage dimg
 
QImage aimg
 
bool att_win = false
 
bool def_win = false
 

Detailed Description

Definition at line 247 of file hudwidget.h.

Constructor & Destructor Documentation

◆ hud_unit_combat()

hud_unit_combat::hud_unit_combat ( int  attacker_unit_id,
int  defender_unit_id,
int  attacker_hp,
int  defender_hp,
bool  make_att_veteran,
bool  make_def_veteran,
float  scale,
QWidget *  parent 
)

Hud unit combat contructor, prepares images to show as result.

Definition at line 1358 of file hudwidget.cpp.

◆ ~hud_unit_combat()

hud_unit_combat::~hud_unit_combat ( )
overridedefault

Hud unit combat destructor.

Member Function Documentation

◆ enterEvent()

void hud_unit_combat::enterEvent ( QEvent *  event)
overrideprotected

Leave event for hud unit combat.

Shows highlight.

Definition at line 1577 of file hudwidget.cpp.

◆ get_focus()

bool hud_unit_combat::get_focus ( )

Returns true if widget has focus (used to prevent hiding parent)

Definition at line 1480 of file hudwidget.cpp.

◆ init_images()

void hud_unit_combat::init_images ( bool  redraw = false)
private

Draws images of units to pixmaps for later use.

Definition at line 1393 of file hudwidget.cpp.

Referenced by hud_unit_combat(), and set_scale().

◆ leaveEvent()

void hud_unit_combat::leaveEvent ( QEvent *  event)
overrideprotected

Leave event for hud unit combat.

Stops showing highlight.

Definition at line 1568 of file hudwidget.cpp.

◆ mousePressEvent()

void hud_unit_combat::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Mouse press event, centers on highlighted combat.

Definition at line 1560 of file hudwidget.cpp.

◆ paintEvent()

void hud_unit_combat::paintEvent ( QPaintEvent *  event)
overrideprotected

Paint event for hud_unit combat.

Definition at line 1485 of file hudwidget.cpp.

◆ set_fading()

void hud_unit_combat::set_fading ( float  fade)

Sets widget fading.

Definition at line 1471 of file hudwidget.cpp.

Referenced by hud_battle_log::add_combat_info().

◆ set_scale()

void hud_unit_combat::set_scale ( float  scale)

Sets scale for images.

Definition at line 1457 of file hudwidget.cpp.

Member Data Documentation

◆ aimg

QImage hud_unit_combat::aimg
private

Definition at line 281 of file hudwidget.h.

Referenced by init_images(), and paintEvent().

◆ att_hp

int hud_unit_combat::att_hp = 0
private

Definition at line 267 of file hudwidget.h.

Referenced by hud_unit_combat().

◆ att_hp_loss

int hud_unit_combat::att_hp_loss = 0
private

Definition at line 269 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ att_veteran

bool hud_unit_combat::att_veteran = false
private

Definition at line 271 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ att_win

bool hud_unit_combat::att_win = false
private

Definition at line 282 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ attacker

struct unit* hud_unit_combat::attacker = nullptr
private

Definition at line 273 of file hudwidget.h.

Referenced by hud_unit_combat(), and init_images().

◆ center_tile

struct tile* hud_unit_combat::center_tile = nullptr
private

Definition at line 277 of file hudwidget.h.

Referenced by hud_unit_combat(), and mousePressEvent().

◆ def_hp

int hud_unit_combat::def_hp = 0
private

Definition at line 268 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ def_hp_loss

int hud_unit_combat::def_hp_loss = 0
private

Definition at line 270 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ def_veteran

bool hud_unit_combat::def_veteran = false
private

Definition at line 272 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ def_win

bool hud_unit_combat::def_win = false
private

Definition at line 283 of file hudwidget.h.

Referenced by hud_unit_combat(), and paintEvent().

◆ defender

struct unit* hud_unit_combat::defender = nullptr
private

Definition at line 274 of file hudwidget.h.

Referenced by hud_unit_combat(), and init_images().

◆ dimg

QImage hud_unit_combat::dimg
private

Definition at line 281 of file hudwidget.h.

Referenced by init_images(), and paintEvent().

◆ fading

float hud_unit_combat::fading = 0.0f
private

Definition at line 279 of file hudwidget.h.

Referenced by paintEvent(), and set_fading().

◆ focus

bool hud_unit_combat::focus = false
private

Definition at line 278 of file hudwidget.h.

Referenced by enterEvent(), get_focus(), init_images(), leaveEvent(), and paintEvent().

◆ hud_scale

float hud_unit_combat::hud_scale
private

Definition at line 280 of file hudwidget.h.

Referenced by hud_unit_combat(), init_images(), paintEvent(), and set_scale().

◆ type_attacker

const struct unit_type* hud_unit_combat::type_attacker = nullptr
private

Definition at line 275 of file hudwidget.h.

Referenced by hud_unit_combat(), and init_images().

◆ type_defender

const struct unit_type* hud_unit_combat::type_defender = nullptr
private

Definition at line 276 of file hudwidget.h.

Referenced by hud_unit_combat(), and init_images().