author | displacer |
Tue, 20 Feb 2007 19:00:46 +0000 | |
changeset 464 | 7f48321fc38a |
parent 425 | a7e1dabc8fb7 |
child 486 | 7ea71cd3acd5 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
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 |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#ifndef GAME_H |
|
20 |
#define GAME_H |
|
21 |
||
22 |
#include <QObject> |
|
23 |
#include <QByteArray> |
|
24 |
#include <QString> |
|
25 |
#include "team.h" |
|
26 |
||
27 |
#include <map> |
|
28 |
||
29 |
#include "tcpBase.h" |
|
30 |
||
31 |
class GameUIConfig; |
|
32 |
class GameCFGWidget; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
33 |
class TeamSelWidget; |
184 | 34 |
|
306 | 35 |
enum GameState { |
36 |
gsNotStarted = 0, |
|
37 |
gsStarted = 1, |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
38 |
gsInterrupted = 2, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
39 |
gsFinished = 3, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
40 |
gsStopped = 4 |
306 | 41 |
}; |
42 |
||
43 |
||
184 | 44 |
class HWGame : public TCPBase |
45 |
{ |
|
46 |
Q_OBJECT |
|
47 |
public: |
|
341 | 48 |
HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget = 0); |
419
fdeed9718e6b
virtual destructors for tcpBase derived classes, readarray clear removed as unneeded
displacer
parents:
395
diff
changeset
|
49 |
virtual ~HWGame(); |
341 | 50 |
void AddTeam(const QString & team); |
184 | 51 |
void PlayDemo(const QString & demofilename); |
52 |
void StartLocal(); |
|
53 |
void StartQuick(); |
|
54 |
void StartNet(); |
|
55 |
||
56 |
protected: |
|
57 |
virtual QStringList setArguments(); |
|
58 |
virtual void onClientRead(); |
|
59 |
virtual void onClientDisconnect(); |
|
60 |
||
61 |
signals: |
|
62 |
void SendNet(const QByteArray & msg); |
|
306 | 63 |
void GameStateChanged(GameState gameState); |
64 |
void GameStats(char type, const QString & info); |
|
425 | 65 |
void ErrorMessage(const QString &); |
184 | 66 |
|
67 |
public slots: |
|
68 |
void FromNet(const QByteArray & msg); |
|
69 |
||
70 |
private: |
|
71 |
enum GameType { |
|
72 |
gtLocal = 1, |
|
73 |
gtQLocal = 2, |
|
74 |
gtDemo = 3, |
|
75 |
gtNet = 4 |
|
76 |
}; |
|
77 |
char msgbuf[MAXMSGCHARS]; |
|
78 |
QString teams[5]; |
|
79 |
QString seed; |
|
80 |
int TeamCount; |
|
81 |
GameUIConfig * config; |
|
82 |
GameCFGWidget * gamecfg; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
83 |
TeamSelWidget* m_pTeamSelWidget; |
184 | 84 |
GameType gameType; |
85 |
||
253 | 86 |
void commonConfig(); |
184 | 87 |
void SendConfig(); |
88 |
void SendQuickConfig(); |
|
341 | 89 |
void SendNetConfig(); |
184 | 90 |
void ParseMessage(const QByteArray & msg); |
91 |
void SaveDemo(const QString & filename); |
|
92 |
}; |
|
93 |
||
94 |
#endif |