X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=4e12f7929a5be2ada8fa319e6ce275827375fae0;hb=558fd3d14ad1a9dc347998691a0b300fd334a16a;hp=a2c306a2ef7050d1fd9d0a468d768d152962229b;hpb=628b3a7276d0b330719e05504b23bafcf88f8fca;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index a2c306a..4e12f79 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -8,6 +8,7 @@ #include "BattleState.h" #include "PartyLayout.h" +#include "states/SelectMoveAction.h" #include "../app/Application.h" #include "../app/Input.h" #include "../geometry/operators.h" @@ -50,6 +51,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { heroTags.push_back(HeroTag(&heroes[i], HeroTag::Alignment((i + 1) % 2))); } + ctrl.PushState(new SelectMoveAction(this)); } void BattleState::ExitState() { @@ -58,35 +60,7 @@ void BattleState::ExitState() { void BattleState::HandleInput(const Input &input) { - if (moveChoice == -1) { - if (input.IsDown(Input::PAD_UP)) { - moveMenu.Select(MoveMenu::CHANGE); - } else if (input.IsDown(Input::PAD_DOWN)) { - moveMenu.Select(MoveMenu::RUN); - } else { - moveMenu.Select(MoveMenu::ATTACK); - } - - if (input.JustPressed(Input::ACTION_A)) { - moveChoice = moveMenu.Selected(); - } - } else { - if (input.IsDown(Input::PAD_UP)) { - attackTypeMenu.Select(AttackTypeMenu::MAGIC); - } else if (input.IsDown(Input::PAD_RIGHT)) { - attackTypeMenu.Select(AttackTypeMenu::DEFEND); - } else if (input.IsDown(Input::PAD_DOWN)) { - attackTypeMenu.Select(AttackTypeMenu::IKARI); - } else if (input.IsDown(Input::PAD_LEFT)) { - attackTypeMenu.Select(AttackTypeMenu::ITEM); - } else { - attackTypeMenu.Select(AttackTypeMenu::SWORD); - } - - if (input.JustPressed(Input::ACTION_A)) { - activeHero = (activeHero + 1) % 4; - } - } + } void BattleState::UpdateWorld(float deltaT) { @@ -94,19 +68,13 @@ void BattleState::UpdateWorld(float deltaT) { } void BattleState::Render(SDL_Surface *screen) { - Vector offset( - (screen->w - background->w) / 2, - (screen->h - background->h) / 2); + Vector offset(CalculateScreenOffset(screen)); RenderBackground(screen, offset); RenderMonsters(screen, offset); // RenderHeroes(screen, offset); RenderHeroTags(screen, offset); - if (moveChoice == -1) { - RenderMoveMenu(screen, offset); - } else { - RenderAttackTypeMenu(screen, offset); - } + RenderAttackTypeMenu(screen, offset); } void BattleState::RenderBackground(SDL_Surface *screen, const Vector &offset) { @@ -133,9 +101,9 @@ void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { } void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector &offset) { - int uiHeight(background->h / 2), uiOffset(uiHeight); + int uiHeight(BackgroundHeight() / 2), uiOffset(uiHeight); int tagHeight((uiHeight - attackTypeMenu.IconHeight()) / 2); - int tagWidth((background->w - attackTypeMenu.IconWidth()) / 2); + int tagWidth((BackgroundWidth() - attackTypeMenu.IconWidth()) / 2); Point tagPosition[4]; tagPosition[0] = Point(0, uiOffset); @@ -150,16 +118,9 @@ void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector &offset) void BattleState::RenderAttackTypeMenu(SDL_Surface *screen, const Vector &offset) { Point position( - (background->w - attackTypeMenu.Width()) / 2, - (background->h * 3 / 4) - (attackTypeMenu.Height() / 2)); + (BackgroundWidth() - attackTypeMenu.Width()) / 2, + (BackgroundHeight() * 3 / 4) - (attackTypeMenu.Height() / 2)); attackTypeMenu.Render(screen, position + offset); } -void BattleState::RenderMoveMenu(SDL_Surface *screen, const Vector &offset) { - Point position( - (background->w - moveMenu.Width()) / 2, - (background->h * 3 / 4) - (moveMenu.Height() / 2)); - moveMenu.Render(screen, position + offset); -} - }