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