}
void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroTargets().HasSelected()) {
+ if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
+ battle->ActiveHeroAttackChoice().SetItem(battle->GetItemMenu().Selected());
ctrl.PopState();
}
}
}
-void SelectItem::HandleInput(const Input &input) {
+void SelectItem::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetItemMenu().SelectedIsEnabled()) {
const Item *item(battle->GetItemMenu().Selected());
- battle->ActiveHeroTargets().Reset();
- if (item->TargetAlly()) {
- battle->ActiveHeroTargets().SelectHeroes();
+ battle->ActiveHeroAttackChoice().Selection().Reset();
+ if (item->GetTargetingMode().TargetsAlly()) {
+ battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
} else {
- battle->ActiveHeroTargets().SelectEnemies();
+ battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
}
- if (item->TargetAll()) {
- battle->SetAttackType(AttackChoice::ITEM);
+ if (item->GetTargetingMode().TargetsAll()) {
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
// TODO: remove item from inventory
battle->ActiveHeroAttackChoice().SetItem(item);
battle->NextHero();
ctrl->PopState();
} else {
- if (item->TargetOne()) {
- battle->ActiveHeroTargets().SetSingle();
+ if (item->GetTargetingMode().TargetsSingle()) {
+ battle->ActiveHeroAttackChoice().Selection().SetSingle();
} else {
- battle->ActiveHeroTargets().SetMultiple();
+ battle->ActiveHeroAttackChoice().Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().itemTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().itemTargetCursor));
}
-// battle->SetAttackType(AttackChoice::ITEM);
-// battle->NextHero();
-// ctrl->PopState();
}
}
if (input.JustPressed(Input::ACTION_B)) {
void SelectItem::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
const Frame *frame(battle->Res().selectFrame);
Point<int> position(frame->BorderWidth(), frame->BorderHeight());
- int width(battle->BackgroundWidth() - 2 * frame->BorderWidth());
+ int width(battle->Width() - 2 * frame->BorderWidth());
int height(battle->Res().normalFont->CharHeight() * 13);
frame->Draw(screen, position + offset, width, height);
}