Freeciv-3.3
Loading...
Searching...
No Matches
fc_client.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__FC_CLIENT_H
15#define FC__FC_CLIENT_H
16
17// In this case we have to include fc_config.h from header file.
18// Some other headers we include demand that fc_config.h must be
19// included also. Usually all source files include fc_config.h, but
20// there's moc generated meta_fc_client.cpp file which does not.
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24
25// Qt
26#include <QMainWindow>
27#include <QPixmapCache>
28#include <QStackedWidget>
29
30// common
31#include "packets.h"
32
33// client
34#include "chatline_common.h"
35#include "client_main.h"
36#include "climisc.h"
37#include "clinet.h"
38#include "mapview_common.h"
39#include "servers.h"
40#include "tilespec.h"
41
42// gui-qt
43#include "canvas.h"
44#include "chatline.h"
45#include "dialogs.h"
46#include "fonts.h"
47#include "gotodlg.h"
48#include "mapview.h"
49#include "menu.h"
50#include "messagewin.h"
51#include "pages.h"
52#include "ratesdlg.h"
53#include "voteinfo_bar.h"
54
61
62class fc_sidebar;
63class fc_sidetax;
64class fc_sidewidget;
65class MainWindow;
66class pregame_options;
67class QApplication;
68class QDialog;
69class QLabel;
70class QLineEdit;
71class QMainWindow;
72class QSocketNotifier;
73class QSpinBox;
74class QStackedLayout;
75class QStatusBar;
76class QString;
77class QTableWidget;
78class QTextEdit;
79class QTimer;
80class QTreeWidget;
81struct fc_shortcut;
82
83
84/****************************************************************************
85 Class helping reading icons/pixmaps from themes/gui-qt/icons folder
86****************************************************************************/
88{
90
91private:
92 explicit fc_icons();
94
95public:
96 static fc_icons *instance();
97 static void drop();
98 QIcon get_icon(const QString& id);
99 QPixmap *get_pixmap(const QString& id);
100 QString get_path(const QString& id);
101};
102
103/****************************************************************************
104 Widget holding all game tabs
105****************************************************************************/
106class fc_game_tab_widget: public QStackedWidget
107{
109public:
111 void init();
112protected:
114private slots:
115 void current_changed(int index);
116};
117
118/****************************************************************************
119 Some qt-specific options like size to save between restarts
120****************************************************************************/
151
152/****************************************************************************
153 Corner widget for menu
154****************************************************************************/
155class fc_corner : public QWidget
156{
158 QMainWindow *mw;
159public:
160 fc_corner(QMainWindow *qmw);
161public slots:
162 void maximize();
163 void minimize();
164 void close_fc();
165};
166
167
168class fc_client : public QMainWindow,
169 private chat_listener
170{
172 QWidget *main_wdg;
173 QWidget *pages[ (int) PAGE_GAME + 2];
174 QWidget *connect_lan;
177
180
185 QLabel *load_pix;
187
193
194 QPushButton *button;
195 QPushButton *obs_button;
196 QPushButton *start_button;
197 QPushButton *nation_button;
198
200
202
204
205 QTableWidget *lan_widget;
206 QTableWidget *wan_widget;
207 QTableWidget *info_widget;
208 QTableWidget *saves_load;
209 QTableWidget *scenarios_load;
211
215
224
225public:
226 fc_client();
227 ~fc_client();
228
233 void add_server_source(int);
235 bool event(QEvent *event);
236
238
239 void set_status_bar(QString str, int timeout = 2000);
240 int add_game_tab(QWidget *widget);
241 void rm_game_tab(int index); // Doesn't delete widget
242 void update_start_page();
243 void toggle_unit_sel_widget(struct tile *ptile);
244 void update_unit_sel();
245 void popdown_unit_sel();
246 void popup_tile_info(struct tile *ptile);
247 void popdown_tile_info();
250 const char *message);
253 void apply_fullscreen();
254
256 QWidget *central_wdg;
283
284 void gimme_place(QWidget *widget, QString str);
288 void write_settings();
289 bool is_closing();
292 void update_fonts();
293
294private slots:
296 void server_input(int sock);
297 void closing();
298 void slot_lan_scan();
299 void slot_meta_scan();
300 void slot_connect();
301 void slot_disconnect();
303 void slot_pregame_start();
306 void slot_pick_nation();
307 void start_new_game();
308 void start_scenario();
309 void start_from_save();
310 void browse_saves();
311 void browse_scenarios();
312 void clear_status_bar();
313 void state_preview(Qt::CheckState state);
314 void state_preview_depr(int state);
315
316public slots:
317 void switch_page(int i);
319 void update_info_label();
320 void quit();
321
322protected slots:
323
325
326private:
328 const struct text_tag_list *tags);
329 void create_main_page();
330 void create_network_page();
331 void create_load_page();
333 void create_start_page();
334 void create_game_page();
335 void create_loading_page();
337 void destroy_server_scans (void);
339 const struct server_list *list);
341 void update_load_page(void);
342 void create_cursors(void);
343 void delete_cursors(void);
344 void update_scenarios_page(void);
345 void set_connection_state(enum connection_state state);
346 void update_buttons();
347 void init();
348 void read_settings();
349
356
357protected:
358 void timerEvent(QTimerEvent *);
360
361signals:
363
364};
365
366/***************************************************************************
367 Class for showing options in PAGE_START, options like ai_fill, ruleset
368 etc.
369***************************************************************************/
370class pregame_options : public QWidget
371{
375 QPushButton *nation;
377public:
378 pregame_options(QWidget *parent);
379 void init();
380
381 void set_rulesets(int num_rulesets, char **rulesets);
382 void set_aifill(int aifill);
383 void update_ai_level();
384 void update_buttons();
385private slots:
386 void max_players_change(int i);
387 void ailevel_change(int i);
388 void ruleset_change(int i);
389 void pick_nation();
390public slots:
392};
393
394// Return fc_client instance. Implementation in gui_main.cpp
395class fc_client *gui();
396
397#endif // FC__FC_CLIENT_H
#define str
Definition astring.c:76
fc_game_tab_widget * game_tab_widget
Definition fc_client.h:259
void chat_message_received(const QString &message, const struct text_tag_list *tags)
void apply_fullscreen()
info_tile * info_tile_wdg
Definition fc_client.h:218
QStringList status_bar_queue
Definition fc_client.h:352
QSocketNotifier * server_notifier
Definition fc_client.h:201
void handle_authentication_req(enum authentication_type type, const char *message)
Definition pages.cpp:1608
QLineEdit * connect_host_edit
Definition fc_client.h:188
fc_sidewidget * sw_tax
Definition fc_client.h:222
void update_buttons()
Definition pages.cpp:1932
void popdown_unit_sel()
QTextEdit * output_window
Definition fc_client.h:181
bool interface_locked
Definition fc_client.h:273
void state_preview_depr(int state)
Definition pages.cpp:876
void init()
trade_generator trade_gen
Definition fc_client.h:269
void update_sidebar_tooltips()
Definition pages.cpp:2160
fc_settings qt_settings
Definition fc_client.h:268
goto_dialog * gtd
Definition fc_client.h:265
mr_menu * menu_bar
Definition fc_client.h:257
bool quitting
Definition fc_client.h:355
fc_sidewidget * sw_economy
Definition fc_client.h:223
QTimer * meta_scan_timer
Definition fc_client.h:212
hud_battle_log * battlelog_wdg
Definition fc_client.h:272
void closing()
QPushButton * start_button
Definition fc_client.h:196
void start_from_save()
Definition pages.cpp:1161
QWidget * connect_lan
Definition fc_client.h:174
int add_game_tab(QWidget *widget)
Definition pages.cpp:821
fc_sidewidget * sw_science
Definition fc_client.h:275
QTableWidget * lan_widget
Definition fc_client.h:205
void browse_saves()
Definition pages.cpp:841
QWidget * connect_metaserver
Definition fc_client.h:175
QWidget * game_main_widget
Definition fc_client.h:176
QLineEdit * connect_confirm_password_edit
Definition fc_client.h:192
chat_input * chat_line
Definition fc_client.h:203
hud_units * unitinfo_wdg
Definition fc_client.h:271
bool map_font_scale
Definition fc_client.h:280
choice_dialog * opened_dialog
Definition fc_client.h:219
pregamevote * pre_vote
Definition fc_client.h:262
QPushButton * nation_button
Definition fc_client.h:197
QTableWidget * saves_load
Definition fc_client.h:208
void read_settings()
mr_idle mr_idler
Definition fc_client.h:255
messagewdg * msgwdg
Definition fc_client.h:260
choice_dialog * get_diplo_dialog()
Definition dialogs.cpp:4920
void set_status_bar(QString str, int timeout=2000)
Definition pages.cpp:456
QPushButton * button
Definition fc_client.h:194
bool is_repo_dlg_open(QString str)
QCheckBox * show_preview
Definition fc_client.h:186
fc_sidewidget * sw_cunit
Definition fc_client.h:274
void server_input(int sock)
enum client_pages page
Definition fc_client.h:350
enum client_pages current_page()
void popdown_tile_info()
Definition mapctrl.cpp:577
bool check_server_scan(server_scan *scan_data)
Definition pages.cpp:1074
units_select * unit_sel
Definition fc_client.h:263
QLineEdit * connect_password_edit
Definition fc_client.h:191
void quit()
minimap_view * minimapview_wdg
Definition fc_client.h:232
QStatusBar * status_bar
Definition fc_client.h:216
void reload_sidebar_icons()
Definition pages.cpp:2145
QTableWidget * wan_widget
Definition fc_client.h:206
void slot_pick_nation()
Definition pages.cpp:2137
void gimme_place(QWidget *widget, QString str)
QCursor * fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES]
Definition fc_client.h:266
map_view * mapview_wdg
Definition fc_client.h:230
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
Definition pages.cpp:1179
void delete_cursors(void)
QStackedLayout * central_layout
Definition fc_client.h:179
void keyCaught(QKeyEvent *e)
fc_sidewidget * sw_indicators
Definition fc_client.h:277
QMenu * page_submenu_AI
Definition fc_client.h:281
void write_settings()
info_tab * infotab
Definition fc_client.h:261
QLabel * scenarios_text
Definition fc_client.h:183
QLabel * load_save_text
Definition fc_client.h:184
void create_start_page()
Definition pages.cpp:651
void slot_disconnect()
QWidget * pages[(int) PAGE_GAME+2]
Definition fc_client.h:173
qfc_rally_list rallies
Definition fc_client.h:270
void clear_status_bar()
Definition pages.cpp:472
void popup_tile_info(struct tile *ptile)
Definition mapctrl.cpp:552
fc_sidewidget * sw_endturn
Definition fc_client.h:276
void slot_pregame_observe()
QTableWidget * info_widget
Definition fc_client.h:207
void set_connection_state(enum connection_state state)
Definition pages.cpp:271
QPushButton * obs_button
Definition fc_client.h:195
QLabel * load_pix
Definition fc_client.h:185
void update_info_label()
Definition mapview.cpp:999
QLabel * status_bar_label
Definition fc_client.h:217
bool send_new_aifill_to_server
Definition fc_client.h:354
QGridLayout * pages_layout[PAGE_GAME+2]
Definition fc_client.h:178
QWidget * main_wdg
Definition fc_client.h:172
QLineEdit * connect_login_edit
Definition fc_client.h:190
void add_server_source(int)
QTextEdit * scenarios_view
Definition fc_client.h:182
QDialogButtonBox * button_box
Definition fc_client.h:199
void destroy_server_scans(void)
Definition pages.cpp:1025
void create_cursors(void)
void update_sidebar_position()
Definition pages.cpp:2332
QMenu * page_submenu_team
Definition fc_client.h:282
void switch_page(int i)
void create_network_page()
Definition pages.cpp:308
QTreeWidget * start_players_tree
Definition fc_client.h:210
bool chat_active_on_page(enum client_pages)
void create_load_page()
Definition pages.cpp:500
QTimer * lan_scan_timer
Definition fc_client.h:213
void update_start_page()
Definition pages.cpp:1703
QLineEdit * connect_port_edit
Definition fc_client.h:189
fc_sidebar * sidebar_wdg
Definition fc_client.h:231
void create_main_page()
Definition pages.cpp:138
float map_scale
Definition fc_client.h:279
void create_loading_page()
Definition pages.cpp:488
void start_page_menu(QPoint)
Definition pages.cpp:1999
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4912
void update_fonts()
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
Definition pages.cpp:911
void update_network_lists()
Definition pages.cpp:1055
QWidget * central_wdg
Definition fc_client.h:256
void slot_meta_scan()
Definition pages.cpp:1119
void fc_main(QApplication *qapp)
QMap< QString, QWidget * > opened_repo_dlgs
Definition fc_client.h:351
QString current_file
Definition fc_client.h:353
void closeEvent(QCloseEvent *event)
void slot_lan_scan()
Definition pages.cpp:1108
xvote * x_vote
Definition fc_client.h:264
void remove_repo_dlg(QString str)
void browse_scenarios()
Definition pages.cpp:894
void slot_pregame_start()
QTimer * update_info_timer
Definition fc_client.h:214
fc_sidewidget * sw_cities
Definition fc_client.h:221
void toggle_unit_sel_widget(struct tile *ptile)
void popup_client_options()
void slot_connect()
Definition pages.cpp:1646
fc_sidewidget * sw_map
Definition fc_client.h:220
void update_unit_sel()
void update_load_page(void)
Definition pages.cpp:1440
void start_scenario()
Definition pages.cpp:1143
pregame_options * pr_options
Definition fc_client.h:267
QTableWidget * scenarios_load
Definition fc_client.h:209
int gimme_index_of(QString str)
void rm_game_tab(int index)
Definition pages.cpp:833
fc_corner * corner_wid
Definition fc_client.h:258
void send_fake_chat_message(const QString &message)
void timerEvent(QTimerEvent *)
fc_sidewidget * sw_diplo
Definition fc_client.h:278
void state_preview(Qt::CheckState state)
Definition pages.cpp:857
bool is_closing()
void create_scenario_page()
Definition pages.cpp:584
void start_new_game()
Definition pages.cpp:1130
void remove_server_source()
void update_scenarios_page(void)
Definition pages.cpp:1471
void create_game_page()
Definition pages.cpp:735
void minimize()
QMainWindow * mw
Definition fc_client.h:158
void maximize()
void close_fc()
void resizeEvent(QResizeEvent *event)
void current_changed(int index)
QIcon get_icon(const QString &id)
static void drop()
static fc_icons * m_instance
Definition fc_client.h:93
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
QString get_path(const QString &id)
Q_DISABLE_COPY(fc_icons)
void popup_server_options()
QPushButton * nation
Definition fc_client.h:375
QComboBox * ailevel
Definition fc_client.h:373
void ailevel_change(int i)
void set_rulesets(int num_rulesets, char **rulesets)
void set_aifill(int aifill)
void max_players_change(int i)
QComboBox * cruleset
Definition fc_client.h:374
void ruleset_change(int i)
QSpinBox * max_players
Definition fc_client.h:376
static struct fc_sockaddr_list * list
Definition clinet.c:102
char * incite_cost
Definition comments.c:76
authentication_type
Definition conn_types.h:41
enum event_type event
Definition events.c:81
connection_state
Definition fc_client.h:55
@ LOGIN_TYPE
Definition fc_client.h:56
@ NEW_PASSWORD_TYPE
Definition fc_client.h:57
@ WAITING_TYPE
Definition fc_client.h:59
@ ENTER_PASSWORD_TYPE
Definition fc_client.h:58
class fc_client * gui()
Definition gui_main.cpp:82
connection_state
Definition pages.c:852
GType type
Definition repodlgs.c:1313
static struct server_list * server_list
Definition connectdlg.c:61
static QApplication * qapp
Definition gui_main.cpp:69
struct player_slot * slots
Definition player.c:51
server_scan_type
Definition servers.h:67
const char * aifill(int amount)
Definition srv_main.c:2506
QByteArray city_splitter2
Definition fc_client.h:135
QByteArray city_geometry
Definition fc_client.h:133
QByteArray help_geometry
Definition fc_client.h:137
float unit_info_pos_fx
Definition fc_client.h:141
QByteArray options_client_geometry
Definition fc_client.h:139
float unit_info_pos_fy
Definition fc_client.h:142
float chat_fwidth
Definition fc_client.h:123
float chat_fheight
Definition fc_client.h:124
QByteArray help_splitter1
Definition fc_client.h:138
float chat_fx_pos
Definition fc_client.h:125
float battlelog_scale
Definition fc_client.h:147
float battlelog_x
Definition fc_client.h:148
QByteArray city_splitter3
Definition fc_client.h:136
float minimap_x
Definition fc_client.h:143
Qt::SortOrder player_report_sort
Definition fc_client.h:130
float minimap_height
Definition fc_client.h:146
Qt::SortOrder city_report_sort
Definition fc_client.h:132
bool show_battle_log
Definition fc_client.h:129
int city_repo_sort_col
Definition fc_client.h:131
float minimap_width
Definition fc_client.h:145
float battlelog_y
Definition fc_client.h:149
QByteArray options_server_geometry
Definition fc_client.h:140
float chat_fy_pos
Definition fc_client.h:126
QByteArray city_splitter1
Definition fc_client.h:134
bool show_new_turn_text
Definition fc_client.h:128
float minimap_y
Definition fc_client.h:144
int player_repo_sort_col
Definition fc_client.h:127
Definition tile.h:50
#define NUM_CURSOR_FRAMES
Definition tilespec.h:305
@ CURSOR_LAST
Definition tilespec.h:301