Freeciv-3.2
Loading...
Searching...
No Matches
spaceshipdlg.cpp
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QGridLayout>
20#include <QLabel>
21
22// common
23#include "game.h"
24#include "victory.h"
25
26// client
27#include "client_main.h"
28
29// gui-qt
30#include "canvas.h"
31#include "fc_client.h"
32#include "qtg_cxxside.h"
33#include "spaceshipdlg.h"
34
35
36class QGridLayout;
37
38/************************************************************************/
42{
43 int w, h;
44
45 setAttribute(Qt::WA_DeleteOnClose);
46 player = pplayer;
48 can = qtg_canvas_create(w, h);
49
51 ss_pix_label = new QLabel;
52 ss_pix_label->setPixmap(can->map_pixmap);
53 layout->addWidget(ss_pix_label, 0, 0, 3, 3);
54 ss_label = new QLabel;
55 layout->addWidget(ss_label, 0, 3, 3, 1);
56 launch_button = new QPushButton(_("Launch"));
57 connect(launch_button, &QAbstractButton::clicked, this, &ss_report::launch);
58 layout->addWidget(launch_button, 4, 3, 1, 1);
61}
62
63/************************************************************************/
67{
68 gui()->remove_repo_dlg("SPS");
70}
71
72/************************************************************************/
76{
77 int index;
78 gui()->gimme_place(this, "SPS");
79 index = gui()->add_game_tab(this);
80 gui()->game_tab_widget->setCurrentIndex(index);
82}
83
84/************************************************************************/
88{
89 const char *ch;
90 struct player_spaceship *pship;
91
93
95 && pship->state == SSHIP_STARTED && pship->success_rate > 0.0) {
96 launch_button->setEnabled(true);
97 } else {
98 launch_button->setEnabled(false);
99 }
101 ss_label->setText(ch);
102 put_spaceship(can, 0, 0, player);
103 ss_pix_label->setPixmap(can->map_pixmap);
104 update();
105}
106
107/************************************************************************/
114
115/************************************************************************/
118void popup_spaceship_dialog(struct player *pplayer)
119{
121 int i;
122 QWidget *w;
123
125 return;
126 }
127 if (!gui()->is_repo_dlg_open("SPS")) {
128 ss_rep = new ss_report(pplayer);
129 ss_rep->init();
130 } else {
131 i = gui()->gimme_index_of("SPS");
132 fc_assert(i != -1);
133 if (gui()->game_tab_widget->currentIndex() == i) {
134 return;
135 }
136 w = gui()->game_tab_widget->widget(i);
137 ss_rep = reinterpret_cast<ss_report *>(w);
138 gui()->game_tab_widget->setCurrentWidget(ss_rep);
139 }
140}
141
142/************************************************************************/
145void popdown_spaceship_dialog(struct player *pplayer)
146{
147 // PORTME
148}
149
150/************************************************************************/
153void refresh_spaceship_dialog(struct player *pplayer)
154{
155 int i;
157 QWidget *w;
158
159 if (!gui()->is_repo_dlg_open("SPS")) {
160 return;
161 } else {
162 i = gui()->gimme_index_of("SPS");
163 fc_assert(i != -1);
164 w = gui()->game_tab_widget->widget(i);
165 ss_rep = reinterpret_cast<ss_report*>(w);
166 gui()->game_tab_widget->setCurrentWidget(ss_rep);
167 ss_rep->update_report();
168 }
169}
170
171/************************************************************************/
175{
176 int i;
178 QWidget *w;
179
180 if (!gui()->is_repo_dlg_open("SPS")) {
181 return;
182 }
183 else {
184 i = gui()->gimme_index_of("SPS");
185 fc_assert(i != -1);
186 w = gui()->game_tab_widget->widget(i);
187 ss_rep = reinterpret_cast<ss_report*>(w);
188 ss_rep->deleteLater();
189 }
190}
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:48
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
QLabel * ss_pix_label
QLabel * ss_label
struct canvas * can
QPushButton * launch_button
void update_report()
ss_report(struct player *pplayer)
bool client_is_global_observer(void)
struct civclient client
char * incite_cost
Definition comments.c:75
@ VC_SPACERACE
Definition fc_types.h:1271
#define _(String)
Definition fcintl.h:67
static PangoLayout * layout
Definition canvas.c:325
#define fc_assert(condition)
Definition log.h:176
void get_spaceship_dimensions(int *width, int *height)
void put_spaceship(struct canvas *pcanvas, int canvas_x, int canvas_y, const struct player *pplayer)
static mpgui * gui
Definition mpgui_qt.cpp:52
int send_packet_spaceship_launch(struct connection *pc)
@ SSHIP_STARTED
Definition spaceship.h:84
void popdown_spaceship_dialog(struct player *pplayer)
void popdown_all_spaceships_dialogs()
void popup_spaceship_dialog(struct player *pplayer)
void refresh_spaceship_dialog(struct player *pplayer)
QPixmap map_pixmap
Definition canvas.h:25
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
struct player_spaceship spaceship
Definition player.h:284
const char * get_spaceship_descr(struct player_spaceship *pship)
Definition text.c:1500
bool victory_enabled(enum victory_condition_type victory)
Definition victory.c:26