author | displacer |
Mon, 21 Jan 2008 21:25:42 +0000 | |
changeset 747 | c7f67e90c3ee |
parent 686 | 494b5880989a |
child 788 | 00720357601f |
permissions | -rw-r--r-- |
184 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
486 | 3 |
* Copyright (c) 2005-2007 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" |
|
24 |
||
25 |
#include "tcpBase.h" |
|
26 |
||
27 |
class GameUIConfig; |
|
28 |
class GameCFGWidget; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
29 |
class TeamSelWidget; |
184 | 30 |
|
306 | 31 |
enum GameState { |
32 |
gsNotStarted = 0, |
|
33 |
gsStarted = 1, |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
34 |
gsInterrupted = 2, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
35 |
gsFinished = 3, |
686 | 36 |
gsStopped = 4, |
37 |
gsDestroyed = 5 |
|
306 | 38 |
}; |
39 |
||
40 |
||
184 | 41 |
class HWGame : public TCPBase |
42 |
{ |
|
43 |
Q_OBJECT |
|
44 |
public: |
|
681 | 45 |
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
|
46 |
virtual ~HWGame(); |
341 | 47 |
void AddTeam(const QString & team); |
184 | 48 |
void PlayDemo(const QString & demofilename); |
49 |
void StartLocal(); |
|
50 |
void StartQuick(); |
|
51 |
void StartNet(); |
|
587 | 52 |
void StartTraining(); |
184 | 53 |
|
54 |
protected: |
|
55 |
virtual QStringList setArguments(); |
|
56 |
virtual void onClientRead(); |
|
57 |
virtual void onClientDisconnect(); |
|
58 |
||
59 |
signals: |
|
60 |
void SendNet(const QByteArray & msg); |
|
306 | 61 |
void GameStateChanged(GameState gameState); |
62 |
void GameStats(char type, const QString & info); |
|
533 | 63 |
void HaveRecord(bool isDemo, const QByteArray & record); |
425 | 64 |
void ErrorMessage(const QString &); |
184 | 65 |
|
66 |
public slots: |
|
67 |
void FromNet(const QByteArray & msg); |
|
68 |
||
69 |
private: |
|
70 |
enum GameType { |
|
588 | 71 |
gtLocal = 1, |
72 |
gtQLocal = 2, |
|
73 |
gtDemo = 3, |
|
74 |
gtNet = 4, |
|
75 |
gtTraining = 5 |
|
184 | 76 |
}; |
77 |
char msgbuf[MAXMSGCHARS]; |
|
78 |
QString teams[5]; |
|
79 |
QString seed; |
|
681 | 80 |
QString ammostr; |
184 | 81 |
int TeamCount; |
82 |
GameUIConfig * config; |
|
83 |
GameCFGWidget * gamecfg; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
84 |
TeamSelWidget* m_pTeamSelWidget; |
184 | 85 |
GameType gameType; |
533 | 86 |
GameState gameState; |
184 | 87 |
|
253 | 88 |
void commonConfig(); |
184 | 89 |
void SendConfig(); |
90 |
void SendQuickConfig(); |
|
341 | 91 |
void SendNetConfig(); |
588 | 92 |
void SendTrainingConfig(); |
184 | 93 |
void ParseMessage(const QByteArray & msg); |
533 | 94 |
void SetGameState(GameState state); |
184 | 95 |
}; |
96 |
||
97 |
#endif |