X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmenu%2FSpellMenu.cpp;h=0c7936595bd2e44525b3ad97c6ca7535619b3008;hb=3aca2860c95bb4d30569a23ab88a5286c3b9b757;hp=0f34d067940ffc56148eacb4a58d82a59a4b7e62;hpb=670dd3c61cba875345b6755d41f479cff8d964c4;p=l2e.git diff --git a/src/menu/SpellMenu.cpp b/src/menu/SpellMenu.cpp index 0f34d06..0c79365 100644 --- a/src/menu/SpellMenu.cpp +++ b/src/menu/SpellMenu.cpp @@ -1,15 +1,9 @@ -/* - * SpellMenu.cpp - * - * Created on: Nov 18, 2012 - * Author: holy - */ - #include "SpellMenu.h" #include "HeroStatus.h" #include "PartyMenu.h" #include "Resources.h" +#include "../app/Application.h" #include "../app/Input.h" #include "../common/GameConfig.h" #include "../common/GameState.h" @@ -17,14 +11,16 @@ #include "../common/Spell.h" #include "../graphics/Font.h" #include "../graphics/Frame.h" +#include "../math/Vector.h" +#include #include #include using app::Input; using common::Hero; using common::Spell; -using geometry::Vector; +using math::Vector; using graphics::Font; using graphics::Frame; using std::vector; @@ -49,7 +45,9 @@ void SpellMenu::OnEnterState(SDL_Surface *) { SDL_SetAlpha(highlight, SDL_SRCALPHA|SDL_RLEACCEL, 0x20); actionMenu.SetSelected(); + actionMenu.StartAnimation(Ctrl()); LoadSpells(); + spellMenu.StartAnimation(Ctrl()); } void SpellMenu::LoadSpells() { @@ -68,6 +66,10 @@ const Hero &SpellMenu::GetHero() const { return *parent->Game().state->party[cursor]; } +Hero &SpellMenu::GetHero() { + return *parent->Game().state->party[cursor]; +} + void SpellMenu::OnExitState(SDL_Surface *) { SDL_FreeSurface(highlight); } @@ -112,7 +114,9 @@ void SpellMenu::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { if (actionMenu.IsActive()) { if (actionMenu.Selected() == CHOICE_SORT) { - // TODO: sort spells + std::sort(GetHero().Spells().begin(), + GetHero().Spells().end(), + Spell::Less); LoadSpells(); } else { actionMenu.SetSelected(); @@ -125,7 +129,8 @@ void SpellMenu::HandleEvents(const Input &input) { // TODO: use spell } } else { - // TODO: swap spells + std::swap(GetHero().Spells().at(spellMenu.SelectedIndex()), + GetHero().Spells().at(spellMenu.SecondaryIndex())); spellMenu.SwapSelected(); spellMenu.SetActive(); } @@ -143,7 +148,7 @@ void SpellMenu::HandleEvents(const Input &input) { } } -void SpellMenu::UpdateWorld(float deltaT) { +void SpellMenu::UpdateWorld(Uint32 deltaT) { }