# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/menu/HeroStatus.cpp \
../src/menu/PartyMenu.cpp \
../src/menu/Resources.cpp
OBJS += \
+./src/menu/HeroStatus.o \
./src/menu/PartyMenu.o \
./src/menu/Resources.o
CPP_DEPS += \
+./src/menu/HeroStatus.d \
./src/menu/PartyMenu.d \
./src/menu/Resources.d
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/menu/HeroStatus.cpp \
../src/menu/PartyMenu.cpp \
../src/menu/Resources.cpp
OBJS += \
+./src/menu/HeroStatus.o \
./src/menu/PartyMenu.o \
./src/menu/Resources.o
CPP_DEPS += \
+./src/menu/HeroStatus.d \
./src/menu/PartyMenu.d \
./src/menu/Resources.d
const std::vector<const Spell *> &Spells() const { return spells; }
graphics::Sprite *BattleSprite() { return battleSprite; }
+ const graphics::Sprite *BattleSprite() const { return battleSprite; }
graphics::Animation *MeleeAnimation() { return meleeAnimation; }
graphics::Animation *AttackAnimation() { return attackAnimation; }
graphics::Animation *SpellAnimation() { return spellAnimation; }
menubg.SetSize(Vector<int>(64, 64));
menuResources.menubg = &menubg;
+ menuResources.normalFont = gameConfig.battleResources->normalFont;
+
+ graphics::Sprite statusLabels(IMG_Load("test-data/status-labels.png"), 32, 16);
+ menuResources.statusLabels = &statusLabels;
+
InitScreen screen(width, height);
app::State *state(0);
--- /dev/null
+/*
+ * 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);
+}
+
+}
--- /dev/null
+/*
+ * HeroStatus.h
+ *
+ * Created on: Oct 21, 2012
+ * Author: holy
+ */
+
+#ifndef MENU_HEROSTATUS_H_
+#define MENU_HEROSTATUS_H_
+
+#include "fwd.h"
+#include "../common/fwd.h"
+#include "../geometry/Vector.h"
+
+#include <SDL.h>
+
+namespace menu {
+
+class HeroStatus {
+
+public:
+ HeroStatus();
+ ~HeroStatus();
+
+public:
+ void SetResources(const Resources *r) { res = r; }
+ void SetHero(const common::Hero *h) { hero = h; }
+ void SetPosition(const geometry::Vector<int> &p) { position = p; }
+
+ int Width() const;
+ int Height() const;
+ geometry::Vector<int> Size() const { return geometry::Vector<int>(Width(), Height()); }
+
+ void Render(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+
+private:
+ const Resources *res;
+ const common::Hero *hero;
+ geometry::Vector<int> position;
+
+};
+
+}
+
+#endif /* MENU_HEROSTATUS_H_ */
#include "../app/Application.h"
#include "../app/Input.h"
#include "../common/GameConfig.h"
+#include "../common/GameState.h"
#include "../geometry/Vector.h"
+#include "../graphics/Font.h"
#include "../graphics/Texture.h"
using app::Input;
PartyMenu::PartyMenu(GameConfig *game)
: game(game) {
-
+ for (int i(0); i < 4; ++i) {
+ status[i].SetHero(game->state->party[i]);
+ status[i].SetResources(game->menuResources);
+ }
+ status[1].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), 0));
+ status[2].SetPosition(Vector<int>(0, status[0].Height() + Res().normalFont->CharHeight()));
+ status[3].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), status[0].Height() + Res().normalFont->CharHeight()));
}
PartyMenu::~PartyMenu() {
void PartyMenu::Render(SDL_Surface *screen) {
Res().menubg->Render(screen, Vector<int>(), Vector<int>(screen->w, screen->h));
+ RenderHeros(screen, Vector<int>());
+}
+
+void PartyMenu::RenderHeros(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+ for (int i(0); i < 4; ++i) {
+ status[i].Render(screen, offset);
+ }
}
#ifndef MENU_PARTYMENU_H_
#define MENU_PARTYMENU_H_
-#include "Resources.h"
+#include "fwd.h"
+#include "HeroStatus.h"
#include "../app/State.h"
-#include "../common/GameConfig.h"
+#include "../common/fwd.h"
+#include "../geometry/Vector.h"
namespace menu {
virtual void OnResize(int width, int height);
+ void RenderHeros(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+
private:
+ HeroStatus status[4];
common::GameConfig *game;
};
graphics::Texture *menubg;
+ graphics::Font *normalFont;
+
+ graphics::Sprite *statusLabels;
+
Resources();
};
namespace menu {
+class HeroStatus;
class PartyMenu;
struct Resources;