Freeciv-3.2
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(int);
314
315public slots:
316 void switch_page(int i);
318 void update_info_label();
319 void quit();
320
321protected slots:
322
324
325private:
327 const struct text_tag_list *tags);
328 void create_main_page();
329 void create_network_page();
330 void create_load_page();
332 void create_start_page();
333 void create_game_page();
334 void create_loading_page();
336 void destroy_server_scans (void);
338 const struct server_list *list);
340 void update_load_page(void);
341 void create_cursors(void);
342 void delete_cursors(void);
343 void update_scenarios_page(void);
344 void set_connection_state(enum connection_state state);
345 void update_buttons();
346 void init();
347 void read_settings();
348
355
356protected:
357 void timerEvent(QTimerEvent *);
359
360signals:
362
363};
364
365/***************************************************************************
366 Class for showing options in PAGE_START, options like ai_fill, ruleset
367 etc.
368***************************************************************************/
369class pregame_options : public QWidget
370{
374 QPushButton *nation;
376public:
377 pregame_options(QWidget *parent);
378 void init();
379
380 void set_rulesets(int num_rulesets, char **rulesets);
381 void set_aifill(int aifill);
382 void update_ai_level();
383 void update_buttons();
384private slots:
385 void max_players_change(int i);
386 void ailevel_change(int i);
387 void ruleset_change(int i);
388 void pick_nation();
389public slots:
391};
392
393// Return fc_client instance. Implementation in gui_main.cpp
394class fc_client *gui();
395
396#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:351
QSocketNotifier * server_notifier
Definition fc_client.h:201
void handle_authentication_req(enum authentication_type type, const char *message)
Definition pages.cpp:1582
QLineEdit * connect_host_edit
Definition fc_client.h:188
fc_sidewidget * sw_tax
Definition fc_client.h:222
void update_buttons()
Definition pages.cpp:1906
void popdown_unit_sel()
QTextEdit * output_window
Definition fc_client.h:181
bool interface_locked
Definition fc_client.h:273
void init()
trade_generator trade_gen
Definition fc_client.h:269
void update_sidebar_tooltips()
Definition pages.cpp:2134
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:354
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:1132
QWidget * connect_lan
Definition fc_client.h:174
int add_game_tab(QWidget *widget)
Definition pages.cpp:811
fc_sidewidget * sw_science
Definition fc_client.h:275
QTableWidget * lan_widget
Definition fc_client.h:205
void browse_saves()
Definition pages.cpp:831
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:4847
void set_status_bar(QString str, int timeout=2000)
Definition pages.cpp:451
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:349
enum client_pages current_page()
void popdown_tile_info()
Definition mapctrl.cpp:577
bool check_server_scan(server_scan *scan_data)
Definition pages.cpp:1045
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:2119
QTableWidget * wan_widget
Definition fc_client.h:206
void slot_pick_nation()
Definition pages.cpp:2111
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:1150
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:641
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:467
void popup_tile_info(struct tile *ptile)
Definition mapctrl.cpp:552
fc_sidewidget * sw_endturn
Definition fc_client.h:276
void slot_pregame_observe()
void state_preview(int)
Definition pages.cpp:847
QTableWidget * info_widget
Definition fc_client.h:207
void set_connection_state(enum connection_state state)
Definition pages.cpp:266
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:353
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:996
void create_cursors(void)
void update_sidebar_position()
Definition pages.cpp:2304
QMenu * page_submenu_team
Definition fc_client.h:282
void switch_page(int i)
void create_network_page()
Definition pages.cpp:303
QTreeWidget * start_players_tree
Definition fc_client.h:210
bool chat_active_on_page(enum client_pages)
void create_load_page()
Definition pages.cpp:495
QTimer * lan_scan_timer
Definition fc_client.h:213
void update_start_page()
Definition pages.cpp:1677
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:483
void start_page_menu(QPoint)
Definition pages.cpp:1973
void set_diplo_dialog(choice_dialog *widget)
Definition dialogs.cpp:4839
void update_fonts()
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
Definition pages.cpp:882
void update_network_lists()
Definition pages.cpp:1026
QWidget * central_wdg
Definition fc_client.h:256
void slot_meta_scan()
Definition pages.cpp:1090
void fc_main(QApplication *qapp)
QMap< QString, QWidget * > opened_repo_dlgs
Definition fc_client.h:350
QString current_file
Definition fc_client.h:352
void closeEvent(QCloseEvent *event)
void slot_lan_scan()
Definition pages.cpp:1079
xvote * x_vote
Definition fc_client.h:264
void remove_repo_dlg(QString str)
void browse_scenarios()
Definition pages.cpp:865
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:1620
fc_sidewidget * sw_map
Definition fc_client.h:220
void update_unit_sel()
void update_load_page(void)
Definition pages.cpp:1414
void start_scenario()
Definition pages.cpp:1114
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:823
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
bool is_closing()
void create_scenario_page()
Definition pages.cpp:574
void start_new_game()
Definition pages.cpp:1101
void remove_server_source()
void update_scenarios_page(void)
Definition pages.cpp:1445
void create_game_page()
Definition pages.cpp:725
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:374
QComboBox * ailevel
Definition fc_client.h:372
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:373
void ruleset_change(int i)
QSpinBox * max_players
Definition fc_client.h:375
static struct fc_sockaddr_list * list
Definition clinet.c:102
char * incite_cost
Definition comments.c:75
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:84
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:71
struct player_slot * slots
Definition player.c:51
server_scan_type
Definition servers.h:67
const char * aifill(int amount)
Definition srv_main.c:2465
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:303
@ CURSOR_LAST
Definition tilespec.h:299