ManaPlus
serverdialog.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 GUI_WINDOWS_SERVERDIALOG_H
25 #define GUI_WINDOWS_SERVERDIALOG_H
26 
27 #include "gui/widgets/window.h"
28 
30 
32 
33 #include "net/serverinfo.h"
34 
35 #include "utils/mutex.h"
36 
38 #include "listeners/keylistener.h"
40 
41 class Button;
42 class CheckBox;
43 class Label;
44 class ListBox;
45 class ServersListModel;
46 
47 namespace Net
48 {
49  class Download;
50 } // namespace Net
51 
57 class ServerDialog final : public Window,
58  public ActionListener,
59  public KeyListener,
60  public SelectionListener
61 {
62  public:
68  ServerDialog(ServerInfo *const serverInfo, const std::string &dir);
69 
71 
72  void postInit() override final;
73 
77  ~ServerDialog() override final;
78 
82  void action(const ActionEvent &event) override final;
83 
84  void keyPressed(KeyEvent &event) override final;
85 
89  void valueChanged(const SelectionEvent &event) override final;
90 
91  void mouseClicked(MouseEvent &event) override final;
92 
93  void logic() override final;
94 
95  void updateServer(const ServerInfo &server, const int index);
96 
98 
99  void close() override final;
100 
101  protected:
102  friend class ServersListModel;
103 
105  { return MutexLocker(&mMutex); }
106 
107  private:
108  friend class EditServerDialog;
109 
113  void downloadServerList();
114 
115  void loadServers(const bool addNew);
116 
117  void loadCustomServers();
118 
119  void saveCustomServers(const ServerInfo &currentServer,
120  const int index);
121 
122  bool needUpdateServers() const;
123 
124  static int downloadUpdate(void *ptr,
125  const DownloadStatusT status,
126  size_t total,
127  const size_t remaining);
128 
131  const std::string &mDir;
142 
149 };
150 
151 #endif // GUI_WINDOWS_SERVERDIALOG_H
Definition: button.h:102
Definition: label.h:91
Definition: mutex.h:34
Net::Download * mDownload
Definition: serverdialog.h:144
void valueChanged(const SelectionEvent &event)
Button * mQuitButton
Definition: serverdialog.h:133
ServerDialogDownloadStatusT mDownloadStatus
Definition: serverdialog.h:148
MutexLocker lock()
Definition: serverdialog.h:104
void saveCustomServers(const ServerInfo &currentServer, const int index)
const std::string & mDir
Definition: serverdialog.h:131
CheckBox * mPersistentIPCheckBox
Definition: serverdialog.h:146
bool needUpdateServers() const
Button * mConnectButton
Definition: serverdialog.h:134
Label * mDescription
Definition: serverdialog.h:132
Button * mEditEntryButton
Definition: serverdialog.h:136
ServerDialog(ServerInfo *const serverInfo, const std::string &dir)
void updateServer(const ServerInfo &server, const int index)
void downloadServerList()
ServerInfos mServers
Definition: serverdialog.h:130
static int downloadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
Button * mInfoButton
Definition: serverdialog.h:139
void action(const ActionEvent &event)
void loadServers(const bool addNew)
void loadCustomServers()
void mouseClicked(MouseEvent &event)
float mDownloadProgress
Definition: serverdialog.h:147
Button * mAddEntryButton
Definition: serverdialog.h:135
void connectToSelectedServer()
void keyPressed(KeyEvent &event)
Button * mLoadButton
Definition: serverdialog.h:138
ListBox * mServersList
Definition: serverdialog.h:141
Button * mDeleteButton
Definition: serverdialog.h:137
ServersListModel * mServersListModel
Definition: serverdialog.h:140
ServerInfo * mServerInfo
Definition: serverdialog.h:145
Definition: window.h:102
DownloadStatus ::T DownloadStatusT
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
ServerDialogDownloadStatus ::T ServerDialogDownloadStatusT
std::vector< ServerInfo > ServerInfos
Definition: serverinfo.h:227