]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/SpellMenu.cpp
added menu cursor animations
[l2e.git] / src / menu / SpellMenu.cpp
index 0f34d067940ffc56148eacb4a58d82a59a4b7e62..0c7936595bd2e44525b3ad97c6ca7535619b3008 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 "../common/Spell.h"
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
+#include "../math/Vector.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;
@@ -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) {
 
 }