GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/progs/manaplus/client.h Lines: 1 3 33.3 %
Date: 2017-11-29 Branches: 0 0 0.0 %

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