From: Daniel Karbach Date: Fri, 10 Aug 2012 20:17:20 +0000 (+0200) Subject: added escape title frame, text, and font X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=923422e6a71f57b8fa24b826d1e2914faa144081;p=l2e.git added escape title frame, text, and font --- diff --git a/src/battle/Resources.h b/src/battle/Resources.h index 89c99ef..5cc8903 100644 --- a/src/battle/Resources.h +++ b/src/battle/Resources.h @@ -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 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) diff --git a/src/battle/states/RunState.cpp b/src/battle/states/RunState.cpp index 08c45e8..7fdc066 100644 --- a/src/battle/states/RunState.cpp +++ b/src/battle/states/RunState.cpp @@ -12,6 +12,10 @@ #include "../../app/Input.h" #include "../../geometry/operators.h" #include "../../geometry/Point.h" +#include "../../graphics/Font.h" +#include "../../graphics/Frame.h" + +#include 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 &offset) { + int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); + battle->Res().titleFrame->Draw(screen, Point(offset.X(), offset.Y()), battle->BackgroundWidth(), height); + + Point 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); } } diff --git a/src/battle/states/RunState.h b/src/battle/states/RunState.h index 870f48d..61c5270 100644 --- a/src/battle/states/RunState.h +++ b/src/battle/states/RunState.h @@ -35,6 +35,9 @@ public: virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); +private: + void RenderTitleBar(SDL_Surface *screen, const geometry::Vector &offset); + private: app::Application *ctrl; BattleState *battle; diff --git a/src/main.cpp b/src/main.cpp index 28656c3..e39d318 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(&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 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 index 0000000..6a57806 Binary files /dev/null and b/test-data/title-frame.png differ