ManaPlus
charselectdialog.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_CHARSELECTDIALOG_H
25 #define GUI_WINDOWS_CHARSELECTDIALOG_H
26 
28 
29 #include "gui/widgets/window.h"
30 
31 #include "net/characters.h"
32 
34 #include "listeners/keylistener.h"
35 
36 class Button;
37 class CharacterDisplay;
38 class CharacterViewBase;
39 class LoginData;
40 class TextDialog;
41 
42 namespace Net
43 {
44  class CharServerHandler;
45 } // namespace Net
46 
52 class CharSelectDialog final : public Window,
53  public ActionListener,
54  public KeyListener
55 {
56  public:
57  friend class CharDeleteConfirm;
58  friend class Net::CharServerHandler;
59 
63  explicit CharSelectDialog(LoginData &data);
64 
66 
68 
69  void action(const ActionEvent &event) override final;
70 
71  void keyPressed(KeyEvent &event) override final;
72 
74  {
75  Focus = 0,
76  Choose
77  };
78 
87  bool selectByName(const std::string &name,
88  const SelectAction action);
89 
90  void askPasswordForDeletion(const int index);
91 
92  void close() override final;
93 
94  void widgetResized(const Event &event) override final;
95 
96  void updateState();
97 
98  void postInit() override final;
99 
100  void setName(const BeingId id, const std::string &newName);
101 
102  private:
103  void attemptCharacterDelete(const int index,
104  const std::string &email);
105 
106  void attemptCharacterSelect(const int index);
107 
108  void setCharacters(const Net::Characters &characters);
109 
110  void setCharacter(Net::Character *const character);
111 
112  void use(const int selected);
113 
114  void lock();
115  void unlock();
116  void setLocked(const bool locked);
117 
119 
128 
130 
134  bool mLocked;
136 };
137 
138 #endif // GUI_WINDOWS_CHARSELECTDIALOG_H
int BeingId
Definition: beingid.h:30
Definition: button.h:102
std::vector< CharacterDisplay * > mCharacterEntries
CharacterViewBase * mCharacterView
bool selectByName(const std::string &name, const SelectAction action)
CharSelectDialog(LoginData &data)
void setName(const BeingId id, const std::string &newName)
Net::CharServerHandler * mCharServerHandler
void action(const ActionEvent &event)
void setLocked(const bool locked)
TextDialog * mDeleteDialog
LoginData * mLoginData
void setCharacter(Net::Character *const character)
void askPasswordForDeletion(const int index)
void widgetResized(const Event &event)
Button * mSwitchLoginButton
Button * mChangePasswordButton
void keyPressed(KeyEvent &event)
void attemptCharacterDelete(const int index, const std::string &email)
void setCharacters(const Net::Characters &characters)
void attemptCharacterSelect(const int index)
void use(const int selected)
Definition: event.h:79
Definition: window.h:102
#define override
Definition: localconsts.h:47
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
uint32_t data
std::list< Character * > Characters
Definition: character.h:61
#define STD_VECTOR
Definition: vector.h:30