GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windowmenu.h Lines: 0 1 0.0 %
Date: 2021-03-17 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-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_WINDOWMENU_H
25
#define GUI_WINDOWMENU_H
26
27
#include "enums/input/inputaction.h"
28
29
#include "gui/widgets/container.h"
30
31
#include "listeners/actionlistener.h"
32
#include "listeners/mouselistener.h"
33
#include "listeners/selectionlistener.h"
34
35
#include "localconsts.h"
36
37
class Button;
38
class ImageSet;
39
40
struct ButtonInfo;
41
struct ButtonText;
42
43
/**
44
 * The window menu. Allows showing and hiding many of the different windows
45
 * used in the game.
46
 *
47
 * \ingroup Interface
48
 */
49
class WindowMenu final : public Container,
50
                         public ConfigListener,
51
                         public ActionListener,
52
                         public SelectionListener,
53
                         public MouseListener
54
{
55
    public:
56
        explicit WindowMenu(const Widget2 *const widget);
57
58
        A_DELETE_COPY(WindowMenu)
59
60
        ~WindowMenu() override final;
61
62
        void action(const ActionEvent &event) override final;
63
64
        void mousePressed(MouseEvent &event) override final;
65
66
        void mouseMoved(MouseEvent &event) override final;
67
68
        void mouseExited(MouseEvent& event A_UNUSED) override final;
69
70
        std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
71
        { return mButtonNames; }
72
73
        STD_VECTOR <Button*> &getButtons() A_WARN_UNUSED
74
        { return mButtons; }
75
76
        STD_VECTOR <ButtonText*> &getButtonTexts() A_WARN_UNUSED
77
        { return mButtonTexts; }
78
79
        void showButton(const std::string &name, const Visible visible);
80
81
        void loadButtons();
82
83
        void saveButtons() const;
84
85
        void optionChanged(const std::string &name) override final;
86
87
#ifdef USE_PROFILER
88
        void logicChildren();
89
#endif  // USE_PROFILER
90
91
    protected:
92
        void drawChildren(Graphics *const graphics) override final
93
                          A_NONNULL(2);
94
95
        void safeDrawChildren(Graphics *const graphics) override final
96
                              A_NONNULL(2);
97
98
    private:
99
        inline void addButton(const char *const text,
100
                              const int iconNumber,
101
                              const std::string &description,
102
                              int &restrict x, int &restrict h,
103
                              const InputActionT key,
104
                              const Visible visible);
105
106
        void updateButtons();
107
108
        Skin *mSkin;
109
        ImageSet *mImageSet;
110
        int mPadding;
111
        int mSpacing;
112
        STD_VECTOR <Button*> mButtons;
113
        STD_VECTOR <ButtonText*> mButtonTexts;
114
        std::map <std::string, ButtonInfo*> mButtonNames;
115
        bool mHaveMouse;
116
        int mAutoHide;
117
        bool mSmallWindow;
118
};
119
120
extern WindowMenu *windowMenu;
121
122
#endif  // GUI_WINDOWMENU_H