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_SETUPWINDOW_H
25 #define GUI_WINDOWS_SETUPWINDOW_H
26 
27 #include "gui/widgets/window.h"
28 
29 #include "listeners/actionlistener.h"
30 
31 class Button;
32 class Label;
33 class SetupTab;
34 class TabbedArea;
35 
36 /**
37  * The setup dialog. Displays several tabs for configuring different aspects
38  * of the game.
39  *
40  * \ingroup GUI
41  */
42 class SetupWindow final : public Window,
43                           public ActionListener
44 {
45     public:
46         SetupWindow();
47 
48         A_DELETE_COPY(SetupWindow)
49 
50         ~SetupWindow() override final;
51 
52         void postInit() override final;
53 
54         void action(const ActionEvent &event) override final;
55 
56         void setInGame(const bool inGame);
57 
58         void externalUpdate();
59 
60         void externalUnload();
61 
62         void registerWindowForReset(Window *const window);
63 
64         void unregisterWindowForReset(const Window *const window);
65 
66         void hideWindows();
67 
clearWindowsForReset()68         void clearWindowsForReset()
69         { mWindowsToReset.clear(); }
70 
71         void doCancel();
72 
73         void activateTab(const std::string &name);
74 
75         void setVisible(Visible visible) override final;
76 
77         void widgetResized(const Event &event) override final;
78 
79     private:
80         void unloadAdditionalTabs();
81 
82         void unloadTab(SetupTab *const page);
83 
84         std::list<SetupTab*> mTabs;
85         std::list<Window*> mWindowsToReset;
86         STD_VECTOR<Button*> mButtons;
87         SetupTab *mModsTab;
88         SetupTab *mQuickTab;
89         Button *mResetWindows;
90         TabbedArea *mPanel A_NONNULLPOINTER;
91         Label *mVersion A_NONNULLPOINTER;
92         int mButtonPadding;
93 };
94 
95 extern SetupWindow* setupWindow;
96 
97 #endif  // GUI_WINDOWS_SETUPWINDOW_H
98