]> git.localhorst.tv Git - l2e.git/commitdiff
added ikari select state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 9 Aug 2012 00:47:02 +0000 (02:47 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 9 Aug 2012 00:47:02 +0000 (02:47 +0200)
Debug/src/battle/states/subdir.mk
Release/src/battle/states/subdir.mk
src/battle/BattleState.cpp
src/battle/BattleState.h
src/battle/Resources.h
src/battle/states/SelectAttackType.cpp
src/battle/states/SelectIkari.cpp [new file with mode: 0644]
src/battle/states/SelectIkari.h [new file with mode: 0644]
src/main.cpp

index 6697dcbd3d1306b31262dc5611a612f9f77839a0..8217544fbcc22a00aecd70c7f4581b2ff40fb617 100644 (file)
@@ -5,18 +5,21 @@
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
 ../src/battle/states/SelectAttackType.cpp \
+../src/battle/states/SelectIkari.cpp \
 ../src/battle/states/SelectItem.cpp \
 ../src/battle/states/SelectMoveAction.cpp \
 ../src/battle/states/SelectSpell.cpp 
 
 OBJS += \
 ./src/battle/states/SelectAttackType.o \
+./src/battle/states/SelectIkari.o \
 ./src/battle/states/SelectItem.o \
 ./src/battle/states/SelectMoveAction.o \
 ./src/battle/states/SelectSpell.o 
 
 CPP_DEPS += \
 ./src/battle/states/SelectAttackType.d \
+./src/battle/states/SelectIkari.d \
 ./src/battle/states/SelectItem.d \
 ./src/battle/states/SelectMoveAction.d \
 ./src/battle/states/SelectSpell.d 
index 5fdaab06eede93738c6e1c5d8589c2f41b16d77a..6bd80356653b561eddbb6f979e554991934fdf80 100644 (file)
@@ -5,18 +5,21 @@
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
 ../src/battle/states/SelectAttackType.cpp \
+../src/battle/states/SelectIkari.cpp \
 ../src/battle/states/SelectItem.cpp \
 ../src/battle/states/SelectMoveAction.cpp \
 ../src/battle/states/SelectSpell.cpp 
 
 OBJS += \
 ./src/battle/states/SelectAttackType.o \
+./src/battle/states/SelectIkari.o \
 ./src/battle/states/SelectItem.o \
 ./src/battle/states/SelectMoveAction.o \
 ./src/battle/states/SelectSpell.o 
 
 CPP_DEPS += \
 ./src/battle/states/SelectAttackType.d \
+./src/battle/states/SelectIkari.d \
 ./src/battle/states/SelectItem.d \
 ./src/battle/states/SelectMoveAction.d \
 ./src/battle/states/SelectSpell.d 
index 382972fe271b654b5ed4c744d986265c345d6961..0c983e7fa2d964fddff019e21a962a64ef662f1b 100644 (file)
@@ -53,6 +53,8 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
        for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
                spellMenus.push_back(res->spellMenuPrototype);
                // TODO: insert spell menu entries
+               ikariMenus.push_back(res->ikariMenuPrototype);
+               // TODO: insert ikari menu entries
                heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], res, HeroTag::Alignment((i + 1) % 2)));
        }
        // TODO: insert item menu entries
index 65e8727906859fd442c174107ce92782d603fb1d..074578e18312252295b6da1dcb210b262243bff5 100644 (file)
@@ -80,6 +80,8 @@ public:
        bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
        graphics::Menu</* Spell */ void *> &GetSpellMenu() { return spellMenus[activeHero]; }
        const graphics::Menu</* Spell */ void *> &GetSpellMenu() const { return spellMenus[activeHero]; }
+       graphics::Menu</* Ikari or Item */ void *> &GetIkariMenu() { return ikariMenus[activeHero]; }
+       const graphics::Menu</* Ikari or Item */ void *> &GetIkariMenu() const { return ikariMenus[activeHero]; }
        graphics::Menu</* Item */ void *> &GetItemMenu() { return itemMenu; }
                const graphics::Menu</* Item */ void *> &GetItemMenu() const { return itemMenu; }
 
@@ -110,6 +112,7 @@ private:
        std::vector<Hero> heroes;
        std::vector<graphics::Menu</* Spell */ void *> > spellMenus;
        graphics::Menu</* Item */ void *> itemMenu;
+       std::vector<graphics::Menu</* Ikari or Item */ void *> > ikariMenus;
        std::vector<HeroTag> heroTags;
        std::vector<AttackChoice> attackChoices;
        int activeHero;
index 0c646670bcd545841bc6867c5337bb56a939df46..0d18b9fbfbd8609127c25bd81f94adf45fdb5f0b 100644 (file)
@@ -47,6 +47,9 @@ struct Resources {
        const char *itemMenuHeadline;
        graphics::Menu</* Spell */ void *> itemMenuPrototype;
 
+       const char *ikariMenuHeadline;
+       graphics::Menu</* Ikari or Item */ void *> ikariMenuPrototype;
+
 
        Resources()
        : moveIcons(0)
@@ -70,6 +73,7 @@ struct Resources {
        , menuCursor(0)
        , spellMenuHeadline("")
        , itemMenuHeadline("")
+       , ikariMenuHeadline("")
        { }
 
 };
index c5e0bba3b580ebcd20886fed04996f54f590b130..5e687b670622ec25f4b870cacfe00fa15a34e3cb 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "SelectAttackType.h"
 
+#include "SelectIkari.h"
 #include "SelectItem.h"
 #include "SelectMoveAction.h"
 #include "SelectSpell.h"
@@ -79,8 +80,7 @@ void SelectAttackType::HandleInput(const Input &input) {
                                battle->NextHero();
                                break;
                        case AttackChoice::IKARI:
-                               // TODO: switch to ikari attack select
-                               battle->NextHero();
+                               ctrl->PushState(new SelectIkari(battle, this));
                                break;
                        case AttackChoice::ITEM:
                                ctrl->PushState(new SelectItem(battle, this));
diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp
new file mode 100644 (file)
index 0000000..3c11164
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * SelectIkari.cpp
+ *
+ *  Created on: Aug 9, 2012
+ *      Author: holy
+ */
+
+#include "SelectIkari.h"
+
+#include "SelectAttackType.h"
+#include "../BattleState.h"
+#include "../../app/Application.h"
+#include "../../app/Input.h"
+#include "../../geometry/Point.h"
+#include "../../geometry/operators.h"
+#include "../../graphics/Frame.h"
+
+using app::Application;
+using app::Input;
+using geometry::Point;
+using geometry::Vector;
+using graphics::Frame;
+
+namespace battle {
+
+void SelectIkari::EnterState(Application &c, SDL_Surface *screen) {
+       ctrl = &c;
+}
+
+void SelectIkari::ExitState(Application &c, SDL_Surface *screen) {
+       ctrl = 0;
+}
+
+void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+
+void SelectIkari::Resize(int width, int height) {
+
+}
+
+
+void SelectIkari::HandleInput(const Input &input) {
+       if (input.JustPressed(Input::ACTION_A)) {
+               // TODO: switch to target select
+               if (battle->GetIkariMenu().SelectedIsEnabled()) {
+                       battle->NextHero();
+                       ctrl->PopState();
+               }
+       }
+       if (input.JustPressed(Input::ACTION_B)) {
+               ctrl->PopState(); // return control to parent
+       }
+       if (input.JustPressed(Input::PAD_UP)) {
+               battle->GetIkariMenu().PreviousRow();
+       }
+       if (input.JustPressed(Input::PAD_RIGHT)) {
+               battle->GetIkariMenu().NextItem();
+       }
+       if (input.JustPressed(Input::PAD_DOWN)) {
+               battle->GetIkariMenu().NextRow();
+       }
+       if (input.JustPressed(Input::PAD_LEFT)) {
+               battle->GetIkariMenu().PreviousItem();
+       }
+}
+
+void SelectIkari::UpdateWorld(float deltaT) {
+
+}
+
+void SelectIkari::Render(SDL_Surface *screen) {
+       parent->Render(screen);
+       Vector<int> offset(battle->CalculateScreenOffset(screen));
+       RenderFrame(screen, offset);
+       RenderHeadline(screen, offset);
+       RenderMenu(screen, offset);
+}
+
+void SelectIkari::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 height(battle->Res().normalFont->CharHeight() * 13);
+       frame->Draw(screen, position + offset, width, height);
+}
+
+void SelectIkari::RenderHeadline(SDL_Surface *screen, const Vector<int> &offset) {
+       const Resources &res(battle->Res());
+       Point<int> position(
+                       2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
+                       2 * res.selectFrame->BorderHeight());
+       res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset);
+}
+
+void SelectIkari::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
+       const Resources &res(battle->Res());
+       Point<int> position(
+                       2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
+                       2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight());
+       battle->GetIkariMenu().Draw(screen, position + offset);
+}
+
+}
diff --git a/src/battle/states/SelectIkari.h b/src/battle/states/SelectIkari.h
new file mode 100644 (file)
index 0000000..1550ed8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SelectIkari.h
+ *
+ *  Created on: Aug 9, 2012
+ *      Author: holy
+ */
+
+#ifndef BATTLE_SELECTIKARI_H_
+#define BATTLE_SELECTIKARI_H_
+
+#include "../../app/State.h"
+
+#include "../../geometry/Vector.h"
+
+namespace battle {
+
+class BattleState;
+class SelectAttackType;
+
+// TODO: looks like item, spell, and ikari select can be merged into one class
+class SelectIkari
+: public app::State {
+
+public:
+       SelectIkari(BattleState *battle, SelectAttackType *parent)
+       : ctrl(0), battle(battle), parent(parent) { }
+
+public:
+       virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
+       virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+
+       virtual void Resize(int width, int height);
+
+       virtual void HandleInput(const app::Input &);
+       virtual void UpdateWorld(float deltaT);
+       virtual void Render(SDL_Surface *);
+
+private:
+       void RenderFrame(SDL_Surface *, const geometry::Vector<int> &offset);
+       void RenderHeadline(SDL_Surface *, const geometry::Vector<int> &offset);
+       void RenderMenu(SDL_Surface *, const geometry::Vector<int> &offset);
+
+private:
+       app::Application *ctrl;
+       BattleState *battle;
+       SelectAttackType *parent;
+
+};
+
+}
+
+#endif /* BATTLE_SELECTIKARI_H_ */
index 8820004ea2d45e44a4088ff3fb55aa36bd668d57..7dbeba0548ba481c81640b550fc9d4baaed94eea 100644 (file)
@@ -247,6 +247,15 @@ int main(int argc, char **argv) {
                battleRes.itemMenuPrototype.Add("Protect ring: 1", 0, false, &ringIcon);
                battleRes.itemMenuPrototype.Add("Mysto jewel : 1", 0, false, &stoneIcon);
 
+               battleRes.ikariMenuHeadline = "Please choose equipment.";
+               battleRes.ikariMenuPrototype = Menu</* Item */ void *>(&normalFont, &disabledFont, &handCursorSprite, 26, 6, 8, 16, 1, 32);
+               battleRes.ikariMenuPrototype.Add("Zirco whip   Thundershriek", 0, false, &swordIcon);
+               battleRes.ikariMenuPrototype.Add("Zircon plate Sudden cure", 0, true, &armorIcon);
+               battleRes.ikariMenuPrototype.Add("Zirco gloves Forcefield", 0, true, &shieldIcon);
+               battleRes.ikariMenuPrototype.Add("Holy cap     Vulnerable", 0, false, &helmetIcon);
+               battleRes.ikariMenuPrototype.Add("Ghost ring   Destroy", 0, true, &ringIcon);
+               battleRes.ikariMenuPrototype.Add("Eagle rock   Dive", 0, true, &stoneIcon);
+
                BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
                battleState->AddMonster(monster);
                battleState->AddMonster(monster);