summaryrefslogtreecommitdiff
path: root/src/gui/ministatus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/ministatus.cpp')
-rw-r--r--src/gui/ministatus.cpp61
1 files changed, 37 insertions, 24 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 18b9d714..9f789a9d 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +22,9 @@
#include "gui.h"
#include "ministatus.h"
#include "progressbar.h"
+#include "status.h"
+#include "../animatedsprite.h"
#include "../configuration.h"
#include "../graphics.h"
#include "../localplayer.h"
@@ -49,32 +50,29 @@ MiniStatusWindow::MiniStatusWindow():
mXpBar->getY() + mXpBar->getHeight());
}
-void MiniStatusWindow::update()
+void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
{
- // HP Bar coloration
- if (player_node->mHp < int(player_node->mMaxHp / 3))
- mHpBar->setColor(223, 32, 32); // Red
- else if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
- mHpBar->setColor(230, 171, 34); // Orange
- else
- mHpBar->setColor(0, 171, 34); // Green
+ if (index >= (int) mIcons.size())
+ mIcons.resize(index + 1, NULL);
- float xp = (float) player_node->getXp() / player_node->mXpForNextLevel;
+ if (mIcons[index])
+ delete mIcons[index];
- if (xp != xp) xp = 0.0f; // check for NaN
- if (xp < 0.0f) xp = 0.0f; // make sure the experience isn't negative (uninitialized pointer most likely)
- if (xp > 1.0f) xp = 1.0f;
+ mIcons[index] = sprite;
+}
- mHpBar->setProgress((float) player_node->mHp / player_node->mMaxHp);
- mMpBar->setProgress((float) player_node->mMp / player_node->mMaxMp);
- mXpBar->setProgress(xp);
+void MiniStatusWindow::eraseIcon(int index)
+{
+ mIcons.erase(mIcons.begin() + index);
+}
- // Update labels
- mHpBar->setText(toString(player_node->mHp));
- mMpBar->setText(toString(player_node->mMp));
+extern volatile int tick_time;
- std::stringstream updatedText;
- updatedText << (float) ((int) (xp * 10000.0f)) / 100.0f << "%";
+void MiniStatusWindow::update()
+{
+ StatusWindow::updateHPBar(mHpBar);
+ StatusWindow::updateMPBar(mMpBar);
+ StatusWindow::updateXPBar(mXpBar);
// Displays the number of monsters to next lvl
// (disabled for now but interesting idea)
@@ -89,7 +87,10 @@ void MiniStatusWindow::update()
}
*/
- mXpBar->setText(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)
@@ -97,3 +98,15 @@ void MiniStatusWindow::draw(gcn::Graphics *graphics)
update();
drawChildren(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();
+ }
+ }
+}