1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2004-2009 The Mana World Development Team |
4 |
|
|
* Copyright (C) 2009-2010 The Mana Developers |
5 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
6 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
7 |
|
|
* |
8 |
|
|
* This file is part of The ManaPlus Client. |
9 |
|
|
* |
10 |
|
|
* This program is free software; you can redistribute it and/or modify |
11 |
|
|
* it under the terms of the GNU General Public License as published by |
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
13 |
|
|
* any later version. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU General Public License |
21 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#ifndef PROGS_MANAPLUS_CLIENT_H |
25 |
|
|
#define PROGS_MANAPLUS_CLIENT_H |
26 |
|
|
|
27 |
|
|
#include "enums/state.h" |
28 |
|
|
|
29 |
|
|
#include "listeners/actionlistener.h" |
30 |
|
|
#include "listeners/configlistener.h" |
31 |
|
|
|
32 |
|
|
#include "net/serverinfo.h" |
33 |
|
|
|
34 |
|
|
#include "localconsts.h" |
35 |
|
|
|
36 |
|
|
class Button; |
37 |
|
|
class Game; |
38 |
|
|
class LoginData; |
39 |
|
|
class Skin; |
40 |
|
|
class Window; |
41 |
|
|
class QuitDialog; |
42 |
|
|
|
43 |
|
|
extern bool isSafeMode; |
44 |
|
|
extern int serverVersion; |
45 |
|
|
extern unsigned int tmwServerVersion; |
46 |
|
|
extern time_t start_time; |
47 |
|
|
extern int textures_count; |
48 |
|
|
|
49 |
|
|
extern std::string errorMessage; |
50 |
|
|
extern LoginData loginData; |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* The core part of the client. This class initializes all subsystems, runs |
54 |
|
|
* the event loop, and shuts everything down again. |
55 |
|
|
*/ |
56 |
|
|
class Client final : public ConfigListener, |
57 |
|
|
public ActionListener |
58 |
|
|
{ |
59 |
|
|
public: |
60 |
|
|
Client(); |
61 |
|
|
|
62 |
|
|
A_DELETE_COPY(Client) |
63 |
|
|
|
64 |
|
|
~Client() override final; |
65 |
|
|
|
66 |
|
|
void gameInit(); |
67 |
|
|
|
68 |
|
|
void testsInit(); |
69 |
|
|
|
70 |
|
|
int gameExec(); |
71 |
|
|
|
72 |
|
|
static int testsExec(); |
73 |
|
|
|
74 |
|
|
void setState(const StateT state) |
75 |
|
|
{ mState = state; } |
76 |
|
|
|
77 |
|
|
StateT getState() const noexcept2 A_WARN_UNUSED |
78 |
|
1 |
{ return mState; } |
79 |
|
|
|
80 |
|
|
static bool isTmw() A_WARN_UNUSED; |
81 |
|
|
|
82 |
|
|
void optionChanged(const std::string &name) override final; |
83 |
|
|
|
84 |
|
|
void action(const ActionEvent &event) override final; |
85 |
|
|
|
86 |
|
|
static void initTradeFilter(); |
87 |
|
|
|
88 |
|
|
void moveButtons(const int width); |
89 |
|
|
|
90 |
|
|
void windowRemoved(const Window *const window); |
91 |
|
|
|
92 |
|
|
void focusWindow(); |
93 |
|
|
|
94 |
|
|
void updatePinState(); |
95 |
|
|
|
96 |
|
|
void slowLogic(); |
97 |
|
|
|
98 |
|
|
ServerInfo &getCurrentServer() |
99 |
|
|
{ return mCurrentServer; } |
100 |
|
|
|
101 |
|
|
private: |
102 |
|
|
void initSoundManager(); |
103 |
|
|
|
104 |
|
|
void initConfigListeners(); |
105 |
|
|
|
106 |
|
|
static void initGraphics(); |
107 |
|
|
|
108 |
|
|
static void initFeatures(); |
109 |
|
|
|
110 |
|
|
static void initPaths(); |
111 |
|
|
|
112 |
|
|
void gameClear(); |
113 |
|
|
|
114 |
|
|
void testsClear(); |
115 |
|
|
|
116 |
|
|
#ifdef ANDROID |
117 |
|
|
static void logVars(); |
118 |
|
|
#else // ANDROID |
119 |
|
|
|
120 |
|
|
static void logVars(); |
121 |
|
|
#endif // ANDROID |
122 |
|
|
|
123 |
|
|
static void stateConnectGame1(); |
124 |
|
|
|
125 |
|
|
void stateConnectServer1(); |
126 |
|
|
|
127 |
|
|
void stateWorldSelect1(); |
128 |
|
|
|
129 |
|
|
void stateGame1(); |
130 |
|
|
|
131 |
|
|
void stateSwitchLogin1(); |
132 |
|
|
|
133 |
|
|
void loadData(); |
134 |
|
|
|
135 |
|
|
void unloadData(); |
136 |
|
|
|
137 |
|
|
void runValidate() |
138 |
|
|
#ifndef BAD_CILKPLUS |
139 |
|
|
__attribute__ ((noreturn)) |
140 |
|
|
#endif // BAD_CILKPLUS |
141 |
|
|
; |
142 |
|
|
|
143 |
|
|
ServerInfo mCurrentServer; |
144 |
|
|
|
145 |
|
|
Game *mGame; |
146 |
|
|
Window *mCurrentDialog; |
147 |
|
|
QuitDialog *mQuitDialog; |
148 |
|
|
Button *mSetupButton; |
149 |
|
|
Button *mVideoButton; |
150 |
|
|
Button *mHelpButton; |
151 |
|
|
Button *mAboutButton; |
152 |
|
|
Button *mThemesButton; |
153 |
|
|
Button *mPerfomanceButton; |
154 |
|
|
#ifdef ANDROID |
155 |
|
|
Button *mCloseButton; |
156 |
|
|
#endif // ANDROID |
157 |
|
|
|
158 |
|
|
StateT mState; |
159 |
|
|
StateT mOldState; |
160 |
|
|
|
161 |
|
|
Skin *mSkin; |
162 |
|
|
int mButtonPadding; |
163 |
|
|
int mButtonSpacing; |
164 |
|
|
int mPing; |
165 |
|
|
bool mConfigAutoSaved; |
166 |
|
|
}; |
167 |
|
|
|
168 |
|
|
extern Client *client; |
169 |
|
|
extern unsigned int mLastHost; |
170 |
|
|
extern unsigned long mSearchHash; |
171 |
|
|
|
172 |
|
|
#endif // PROGS_MANAPLUS_CLIENT_H |