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)
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 ***********************************************************************/
18 #include <fc_config.h>
22 #include "dialogs_g.h"
27 #include <QMessageBox>
32 #include "hudwidget.h"
46 typedef void (*pfcn_void
)(QVariant
, QVariant
);
47 void update_nationset_combo();
48 void popup_races_dialog(struct player
*pplayer
);
49 void restart_notify_dialogs();
54 Q_DISABLE_COPY(qdef_act
);
58 static qdef_act
* m_instance
;
62 static qdef_act
* action();
64 void vs_city_set(int i
);
65 void vs_unit_set(int i
);
70 /***************************************************************************
71 Nonmodal message box for disbanding units
72 ***************************************************************************/
73 class disband_box
: public hud_message_box
76 struct unit_list
*cpunits
;
78 explicit disband_box(struct unit_list
*punits
, QWidget
*parent
= 0);
81 void disband_clicked();
84 /***************************************************************************
86 ***************************************************************************/
87 class notify_goto
: public QMessageBox
90 QPushButton
*goto_but
;
91 QPushButton
*inspect_but
;
92 QPushButton
*close_but
;
95 notify_goto(const char *headline
, const char *lines
,
96 const struct text_tag_list
*tags
, struct tile
*ptile
,
104 /***************************************************************************
105 Dialog for selecting nation, style and leader leader
106 ***************************************************************************/
107 class races_dialog
:public QDialog
110 QGridLayout
*main_layout
;
111 QTableWidget
*nation_tabs
;
112 QList
<QWidget
*> *nations_tabs_list
;
113 QTableWidget
*selected_nation_tabs
;
114 QComboBox
*leader_name
;
115 QComboBox
*qnation_set
;
116 QRadioButton
*is_male
;
117 QRadioButton
*is_female
;
118 QTableWidget
*styles
;
119 QTextEdit
*description
;
120 QPushButton
*ok_button
;
121 QPushButton
*random_button
;
124 races_dialog(struct player
*pplayer
, QWidget
*parent
= 0);
127 void update_nationset_combo();
130 void set_index(int index
);
131 void nation_selected(const QItemSelection
&sl
, const QItemSelection
&ds
);
132 void style_selected(const QItemSelection
&sl
, const QItemSelection
&ds
);
133 void group_selected(const QItemSelection
&sl
, const QItemSelection
&ds
);
134 void nationset_changed(int index
);
135 void leader_selected(int index
);
137 void cancel_pressed();
138 void random_pressed();
144 struct player
*tplayer
;
148 /***************************************************************************
149 Widget around map view to display informations like demographics report,
150 top 5 cities, traveler's report.
151 ***************************************************************************/
152 class notify_dialog
:public fcwidget
156 notify_dialog(const char *caption
, const char *headline
,
157 const char *lines
, QWidget
*parent
= 0);
158 virtual void update_menu();
162 void mousePressEvent(QMouseEvent
*event
);
163 void mouseMoveEvent(QMouseEvent
*event
);
164 void mouseReleaseEvent(QMouseEvent
*event
);
166 void paintEvent(QPaintEvent
*paint_event
);
167 void calc_size(int &x
, int&y
);
178 /***************************************************************************
179 Transparent widget for selecting units
180 TODO Add some simple scrollbars (just paint it during paint event,
181 if 'more' is true->scroll visible and would depend on show_line
182 ***************************************************************************/
183 class units_select
: public fcwidget
187 QPixmap
*h_pix
; /** pixmap for highlighting */
188 QSize item_size
; /** size of each pixmap of unit */
189 QList
<unit
*> unit_list
; /** storing units only for drawing, for rest units
190 * iterate utile->units */
196 units_select(struct tile
*ptile
, QWidget
*parent
);
200 void create_pixmap();
203 void paint(QPainter
*painter
, QPaintEvent
*event
);
204 void paintEvent(QPaintEvent
*event
);
205 void mousePressEvent(QMouseEvent
*event
);
206 void keyPressEvent(QKeyEvent
*event
);
207 void mouseMoveEvent(QMouseEvent
*event
);
208 void wheelEvent(QWheelEvent
*event
);
209 void closeEvent(QCloseEvent
*event
);
218 /**************************************************************************
219 A QPushButton that includes data like function to call and parmeters
220 **************************************************************************/
221 class Choice_dialog_button
: public QPushButton
225 QVariant data1
, data2
;
227 Choice_dialog_button(const QString title
, pfcn_void func_in
,
228 QVariant data1_in
, QVariant data2_in
);
232 void setData1(QVariant wariat
);
233 void setData2(QVariant wariat
);
236 /***************************************************************************
237 Simple choice dialog, allowing choosing one of set actions
238 ***************************************************************************/
239 class choice_dialog
: public QWidget
242 QPushButton
*target_unit_button
;
243 QSignalMapper
*signal_mapper
;
245 QHBoxLayout
*unit_skip
;
246 QList
<Choice_dialog_button
*> buttons_list
;
247 QList
<Choice_dialog_button
*> last_buttons_stack
;
248 QList
<Choice_dialog_button
*> action_button_map
;
249 void (*run_on_close
)(int);
250 void switch_target();
252 choice_dialog(const QString title
, const QString text
,
253 QWidget
*parent
= NULL
,
254 void (*run_on_close_in
)(int) = NULL
);
257 void add_item(QString title
, pfcn_void func
, QVariant data1
,
258 QVariant data2
, QString tool_tip
, const int button_id
);
260 void stack_button(Choice_dialog_button
*button
);
261 void unstack_all_buttons();
262 QVBoxLayout
*get_layout();
263 Choice_dialog_button
*get_identified_button(const int id
);
265 int target_id
[ATK_COUNT
];
266 struct unit
* targeted_unit
;
267 void update_dialog(const struct act_prob
*act_probs
);
269 void execute_action(const int action
);
275 void popup_revolution_dialog(struct government
*government
= NULL
);
276 void revolution_response(struct government
*government
);
277 void popup_upgrade_dialog(struct unit_list
*punits
);
278 void popup_disband_dialog(struct unit_list
*punits
);
279 bool try_default_unit_action(QVariant q1
, QVariant q2
);
280 bool try_default_city_action(QVariant q1
, QVariant q2
);
282 #endif /* FC__DIALOGS_H */