]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/HeroStatus.cpp
added hero status tags in party menu
[l2e.git] / src / menu / HeroStatus.cpp
diff --git a/src/menu/HeroStatus.cpp b/src/menu/HeroStatus.cpp
new file mode 100644 (file)
index 0000000..e84327e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * HeroStatus.cpp
+ *
+ *  Created on: Oct 21, 2012
+ *      Author: holy
+ */
+
+#include "HeroStatus.h"
+
+#include "Resources.h"
+#include "../common/Hero.h"
+#include "../graphics/Font.h"
+#include "../graphics/Sprite.h"
+
+using geometry::Vector;
+
+namespace menu {
+
+HeroStatus::HeroStatus()
+: res(0)
+, hero(0) {
+
+}
+
+HeroStatus::~HeroStatus() {
+
+}
+
+
+int HeroStatus::Width() const {
+       return hero->BattleSprite()->Width() + res->normalFont->CharWidth() * 10;
+}
+
+int HeroStatus::Height() const {
+       return hero->BattleSprite()->Height();
+}
+
+
+void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
+       if (!hero) return;
+
+       hero->BattleSprite()->Draw(screen, position + offset, 0, 0);
+
+       // for some reason, fonts are shifted by one pixel in the original
+       Vector<int> nameOffset(
+                       hero->BattleSprite()->Width(),
+                       res->normalFont->CharHeight() * 7 / 8);
+       nameOffset += position + offset;
+       res->normalFont->DrawString(hero->Name(), screen, nameOffset, 5);
+
+       Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->normalFont->CharWidth(), nameOffset.Y());
+       res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
+
+       Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->normalFont->CharWidth(), levelLabelOffset.Y());
+       res->normalFont->DrawNumber(hero->Level(), screen, levelOffset, 2);
+
+       Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->normalFont->CharHeight());
+       res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
+
+       Vector<int> healthOffset(nameOffset.X() + 3 * res->normalFont->CharWidth(), nameOffset.Y() + res->normalFont->CharHeight());
+       res->normalFont->DrawNumber(hero->Health(), screen, healthOffset, 3);
+
+       Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->normalFont->CharWidth(), healthOffset.Y());
+       res->normalFont->DrawChar('/', screen, healthSeparatorOffset);
+
+       Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->normalFont->CharWidth(), healthOffset.Y());
+       res->normalFont->DrawNumber(hero->MaxHealth(), screen, maxHealthOffset, 3);
+
+       Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->normalFont->CharHeight());
+       res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
+
+       Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->normalFont->CharHeight());
+       res->normalFont->DrawNumber(hero->Mana(), screen, manaOffset, 3);
+
+       Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
+       res->normalFont->DrawChar('/', screen, manaSeparatorOffset);
+
+       Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
+       res->normalFont->DrawNumber(hero->MaxMana(), screen, maxManaOffset, 3);
+}
+
+}