]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/SpellMenu.cpp
implemented spell sorting
[l2e.git] / src / menu / SpellMenu.cpp
index 0f34d067940ffc56148eacb4a58d82a59a4b7e62..3be722bffa550313b9005d408a166268bb68b329 100644 (file)
@@ -18,6 +18,7 @@
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
 
+#include <algorithm>
 #include <SDL.h>
 #include <vector>
 
@@ -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();