GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/ministatuswindow.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_WINDOWS_MINISTATUSWINDOW_H
25
#define GUI_WINDOWS_MINISTATUSWINDOW_H
26
27
#include "listeners/arrowslistener.h"
28
#include "listeners/attributelistener.h"
29
#include "listeners/inventorylistener.h"
30
#include "listeners/statlistener.h"
31
#include "listeners/updatestatuslistener.h"
32
33
#include "gui/widgets/window.h"
34
35
class AnimatedSprite;
36
class Graphics;
37
class Inventory;
38
class ProgressBar;
39
class StatusPopup;
40
41
/**
42
 * The player mini-status dialog.
43
 *
44
 * \ingroup Interface
45
 */
46
class MiniStatusWindow final : public Window,
47
                               public InventoryListener,
48
                               public AttributeListener,
49
                               public StatListener,
50
                               public ArrowsListener,
51
                               public UpdateStatusListener
52
{
53
    public:
54
        MiniStatusWindow();
55
56
        A_DELETE_COPY(MiniStatusWindow)
57
58
        ~MiniStatusWindow() override final;
59
60
        /**
61
         * Sets one of the icons.
62
         */
63
        void setIcon(const int index, AnimatedSprite *const sprite);
64
65
        void eraseIcon(const int index);
66
67
        void drawIcons(Graphics *const graphics) A_NONNULL(2);
68
69
        void updateStatus() override final;
70
71
        void logic() override final;
72
73
        void draw(Graphics *const graphics) override final A_NONNULL(2);
74
75
        void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
76
77
        void mouseMoved(MouseEvent &event) override final;
78
79
        void mousePressed(MouseEvent &event) override final;
80
81
        void mouseExited(MouseEvent &event) override final;
82
83
        void showBar(const std::string &name, const Visible visible);
84
85
        void updateBars();
86
87
        void slotsChanged(const Inventory *const inventory) override final;
88
89
        STD_VECTOR <ProgressBar*> &getBars() A_WARN_UNUSED
90
        { return mBars; }
91
92
        Rect getChildrenArea() override final A_WARN_UNUSED;
93
94
        void attributeChanged(const AttributesT id,
95
                              const int64_t oldVal,
96
                              const int64_t newVal) override final;
97
98
        void statChanged(const AttributesT id,
99
                         const int oldVal1,
100
                         const int oldVal2) override final;
101
102
        void arrowsChanged() override final;
103
104
#ifdef USE_PROFILER
105
        void logicChildren();
106
#endif  // USE_PROFILER
107
108
    private:
109
        bool isInBar(ProgressBar *bar, int x, int y) const;
110
111
        ProgressBar *createBar(const float progress,
112
                               const int width,
113
                               const int height,
114
                               const ThemeColorIdT textColor,
115
                               const ProgressColorIdT backColor,
116
                               const std::string &restrict skin,
117
                               const std::string &restrict skinFill,
118
                               const std::string &restrict name,
119
                               const std::string &restrict description)
120
                               A_WARN_UNUSED;
121
122
        void loadBars();
123
124
        void saveBars() const;
125
126
        STD_VECTOR <ProgressBar*> mBars;
127
        std::map <std::string, ProgressBar*> mBarNames;
128
        STD_VECTOR<AnimatedSprite *> mIcons;
129
130
        /*
131
         * Mini Status Bars
132
         */
133
        ProgressBar *mHpBar;
134
        ProgressBar *mMpBar;
135
        ProgressBar *mXpBar;
136
        ProgressBar *mJobBar;
137
        ProgressBar *mWeightBar;
138
        ProgressBar *mInvSlotsBar;
139
        ProgressBar *mMoneyBar;
140
        ProgressBar *mArrowsBar;
141
        ProgressBar *mStatusBar;
142
        StatusPopup *mStatusPopup;
143
144
        int mSpacing;
145
        int mIconPadding;
146
        int mIconSpacing;
147
        int mMaxX;
148
};
149
150
extern MiniStatusWindow *miniStatusWindow;
151
152
#endif  // GUI_WINDOWS_MINISTATUSWINDOW_H