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-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_WINDOWS_MINISTATUSWINDOW_H
24 #define GUI_WINDOWS_MINISTATUSWINDOW_H
25 
29 #include "listeners/statlistener.h"
31 
32 #include "gui/widgets/window.h"
33 
34 class AnimatedSprite;
35 class Graphics;
36 class Inventory;
37 class ProgressBar;
38 class StatusPopup;
39 
45 class MiniStatusWindow final : public Window,
46  public InventoryListener,
47  public AttributeListener,
48  public StatListener,
49  public ArrowsListener,
51 {
52  public:
54 
56 
57  ~MiniStatusWindow() override final;
58 
62  void setIcon(const int index, AnimatedSprite *const sprite);
63 
64  void eraseIcon(const int index);
65 
66  void drawIcons(Graphics *const graphics) A_NONNULL(2);
67 
68  void updateStatus() override final;
69 
70  void logic() override final;
71 
72  void draw(Graphics *const graphics) override final A_NONNULL(2);
73 
74  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
75 
76  void mouseMoved(MouseEvent &event) override final;
77 
78  void mousePressed(MouseEvent &event) override final;
79 
80  void mouseExited(MouseEvent &event) override final;
81 
82  void showBar(const std::string &name, const Visible visible);
83 
84  void updateBars();
85 
86  void slotsChanged(const Inventory *const inventory) override final;
87 
88  STD_VECTOR <ProgressBar*> &getBars() A_WARN_UNUSED
89  { return mBars; }
90 
91  Rect getChildrenArea() override final A_WARN_UNUSED;
92 
93  void attributeChanged(const AttributesT id,
94  const int64_t oldVal,
95  const int64_t newVal) override final;
96 
97  void statChanged(const AttributesT id,
98  const int oldVal1,
99  const int oldVal2) override final;
100 
101  void arrowsChanged() override final;
102 
103 #ifdef USE_PROFILER
104  void logicChildren();
105 #endif // USE_PROFILER
106 
107  private:
108  bool isInBar(ProgressBar *bar, int x, int y) const;
109 
110  ProgressBar *createBar(const float progress,
111  const int width,
112  const int height,
113  const ThemeColorIdT textColor,
114  const ProgressColorIdT backColor,
115  const std::string &restrict skin,
116  const std::string &restrict skinFill,
117  const std::string &restrict name,
118  const std::string &restrict description)
120 
121  void loadBars();
122 
123  void saveBars() const;
124 
125  STD_VECTOR <ProgressBar*> mBars;
126  std::map <std::string, ProgressBar*> mBarNames;
127  STD_VECTOR<AnimatedSprite *> mIcons;
128 
129  /*
130  * Mini Status Bars
131  */
142 
143  int mSpacing;
146  int mMaxX;
147 };
148 
150 
151 #endif // GUI_WINDOWS_MINISTATUSWINDOW_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
ProgressColorId ::T ProgressColorIdT
void statChanged(const AttributesT id, const int oldVal1, const int oldVal2)
std::map< std::string, ProgressBar * > mBarNames
ProgressBar * mMoneyBar
void safeDraw(Graphics *const graphics)
ProgressBar * mStatusBar
Definition: rect.h:72
#define A_WARN_UNUSED
Definition: localconsts.h:172
Definition: window.h:98
#define final
Definition: localconsts.h:45
void mouseMoved(MouseEvent &event)
void attributeChanged(const AttributesT id, const int64_t oldVal, const int64_t newVal)
void drawIcons(Graphics *const graphics)
MiniStatusWindow * miniStatusWindow
#define A_NONNULL(...)
Definition: localconsts.h:179
ProgressBar * mWeightBar
ThemeColorId ::T ThemeColorIdT
Definition: themecolorid.h:256
void mousePressed(MouseEvent &event)
void eraseIcon(const int index)
virtual void logicChildren()
void mouseExited(MouseEvent &event)
StatusPopup * mStatusPopup
ProgressBar * mArrowsBar
void showBar(const std::string &name, const Visible visible)
ProgressBar * mInvSlotsBar
void draw(Graphics *const graphics)
ProgressBar * mHpBar
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)
bool isInBar(ProgressBar *bar, int x, int y) const
ProgressBar * mXpBar
Attributes ::T AttributesT
Definition: attributes.h:117
#define restrict
Definition: localconsts.h:176
std::vector< AnimatedSprite * > mIcons
void slotsChanged(const Inventory *const inventory)
std::vector< ProgressBar * > & getBars()
std::vector< ProgressBar * > mBars
ProgressBar * mJobBar
ProgressBar * mMpBar
void setIcon(const int index, AnimatedSprite *const sprite)