equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. |
12 * GNU General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 */ |
17 */ |
|
18 |
|
19 #include <QApplication> |
|
20 #include <QClipboard> |
18 |
21 |
19 #include <QString> |
22 #include <QString> |
20 #include <QCheckBox> |
23 #include <QCheckBox> |
21 #include <QByteArray> |
24 #include <QByteArray> |
22 #include <QUuid> |
25 #include <QUuid> |
58 netSuspend = false; |
61 netSuspend = false; |
59 |
62 |
60 lastGameCfg = gamecfg; |
63 lastGameCfg = gamecfg; |
61 lastGameAmmo = ammo; |
64 lastGameAmmo = ammo; |
62 lastGameTeamSel = pTeamSelWidget; |
65 lastGameTeamSel = pTeamSelWidget; |
|
66 |
|
67 gameState = gsNotStarted; |
|
68 gameType = gtNone; |
63 } |
69 } |
64 |
70 |
65 HWGame::~HWGame() |
71 HWGame::~HWGame() |
66 { |
72 { |
67 SetGameState(gsDestroyed); |
73 SetGameState(gsDestroyed); |
140 HWProto::addStringToBuffer(teamscfg, QString("etheme %1") |
146 HWProto::addStringToBuffer(teamscfg, QString("etheme %1") |
141 .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data(ThemeModel::ActualNameRole).toString() : "steel")); |
147 .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data(ThemeModel::ActualNameRole).toString() : "steel")); |
142 HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); |
148 HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); |
143 |
149 |
144 HWProto::addStringToBuffer(teamscfg, "e$template_filter 2"); |
150 HWProto::addStringToBuffer(teamscfg, "e$template_filter 2"); |
|
151 HWProto::addStringToBuffer(teamscfg, "e$feature_size "+QString::number(rand()%18+4)); |
145 |
152 |
146 HWTeam team1; |
153 HWTeam team1; |
147 team1.setDifficulty(0); |
154 team1.setDifficulty(0); |
148 team1.setColor(0); |
155 team1.setColor(0); |
149 team1.setNumHedgehogs(4); |
156 team1.setNumHedgehogs(4); |
243 break; |
250 break; |
244 } |
251 } |
245 case 'E': |
252 case 'E': |
246 { |
253 { |
247 int size = msg.size(); |
254 int size = msg.size(); |
248 emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); |
255 emit ErrorMessage( |
|
256 tr("A Fatal ERROR occured! - The game engine had to stop.\n\n" |
|
257 "We are very sorry for the inconvenience :(\n\n" |
|
258 "If this keeps happening, please click the '%1' button in the main menu!\n\n" |
|
259 "Last two engine messages:\n%2") |
|
260 .arg("Feedback") |
|
261 .arg(QString::fromUtf8(msg.mid(2).left(size - 4)))); |
249 return; |
262 return; |
|
263 } |
|
264 case 'y': |
|
265 { |
|
266 // copy string to clipboard |
|
267 QApplication::clipboard()->setText(QString::fromUtf8(msg.mid(2))); |
|
268 break; |
|
269 } |
|
270 case 'Y': |
|
271 { |
|
272 // paste clipboard to game |
|
273 SendIPC(QString("Y").toAscii() + QApplication::clipboard()->text().toUtf8().left(250).replace('\n', ' ')); |
|
274 break; |
250 } |
275 } |
251 case 'i': |
276 case 'i': |
252 { |
277 { |
253 emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); |
278 emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); |
254 break; |
279 break; |
299 int size = msg.size(); |
324 int size = msg.size(); |
300 QString newResolution = QString().append(msg.mid(2)).left(size - 4); |
325 QString newResolution = QString().append(msg.mid(2)).left(size - 4); |
301 QStringList wh = newResolution.split('x'); |
326 QStringList wh = newResolution.split('x'); |
302 config->Form->ui.pageOptions->windowWidthEdit->setValue(wh[0].toInt()); |
327 config->Form->ui.pageOptions->windowWidthEdit->setValue(wh[0].toInt()); |
303 config->Form->ui.pageOptions->windowHeightEdit->setValue(wh[1].toInt()); |
328 config->Form->ui.pageOptions->windowHeightEdit->setValue(wh[1].toInt()); |
|
329 break; |
|
330 } |
|
331 case '~': |
|
332 { |
|
333 int size = msg.size(); |
|
334 QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); |
|
335 emit SendConsoleCommand(msgbody); |
304 break; |
336 break; |
305 } |
337 } |
306 default: |
338 default: |
307 { |
339 { |
308 if (gameType == gtNet && !netSuspend) |
340 if (gameType == gtNet && !netSuspend) |