graphics::Sprite *attackIcons;
graphics::Sprite *attackChoiceIcons;
+ graphics::Frame *titleFrame;
+ graphics::Font *titleFont;
+
graphics::Frame *heroTagFrame;
graphics::Frame *activeHeroTagFrame;
graphics::Menu<const common::Item *> ikariMenuPrototype;
const char *noEquipmentText;
+ const char *escapeText;
+
graphics::Sprite *weaponMenuIcon;
graphics::Sprite *armorMenuIcon;
graphics::Sprite *shieldMenuIcon;
, attackIcons(0)
, attackChoiceIcons(0)
+ , titleFrame(0)
+ , titleFont(0)
+
, heroTagFrame(0)
, activeHeroTagFrame(0)
, ikariMenuHeadline("")
, noEquipmentText("")
+ , escapeText("")
+
, weaponMenuIcon(0)
, armorMenuIcon(0)
, shieldMenuIcon(0)
#include "../../app/Input.h"
#include "../../geometry/operators.h"
#include "../../geometry/Point.h"
+#include "../../graphics/Font.h"
+#include "../../graphics/Frame.h"
+
+#include <cstring>
using app::Application;
using app::Input;
battle->RenderMonsters(screen, offset);
battle->RenderHeroes(screen, offset);
// render small tags
+ RenderTitleBar(screen, offset);
+}
+
+void RunState::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {
+ int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
+ battle->Res().titleFrame->Draw(screen, Point<int>(offset.X(), offset.Y()), battle->BackgroundWidth(), height);
+
+ Point<int> textPosition(
+ (battle->BackgroundWidth() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2,
+ battle->Res().titleFrame->BorderHeight());
+ battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset);
}
}
SDL_Surface *moveIconsImg(IMG_Load("test-data/move-icons.png"));
Sprite moveIconsSprite(moveIconsImg, 32, 32);
battleRes.moveIcons = &moveIconsSprite;
+
+ SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
+ Frame titleFrame(titleFrameImg, 16, 16);
+ battleRes.titleFrame = &titleFrame;
+
+ SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
+ Sprite largeFontSprite(largeFontImg, 16, 32);
+ Font largeFont(&largeFontSprite);
+ largeFont.MapRange('A', 'M', 0, 1);
+ largeFont.MapRange('N', 'Z', 0, 2);
+ largeFont.MapRange('a', 'm', 0, 3);
+ largeFont.MapRange('n', 'z', 0, 4);
+ largeFont.MapChar(':', 10, 0);
+ largeFont.MapChar('!', 11, 0);
+ largeFont.MapChar('?', 12, 0);
+ // TODO: add '.' and '-' characters
+ battleRes.titleFont = &largeFont;
+
SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
Sprite heroTagSprite(heroTagImg, 32, 16);
battleRes.heroTagLabels = &heroTagSprite;
battleRes.noEquipmentText = "No equip";
battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
+ battleRes.escapeText = "Escapes.";
+
BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
battleState->AddMonster(monster);
battleState->AddMonster(monster);