Freeciv-3.4
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);
175private slots:
176 void on_clicked();
177 void on_right_clicked();
178};
179
180/****************************************************************************
181 List of unit actions
182****************************************************************************/
183class unit_actions: public QWidget
184{
186public:
187 unit_actions(QWidget *parent, unit *punit);
189 void init_layout();
190 int update_actions();
191 void clear_layout();
194private:
196};
197
198/****************************************************************************
199 Widget showing current unit, tile and possible actions
200****************************************************************************/
201class hud_units: public QFrame
202{
210public:
211 hud_units(QWidget *parent);
212 ~hud_units();
213 void update_actions(unit_list *punits);
214protected:
216private:
218 unit_list *ul_units;
220};
221
222/****************************************************************************
223 Widget allowing load units on transport
224****************************************************************************/
225class hud_unit_loader : public QTableWidget
226{
229public:
230 hud_unit_loader(struct unit *pcargo, struct tile *ptile);
232 void show_me();
233protected slots:
235private:
236 struct unit *cargo;
237 struct tile *qtile;
238};
239
240/****************************************************************************
241 Widget allowing quick select given type of units
242****************************************************************************/
286
287/****************************************************************************
288 Widget showing one combat result
289****************************************************************************/
290class hud_unit_combat : public QWidget
291{
293public:
294 hud_unit_combat(int attacker_unit_id, int defender_unit_id,
295 int attacker_hp, int defender_hp,
296 bool make_att_veteran, bool make_def_veteran,
297 float scale, QWidget *parent);
299 bool get_focus();
300 void set_fading(float fade);
301 void set_scale(float scale);
302protected:
305 void leaveEvent(QEvent *event);
307private:
308 void init_images(bool redraw = false);
315 struct unit *attacker;
316 struct unit *defender;
320 bool focus;
321 float fading;
324};
325
326/****************************************************************************
327 Widget for resizing other widgets
328****************************************************************************/
329class scale_widget : public QRubberBand
330{
332public:
333 scale_widget(Shape s, QWidget *p = 0);
334 float scale;
335protected:
338private:
339 int size;
342};
343
344
345/****************************************************************************
346 Widget showing combat log
347****************************************************************************/
348class hud_battle_log : public QWidget
349{
353public:
354 hud_battle_log(QWidget *parent);
357 void set_scale(float s);
358 float scale;
359protected:
364private:
365 void update_size();
366 void te_inner();
367
371};
372
373#endif // FC__HUDWIDGET_H
374
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:369
QList< hud_unit_combat * > lhuc
Definition hudwidget.h:352
QElapsedTimer m_timer
Definition hudwidget.h:370
void add_combat_info(hud_unit_combat *huc)
QVBoxLayout * main_layout
Definition hudwidget.h:351
void moveEvent(QMoveEvent *event)
void timerEvent(QTimerEvent *event)
scale_widget * sw
Definition hudwidget.h:368
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:316
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *event)
void init_images(bool redraw=false)
struct unit * attacker
Definition hudwidget.h:315
const struct unit_type * type_attacker
Definition hudwidget.h:317
void set_scale(float scale)
struct tile * center_tile
Definition hudwidget.h:319
const struct unit_type * type_defender
Definition hudwidget.h:318
void enterEvent(QEnterEvent *event)
struct tile * qtile
Definition hudwidget.h:237
struct unit * cargo
Definition hudwidget.h:236
void selection_changed(const QItemSelection &, const QItemSelection &)
QList< unit * > transports
Definition hudwidget.h:227
QLabel text_label
Definition hudwidget.h:206
void update_actions(unit_list *punits)
void moveEvent(QMoveEvent *event)
click_label unit_label
Definition hudwidget.h:204
QFont * ufont
Definition hudwidget.h:207
click_label tile_label
Definition hudwidget.h:205
move_widget * mw
Definition hudwidget.h:217
unit_list * ul_units
Definition hudwidget.h:218
tile * current_tile
Definition hudwidget.h:219
QHBoxLayout * main_layout
Definition hudwidget.h:208
unit_actions * unit_icons
Definition hudwidget.h:209
void paintEvent(QPaintEvent *event)
void mousePressEvent(QMouseEvent *event)
QPixmap minus
Definition hudwidget.h:341
QPixmap plus
Definition hudwidget.h:340
void clear_layout()
QList< hud_action * > actions
Definition hudwidget.h:193
void init_layout()
unit * current_unit
Definition hudwidget.h:195
int update_actions()
QHBoxLayout * layout
Definition hudwidget.h:192
QRadioButton * this_continent
Definition hudwidget.h:278
QComboBox * unit_sel_type
Definition hudwidget.h:247
QRadioButton * sentried
Definition hudwidget.h:270
void keyPressEvent(QKeyEvent *event)
QVBoxLayout * main_layout
Definition hudwidget.h:246
QRadioButton * anywhere
Definition hudwidget.h:280
QRadioButton * main_continent
Definition hudwidget.h:279
QRadioButton * full_hp_mp
Definition hudwidget.h:275
QPushButton * cancel
Definition hudwidget.h:249
bool island_filter(struct unit *punit)
bool type_filter(struct unit *punit)
QRadioButton * full_mp
Definition hudwidget.h:273
void select_units(int x=0)
QRadioButton * fortified
Definition hudwidget.h:268
QRadioButton * this_tile
Definition hudwidget.h:277
QRadioButton * any_type
Definition hudwidget.h:283
QRadioButton * any_activity
Definition hudwidget.h:267
QPushButton * select
Definition hudwidget.h:248
QRadioButton * any
Definition hudwidget.h:272
bool activity_filter(struct unit *punit)
bool hp_filter(struct unit *punit)
QRadioButton * full_hp
Definition hudwidget.h:274
QRadioButton * this_type
Definition hudwidget.h:282
QRadioButton * idle
Definition hudwidget.h:269
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:242
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