author | unc0rr |
Sun, 14 Jan 2007 21:17:35 +0000 | |
changeset 336 | 82d654db133d |
parent 324 | f4c109c82a0c |
child 339 | 7535ab6c3820 |
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; |
|
33 |
||
306 | 34 |
enum GameState { |
35 |
gsNotStarted = 0, |
|
36 |
gsStarted = 1, |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
37 |
gsInterrupted = 2, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
38 |
gsFinished = 3, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
39 |
gsStopped = 4 |
306 | 40 |
}; |
41 |
||
42 |
||
184 | 43 |
class HWGame : public TCPBase |
44 |
{ |
|
45 |
Q_OBJECT |
|
46 |
public: |
|
47 |
HWGame(GameUIConfig * config, GameCFGWidget * gamecfg); |
|
213 | 48 |
void AddTeam(const QString & team, HWTeamTempParams teamParams); |
184 | 49 |
void PlayDemo(const QString & demofilename); |
50 |
void StartLocal(); |
|
51 |
void StartQuick(); |
|
52 |
void StartNet(); |
|
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); |
|
184 | 63 |
|
64 |
public slots: |
|
65 |
void FromNet(const QByteArray & msg); |
|
66 |
void LocalCFG(const QString & teamname); |
|
67 |
||
68 |
private: |
|
69 |
enum GameType { |
|
70 |
gtLocal = 1, |
|
71 |
gtQLocal = 2, |
|
72 |
gtDemo = 3, |
|
73 |
gtNet = 4 |
|
74 |
}; |
|
75 |
char msgbuf[MAXMSGCHARS]; |
|
76 |
QString teams[5]; |
|
213 | 77 |
std::map<QString, HWTeamTempParams> m_teamsParams; |
184 | 78 |
QString seed; |
79 |
int TeamCount; |
|
80 |
GameUIConfig * config; |
|
81 |
GameCFGWidget * gamecfg; |
|
82 |
GameType gameType; |
|
83 |
||
253 | 84 |
void commonConfig(); |
184 | 85 |
void SendConfig(); |
86 |
void SendQuickConfig(); |
|
87 |
void SendTeamConfig(int index); |
|
88 |
void ParseMessage(const QByteArray & msg); |
|
89 |
void SaveDemo(const QString & filename); |
|
90 |
}; |
|
91 |
||
92 |
#endif |