]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/SpellMenu.cpp
switched geometric scalars from floating to fixed
[l2e.git] / src / menu / SpellMenu.cpp
index 0f34d067940ffc56148eacb4a58d82a59a4b7e62..09ca56ca53faa8c88fc28b2c0c971d31ea491964 100644 (file)
@@ -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"
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
 
+#include <algorithm>
 #include <SDL.h>
 #include <vector>
 
 using app::Input;
 using common::Hero;
 using common::Spell;
-using geometry::Vector;
+using math::Vector;
 using graphics::Font;
 using graphics::Frame;
 using std::vector;
@@ -68,6 +63,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 +111,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 +126,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 +145,7 @@ void SpellMenu::HandleEvents(const Input &input) {
        }
 }
 
-void SpellMenu::UpdateWorld(float deltaT) {
+void SpellMenu::UpdateWorld(Uint32 deltaT) {
 
 }