author | displacer |
Wed, 24 Jan 2007 21:58:43 +0000 | |
changeset 363 | c0d788307314 |
parent 341 | 184230eb4151 |
child 395 | 641ed71c7c93 |
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); |
49 |
void AddTeam(const QString & team); |
|
184 | 50 |
void PlayDemo(const QString & demofilename); |
51 |
void StartLocal(); |
|
52 |
void StartQuick(); |
|
53 |
void StartNet(); |
|
54 |
||
55 |
protected: |
|
56 |
virtual QStringList setArguments(); |
|
57 |
virtual void onClientRead(); |
|
58 |
virtual void onClientDisconnect(); |
|
59 |
||
60 |
signals: |
|
61 |
void SendNet(const QByteArray & msg); |
|
306 | 62 |
void GameStateChanged(GameState gameState); |
63 |
void GameStats(char type, const QString & info); |
|
184 | 64 |
|
65 |
public slots: |
|
66 |
void FromNet(const QByteArray & msg); |
|
67 |
void LocalCFG(const QString & teamname); |
|
68 |
||
69 |
private: |
|
70 |
enum GameType { |
|
71 |
gtLocal = 1, |
|
72 |
gtQLocal = 2, |
|
73 |
gtDemo = 3, |
|
74 |
gtNet = 4 |
|
75 |
}; |
|
76 |
char msgbuf[MAXMSGCHARS]; |
|
77 |
QString teams[5]; |
|
78 |
QString seed; |
|
79 |
int TeamCount; |
|
80 |
GameUIConfig * config; |
|
81 |
GameCFGWidget * gamecfg; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
82 |
TeamSelWidget* m_pTeamSelWidget; |
184 | 83 |
GameType gameType; |
84 |
||
253 | 85 |
void commonConfig(); |
184 | 86 |
void SendConfig(); |
87 |
void SendQuickConfig(); |
|
341 | 88 |
void SendNetConfig(); |
184 | 89 |
void SendTeamConfig(int index); |
90 |
void ParseMessage(const QByteArray & msg); |
|
91 |
void SaveDemo(const QString & filename); |
|
92 |
}; |
|
93 |
||
94 |
#endif |