From: Daniel Karbach Date: Wed, 8 Aug 2012 18:53:33 +0000 (+0200) Subject: write hero's name on tag X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=e16f1b77f9d7f09d232cfe34e4fc8b4be06f571d;hp=2f2dad58f3b9f7c98cf20211929ff31f5ebf5e5f;p=l2e.git write hero's name on tag --- diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 01cee44..531031f 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -26,6 +26,7 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi // frame const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame); Vector frameOffset(frame->BorderWidth(), frame->BorderHeight()); + Vector alignOffset(align == LEFT ? 4 * res->heroTagFont->CharWidth() : 0, 0); frame->Draw(screen, position, width, height); int yOffset((height - hero->Sprite()->Height()) / 2); @@ -74,6 +75,9 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi Vector manaNumberOffset(labelX + res->heroTagLabels->Width(), manaLabelOffset.Y()); res->heroTagFont->DrawNumber(hero->Mana(), screen, position + manaNumberOffset, 3); + // name + res->normalFont->DrawString(hero->Name(), screen, position + frameOffset + alignOffset, 5); + // hero Vector heroOffset( (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset, diff --git a/src/battle/Resources.h b/src/battle/Resources.h index 7c37bca..8d1144f 100644 --- a/src/battle/Resources.h +++ b/src/battle/Resources.h @@ -34,6 +34,8 @@ struct Resources { graphics::Frame *selectFrame; + graphics::Font *normalFont; + Resources() : moveIcons(0) @@ -50,6 +52,8 @@ struct Resources { , ikariGauge(0) , selectFrame(0) + + , normalFont(0) { } }; diff --git a/src/main.cpp b/src/main.cpp index 29c08a5..d9a2f57 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -154,6 +154,15 @@ int main(int argc, char **argv) { Frame selectFrame(selectFrameImg, 16, 16); battleRes.selectFrame = &selectFrame; + SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png")); + Sprite normalFontSprite(normalFontImg, 16, 16); + Font normalFont(&normalFontSprite); + normalFont.MapRange('A', 'M', 0, 1); + normalFont.MapRange('N', 'Z', 0, 2); + normalFont.MapRange('a', 'm', 0, 3); + normalFont.MapRange('n', 'z', 0, 4); + battleRes.normalFont = &normalFont; + BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes)); battleState->AddMonster(monster); battleState->AddMonster(monster); diff --git a/test-data/normal-font.png b/test-data/normal-font.png new file mode 100644 index 0000000..b2b1a40 Binary files /dev/null and b/test-data/normal-font.png differ