ManaPlus
ministatuswindow.h
Go to the documentation of this file.
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 
30 #include "listeners/statlistener.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 
46 class MiniStatusWindow final : public Window,
47  public InventoryListener,
48  public AttributeListener,
49  public StatListener,
50  public ArrowsListener,
52 {
53  public:
55 
57 
58  ~MiniStatusWindow() override final;
59 
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 
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 
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)
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  */
143 
144  int mSpacing;
147  int mMaxX;
148 };
149 
151 
152 #endif // GUI_WINDOWS_MINISTATUSWINDOW_H
Attributes ::T AttributesT
Definition: attributes.h:118
virtual void logicChildren()
void mouseMoved(MouseEvent &event)
std::vector< AnimatedSprite * > mIcons
ProgressBar * mMoneyBar
ProgressBar * mHpBar
ProgressBar * mWeightBar
std::map< std::string, ProgressBar * > mBarNames
void mouseExited(MouseEvent &event)
void setIcon(const int index, AnimatedSprite *const sprite)
ProgressBar * mInvSlotsBar
std::vector< ProgressBar * > mBars
void eraseIcon(const int index)
void safeDraw(Graphics *const graphics)
ProgressBar * mMpBar
void draw(Graphics *const graphics)
ProgressBar * mStatusBar
ProgressBar * createBar(const float progress, const int width, const int height, const ThemeColorIdT textColor, const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill, const std::string &name, const std::string &description)
ProgressBar * mJobBar
void drawIcons(Graphics *const graphics)
void statChanged(const AttributesT id, const int oldVal1, const int oldVal2)
void attributeChanged(const AttributesT id, const int64_t oldVal, const int64_t newVal)
std::vector< ProgressBar * > & getBars()
bool isInBar(ProgressBar *bar, int x, int y) const
StatusPopup * mStatusPopup
void slotsChanged(const Inventory *const inventory)
ProgressBar * mArrowsBar
void showBar(const std::string &name, const Visible visible)
void mousePressed(MouseEvent &event)
ProgressBar * mXpBar
Definition: rect.h:74
Definition: window.h:102
#define restrict
Definition: localconsts.h:165
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
MiniStatusWindow * miniStatusWindow
ProgressColorId ::T ProgressColorIdT
ThemeColorId ::T ThemeColorIdT
Definition: themecolorid.h:35
bool Visible
Definition: visible.h:30