X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmenu%2FSpellMenu.cpp;h=57989ed2a9396e659fc0fa5cb5a416f0830d0b94;hb=aacd6d095d1e200cee6033fbf8221bea9a6c3112;hp=0f34d067940ffc56148eacb4a58d82a59a4b7e62;hpb=670dd3c61cba875345b6755d41f479cff8d964c4;p=l2e.git diff --git a/src/menu/SpellMenu.cpp b/src/menu/SpellMenu.cpp index 0f34d06..57989ed 100644 --- a/src/menu/SpellMenu.cpp +++ b/src/menu/SpellMenu.cpp @@ -18,6 +18,7 @@ #include "../graphics/Font.h" #include "../graphics/Frame.h" +#include #include #include @@ -68,6 +69,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 +117,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 +132,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(); }