]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/SpellMenu.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / menu / SpellMenu.cpp
index 0f34d067940ffc56148eacb4a58d82a59a4b7e62..b42a39afa04d4724a3385282fe7d02545a5c9dd6 100644 (file)
@@ -1,10 +1,3 @@
-/*
- * SpellMenu.cpp
- *
- *  Created on: Nov 18, 2012
- *      Author: holy
- */
-
 #include "SpellMenu.h"
 
 #include "HeroStatus.h"
@@ -18,6 +11,7 @@
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
 
+#include <algorithm>
 #include <SDL.h>
 #include <vector>
 
@@ -68,6 +62,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 +110,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 +125,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();
                }