ManaPlus
client.h
Go to the documentation of this file.
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 
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 
56 class Client final : public ConfigListener,
57  public ActionListener
58 {
59  public:
60  Client();
61 
63 
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 
78  { 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 
95 
96  void slowLogic();
97 
99  { return mCurrentServer; }
100 
101  private:
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 
144 
154 #ifdef ANDROID
155  Button *mCloseButton;
156 #endif // ANDROID
157 
158  StateT mState;
160 
161  Skin *mSkin;
162  int mButtonPadding;
163  int mButtonSpacing;
164  int mPing;
166 };
167 
168 extern Client *client;
169 extern unsigned int mLastHost;
170 extern unsigned long mSearchHash;
171 
172 #endif // PROGS_MANAPLUS_CLIENT_H
Definition: button.h:102
Definition: client.h:50
void runValidate() __attribute__((noreturn))
Definition: client.cpp:2088
static void initGraphics()
void setState(const StateT state)
Definition: client.h:66
void stateGame1()
Definition: client.cpp:909
void loadData()
Definition: client.cpp:1980
static void initPaths()
void action(const ActionEvent &event)
Definition: client.cpp:732
StateT mState
Definition: client.h:112
static void initFeatures()
Definition: client.cpp:1806
int mButtonPadding
Definition: client.h:116
void gameInit()
Definition: client.cpp:170
int mButtonSpacing
Definition: client.h:117
Button * mAboutButton
Definition: client.h:105
StateT mOldState
Definition: client.h:113
void initConfigListeners()
Definition: client.cpp:585
static void stateConnectGame1()
Definition: client.cpp:806
Button * mPerfomanceButton
Definition: client.h:107
static int testsExec()
Definition: client.cpp:833
void focusWindow()
Definition: client.cpp:809
void windowRemoved(const Window *const window)
Definition: client.cpp:803
void moveButtons(const int width)
Definition: client.cpp:774
ServerInfo & getCurrentServer()
Definition: client.h:98
void slowLogic()
Definition: client.cpp:829
static void logVars()
void updatePinState()
Definition: client.cpp:817
static void initTradeFilter()
Definition: client.cpp:1832
static void logVars()
Definition: client.cpp:821
int mPing
Definition: client.h:164
Game * mGame
Definition: client.h:145
static bool isTmw()
void testsInit()
Definition: client.cpp:161
void stateSwitchLogin1()
Definition: client.cpp:951
void stateConnectServer1()
Definition: client.cpp:816
void stateWorldSelect1()
Definition: client.cpp:899
bool mConfigAutoSaved
Definition: client.h:165
Button * mVideoButton
Definition: client.h:103
void initSoundManager()
void optionChanged(const std::string &name)
Definition: client.cpp:1715
void gameClear()
Button * mHelpButton
Definition: client.h:104
Button * mSetupButton
Definition: client.h:102
int gameExec()
Definition: client.cpp:577
ServerInfo mCurrentServer
Definition: client.h:143
QuitDialog * mQuitDialog
Definition: client.h:147
Button * mThemesButton
Definition: client.h:106
StateT getState() const
Definition: client.h:77
void testsClear()
Skin * mSkin
Definition: client.h:115
void unloadData()
Definition: client.cpp:2044
Window * mCurrentDialog
Definition: client.h:101
Definition: game.h:64
Definition: skin.h:37
Definition: window.h:102
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
union EAthena::ItemFlags __attribute__((packed))
Client * client
Definition: client.cpp:118
int textures_count
Definition: client.cpp:138
unsigned int tmwServerVersion
Definition: client.cpp:134
unsigned int mLastHost
Definition: client.cpp:136
unsigned long mSearchHash
Definition: client.cpp:137
std::string errorMessage
Definition: client.cpp:116
bool isSafeMode
Definition: client.cpp:123
int serverVersion
Definition: client.cpp:124
time_t start_time
Definition: client.cpp:135
LoginData loginData
Definition: client.cpp:185
State ::T StateT
Definition: state.h:71