Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/fc_client.cpp Source File

Freeciv-3.1

Loading...
Searching...
No Matches
fc_client.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QComboBox>
21#include <QFormLayout>
22#include <QLineEdit>
23#include <QMainWindow>
24#include <QPainter>
25#include <QResizeEvent>
26#include <QScrollBar>
27#include <QSettings>
28#include <QSocketNotifier>
29#include <QSpinBox>
30#include <QStackedLayout>
31#include <QStandardPaths>
32#include <QStatusBar>
33#include <QStyleFactory>
34#include <QTabBar>
35#include <QTextBlock>
36
37#ifdef FC_QT5_MODE
38#include <QTextCodec>
39#endif /* FC_QT5_MODE */
40
41#include <QTextEdit>
42
43// common
44#include "game.h"
45
46// client
47#include "connectdlg_common.h"
48
49// gui-qt
50#include "fc_client.h"
51#include "fonts.h"
52#include "gui_main.h"
53#include "optiondlg.h"
54#include "sidebar.h"
55#include "sprite.h"
56
57 fc_icons* fc_icons::m_instance = 0;
58 fc_font* fc_font::m_instance = 0;
59extern "C" {
60 bool get_turn_done_button_state();
61 void real_science_report_dialog_update(void*);
62}
63extern void write_shortcuts();
64
65QString current_theme;
66
67/************************************************************************/
70fc_client::fc_client() : QMainWindow()
71{
72 QString wtitle;
73
74#ifdef FC_QT5_MODE
75 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
76#endif /* FC_QT5_MODE */
84 main_wdg = NULL;
85 connect_lan = NULL;
86 connect_metaserver = NULL;
87 central_layout = NULL;
88 output_window = NULL;
89 scenarios_view = NULL;
90 connect_host_edit = NULL;
91 connect_port_edit = NULL;
92 connect_login_edit = NULL;
93 connect_password_edit = NULL;
94 connect_confirm_password_edit = NULL;
95 button = NULL;
96 button_box = NULL;
97 server_notifier = NULL;
98 chat_line = NULL;
99 lan_widget = NULL;
100 wan_widget = NULL;
101 info_widget = NULL;
102 saves_load = NULL;
103 scenarios_load = NULL;
104 meta_scan_timer = NULL;
105 lan_scan_timer = NULL;
106 status_bar = NULL;
107 status_bar_label = NULL;
108 menu_bar = NULL;
109 mapview_wdg = NULL;
110 sidebar_wdg = nullptr;
111 msgwdg = NULL;
112 infotab = NULL;
113 central_wdg = NULL;
114 game_tab_widget = NULL;
115 start_players_tree = NULL;
116 unit_sel = NULL;
117 info_tile_wdg = nullptr;
118 opened_dialog = NULL;
119 current_file = "";
120 status_bar_queue.clear();
121 quitting = false;
122 pre_vote = NULL;
123 x_vote = NULL;
124 gtd = NULL;
125 update_info_timer = nullptr;
126 unitinfo_wdg = nullptr;
127 battlelog_wdg = nullptr;
128 interface_locked = false;
129 map_scale = 1.0f;
130 map_font_scale = true;
131 for (int i = 0; i <= PAGE_GAME; i++) {
132 pages_layout[i] = NULL;
133 pages[i] = NULL;
134 }
135
136 wtitle = _("Freeciv (%1)");
137 wtitle = wtitle.arg(
138#if FC_QT5_MODE
139 "Qt5"
140#else // FC_QT5_MODE
141 "Qt6"
142#endif // FC_QT5_MODE
143 );
144
145 setWindowTitle(wtitle);
146
147 init();
148}
149
150/************************************************************************/
153 void fc_client::init()
154{
155 fc_font::instance()->init_fonts();
156 read_settings();
157 QApplication::setFont(*fc_font::instance()->get_font(fonts::default_font));
158 QString path;
159 central_wdg = new QWidget;
160 central_layout = new QStackedLayout;
161
162 // General part not related to any single page
163 menu_bar = new mr_menu();
164 if (!gui_options.gui_qt_show_titlebar) {
165 corner_wid = new fc_corner(this);
166 menu_bar->setCornerWidget(corner_wid);
167 }
168 setMenuBar(menu_bar);
169 status_bar = statusBar();
170 status_bar_label = new QLabel;
171 status_bar_label->setAlignment(Qt::AlignCenter);
172 status_bar->addWidget(status_bar_label, 1);
173 set_status_bar(_("Welcome to Freeciv"));
174 create_cursors();
175
176 // PAGE_MAIN
177 pages[PAGE_MAIN] = new QWidget(central_wdg);
178 page = PAGE_MAIN;
179 create_main_page();
180
181 // PAGE_START
182 pages[PAGE_START] = new QWidget(central_wdg);
183 create_start_page();
184
185 // PAGE_SCENARIO
186 pages[PAGE_SCENARIO] = new QWidget(central_wdg);
187 create_scenario_page();
188
189 // PAGE_LOAD
190 pages[PAGE_LOAD] = new QWidget(central_wdg);
191 create_load_page();
192
193 // PAGE_NETWORK
194 pages[PAGE_NETWORK] = new QWidget(central_wdg);
195 create_network_page();
196 pages[PAGE_NETWORK]->setVisible(false);
197
198 // PAGE_GAME
199 gui_options.gui_qt_allied_chat_only = true;
200 path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
201 if (!path.isEmpty()) {
202 QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, path);
203 }
204 pages[PAGE_GAME] = new QWidget(central_wdg);
205 init_mapcanvas_and_overview();
206 create_game_page();
207
208 pages[PAGE_GAME + 1] = new QWidget(central_wdg);
209 create_loading_page();
210
211 pages_layout[PAGE_GAME]->setContentsMargins(0, 0, 0, 0);
212
213 pages[PAGE_MAIN]->setLayout(pages_layout[PAGE_MAIN]);
214 pages[PAGE_NETWORK]->setLayout(pages_layout[PAGE_NETWORK]);
215 pages[PAGE_LOAD]->setLayout(pages_layout[PAGE_LOAD]);
216 pages[PAGE_SCENARIO]->setLayout(pages_layout[PAGE_SCENARIO]);
217 pages[PAGE_START]->setLayout(pages_layout[PAGE_START]);
218 pages[PAGE_GAME]->setLayout(pages_layout[PAGE_GAME]);
219 pages[PAGE_GAME + 1]->setLayout(pages_layout[PAGE_GAME + 1]);
220
221 central_layout->addWidget(pages[PAGE_MAIN]);
222 central_layout->addWidget(pages[PAGE_NETWORK]);
223 central_layout->addWidget(pages[PAGE_LOAD]);
224 central_layout->addWidget(pages[PAGE_SCENARIO]);
225 central_layout->addWidget(pages[PAGE_START]);
226 central_layout->addWidget(pages[PAGE_GAME]);
227 central_layout->addWidget(pages[PAGE_GAME + 1]);
228
229 central_wdg->setLayout(central_layout);
230 setCentralWidget(central_wdg);
231
232 resize(pages[PAGE_MAIN]->minimumSizeHint());
233 setVisible(true);
234
235 game_tab_widget->init();
236 chat_listener::listen();
237
238 QPixmapCache::setCacheLimit(80000);
239}
240
241/************************************************************************/
244fc_client::~fc_client()
245{
246 status_bar_queue.clear();
247 if (fc_shortcuts::sc()) {
248 delete fc_shortcuts::sc();
249 }
250 delete_cursors();
251}
252
253
254/************************************************************************/
260 void fc_client::fc_main(QApplication *qapp)
261{
262 qRegisterMetaType<QTextCursor>("QTextCursor");
263 qRegisterMetaType<QTextBlock>("QTextBlock");
264 fc_allocate_ow_mutex();
265 real_output_window_append(_("This is Qt-client for Freeciv."), NULL, -1);
266 fc_release_ow_mutex();
267 chat_welcome_message(true);
268
269 set_client_state(C_S_DISCONNECTED);
270
271 startTimer(TIMER_INTERVAL);
272 connect(qapp, &QCoreApplication::aboutToQuit, this, &fc_client::closing);
273 qapp->exec();
274
275 free_mapcanvas_and_overview();
276 tileset_free_tiles(tileset);
277}
278
279/************************************************************************/
282 bool fc_client::is_closing()
283{
284 return quitting;
285}
286
287/************************************************************************/
290 void fc_client::closing()
291{
292 quitting = true;
293}
294
295/************************************************************************/
298 void fc_client::send_fake_chat_message(const QString &message)
299{
300 send_chat_message(message);
301}
302
303/************************************************************************/
306 void fc_client::chat_message_received(const QString &message,
307 const struct text_tag_list *tags)
308{
309 QTextCursor cursor;
310 QColor col = output_window->palette().color(QPalette::Text);
311 QString str = apply_tags(message, tags, col);
312
313 if (output_window != NULL) {
314 output_window->append(str);
315 output_window->verticalScrollBar()->setSliderPosition(
316 output_window->verticalScrollBar()->maximum());
317 }
318}
319
320/************************************************************************/
323 bool fc_client::chat_active_on_page(enum client_pages check)
324{
325 if (check == PAGE_START || check == PAGE_GAME) {
326 return true;
327 }
328
329 return false;
330}
331
332/************************************************************************/
338 void fc_client::switch_page(int new_pg)
339{
340 char buf[256];
341 enum client_pages new_page;
342 int i_page;
343
344 new_page = static_cast<client_pages>(new_pg);
345
346 if ((new_page == PAGE_SCENARIO || new_page == PAGE_LOAD)
347 && !is_server_running()) {
348 current_file = "";
349 client_start_server_and_set_page(new_page);
350 return;
351 }
352
353 if (page == PAGE_NETWORK) {
354 destroy_server_scans();
355 }
356 menuBar()->setVisible(false);
357 if (status_bar != nullptr) {
358 status_bar->setVisible(true);
359 }
360 QApplication::alert(gui()->central_wdg);
361 central_layout->setCurrentWidget(pages[new_pg]);
362 page = new_page;
363 i_page = new_page;
364 switch (i_page) {
365 case PAGE_MAIN:
366 break;
367 case PAGE_START:
368 pre_vote->hide();
369 voteinfo_gui_update();
370 break;
371 case PAGE_LOAD:
372 update_load_page();
373 break;
374 case PAGE_GAME:
375 if (!gui_options.gui_qt_show_titlebar) {
376 setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
377 }
378 showMaximized();
379 /* For MS Windows, it might ignore first */
380 showMaximized();
381 gui()->infotab->chtwdg->update_widgets();
382 status_bar->setVisible(false);
383
384 if (gui_options.gui_qt_fullscreen) {
385 apply_fullscreen();
386 }
387
388 menuBar()->setVisible(true);
389 mapview_wdg->setFocus();
390 center_on_something();
391 voteinfo_gui_update();
392 update_info_label();
393 minimapview_wdg->reset();
394 overview_size_changed();
395 update_sidebar_tooltips();
396 real_science_report_dialog_update(nullptr);
397 show_new_turn_info();
398 break;
399 case PAGE_SCENARIO:
400 update_scenarios_page();
401 break;
402 case PAGE_NETWORK:
403 update_network_lists();
404 set_connection_state(LOGIN_TYPE);
405 connect_host_edit->setText(server_host);
406 fc_snprintf(buf, sizeof(buf), "%d", server_port);
407 connect_port_edit->setText(buf);
408 connect_login_edit->setText(user_name);
409 connect_password_edit->setDisabled(true);
410 connect_confirm_password_edit->setDisabled(true);
411 break;
412 case (PAGE_GAME + 1):
413 break;
414 default:
415 if (client.conn.used) {
416 disconnect_from_server();
417 }
418 set_client_page(PAGE_MAIN);
419 break;
420 }
421}
422
423/************************************************************************/
426 void fc_client::apply_fullscreen()
427{
428 if (gui_options.gui_qt_fullscreen) {
429 gui()->showFullScreen();
430 gui()->game_tab_widget->showFullScreen();
431 } else {
432 // FIXME: Doesn't return properly, probably something with sidebar
433 gui()->showNormal();
434 gui()->game_tab_widget->showNormal();
435 }
436}
437
438/************************************************************************/
441 enum client_pages fc_client::current_page()
442{
443 return page;
444}
445
446/************************************************************************/
449 void fc_client::add_server_source(int sock)
450{
451 server_notifier = new QSocketNotifier(sock, QSocketNotifier::Read);
452
453 connect(server_notifier, &QSocketNotifier::activated, this,
454 &fc_client::server_input);
455}
456
457/************************************************************************/
460 void fc_client::update_fonts()
461{
462 sidebar_wdg->update_fonts();
463}
464
465/************************************************************************/
468 bool fc_client::event(QEvent *event)
469{
470 if (event->type() == QEvent::User) {
471 version_message_event vmevt =
472 dynamic_cast< version_message_event&>(*event);
473 set_status_bar(vmevt.get_message());
474 return true;
475 } else {
476 return QMainWindow::event(event);
477 }
478}
479
480/************************************************************************/
483 void fc_client::closeEvent(QCloseEvent *event)
484{
485 if (!is_client_quitting()) {
486 popup_quit_dialog();
487 event->ignore();
488 }
489}
490
491/************************************************************************/
494 void fc_client::remove_server_source()
495{
496 server_notifier->deleteLater();
497}
498
499/************************************************************************/
502 void fc_client::server_input(int sock)
503{
504 server_notifier->setEnabled(false);
505 input_from_server(sock);
506 server_notifier->setEnabled(true);
507}
508
509/************************************************************************/
512 void fc_client::timerEvent(QTimerEvent *event)
513{
514 // Prevent current timer from repeating with possibly wrong interval
515 killTimer(event->timerId());
516
517 // Call timer callback in client common code and
518 // start new timer with correct interval
519 startTimer(real_timer_callback() * 1000);
520}
521
522/************************************************************************/
525 void fc_client::quit()
526{
527 QApplication *qapp = current_app();
528
529 if (qapp != nullptr) {
530 qapp->quit();
531 }
532}
533
534/************************************************************************/
537 void fc_client::slot_disconnect()
538{
539 if (client.conn.used) {
540 disconnect_from_server();
541 }
542
543 switch_page(PAGE_MAIN);
544}
545
546/************************************************************************/
549 void fc_client::slot_pregame_observe()
550{
551 if (client_is_observer() || client_is_global_observer()) {
552 if (game.info.is_new_game) {
553 send_chat("/take -");
554 } else {
555 send_chat("/detach");
556 }
557 obs_button->setText(_("Don't Observe"));
558 } else {
559 send_chat("/observe");
560 obs_button->setText(_("Observe"));
561 }
562}
563
564/************************************************************************/
567 void fc_client::slot_pregame_start()
568{
569 if (can_client_control()) {
570 dsend_packet_player_ready(&client.conn,
571 player_number(client_player()),
572 !client_player()->is_ready);
573 } else {
574 dsend_packet_player_ready(&client.conn, 0, TRUE);
575 }
576}
577
578/****************************************************************************
579 Deletes cursors
580****************************************************************************/
581 void fc_client::delete_cursors(void)
582{
583 int frame;
584 int cursor;
585
586 for (cursor = 0; cursor < CURSOR_LAST; cursor++) {
587 for (frame = 0; frame < NUM_CURSOR_FRAMES; frame++) {
588 delete fc_cursors[cursor][frame];
589 }
590 }
591}
592
593
594/************************************************************************/
597 void fc_client::gimme_place(QWidget *widget, QString str)
598{
599 QString x;
600
601 x = opened_repo_dlgs.key(widget);
602
603 if (x.isEmpty()) {
604 opened_repo_dlgs.insert(str, widget);
605 return;
606 }
607 log_error("Failed to find place for new tab widget");
608 return;
609}
610
611/************************************************************************/
616 bool fc_client::is_repo_dlg_open(QString str)
617{
618 QWidget *w;
619
620 w = opened_repo_dlgs.value(str);
621
622 if (w == NULL) {
623 return false;
624 }
625
626 return true;
627}
628
629/************************************************************************/
632 int fc_client::gimme_index_of(QString str)
633{
634 int i;
635 QWidget *w;
636
637 if (str == "MAP") {
638 return 0;
639 }
640
641 w = opened_repo_dlgs.value(str);
642 i = game_tab_widget->indexOf(w);
643 return i;
644}
645
646/************************************************************************/
649 void fc_client::read_settings()
650{
651 // This can't be shared between freeciv versions as the content
652 // might be incompatible.
653 QString sname = "freeciv-qt-client-set-"
654 + QString::number(MAJOR_NEW_OPTION_FILE_NAME) + "."
655 + QString::number(MINOR_NEW_OPTION_FILE_NAME);
656 QSettings s(QSettings::IniFormat, QSettings::UserScope,
657 sname);
658
659 if (s.contains("Chat-fx-size")) {
660 qt_settings.chat_fwidth = s.value("Chat-fx-size").toFloat();
661 } else {
662 qt_settings.chat_fwidth = 0.2;
663 }
664 if (s.contains("Chat-fy-size")) {
665 qt_settings.chat_fheight = s.value("Chat-fy-size").toFloat();
666 } else {
667 qt_settings.chat_fheight = 0.4;
668 }
669 if (s.contains("Chat-fx-pos")) {
670 qt_settings.chat_fx_pos = s.value("Chat-fx-pos").toFloat();
671 } else {
672 qt_settings.chat_fx_pos = 0.0;
673 }
674 if (s.contains("Chat-fy-pos")) {
675 qt_settings.chat_fy_pos = s.value("Chat-fy-pos").toFloat();
676 } else {
677 qt_settings.chat_fy_pos = 0.6;
678 }
679 if (s.contains("unit_fx")) {
680 qt_settings.unit_info_pos_fx = s.value("unit_fx").toFloat();
681 } else {
682 qt_settings.unit_info_pos_fx = 0.33;
683 }
684 if (s.contains("unit_fy")) {
685 qt_settings.unit_info_pos_fy = s.value("unit_fy").toFloat();
686 } else {
687 qt_settings.unit_info_pos_fy = 0.88;
688 }
689 if (s.contains("minimap_x")) {
690 qt_settings.minimap_x = s.value("minimap_x").toFloat();
691 } else {
692 qt_settings.minimap_x = 0.84;
693 }
694 if (s.contains("minimap_y")) {
695 qt_settings.minimap_y = s.value("minimap_y").toFloat();
696 } else {
697 qt_settings.minimap_y = 0.79;
698 }
699 if (s.contains("minimap_width")) {
700 qt_settings.minimap_width = s.value("minimap_width").toFloat();
701 } else {
702 qt_settings.minimap_width = 0.15;
703 }
704 if (s.contains("minimap_height")) {
705 qt_settings.minimap_height = s.value("minimap_height").toFloat();
706 } else {
707 qt_settings.minimap_height = 0.2;
708 }
709 if (s.contains("battlelog_scale")) {
710 qt_settings.battlelog_scale = s.value("battlelog_scale").toFloat();
711 } else {
712 qt_settings.battlelog_scale = 1;
713 }
714
715 if (s.contains("City-dialog")) {
716 qt_settings.city_geometry = s.value("City-dialog").toByteArray();
717 }
718 if (s.contains("splitter1")) {
719 qt_settings.city_splitter1 = s.value("splitter1").toByteArray();
720 }
721 if (s.contains("splitter2")) {
722 qt_settings.city_splitter2 = s.value("splitter2").toByteArray();
723 }
724 if (s.contains("splitter3")) {
725 qt_settings.city_splitter3 = s.value("splitter3").toByteArray();
726 }
727 if (s.contains("help-dialog")) {
728 qt_settings.help_geometry = s.value("help-dialog").toByteArray();
729 }
730 if (s.contains("help_splitter1")) {
731 qt_settings.help_splitter1 = s.value("help_splitter1").toByteArray();
732 }
733 if (s.contains("opt-client-dialog")) {
734 qt_settings.options_client_geometry = s.value("opt-client-dialog").toByteArray();
735 }
736 if (s.contains("opt-server-dialog")) {
737 qt_settings.options_server_geometry = s.value("opt-server-dialog").toByteArray();
738 }
739 if (s.contains("new_turn_text")) {
740 qt_settings.show_new_turn_text = s.value("new_turn_text").toBool();
741 } else {
742 qt_settings.show_new_turn_text = true;
743 }
744 if (s.contains("show_battle_log")) {
745 qt_settings.show_battle_log = s.value("show_battle_log").toBool();
746 } else {
747 qt_settings.show_battle_log = false;
748 }
749 if (s.contains("battlelog_x")) {
750 qt_settings.battlelog_x = s.value("battlelog_x").toFloat();
751 } else {
752 qt_settings.battlelog_x = 0.0;
753 }
754 if (s.contains("minimap_y")) {
755 qt_settings.battlelog_y = s.value("battlelog_y").toFloat();
756 } else {
757 qt_settings.battlelog_y = 0.0;
758 }
759 qt_settings.player_repo_sort_col = -1;
760 qt_settings.city_repo_sort_col = -1;
761
762 if (qt_settings.chat_fx_pos < 0 || qt_settings.chat_fx_pos >= 1) {
763 qt_settings.chat_fx_pos = 0.0;
764 }
765 if (qt_settings.chat_fy_pos >= 1 || qt_settings.chat_fy_pos < 0) {
766 qt_settings.chat_fy_pos = 0.6;
767 }
768 if (qt_settings.chat_fwidth < 0.05 || qt_settings.chat_fwidth > 0.9) {
769 qt_settings.chat_fwidth = 0.2;
770 }
771 if (qt_settings.chat_fheight < 0.05 || qt_settings.chat_fheight > 0.9) {
772 qt_settings.chat_fheight = 0.33;
773 }
774 if (qt_settings.battlelog_x < 0.0) {
775 qt_settings.battlelog_x = 0.33;
776 }
777 if (qt_settings.battlelog_y < 0.0) {
778 qt_settings.battlelog_y = 0.0;
779 }
780 if (qt_settings.battlelog_scale > 5.0) {
781 qt_settings.battlelog_y = 5.0;
782 }
783 if (qt_settings.minimap_x < 0 || qt_settings.minimap_x > 1) {
784 qt_settings.chat_fx_pos = 0.84;
785 }
786 if (qt_settings.minimap_y < 0 || qt_settings.minimap_y > 1) {
787 qt_settings.chat_fx_pos = 0.79;
788 }
789}
790
791/************************************************************************/
794 void fc_client::write_settings()
795{
796 QString sname = "freeciv-qt-client-set-"
797 + QString::number(MAJOR_NEW_OPTION_FILE_NAME) + "."
798 + QString::number(MINOR_NEW_OPTION_FILE_NAME);
799 QSettings s(QSettings::IniFormat, QSettings::UserScope,
800 sname);
801
802 s.setValue("Chat-fx-size", qt_settings.chat_fwidth);
803 s.setValue("Chat-fy-size", qt_settings.chat_fheight);
804 s.setValue("Chat-fx-pos", qt_settings.chat_fx_pos);
805 s.setValue("Chat-fy-pos", qt_settings.chat_fy_pos);
806 s.setValue("City-dialog", qt_settings.city_geometry);
807 s.setValue("splitter1", qt_settings.city_splitter1);
808 s.setValue("splitter2", qt_settings.city_splitter2);
809 s.setValue("splitter3", qt_settings.city_splitter3);
810 s.setValue("help-dialog", qt_settings.help_geometry);
811 s.setValue("help_splitter1", qt_settings.help_splitter1);
812 s.setValue("opt-client-dialog", qt_settings.options_client_geometry);
813 s.setValue("opt-server-dialog", qt_settings.options_server_geometry);
814 s.setValue("unit_fx", qt_settings.unit_info_pos_fx);
815 s.setValue("unit_fy", qt_settings.unit_info_pos_fy);
816 s.setValue("minimap_x", qt_settings.minimap_x);
817 s.setValue("minimap_y", qt_settings.minimap_y);
818 s.setValue("minimap_width", qt_settings.minimap_width);
819 s.setValue("minimap_height", qt_settings.minimap_height);
820 s.setValue("battlelog_scale", qt_settings.battlelog_scale);
821 s.setValue("battlelog_x", qt_settings.battlelog_x);
822 s.setValue("battlelog_y", qt_settings.battlelog_y);
823 s.setValue("new_turn_text", qt_settings.show_new_turn_text);
824 s.setValue("show_battle_log", qt_settings.show_battle_log);
825 write_shortcuts();
826}
827
828/************************************************************************/
831 void fc_client::toggle_unit_sel_widget(struct tile *ptile)
832{
833 if (unit_sel != NULL) {
834 unit_sel->close();
835 delete unit_sel;
836 unit_sel = new units_select(ptile, gui()->mapview_wdg);
837 unit_sel->show();
838 } else {
839 unit_sel = new units_select(ptile, gui()->mapview_wdg);
840 unit_sel->show();
841 }
842}
843
844/************************************************************************/
847 void fc_client::update_unit_sel()
848{
849 if (unit_sel != NULL) {
850 unit_sel->update_units();
851 unit_sel->create_pixmap();
852 unit_sel->update();
853 }
854}
855
856/************************************************************************/
859 void fc_client::popdown_unit_sel()
860{
861 if (unit_sel != nullptr) {
862 unit_sel->close();
863 delete unit_sel;
864 unit_sel = nullptr;
865 }
866}
867
868/************************************************************************/
871 void fc_client::remove_repo_dlg(QString str)
872{
873 /* if app is closing opened_repo_dlg is already deleted */
874 if (!is_closing()) {
875 opened_repo_dlgs.remove(str);
876 }
877}
878
879/************************************************************************/
882 void fc_client::popup_client_options()
883{
884 option_dialog_popup(_("Set local options"), client_optset, true);
885}
886
887/************************************************************************/
890 void fc_client::create_cursors(void)
891{
892 enum cursor_type curs;
893 int cursor;
894 QPixmap *pix;
895 int hot_x, hot_y;
896 struct sprite *sprite;
897 int frame;
898 QCursor *c;
899 for (cursor = 0; cursor < CURSOR_LAST; cursor++) {
900 for (frame = 0; frame < NUM_CURSOR_FRAMES; frame++) {
901 curs = static_cast< cursor_type>(cursor);
902 sprite = get_cursor_sprite(tileset, curs, &hot_x, &hot_y, frame);
903 pix = sprite->pm;
904 c = new QCursor(*pix, hot_x, hot_y);
905 fc_cursors[cursor][frame] = c;
906 }
907 }
908}
909
910/************************************************************************/
913fc_corner::fc_corner(QMainWindow *qmw): QWidget()
914{
915 QHBoxLayout *hb;
916 QPushButton *qpb;
917 int h;
918 QFont *f = fc_font::instance()->get_font(fonts::default_font);
919
920 if (f->pointSize() > 0) {
921 h = f->pointSize();
922 } else {
923 h = f->pixelSize();
924 }
925 mw = qmw;
926 hb = new QHBoxLayout();
927 qpb = new QPushButton(fc_icons::instance()->get_icon("cmin"), "");
928 qpb->setFixedSize(h, h);
929 connect(qpb, &QAbstractButton::clicked, this, &fc_corner::minimize);
930 hb->addWidget(qpb);
931 qpb = new QPushButton(fc_icons::instance()->get_icon("cmax"), "");
932 qpb->setFixedSize(h, h);
933 connect(qpb, &QAbstractButton::clicked, this, &fc_corner::maximize);
934 hb->addWidget(qpb);
935 qpb = new QPushButton(fc_icons::instance()->get_icon("cclose"), "");
936 qpb->setFixedSize(h, h);
937 connect(qpb, &QAbstractButton::clicked, this, &fc_corner::close_fc);
938 hb->addWidget(qpb);
939 setLayout(hb);
940}
941
942/************************************************************************/
945 void fc_corner::close_fc()
946{
947 mw->close();
948}
949
950/************************************************************************/
953 void fc_corner::maximize()
954{
955 if (!mw->isMaximized()) {
956 mw->showMaximized();
957 } else {
958 mw->showNormal();
959 }
960}
961
962/************************************************************************/
965 void fc_corner::minimize()
966{
967 mw->showMinimized();
968}
969
970/************************************************************************/
973fc_game_tab_widget::fc_game_tab_widget(): QStackedWidget()
974{
975}
976
977/************************************************************************/
980 void fc_game_tab_widget::init()
981{
982 connect(this, &QStackedWidget::currentChanged, this, &fc_game_tab_widget::current_changed);
983}
984
985/************************************************************************/
988fc_icons::fc_icons()
989{
990}
991
992/************************************************************************/
995 fc_icons *fc_icons::instance()
996{
997 if (!m_instance) {
998 m_instance = new fc_icons;
999 }
1000 return m_instance;
1001}
1002
1003/************************************************************************/
1006 void fc_icons::drop()
1007{
1008 if (m_instance) {
1009 delete m_instance;
1010 m_instance = 0;
1011 }
1012}
1013
1014/************************************************************************/
1017QIcon fc_icons::get_icon(const QString &id)
1018{
1019 QIcon icon;
1020 QString str;
1021 QByteArray pn_bytes;
1022 QByteArray png_bytes;
1023
1024 str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
1025 /* Try custom icon from theme */
1026 pn_bytes = str.toUtf8();
1027 png_bytes = QString(pn_bytes.data() + current_theme + DIR_SEPARATOR
1028 + id + ".png").toUtf8();
1029 icon.addFile(fileinfoname(get_data_dirs(),
1030 png_bytes.data()));
1031 str = str + "icons" + DIR_SEPARATOR;
1032 /* Try icon from icons dir */
1033 if (icon.isNull()) {
1034 pn_bytes = str.toUtf8();
1035 png_bytes = QString(pn_bytes.data() + id + ".png").toUtf8();
1036 icon.addFile(fileinfoname(get_data_dirs(),
1037 png_bytes.data()));
1038 }
1039
1040 return QIcon(icon);
1041}
1042
1043/************************************************************************/
1046QPixmap *fc_icons::get_pixmap(const QString &id)
1047{
1048 QPixmap *pm;
1049 bool status;
1050 QString str;
1051 QByteArray png_bytes;
1052
1053 pm = new QPixmap;
1054 if (QPixmapCache::find(id, pm)) {
1055 return pm;
1056 }
1057 str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
1058 png_bytes = QString(str + current_theme + DIR_SEPARATOR
1059 + id + ".png").toUtf8();
1060 status = pm->load(fileinfoname(get_data_dirs(),
1061 png_bytes.data()));
1062
1063 if (!status) {
1064 str = str + "icons" + DIR_SEPARATOR;
1065 png_bytes = QString(str + id + ".png").toUtf8();
1066 pm->load(fileinfoname(get_data_dirs(), png_bytes.data()));
1067 }
1068 QPixmapCache::insert(id, *pm);
1069
1070 return pm;
1071}
1072
1073/************************************************************************/
1076QString fc_icons::get_path(const QString &id)
1077{
1078 QString str;
1079 QByteArray png_bytes;
1080
1081 str = QString("themes") + DIR_SEPARATOR + "gui-qt"
1082 + DIR_SEPARATOR + "icons" + DIR_SEPARATOR;
1083 png_bytes = QString(str + id + ".png").toUtf8();
1084
1085 return fileinfoname(get_data_dirs(),
1086 png_bytes.data());
1087}
1088
1089/************************************************************************/
1092 void fc_game_tab_widget::resizeEvent(QResizeEvent *event)
1093{
1094 QSize size;
1095
1096 size = event->size();
1097 if (C_S_RUNNING <= client_state()) {
1098 gui()->sidebar_wdg->resize_me(size.height());
1099 map_canvas_resized(size.width(), size.height());
1100 gui()->infotab->resize(qRound((size.width()
1101 * gui()->qt_settings.chat_fwidth)),
1102 qRound((size.height()
1103 * gui()->qt_settings.chat_fheight)));
1104 gui()->infotab->move(qRound((size.width()
1105 * gui()->qt_settings.chat_fx_pos)),
1106 qRound((size.height()
1107 * gui()->qt_settings.chat_fy_pos)));
1108 gui()->infotab->restore_chat();
1109 gui()->minimapview_wdg->move(qRound(gui()->qt_settings.minimap_x
1110 * mapview.width),
1111 qRound(gui()->qt_settings.minimap_y
1112 * mapview.height));
1113 gui()->minimapview_wdg->resize(qRound(gui()->qt_settings.minimap_width
1114 * mapview.width),
1115 qRound(gui()->qt_settings.minimap_height
1116 * mapview.height));
1117 gui()->battlelog_wdg->set_scale(gui()->qt_settings.battlelog_scale);
1118 gui()->battlelog_wdg->move(qRound(gui()->qt_settings.battlelog_x
1119 * mapview.width),
1120 qRound(gui()->qt_settings.battlelog_y
1121 * mapview.height));
1122 gui()->x_vote->move(width() / 2 - gui()->x_vote->width() / 2, 0);
1123 gui()->update_sidebar_tooltips();
1124 side_disable_endturn(get_turn_done_button_state());
1125 gui()->mapview_wdg->resize(event->size().width(),size.height());
1126 gui()->unitinfo_wdg->update_actions(nullptr);
1127 }
1128 event->setAccepted(true);
1129}
1130
1131/************************************************************************/
1134 void fc_game_tab_widget::current_changed(int index)
1135{
1136 QList<fc_sidewidget*> objs;
1137 fc_sidewidget *sw;
1138
1139 if (gui()->is_closing()) {
1140 return;
1141 }
1142 objs = gui()->sidebar_wdg->objects;
1143
1144 foreach(sw, objs) {
1145 sw->update_final_pixmap();
1146 }
1147 currentWidget()->hide();
1148 widget(index)->show();
1149
1150 /* Set focus to map instead sidebar */
1151 if (gui()->mapview_wdg && gui()->current_page() == PAGE_GAME
1152 && index == 0) {
1153 gui()->mapview_wdg->setFocus();
1154 }
1155
1156}
1157
1158/************************************************************************/
1161pregame_options::pregame_options(QWidget *parent) : QWidget(parent)
1162{
1163}
1164
1165/************************************************************************/
1168 void pregame_options::init()
1169{
1170 QFormLayout *layout;
1171 QPushButton *qclient_options;
1172 QHBoxLayout *hbox = nullptr;
1173 QPushButton *but;
1174 int level;
1175
1176 layout = new QFormLayout(this);
1177 nation = new QPushButton(this);
1178 qclient_options = new QPushButton(_("Client Options"));
1179 max_players = new QSpinBox(this);
1180 ailevel = new QComboBox(this);
1181 cruleset = new QComboBox(this);
1182 max_players->setRange(1, MAX_NUM_PLAYERS);
1183
1184 // Text and icon set by update_buttons()
1185 connect(nation, &QPushButton::clicked,
1186 this, &pregame_options::pick_nation);
1187 connect(qclient_options, SIGNAL(clicked()), parentWidget(),
1188 SLOT(popup_client_options()));
1189 for (level = 0; level < AI_LEVEL_COUNT; level++) {
1190 if (is_settable_ai_level(static_cast<ai_level>(level))) {
1191 const char *level_name = ai_level_translated_name(
1192 static_cast<ai_level>(level));
1193 ailevel->addItem(level_name, level);
1194 }
1195 }
1196 ailevel->setCurrentIndex(-1);
1197
1198 connect(max_players, SIGNAL(valueChanged(int)),
1199 SLOT(max_players_change(int)));
1200 connect(ailevel, SIGNAL(currentIndexChanged(int)),
1201 SLOT(ailevel_change(int)));
1202 connect(cruleset, SIGNAL(currentIndexChanged(int)),
1203 SLOT(ruleset_change(int)));
1204
1205 but = new QPushButton;
1206 but->setText(_("More Game Options"));
1207 but->setIcon(fc_icons::instance()->get_icon("preferences-other"));
1208 QObject::connect(but, &QAbstractButton::clicked, this,
1209 &pregame_options::popup_server_options);
1210
1211 layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
1212 layout->addRow(_("Nation:"), nation);
1213 layout->addRow(_("Rules:"), cruleset);
1214
1215 hbox = new QHBoxLayout();
1216 hbox->addWidget(max_players);
1217 hbox->addWidget(ailevel);
1218 layout->addRow(_("Players:"), hbox);
1219 layout->addWidget(but);
1220 layout->addWidget(qclient_options);
1221 setLayout(layout);
1222
1223 update_buttons();
1224}
1225
1226/************************************************************************/
1229 void pregame_options::set_rulesets(int num_rulesets, char **rulesets)
1230{
1231 int i;
1232 int def_idx = -1;
1233
1234 cruleset->clear();
1235 cruleset->blockSignals(true);
1236 for (i = 0; i < num_rulesets; i++) {
1237 cruleset->addItem(rulesets[i], i);
1238 if (!strcmp("default", rulesets[i])) {
1239 def_idx = i;
1240 }
1241 }
1242
1243 /* HACK: server should tell us the current ruleset. */
1244 cruleset->setCurrentIndex(def_idx);
1245 cruleset->blockSignals(false);
1246}
1247
1248/************************************************************************/
1252 void pregame_options::set_aifill(int aifill)
1253{
1254 max_players->blockSignals(true);
1255 max_players->setValue(aifill);
1256 max_players->blockSignals(false);
1257}
1258
1259/************************************************************************/
1262 void pregame_options::update_buttons()
1263{
1264 struct sprite *psprite = nullptr;
1265 QPixmap *pixmap = nullptr;
1266 const struct player *pplayer = client_player();
1267
1268 // Update the "Select Nation" button
1269 if (pplayer != nullptr) {
1270 if (pplayer->nation != nullptr) {
1271 // Defeat keyboard shortcut mnemonics
1272 nation->setText(QString(nation_adjective_for_player(pplayer))
1273 .replace("&", "&&"));
1274 psprite = get_nation_shield_sprite(tileset, pplayer->nation);
1275 pixmap = psprite->pm;
1276 nation->setIconSize(pixmap->size());
1277 nation->setIcon(QIcon(*pixmap));
1278 } else {
1279 nation->setText(_("Random"));
1280 nation->setIcon(fc_icons::instance()->get_icon("flush-random"));
1281 }
1282 }
1283}
1284
1285/************************************************************************/
1288 void pregame_options::update_ai_level()
1289{
1290 enum ai_level level = server_ai_level();
1291
1292 if (ai_level_is_valid(level)) {
1293 int i = ailevel->findData(level);
1294
1295 ailevel->setCurrentIndex(i);
1296 } else {
1297 ailevel->setCurrentIndex(-1);
1298 }
1299}
1300
1301/************************************************************************/
1304 void pregame_options::max_players_change(int i)
1305{
1306 option_int_set(optset_option_by_name(server_optset, "aifill"), i);
1307}
1308
1309/************************************************************************/
1312 void pregame_options::ailevel_change(int i)
1313{
1314 QVariant v = ailevel->currentData();
1315
1316 if (v.isValid()) {
1317 enum ai_level k = static_cast<ai_level>(v.toInt());
1318
1319 /* Suppress changes provoked by server rather than local user */
1320 if (server_ai_level() != k) {
1321 const char *name = ai_level_cmd(k);
1322
1323 send_chat_printf("/%s", name);
1324 }
1325 }
1326}
1327
1328/************************************************************************/
1331 void pregame_options::ruleset_change(int i)
1332{
1333 if (!cruleset->currentText().isEmpty()) {
1334 QByteArray rn_bytes;
1335
1336 rn_bytes = cruleset->currentText().toUtf8();
1337 set_ruleset(rn_bytes.data());
1338 }
1339}
1340
1341/************************************************************************/
1344 void pregame_options::pick_nation()
1345{
1346 popup_races_dialog(client_player());
1347}
1348
1349/************************************************************************/
1352 void pregame_options::popup_server_options()
1353{
1354 option_dialog_popup(_("Set server options"), server_optset, false);
1355}
str
#define str
Definition astring.c:76
get_font
static QFont * get_font(enum client_font font)
Definition canvas.cpp:359
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
psprite
struct canvas int int struct sprite * psprite
Definition canvas_g.h:50
apply_tags
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
Definition chatline.cpp:557
send_chat_printf
int send_chat_printf(const char *format,...)
Definition chatline_common.c:55
send_chat
int send_chat(const char *message)
Definition chatline_common.c:46
fc_allocate_ow_mutex
void fc_allocate_ow_mutex(void)
Definition chatline_common.c:71
fc_release_ow_mutex
void fc_release_ow_mutex(void)
Definition chatline_common.c:79
chat_welcome_message
void chat_welcome_message(bool gui_has_copying_mitem)
Definition chatline_common.c:177
chat_listener::send_chat_message
void send_chat_message(const QString &message)
Definition chatline.cpp:109
chatwdg::update_widgets
void update_widgets()
Definition chatline.cpp:488
fc_client::game_tab_widget
fc_game_tab_widget * game_tab_widget
Definition fc_client.h:259
fc_client::chat_message_received
void chat_message_received(const QString &message, const struct text_tag_list *tags)
Definition fc_client.cpp:306
fc_client::apply_fullscreen
void apply_fullscreen()
Definition fc_client.cpp:426
fc_client::info_tile_wdg
info_tile * info_tile_wdg
Definition fc_client.h:218
fc_client::status_bar_queue
QStringList status_bar_queue
Definition fc_client.h:351
fc_client::server_notifier
QSocketNotifier * server_notifier
Definition fc_client.h:201
fc_client::connect_host_edit
QLineEdit * connect_host_edit
Definition fc_client.h:188
fc_client::popdown_unit_sel
void popdown_unit_sel()
Definition fc_client.cpp:859
fc_client::output_window
QTextEdit * output_window
Definition fc_client.h:181
fc_client::interface_locked
bool interface_locked
Definition fc_client.h:273
fc_client::~fc_client
~fc_client()
Definition fc_client.cpp:244
fc_client::init
void init()
Definition fc_client.cpp:153
fc_client::update_sidebar_tooltips
void update_sidebar_tooltips()
Definition pages.cpp:2125
fc_client::qt_settings
fc_settings qt_settings
Definition fc_client.h:268
fc_client::gtd
goto_dialog * gtd
Definition fc_client.h:265
fc_client::menu_bar
mr_menu * menu_bar
Definition fc_client.h:257
fc_client::quitting
bool quitting
Definition fc_client.h:354
fc_client::meta_scan_timer
QTimer * meta_scan_timer
Definition fc_client.h:212
fc_client::battlelog_wdg
hud_battle_log * battlelog_wdg
Definition fc_client.h:272
fc_client::closing
void closing()
Definition fc_client.cpp:290
fc_client::connect_lan
QWidget * connect_lan
Definition fc_client.h:174
fc_client::lan_widget
QTableWidget * lan_widget
Definition fc_client.h:205
fc_client::fc_client
fc_client()
Definition fc_client.cpp:70
fc_client::connect_metaserver
QWidget * connect_metaserver
Definition fc_client.h:175
fc_client::connect_confirm_password_edit
QLineEdit * connect_confirm_password_edit
Definition fc_client.h:192
fc_client::chat_line
chat_input * chat_line
Definition fc_client.h:203
fc_client::unitinfo_wdg
hud_units * unitinfo_wdg
Definition fc_client.h:271
fc_client::map_font_scale
bool map_font_scale
Definition fc_client.h:280
fc_client::opened_dialog
choice_dialog * opened_dialog
Definition fc_client.h:219
fc_client::pre_vote
pregamevote * pre_vote
Definition fc_client.h:262
fc_client::saves_load
QTableWidget * saves_load
Definition fc_client.h:208
fc_client::read_settings
void read_settings()
Definition fc_client.cpp:649
fc_client::msgwdg
messagewdg * msgwdg
Definition fc_client.h:260
fc_client::set_status_bar
void set_status_bar(QString str, int timeout=2000)
Definition pages.cpp:437
fc_client::button
QPushButton * button
Definition fc_client.h:194
fc_client::is_repo_dlg_open
bool is_repo_dlg_open(QString str)
Definition fc_client.cpp:616
fc_client::server_input
void server_input(int sock)
Definition fc_client.cpp:502
fc_client::page
enum client_pages page
Definition fc_client.h:349
fc_client::current_page
enum client_pages current_page()
Definition fc_client.cpp:441
fc_client::unit_sel
units_select * unit_sel
Definition fc_client.h:263
fc_client::connect_password_edit
QLineEdit * connect_password_edit
Definition fc_client.h:191
fc_client::quit
void quit()
Definition fc_client.cpp:525
fc_client::minimapview_wdg
minimap_view * minimapview_wdg
Definition fc_client.h:232
fc_client::status_bar
QStatusBar * status_bar
Definition fc_client.h:216
fc_client::wan_widget
QTableWidget * wan_widget
Definition fc_client.h:206
fc_client::gimme_place
void gimme_place(QWidget *widget, QString str)
Definition fc_client.cpp:597
fc_client::fc_cursors
QCursor * fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES]
Definition fc_client.h:266
fc_client::mapview_wdg
map_view * mapview_wdg
Definition fc_client.h:230
fc_client::delete_cursors
void delete_cursors(void)
Definition fc_client.cpp:581
fc_client::central_layout
QStackedLayout * central_layout
Definition fc_client.h:179
fc_client::write_settings
void write_settings()
Definition fc_client.cpp:794
fc_client::infotab
info_tab * infotab
Definition fc_client.h:261
fc_client::create_start_page
void create_start_page()
Definition pages.cpp:627
fc_client::slot_disconnect
void slot_disconnect()
Definition fc_client.cpp:537
fc_client::pages
QWidget * pages[(int) PAGE_GAME+2]
Definition fc_client.h:173
fc_client::slot_pregame_observe
void slot_pregame_observe()
Definition fc_client.cpp:549
fc_client::info_widget
QTableWidget * info_widget
Definition fc_client.h:207
fc_client::set_connection_state
void set_connection_state(enum connection_state state)
Definition pages.cpp:252
fc_client::obs_button
QPushButton * obs_button
Definition fc_client.h:195
fc_client::update_info_label
void update_info_label()
Definition mapview.cpp:993
fc_client::status_bar_label
QLabel * status_bar_label
Definition fc_client.h:217
fc_client::pages_layout
QGridLayout * pages_layout[PAGE_GAME+2]
Definition fc_client.h:178
fc_client::main_wdg
QWidget * main_wdg
Definition fc_client.h:172
fc_client::connect_login_edit
QLineEdit * connect_login_edit
Definition fc_client.h:190
fc_client::add_server_source
void add_server_source(int)
Definition fc_client.cpp:449
fc_client::scenarios_view
QTextEdit * scenarios_view
Definition fc_client.h:182
fc_client::button_box
QDialogButtonBox * button_box
Definition fc_client.h:199
fc_client::destroy_server_scans
void destroy_server_scans(void)
Definition pages.cpp:982
fc_client::create_cursors
void create_cursors(void)
Definition fc_client.cpp:890
fc_client::switch_page
void switch_page(int i)
Definition fc_client.cpp:338
fc_client::create_network_page
void create_network_page()
Definition pages.cpp:289
fc_client::start_players_tree
QTreeWidget * start_players_tree
Definition fc_client.h:210
fc_client::chat_active_on_page
bool chat_active_on_page(enum client_pages)
Definition fc_client.cpp:323
fc_client::create_load_page
void create_load_page()
Definition pages.cpp:481
fc_client::lan_scan_timer
QTimer * lan_scan_timer
Definition fc_client.h:213
fc_client::connect_port_edit
QLineEdit * connect_port_edit
Definition fc_client.h:189
fc_client::sidebar_wdg
fc_sidebar * sidebar_wdg
Definition fc_client.h:231
fc_client::create_main_page
void create_main_page()
Definition pages.cpp:136
fc_client::event
bool event(QEvent *event)
Definition fc_client.cpp:468
fc_client::map_scale
float map_scale
Definition fc_client.h:279
fc_client::create_loading_page
void create_loading_page()
Definition pages.cpp:469
fc_client::update_fonts
void update_fonts()
Definition fc_client.cpp:460
fc_client::update_network_lists
void update_network_lists()
Definition pages.cpp:1012
fc_client::central_wdg
QWidget * central_wdg
Definition fc_client.h:256
fc_client::fc_main
void fc_main(QApplication *qapp)
Definition fc_client.cpp:260
fc_client::opened_repo_dlgs
QMap< QString, QWidget * > opened_repo_dlgs
Definition fc_client.h:350
fc_client::current_file
QString current_file
Definition fc_client.h:352
fc_client::closeEvent
void closeEvent(QCloseEvent *event)
Definition fc_client.cpp:483
fc_client::x_vote
xvote * x_vote
Definition fc_client.h:264
fc_client::remove_repo_dlg
void remove_repo_dlg(QString str)
Definition fc_client.cpp:871
fc_client::slot_pregame_start
void slot_pregame_start()
Definition fc_client.cpp:567
fc_client::update_info_timer
QTimer * update_info_timer
Definition fc_client.h:214
fc_client::toggle_unit_sel_widget
void toggle_unit_sel_widget(struct tile *ptile)
Definition fc_client.cpp:831
fc_client::popup_client_options
void popup_client_options()
Definition fc_client.cpp:882
fc_client::update_unit_sel
void update_unit_sel()
Definition fc_client.cpp:847
fc_client::update_load_page
void update_load_page(void)
Definition pages.cpp:1398
fc_client::scenarios_load
QTableWidget * scenarios_load
Definition fc_client.h:209
fc_client::gimme_index_of
int gimme_index_of(QString str)
Definition fc_client.cpp:632
fc_client::corner_wid
fc_corner * corner_wid
Definition fc_client.h:258
fc_client::send_fake_chat_message
void send_fake_chat_message(const QString &message)
Definition fc_client.cpp:298
fc_client::timerEvent
void timerEvent(QTimerEvent *)
Definition fc_client.cpp:512
fc_client::is_closing
bool is_closing()
Definition fc_client.cpp:282
fc_client::create_scenario_page
void create_scenario_page()
Definition pages.cpp:560
fc_client::remove_server_source
void remove_server_source()
Definition fc_client.cpp:494
fc_client::update_scenarios_page
void update_scenarios_page(void)
Definition pages.cpp:1429
fc_client::create_game_page
void create_game_page()
Definition pages.cpp:711
fc_corner
Definition fc_client.h:156
fc_corner::minimize
void minimize()
Definition fc_client.cpp:965
fc_corner::mw
QMainWindow * mw
Definition fc_client.h:158
fc_corner::maximize
void maximize()
Definition fc_client.cpp:953
fc_corner::close_fc
void close_fc()
Definition fc_client.cpp:945
fc_corner::fc_corner
fc_corner(QMainWindow *qmw)
Definition fc_client.cpp:913
fc_font
Definition fonts.h:39
fc_font::m_instance
static fc_font * m_instance
Definition fonts.h:43
fc_font::init_fonts
void init_fonts()
Definition fonts.cpp:79
fc_font::instance
static fc_font * instance()
Definition fonts.cpp:41
fc_font::get_font
QFont * get_font(QString name)
Definition fonts.cpp:63
fc_game_tab_widget::fc_game_tab_widget
fc_game_tab_widget()
Definition fc_client.cpp:973
fc_game_tab_widget::init
void init()
Definition fc_client.cpp:980
fc_game_tab_widget::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition fc_client.cpp:1092
fc_game_tab_widget::current_changed
void current_changed(int index)
Definition fc_client.cpp:1134
fc_icons
Definition fc_client.h:88
fc_icons::fc_icons
fc_icons()
Definition fc_client.cpp:988
fc_icons::get_icon
QIcon get_icon(const QString &id)
Definition fc_client.cpp:1017
fc_icons::drop
static void drop()
Definition fc_client.cpp:1006
fc_icons::m_instance
static fc_icons * m_instance
Definition fc_client.h:93
fc_icons::get_pixmap
QPixmap * get_pixmap(const QString &id)
Definition fc_client.cpp:1046
fc_icons::instance
static fc_icons * instance()
Definition fc_client.cpp:995
fc_icons::get_path
QString get_path(const QString &id)
Definition fc_client.cpp:1076
fc_shortcuts::sc
static fc_shortcuts * sc()
Definition shortcuts.cpp:277
fc_sidewidget
Definition sidebar.h:49
fc_sidewidget::update_final_pixmap
void update_final_pixmap()
Definition sidebar.cpp:393
hud_battle_log::set_scale
void set_scale(float s)
Definition hudwidget.cpp:2034
hud_units::update_actions
void update_actions(unit_list *punits)
Definition hudwidget.cpp:577
info_tab::restore_chat
void restore_chat()
Definition messagewin.cpp:64
info_tab::chtwdg
chatwdg * chtwdg
Definition messagewin.h:79
listener< chat_listener >::listen
void listen()
Definition listener.h:149
minimap_view::reset
void reset()
Definition mapview.cpp:729
pregame_options::pick_nation
void pick_nation()
Definition fc_client.cpp:1344
pregame_options::popup_server_options
void popup_server_options()
Definition fc_client.cpp:1352
pregame_options::nation
QPushButton * nation
Definition fc_client.h:374
pregame_options::update_ai_level
void update_ai_level()
Definition fc_client.cpp:1288
pregame_options::ailevel
QComboBox * ailevel
Definition fc_client.h:372
pregame_options::ailevel_change
void ailevel_change(int i)
Definition fc_client.cpp:1312
pregame_options::set_rulesets
void set_rulesets(int num_rulesets, char **rulesets)
Definition fc_client.cpp:1229
pregame_options::set_aifill
void set_aifill(int aifill)
Definition fc_client.cpp:1252
pregame_options::max_players_change
void max_players_change(int i)
Definition fc_client.cpp:1304
pregame_options::init
void init()
Definition fc_client.cpp:1168
pregame_options::cruleset
QComboBox * cruleset
Definition fc_client.h:373
pregame_options::pregame_options
pregame_options(QWidget *parent)
Definition fc_client.cpp:1161
pregame_options::ruleset_change
void ruleset_change(int i)
Definition fc_client.cpp:1331
pregame_options::update_buttons
void update_buttons()
Definition fc_client.cpp:1262
pregame_options::max_players
QSpinBox * max_players
Definition fc_client.h:375
units_select
Definition dialogs.h:203
units_select::update_units
void update_units()
Definition dialogs.cpp:4654
units_select::create_pixmap
void create_pixmap()
Definition dialogs.cpp:4353
version_message_event
Definition chatline.h:146
version_message_event::get_message
QString get_message() const
Definition chatline.h:150
is_client_quitting
bool is_client_quitting(void)
Definition client_main.c:1637
can_client_control
bool can_client_control(void)
Definition client_main.c:1254
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1346
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
user_name
char user_name[512]
Definition client_main.c:141
real_timer_callback
double real_timer_callback(void)
Definition client_main.c:1183
server_host
char server_host[512]
Definition client_main.c:140
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
server_port
int server_port
Definition client_main.c:144
set_client_state
void set_client_state(enum client_states newstate)
Definition client_main.c:847
client_player
#define client_player()
Definition client_main.h:106
TIMER_INTERVAL
#define TIMER_INTERVAL
Definition client_main.h:30
C_S_DISCONNECTED
@ C_S_DISCONNECTED
Definition client_main.h:45
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
server_ai_level
enum ai_level server_ai_level(void)
Definition climisc.c:1501
center_on_something
void center_on_something(void)
Definition climisc.c:424
input_from_server
void input_from_server(int fd)
Definition clinet.c:406
disconnect_from_server
void disconnect_from_server(void)
Definition clinet.c:305
set_ruleset
void set_ruleset(const char *ruleset)
Definition connectdlg_common.c:774
is_server_running
bool is_server_running(void)
Definition connectdlg_common.c:124
connectdlg_common.h
event
enum event_type event
Definition events.c:81
get_turn_done_button_state
bool get_turn_done_button_state()
Definition mapctrl_common.c:519
current_theme
QString current_theme
Definition fc_client.cpp:65
real_science_report_dialog_update
void real_science_report_dialog_update(void *)
Definition repodlgs.c:751
write_shortcuts
void write_shortcuts()
Definition shortcuts.cpp:791
fc_client.h
LOGIN_TYPE
@ LOGIN_TYPE
Definition fc_client.h:56
gui
class fc_client * gui()
Definition gui_main.cpp:83
MAX_NUM_PLAYERS
#define MAX_NUM_PLAYERS
Definition fc_types.h:36
_
#define _(String)
Definition fcintl.h:67
fonts.h
game
struct civ_game game
Definition game.c:57
game.h
layout
static PangoLayout * layout
Definition canvas.c:331
real_output_window_append
void real_output_window_append(const char *astring, const struct text_tag_list *tags, int conn_id)
Definition chatline.c:874
popup_races_dialog
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1223
popup_quit_dialog
void popup_quit_dialog(void)
Definition gui_main.c:2153
overview_size_changed
void overview_size_changed(void)
Definition mapview.c:309
option_dialog_popup
void option_dialog_popup(const char *name, const struct option_set *poptset)
Definition optiondlg.c:979
current_page
static enum client_pages current_page
Definition pages.c:78
real_science_report_dialog_update
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
voteinfo_gui_update
void voteinfo_gui_update(void)
Definition voteinfo_bar.c:214
gui_main.h
optiondlg.h
sprite.h
qapp
static QApplication * qapp
Definition gui_main.cpp:70
current_app
QApplication * current_app()
Definition gui_main.cpp:220
show_new_turn_info
void show_new_turn_info()
Definition hudwidget.cpp:1659
name
const char * name
Definition inputfile.c:127
log_error
#define log_error(message,...)
Definition log.h:103
side_disable_endturn
void side_disable_endturn(bool do_restore)
Definition sidebar.cpp:677
init_mapcanvas_and_overview
void init_mapcanvas_and_overview(void)
Definition mapview_common.c:3683
mapview
struct view mapview
Definition mapview_common.c:74
free_mapcanvas_and_overview
void free_mapcanvas_and_overview(void)
Definition mapview_common.c:3692
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3592
fonts::default_font
const char *const default_font
Definition fonts.h:27
nation_adjective_for_player
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:168
server_optset
const struct option_set * server_optset
Definition options.c:4009
client_optset
const struct option_set * client_optset
Definition options.c:1255
gui_options
struct client_options gui_options
Definition options.c:71
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
option_int_set
bool option_int_set(struct option *poption, int val)
Definition options.c:853
MAJOR_NEW_OPTION_FILE_NAME
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:37
MINOR_NEW_OPTION_FILE_NAME
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:41
dsend_packet_player_ready
int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
Definition packets_gen.c:2969
client_start_server_and_set_page
void client_start_server_and_set_page(enum client_pages page)
Definition update_queue.c:506
set_client_page
void set_client_page(enum client_pages page)
Definition update_queue.c:496
is_settable_ai_level
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1883
player_number
int player_number(const struct player *pplayer)
Definition player.c:828
ai_level_cmd
#define ai_level_cmd(_level_)
Definition player.h:565
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
fileinfoname
const char * fileinfoname(const struct strvec *dirs, const char *filename)
Definition shared.c:1094
get_data_dirs
const struct strvec * get_data_dirs(void)
Definition shared.c:886
DIR_SEPARATOR
#define DIR_SEPARATOR
Definition shared.h:127
sidebar.h
size
size_t size
Definition specvec.h:72
aifill
const char * aifill(int amount)
Definition srv_main.c:2395
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_qt_fullscreen
bool gui_qt_fullscreen
Definition options.h:386
client_options::gui_qt_allied_chat_only
bool gui_qt_allied_chat_only
Definition options.h:388
client_options::gui_qt_show_titlebar
bool gui_qt_show_titlebar
Definition options.h:399
connection::used
bool used
Definition connection.h:144
fc_settings::city_splitter2
QByteArray city_splitter2
Definition fc_client.h:135
fc_settings::city_geometry
QByteArray city_geometry
Definition fc_client.h:133
fc_settings::help_geometry
QByteArray help_geometry
Definition fc_client.h:137
fc_settings::unit_info_pos_fx
float unit_info_pos_fx
Definition fc_client.h:141
fc_settings::options_client_geometry
QByteArray options_client_geometry
Definition fc_client.h:139
fc_settings::unit_info_pos_fy
float unit_info_pos_fy
Definition fc_client.h:142
fc_settings::chat_fwidth
float chat_fwidth
Definition fc_client.h:123
fc_settings::chat_fheight
float chat_fheight
Definition fc_client.h:124
fc_settings::help_splitter1
QByteArray help_splitter1
Definition fc_client.h:138
fc_settings::chat_fx_pos
float chat_fx_pos
Definition fc_client.h:125
fc_settings::battlelog_scale
float battlelog_scale
Definition fc_client.h:147
fc_settings::battlelog_x
float battlelog_x
Definition fc_client.h:148
fc_settings::city_splitter3
QByteArray city_splitter3
Definition fc_client.h:136
fc_settings::minimap_x
float minimap_x
Definition fc_client.h:143
fc_settings::minimap_height
float minimap_height
Definition fc_client.h:146
fc_settings::show_battle_log
bool show_battle_log
Definition fc_client.h:129
fc_settings::city_repo_sort_col
int city_repo_sort_col
Definition fc_client.h:131
fc_settings::minimap_width
float minimap_width
Definition fc_client.h:145
fc_settings::battlelog_y
float battlelog_y
Definition fc_client.h:149
fc_settings::options_server_geometry
QByteArray options_server_geometry
Definition fc_client.h:140
fc_settings::chat_fy_pos
float chat_fy_pos
Definition fc_client.h:126
fc_settings::city_splitter1
QByteArray city_splitter1
Definition fc_client.h:134
fc_settings::show_new_turn_text
bool show_new_turn_text
Definition fc_client.h:128
fc_settings::minimap_y
float minimap_y
Definition fc_client.h:144
fc_settings::player_repo_sort_col
int player_repo_sort_col
Definition fc_client.h:127
message
Definition messagewin_common.h:29
packet_game_info::is_new_game
bool is_new_game
Definition packets_gen.h:186
player
Definition player.h:249
player::nation
struct nation_type * nation
Definition player.h:260
sprite
Definition sprite.h:22
sprite::pm
QPixmap * pm
Definition sprite.h:25
tile
Definition tile.h:49
tileset
Definition tilespec.c:459
view::height
int height
Definition mapview_common.h:38
view::width
int width
Definition mapview_common.h:38
widget
Definition widget.h:112
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
TRUE
#define TRUE
Definition support.h:46
tileset_free_tiles
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6346
get_nation_shield_sprite
struct sprite * get_nation_shield_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6480
get_cursor_sprite
struct sprite * get_cursor_sprite(const struct tileset *t, enum cursor_type cursor, int *hot_x, int *hot_y, int frame)
Definition tilespec.c:6660
NUM_CURSOR_FRAMES
#define NUM_CURSOR_FRAMES
Definition tilespec.h:300
cursor_type
cursor_type
Definition tilespec.h:285
CURSOR_LAST
@ CURSOR_LAST
Definition tilespec.h:296