author | koda |
Tue, 30 Jun 2009 12:31:32 +0000 | |
changeset 2213 | bd51bbf06033 |
parent 1907 | a104432e8301 |
child 2403 | 6c5d504af2ba |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2005-2008 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 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 <QString> |
|
23 |
#include "team.h" |
|
1907 | 24 |
#include "namegen.h" |
184 | 25 |
|
26 |
#include "tcpBase.h" |
|
27 |
||
28 |
class GameUIConfig; |
|
29 |
class GameCFGWidget; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
30 |
class TeamSelWidget; |
184 | 31 |
|
306 | 32 |
enum GameState { |
33 |
gsNotStarted = 0, |
|
34 |
gsStarted = 1, |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
35 |
gsInterrupted = 2, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
36 |
gsFinished = 3, |
686 | 37 |
gsStopped = 4, |
38 |
gsDestroyed = 5 |
|
306 | 39 |
}; |
40 |
||
41 |
||
184 | 42 |
class HWGame : public TCPBase |
43 |
{ |
|
44 |
Q_OBJECT |
|
45 |
public: |
|
681 | 46 |
HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); |
419
fdeed9718e6b
virtual destructors for tcpBase derived classes, readarray clear removed as unneeded
displacer
parents:
395
diff
changeset
|
47 |
virtual ~HWGame(); |
341 | 48 |
void AddTeam(const QString & team); |
184 | 49 |
void PlayDemo(const QString & demofilename); |
50 |
void StartLocal(); |
|
51 |
void StartQuick(); |
|
52 |
void StartNet(); |
|
587 | 53 |
void StartTraining(); |
184 | 54 |
|
55 |
protected: |
|
56 |
virtual QStringList setArguments(); |
|
57 |
virtual void onClientRead(); |
|
58 |
virtual void onClientDisconnect(); |
|
59 |
||
60 |
signals: |
|
61 |
void SendNet(const QByteArray & msg); |
|
1356 | 62 |
void SendChat(const QString & msg); |
306 | 63 |
void GameStateChanged(GameState gameState); |
64 |
void GameStats(char type, const QString & info); |
|
533 | 65 |
void HaveRecord(bool isDemo, const QByteArray & record); |
425 | 66 |
void ErrorMessage(const QString &); |
184 | 67 |
|
68 |
public slots: |
|
69 |
void FromNet(const QByteArray & msg); |
|
1356 | 70 |
void FromNetChat(const QString & msg); |
184 | 71 |
|
72 |
private: |
|
1375 | 73 |
enum GameType { |
74 |
gtLocal = 1, |
|
75 |
gtQLocal = 2, |
|
76 |
gtDemo = 3, |
|
77 |
gtNet = 4, |
|
78 |
gtTraining = 5 |
|
184 | 79 |
}; |
80 |
char msgbuf[MAXMSGCHARS]; |
|
81 |
QString teams[5]; |
|
681 | 82 |
QString ammostr; |
184 | 83 |
int TeamCount; |
84 |
GameUIConfig * config; |
|
85 |
GameCFGWidget * gamecfg; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
86 |
TeamSelWidget* m_pTeamSelWidget; |
184 | 87 |
GameType gameType; |
533 | 88 |
GameState gameState; |
184 | 89 |
|
253 | 90 |
void commonConfig(); |
184 | 91 |
void SendConfig(); |
92 |
void SendQuickConfig(); |
|
341 | 93 |
void SendNetConfig(); |
588 | 94 |
void SendTrainingConfig(); |
184 | 95 |
void ParseMessage(const QByteArray & msg); |
533 | 96 |
void SetGameState(GameState state); |
184 | 97 |
}; |
98 |
||
99 |
#endif |