]> git.localhorst.tv Git - l2e.git/commitdiff
added escape title frame, text, and font
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 20:17:20 +0000 (22:17 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 20:17:20 +0000 (22:17 +0200)
src/battle/Resources.h
src/battle/states/RunState.cpp
src/battle/states/RunState.h
src/main.cpp
test-data/large-font.png [new file with mode: 0644]
test-data/title-frame.png [new file with mode: 0644]

index 89c99efef6b3622d1c31c16151ab8259a97d6ab7..5cc8903131f84a7f625f2820a08f2da5f5b0166b 100644 (file)
@@ -31,6 +31,9 @@ struct Resources {
        graphics::Sprite *attackIcons;
        graphics::Sprite *attackChoiceIcons;
 
+       graphics::Frame *titleFrame;
+       graphics::Font *titleFont;
+
        graphics::Frame *heroTagFrame;
        graphics::Frame *activeHeroTagFrame;
 
@@ -62,6 +65,8 @@ struct Resources {
        graphics::Menu<const common::Item *> ikariMenuPrototype;
        const char *noEquipmentText;
 
+       const char *escapeText;
+
        graphics::Sprite *weaponMenuIcon;
        graphics::Sprite *armorMenuIcon;
        graphics::Sprite *shieldMenuIcon;
@@ -76,6 +81,9 @@ struct Resources {
        , attackIcons(0)
        , attackChoiceIcons(0)
 
+       , titleFrame(0)
+       , titleFont(0)
+
        , heroTagFrame(0)
        , activeHeroTagFrame(0)
 
@@ -102,6 +110,8 @@ struct Resources {
        , ikariMenuHeadline("")
        , noEquipmentText("")
 
+       , escapeText("")
+
        , weaponMenuIcon(0)
        , armorMenuIcon(0)
        , shieldMenuIcon(0)
index 08c45e80cd8fb97f1a35f9cbc88783204da4a4a8..7fdc0665c82b6bd09bc64fa2c31d033ae728ad8c 100644 (file)
 #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;
@@ -61,6 +65,17 @@ void RunState::Render(SDL_Surface *screen) {
        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);
 }
 
 }
index 870f48d5abf5c744b794b1532b723b838f5732e4..61c52709848959b42661f279cdce685254f66559 100644 (file)
@@ -35,6 +35,9 @@ public:
        virtual void UpdateWorld(float deltaT);
        virtual void Render(SDL_Surface *);
 
+private:
+       void RenderTitleBar(SDL_Surface *screen, const geometry::Vector<int> &offset);
+
 private:
        app::Application *ctrl;
        BattleState *battle;
index 28656c3b050a475badb08489d236fb255faef1b7..e39d31830976b38b40e396da5f38a28dc114770a 100644 (file)
@@ -147,6 +147,24 @@ int main(int argc, char **argv) {
                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;
@@ -540,6 +558,8 @@ int main(int argc, char **argv) {
                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);
diff --git a/test-data/large-font.png b/test-data/large-font.png
new file mode 100644 (file)
index 0000000..c01542a
Binary files /dev/null and b/test-data/large-font.png differ
diff --git a/test-data/title-frame.png b/test-data/title-frame.png
new file mode 100644 (file)
index 0000000..6a57806
Binary files /dev/null and b/test-data/title-frame.png differ