author | unc0rr |
Thu, 12 Jul 2007 14:44:41 +0000 | |
changeset 555 | 0376fdcc6322 |
parent 533 | eebb7684ac22 |
child 587 | 74db4115064a |
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, |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
36 |
gsStopped = 4 |
306 | 37 |
}; |
38 |
||
39 |
||
184 | 40 |
class HWGame : public TCPBase |
41 |
{ |
|
42 |
Q_OBJECT |
|
43 |
public: |
|
341 | 44 |
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
|
45 |
virtual ~HWGame(); |
341 | 46 |
void AddTeam(const QString & team); |
184 | 47 |
void PlayDemo(const QString & demofilename); |
48 |
void StartLocal(); |
|
49 |
void StartQuick(); |
|
50 |
void StartNet(); |
|
51 |
||
52 |
protected: |
|
53 |
virtual QStringList setArguments(); |
|
54 |
virtual void onClientRead(); |
|
55 |
virtual void onClientDisconnect(); |
|
56 |
||
57 |
signals: |
|
58 |
void SendNet(const QByteArray & msg); |
|
306 | 59 |
void GameStateChanged(GameState gameState); |
60 |
void GameStats(char type, const QString & info); |
|
533 | 61 |
void HaveRecord(bool isDemo, const QByteArray & record); |
425 | 62 |
void ErrorMessage(const QString &); |
184 | 63 |
|
64 |
public slots: |
|
65 |
void FromNet(const QByteArray & msg); |
|
66 |
||
67 |
private: |
|
68 |
enum GameType { |
|
69 |
gtLocal = 1, |
|
70 |
gtQLocal = 2, |
|
71 |
gtDemo = 3, |
|
72 |
gtNet = 4 |
|
73 |
}; |
|
74 |
char msgbuf[MAXMSGCHARS]; |
|
75 |
QString teams[5]; |
|
76 |
QString seed; |
|
77 |
int TeamCount; |
|
78 |
GameUIConfig * config; |
|
79 |
GameCFGWidget * gamecfg; |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
324
diff
changeset
|
80 |
TeamSelWidget* m_pTeamSelWidget; |
184 | 81 |
GameType gameType; |
533 | 82 |
GameState gameState; |
184 | 83 |
|
253 | 84 |
void commonConfig(); |
184 | 85 |
void SendConfig(); |
86 |
void SendQuickConfig(); |
|
341 | 87 |
void SendNetConfig(); |
184 | 88 |
void ParseMessage(const QByteArray & msg); |
533 | 89 |
void SetGameState(GameState state); |
184 | 90 |
}; |
91 |
||
92 |
#endif |