summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/ministatus.cpp41
-rw-r--r--src/gui/ministatus.h13
-rw-r--r--src/gui/viewport.cpp6
3 files changed, 58 insertions, 2 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index baae14a7..436c90cd 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -79,6 +79,26 @@ MiniStatusWindow::MiniStatusWindow():
loadWindowState();
}
+void
+MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
+{
+ if (index >= (int) mIcons.size())
+ mIcons.resize(index + 1, NULL);
+
+ if (mIcons[index])
+ delete mIcons[index];
+
+ mIcons[index] = sprite;
+}
+
+void
+MiniStatusWindow::eraseIcon(int index)
+{
+ mIcons.erase(mIcons.begin() + index);
+}
+
+extern volatile int tick_time;
+
void MiniStatusWindow::update()
{
// HP Bar coloration
@@ -128,10 +148,27 @@ void MiniStatusWindow::update()
*/
mXpLabel->setCaption(updatedText.str());
+
+ for (unsigned int i = 0; i < mIcons.size(); i++)
+ if (mIcons[i])
+ mIcons[i]->update(tick_time * 10);
+
}
-void MiniStatusWindow::draw(gcn::Graphics *graphics)
+void MiniStatusWindow::draw(gcn::Graphics *gcn_graphics)
{
update();
- drawChildren(graphics);
+ drawChildren(gcn_graphics);
+}
+
+void
+MiniStatusWindow::drawIcons(Graphics *graphics)
+{
+ // Draw icons
+ int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4;
+ for (unsigned int i = 0; i < mIcons.size(); i++)
+ if (mIcons[i]) {
+ mIcons[i]->draw(graphics, icon_x, 3);
+ icon_x += 2 + mIcons[i]->getWidth();
+ }
}
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index d7f6f68c..fa9d3d24 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -23,10 +23,12 @@
#define _TMW_MINISTATUS_H
#include <iosfwd>
+#include <vector>
#include "window.h"
#include "../guichanfwd.h"
+#include "../animatedsprite.h"
class ProgressBar;
@@ -48,6 +50,15 @@ class MiniStatusWindow : public Window
*/
void draw(gcn::Graphics *graphics);
+ /**
+ * Sets one of the icons
+ */
+ void setIcon(int index, AnimatedSprite *sprite);
+
+ void eraseIcon(int index);
+
+ void drawIcons(Graphics *graphics);
+
private:
/**
* Updates this dialog with values from player_node
@@ -63,6 +74,8 @@ class MiniStatusWindow : public Window
gcn::Label *mHpLabel;
gcn::Label *mMpLabel;
gcn::Label *mXpLabel;
+
+ std::vector<AnimatedSprite *> mIcons;
};
#endif
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 37e7bcce..4b661ba3 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -25,6 +25,7 @@
#include "gui.h"
#include "popupmenu.h"
+#include "ministatus.h"
#include "../simpleanimation.h"
#include "../beingmanager.h"
@@ -137,6 +138,8 @@ Viewport::setMap(Map *map)
mMap = map;
}
+extern MiniStatusWindow *miniStatusWindow;
+
void
Viewport::draw(gcn::Graphics *gcnGraphics)
{
@@ -268,6 +271,9 @@ Viewport::draw(gcn::Graphics *gcnGraphics)
(*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
}
+ if (miniStatusWindow)
+ miniStatusWindow->drawIcons(graphics);
+
// Draw contained widgets
WindowContainer::draw(gcnGraphics);
}