-/*
- * SelectItem.cpp
- *
- * Created on: Aug 9, 2012
- * Author: holy
- */
-
#include "SelectItem.h"
#include "SelectAttackType.h"
#include "../../app/Input.h"
#include "../../common/Item.h"
#include "../../graphics/Frame.h"
+#include "../../math/Vector.h"
using app::Application;
using app::Input;
using common::Item;
-using geometry::Vector;
+using math::Vector;
using graphics::Frame;
namespace battle {
-void SelectItem::EnterState(Application &c, SDL_Surface *screen) {
- ctrl = &c;
+void SelectItem::OnEnterState(SDL_Surface *screen) {
+
}
-void SelectItem::ExitState(Application &c, SDL_Surface *screen) {
- ctrl = 0;
+void SelectItem::OnExitState(SDL_Surface *screen) {
+
}
-void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnResumeState(SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM);
battle->ActiveHero().GetAttackChoice().SetItem(battle->ItemMenu().Selected());
- ctrl.PopState();
+ Ctrl().PopState();
}
}
-void SelectItem::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnPauseState(SDL_Surface *screen) {
}
-void SelectItem::Resize(int width, int height) {
+void SelectItem::OnResize(int width, int height) {
}
}
if (item->GetTargetingMode().TargetsAll()) {
ac.SetType(AttackChoice::ITEM);
- // TODO: remove item from inventory
ac.SetItem(item);
battle->NextHero();
- ctrl->PopState();
+ Ctrl().PopState();
} else {
if (item->GetTargetingMode().TargetsSingle()) {
ac.Selection().SetSingle();
} else {
ac.Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor));
+ Ctrl().PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor));
}
}
}
if (input.JustPressed(Input::ACTION_B)) {
- ctrl->PopState(); // return control to parent
+ Ctrl().PopState(); // return control to parent
}
if (input.JustPressed(Input::PAD_UP)) {
battle->ItemMenu().PreviousRow();
}
}
-void SelectItem::UpdateWorld(float deltaT) {
+void SelectItem::UpdateWorld(Uint32 deltaT) {
}
void SelectItem::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
const Frame *frame(battle->Res().selectFrame);
- Vector<int> position(frame->BorderWidth(), frame->BorderHeight());
+ Vector<int> position(frame->BorderSize());
int width(battle->Width() - 2 * frame->BorderWidth());
int height(battle->Res().normalFont->CharHeight() * 13);
frame->Draw(screen, position + offset, width, height);