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