Freeciv-3.3
Loading...
Searching...
No Matches
hudwidget.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__HUDWIDGET_H
15#define FC__HUDWIDGET_H
16
17// Needed for the moc-generated meta file
18#ifdef HAVE_CONFIG_H
19#include <fc_config.h>
20#endif
21
22// Qt
23#include <QDialog>
24#include <QElapsedTimer>
25#include <QEnterEvent>
26#include <QLabel>
27#include <QLineEdit>
28#include <QMessageBox>
29#include <QRubberBand>
30#include <QTableWidget>
31
32// common
33#include "unit.h"
34
35// gui-qt
36#include "shortcuts.h"
37
38class move_widget;
39class QComboBox;
40class QHBoxLayout;
41class QIcon;
42class QLabel;
43class QRadioButton;
44class QVBoxLayout;
45struct tile;
46struct unit;
47struct unit_list;
48
51
52/****************************************************************************
53 Custom message box with animated background
54****************************************************************************/
81
82/****************************************************************************
83 Class for showing text on screen
84****************************************************************************/
85class hud_text: public QWidget
86{
88public:
89 hud_text(QString s, int time_secs, QWidget *parent);
90 ~hud_text();
91 void show_me();
92protected:
95private:
96 void center_me();
105};
106
107/****************************************************************************
108 Custom input box with animated background
109****************************************************************************/
136
137/****************************************************************************
138 Custom label to center on current unit
139****************************************************************************/
140class click_label : public QLabel
141{
143public:
144 click_label();
145signals:
147private slots:
148 void on_clicked();
149protected:
151};
152
153/****************************************************************************
154 Single action on unit actions
155****************************************************************************/
156class hud_action : public QWidget
157{
160 bool focus;
161public:
162 hud_action(QWidget *parent);
163 ~hud_action();
164 void set_pixmap(QPixmap *p);
166signals:
169protected:
173 void leaveEvent(QEvent *event);
174#ifndef FC_QT5_MODE
176#else // FC_QT5_MODE
177 void enterEvent(QEvent *event);
178#endif // FC_QT5_MODE
179private slots:
180 void on_clicked();
181 void on_right_clicked();
182};
183
184/****************************************************************************
185 List of unit actions
186****************************************************************************/
187class unit_actions: public QWidget
188{
190public:
191 unit_actions(QWidget *parent, unit *punit);
193 void init_layout();
194 int update_actions();
195 void clear_layout();
198private:
200};
201
202/****************************************************************************
203 Widget showing current unit, tile and possible actions
204****************************************************************************/
205class hud_units: public QFrame
206{
214public:
215 hud_units(QWidget *parent);
216 ~hud_units();
217 void update_actions(unit_list *punits);
218protected:
220private:
222 unit_list *ul_units;
224};
225
226/****************************************************************************
227 Widget allowing load units on transport
228****************************************************************************/
229class hud_unit_loader : public QTableWidget
230{
233public:
234 hud_unit_loader(struct unit *pcargo, struct tile *ptile);
236 void show_me();
237protected slots:
239private:
240 struct unit *cargo;
241 struct tile *qtile;
242};
243
244/****************************************************************************
245 Widget allowing quick select given type of units
246****************************************************************************/
290
291/****************************************************************************
292 Widget showing one combat result
293****************************************************************************/
294class hud_unit_combat : public QWidget
295{
297public:
298 hud_unit_combat(int attacker_unit_id, int defender_unit_id,
299 int attacker_hp, int defender_hp,
300 bool make_att_veteran, bool make_def_veteran,
301 float scale, QWidget *parent);
303 bool get_focus();
304 void set_fading(float fade);
305 void set_scale(float scale);
306protected:
309 void leaveEvent(QEvent *event);
310#ifndef FC_QT5_MODE
312#else // FC_QT5_MODE
313 void enterEvent(QEvent *event);
314#endif // FC_QT5_MODE
315private:
316 void init_images(bool redraw = false);
323 struct unit *attacker;
324 struct unit *defender;
328 bool focus;
329 float fading;
332};
333
334/****************************************************************************
335 Widget for resizing other widgets
336****************************************************************************/
337class scale_widget : public QRubberBand
338{
340public:
341 scale_widget(Shape s, QWidget *p = 0);
342 float scale;
343protected:
346private:
347 int size;
350};
351
352
353/****************************************************************************
354 Widget showing combat log
355****************************************************************************/
356class hud_battle_log : public QWidget
357{
361public:
362 hud_battle_log(QWidget *parent);
365 void set_scale(float s);
366 float scale;
367protected:
372private:
373 void update_size();
374 void te_inner();
375
379};
380
381#endif // FC__HUDWIDGET_H
382
void left_clicked()
void mousePressEvent(QMouseEvent *e)
void on_clicked()
void paintEvent(QPaintEvent *event)
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void on_clicked()
void mouseMoveEvent(QMouseEvent *event)
void right_clicked()
QPixmap * action_pixmap
Definition hudwidget.h:159
void on_right_clicked()
void enterEvent(QEnterEvent *event)
shortcut_id action_shortcut
Definition hudwidget.h:165
void left_clicked()
void set_pixmap(QPixmap *p)
move_widget * mw
Definition hudwidget.h:377
QList< hud_unit_combat * > lhuc
Definition hudwidget.h:360
QElapsedTimer m_timer
Definition hudwidget.h:378
void add_combat_info(hud_unit_combat *huc)
QVBoxLayout * main_layout
Definition hudwidget.h:359
void moveEvent(QMoveEvent *event)
void timerEvent(QTimerEvent *event)
scale_widget * sw
Definition hudwidget.h:376
void paintEvent(QPaintEvent *event)
void set_scale(float s)
void showEvent(QShowEvent *event)
QString cs1
Definition hudwidget.h:131
void set_text_title_definput(QString s1, QString s2, QString def_input)
void paintEvent(QPaintEvent *event)
QElapsedTimer m_timer
Definition hudwidget.h:113
QString cs2
Definition hudwidget.h:131
void timerEvent(QTimerEvent *event)
QFontMetrics * fm_text
Definition hudwidget.h:128
QLineEdit input_edit
Definition hudwidget.h:119
QFontMetrics * fm_title
Definition hudwidget.h:129
QString text
Definition hudwidget.h:126
QString title
Definition hudwidget.h:127
QFontMetrics * fm_text
Definition hudwidget.h:73
QString title
Definition hudwidget.h:72
QElapsedTimer m_timer
Definition hudwidget.h:58
void timerEvent(QTimerEvent *event)
void paintEvent(QPaintEvent *event)
int set_text_title(QString s1, QString s2, bool return_exec=false)
void keyPressEvent(QKeyEvent *event)
QFontMetrics * fm_title
Definition hudwidget.h:74
QElapsedTimer m_timer
Definition hudwidget.h:101
QString text
Definition hudwidget.h:100
void timerEvent(QTimerEvent *event)
QFont f_text
Definition hudwidget.h:103
int timeout
Definition hudwidget.h:98
void center_me()
QFont f_title
Definition hudwidget.h:104
QRect bound_rect
Definition hudwidget.h:97
void show_me()
void paintEvent(QPaintEvent *event)
QFontMetrics * fm_text
Definition hudwidget.h:102
int m_animate_step
Definition hudwidget.h:99
void set_fading(float fade)
struct unit * defender
Definition hudwidget.h:324
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *event)
void init_images(bool redraw=false)
struct unit * attacker
Definition hudwidget.h:323
const struct unit_type * type_attacker
Definition hudwidget.h:325
void set_scale(float scale)
struct tile * center_tile
Definition hudwidget.h:327
const struct unit_type * type_defender
Definition hudwidget.h:326
void enterEvent(QEnterEvent *event)
struct tile * qtile
Definition hudwidget.h:241
struct unit * cargo
Definition hudwidget.h:240
void selection_changed(const QItemSelection &, const QItemSelection &)
QList< unit * > transports
Definition hudwidget.h:231
QLabel text_label
Definition hudwidget.h:210
void update_actions(unit_list *punits)
void moveEvent(QMoveEvent *event)
click_label unit_label
Definition hudwidget.h:208
QFont * ufont
Definition hudwidget.h:211
click_label tile_label
Definition hudwidget.h:209
move_widget * mw
Definition hudwidget.h:221
unit_list * ul_units
Definition hudwidget.h:222
tile * current_tile
Definition hudwidget.h:223
QHBoxLayout * main_layout
Definition hudwidget.h:212
unit_actions * unit_icons
Definition hudwidget.h:213
void paintEvent(QPaintEvent *event)
void mousePressEvent(QMouseEvent *event)
QPixmap minus
Definition hudwidget.h:349
QPixmap plus
Definition hudwidget.h:348
void clear_layout()
QList< hud_action * > actions
Definition hudwidget.h:197
void init_layout()
unit * current_unit
Definition hudwidget.h:199
int update_actions()
QHBoxLayout * layout
Definition hudwidget.h:196
QRadioButton * this_continent
Definition hudwidget.h:282
QComboBox * unit_sel_type
Definition hudwidget.h:251
QRadioButton * sentried
Definition hudwidget.h:274
void keyPressEvent(QKeyEvent *event)
QVBoxLayout * main_layout
Definition hudwidget.h:250
QRadioButton * anywhere
Definition hudwidget.h:284
QRadioButton * main_continent
Definition hudwidget.h:283
QRadioButton * full_hp_mp
Definition hudwidget.h:279
QPushButton * cancel
Definition hudwidget.h:253
bool island_filter(struct unit *punit)
bool type_filter(struct unit *punit)
QRadioButton * full_mp
Definition hudwidget.h:277
void select_units(int x=0)
QRadioButton * fortified
Definition hudwidget.h:272
QRadioButton * this_tile
Definition hudwidget.h:281
QRadioButton * any_type
Definition hudwidget.h:287
QRadioButton * any_activity
Definition hudwidget.h:271
QPushButton * select
Definition hudwidget.h:252
QRadioButton * any
Definition hudwidget.h:276
bool activity_filter(struct unit *punit)
bool hp_filter(struct unit *punit)
QRadioButton * full_hp
Definition hudwidget.h:278
QRadioButton * this_type
Definition hudwidget.h:286
QRadioButton * idle
Definition hudwidget.h:273
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
enum event_type event
Definition events.c:81
int Unit_type_id
Definition fc_types.h:241
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
void show_new_turn_info()
struct player_slot * slots
Definition player.c:51
shortcut_id
Definition shortcuts.h:33
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
struct sprite int x
Definition sprite_g.h:31
Definition tile.h:50
Definition unit.h:140