-/*
- * 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>
return *parent->Game().state->party[cursor];
}
+Hero &SpellMenu::GetHero() {
+ return *parent->Game().state->party[cursor];
+}
+
void SpellMenu::OnExitState(SDL_Surface *) {
SDL_FreeSurface(highlight);
}
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();
// TODO: use spell
}
} else {
- // TODO: swap spells
+ std::swap(GetHero().Spells().at(spellMenu.SelectedIndex()),
+ GetHero().Spells().at(spellMenu.SecondaryIndex()));
spellMenu.SwapSelected();
spellMenu.SetActive();
}