]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
cached some of the battle coordinates
[l2e.git] / src / battle / BattleState.cpp
index 66097fbd46d05a8d5315196fb161fef1bc5a34cb..57ff3270d170daab546e8c51c461bcb6195b5ba3 100644 (file)
@@ -73,7 +73,9 @@ void BattleState::SwapHeroes(int lhs, int rhs) {
 
 
 void BattleState::OnResize(int w, int h) {
-
+       offset = Vector<int>(
+                               (w - background->w) / 2,
+                               (h - background->h) / 2);
 }
 
 
@@ -111,6 +113,8 @@ void BattleState::OnEnterState(SDL_Surface *screen) {
        smallHeroTagPositions[2] = Vector<int>(xOffset + tagWidth, yOffset);
        smallHeroTagPositions[3] = Vector<int>(xOffset + 3 * tagWidth, yOffset);
 
+       OnResize(screen->w, screen->h);
+
        itemMenu = *res->itemMenuProperties;
        LoadInventory();
        ClearAllAttacks();
@@ -396,12 +400,11 @@ void BattleState::UpdateWorld(Uint32 deltaT) {
 
 void BattleState::Render(SDL_Surface *screen) {
        assert(screen);
-       Vector<int> offset(CalculateScreenOffset(screen));
-       RenderBackground(screen, offset);
-       RenderMonsters(screen, offset);
+       RenderBackground(screen);
+       RenderMonsters(screen);
 }
 
-void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderBackground(SDL_Surface *screen) {
        assert(screen);
        // black for now
        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
@@ -413,7 +416,7 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offse
        SDL_BlitSurface(background, 0, screen, &destRect);
 }
 
-void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderMonsters(SDL_Surface *screen) {
        assert(screen);
        for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
                if (MonsterPositionOccupied(i)) {
@@ -426,7 +429,7 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset)
        }
 }
 
-void BattleState::RenderHeroes(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderHeroes(SDL_Surface *screen) {
        assert(screen);
        for (int i(0); i < numHeroes; ++i) {
                if (heroes[i].GetAnimation().Running()) {
@@ -438,7 +441,7 @@ void BattleState::RenderHeroes(SDL_Surface *screen, const Vector<int> &offset) {
        }
 }
 
-void BattleState::RenderCapsule(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderCapsule(SDL_Surface *screen) {
        if (!capsule.Active() || capsule.Health() <= 0) return;
        if (capsule.GetAnimation().Running()) {
                capsule.GetAnimation().DrawCenter(screen, capsule.Position() + offset);
@@ -447,7 +450,7 @@ void BattleState::RenderCapsule(SDL_Surface *screen, const Vector<int> &offset)
        }
 }
 
-void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderHeroTags(SDL_Surface *screen) {
        assert(screen);
        int tagHeight(attackTypeMenu.Height());
        int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
@@ -457,7 +460,7 @@ void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector<int> &offset)
        }
 }
 
-void BattleState::RenderSmallHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderSmallHeroTags(SDL_Surface *screen) {
        assert(screen);
        int tagHeight(res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2);
        int tagWidth(res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2);