1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/***************************************************************************
kbattleship.h
-----------------
Developers: (c) 2000-2001 Nikolas Zimmermann <wildfox@kde.org>
(c) 2000-2001 Daniel Molkentin <molkentin@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KBATTLESHIP_H
#define KBATTLESHIP_H
#include <kaction.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmainwindow.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <kstdaction.h>
#include <tqstring.h>
#include "dialogs/infoDlg.h"
#include "kbaiplayer.h"
#include "kbattleshipclient.h"
#include "kbattleshipserver.h"
#include "kbattleshipview.h"
#include "kchatwidget.h"
#include "kclientdialog.h"
#include "konnectionhandling.h"
#include "kserverdialog.h"
#include "kship.h"
#include "kshiplist.h"
#include "kstatdialog.h"
class KBattleshipWindow : public KMainWindow
{
Q_OBJECT
public:
enum{ID_STATUS_MSG, ID_PLAYER_OWN, ID_PLAYER_ENEMY};
KBattleshipWindow();
~KBattleshipWindow();
void init();
KShip *shipAt(int fieldx, int fieldy);
KShip *enemyShipAt(int fieldx, int fieldy);
private slots:
void changeShipPlacementDirection();
void slotConfigureNotifications();
void slotLost(KMessage *msg);
void slotStatusMsg(const TQString &text);
void slotReceivedEnemyFieldData(int fieldx, int fieldx1, int enemystate, int xstart, int xstop, int ystart, int ystop, bool death);
void slotSendEnemyFieldState(int, int);
void slotChangeOwnPlayer(const TQString &text);
void slotChangeEnemyPlayer(const TQString &text);
void slotSendVersion();
void slotSendGreet();
void slotShipsReady();
void slotSetPlaceable(bool place);
void slotSetShootable(bool shoot);
void slotEnemyFieldClick(int fieldx, int fieldy);
void slotSendMessage(int fieldx, int fieldy, int state);
void slotSendMessage(KMessage *msg);
void slotClientLost();
void slotServerLost();
void slotServerReplay();
void slotClientReplay();
void slotAIReady();
void slotAIShootsAt(const TQPoint pos);
void slotDeleteAI();
void slotRestartAI();
void slotSinglePlayer();
void slotServerConnect();
void slotDeleteConnectDialog();
void slotNewServer();
void slotDeleteServerDialog();
void slotHighscore();
void slotShowGrid();
void slotStartBattleshipGame();
void slotStartBattleshipGame(bool clearstat);
void slotStartBattleshipServer();
/**
* Get server to connect to from "Connect to server" dialog.
*/
void slotConnectToBattleshipServer();
void slotConnectToBattleshipServer(const TQString &host, int port, const TQString &nickname);
void slotPlaceShipPreview(int fieldx, int fieldy);
void slotPlaceShip(int fieldx, int fieldy);
void slotChangeOwnFieldData(int fieldx, int fieldy, int type);
void slotChangeEnemyFieldData(int fieldx, int fieldy, int type);
void slotUpdateHighscore();
void slotAbortNetworkGame();
void slotReplay();
void slotReplayRequest();
void slotChangedNickCommand(const TQString &text);
void slotSendChatMessage(const TQString &text);
void slotEnemyClientInfo();
void slotReceivedClientInformation(const TQString &client, const TQString &clientVersion, const TQString &clientInformation, const TQString &protocolVersion);
private:
bool shift;
void initActions();
void initStatusBar();
void initView();
void initChat();
void initShipPlacing();
void saveOptions();
void readOptions();
void cleanup(bool placechange = true);
void playSound(bool enemy, int fieldstate);
void parseCommandLine();
bool m_placeable;
bool m_shootable;
bool m_aiPlaying;
bool m_serverHasClient;
bool m_lost;
int m_aiHits;
TQString m_enemyClient;
TQString m_enemyClientVersion;
TQString m_enemyClientDescription;
TQString m_enemyProtocolVersion;
KConfig *m_config;
KBAIPlayer *m_aiPlayer;
KonnectionHandling *m_connection;
KBattleshipServer *m_kbserver;
KBattleshipClient *m_kbclient;
KChatWidget *m_chat;
KStatDialog *m_stat;
KBattleshipView *m_view;
KAction *m_gameServerConnect;
KAction *m_gameNewServer;
KAction *m_gameQuit;
KAction *m_gameEnemyInfo;
KAction *m_gameSingle;
KToggleAction *m_configSound;
KToggleAction *m_configGrid;
KClientDialog *m_client;
KServerDialog *m_server;
KShipList *m_ownshiplist;
KShipList *m_enemyshiplist;
TQString m_ownNickname;
TQString m_enemyNickname;
};
#endif
|