#include "../graphics/Font.h"
#include "../graphics/Frame.h"
#include "../graphics/Texture.h"
+#include "../math/Vector.h"
using app::Input;
using common::Capsule;
using common::Inventory;
using common::Item;
-using geometry::Vector;
+using math::Vector;
using graphics::Font;
using graphics::Frame;
void CapsuleChangeMenu::HandleEvents(const Input &input) {
- if (input.JustPressed(Input::ACTION_B)) {
+ if (input.JustPressed(Input::ACTION_A)
+ || input.JustPressed(Input::ACTION_B)) {
Ctrl().PopState();
}
+
+ if (input.JustPressed(Input::PAD_UP)) {
+ NextClass();
+ }
+ if (input.JustPressed(Input::PAD_RIGHT)) {
+ NextCapsule();
+ }
+ if (input.JustPressed(Input::PAD_DOWN)) {
+ PreviousClass();
+ }
+ if (input.JustPressed(Input::PAD_LEFT)) {
+ PreviousCapsule();
+ }
}
-void CapsuleChangeMenu::UpdateWorld(float deltaT) {
+void CapsuleChangeMenu::NextCapsule() {
+ int storedClass = parent->Game().state->GetCapsule().ClassIndex();
+ int &index = parent->Game().state->capsule;
+ ++index;
+ index %= parent->Game().state->NumCapsules();
+ // skip unexplored
+ while (parent->Game().state->GetCapsule().MaxClass() <= 0) {
+ ++index;
+ index %= parent->Game().state->NumCapsules();
+ }
+ parent->Game().state->GetCapsule().SetClass(storedClass);
+}
+
+void CapsuleChangeMenu::PreviousCapsule() {
+ int storedClass = parent->Game().state->GetCapsule().ClassIndex();
+ int &index = parent->Game().state->capsule;
+ --index;
+ if (index < 0) index += parent->Game().state->NumCapsules();
+ // skip unexplored
+ while (GetCapsule().MaxClass() <= 0) {
+ --index;
+ if (index < 0) index += parent->Game().state->NumCapsules();
+ }
+ parent->Game().state->GetCapsule().SetClass(storedClass);
+}
+
+void CapsuleChangeMenu::NextClass() {
+ GetCapsule().NextClass();
+}
+
+void CapsuleChangeMenu::PreviousClass() {
+ GetCapsule().PreviousClass();
+}
+
+
+void CapsuleChangeMenu::UpdateWorld(Uint32 deltaT) {
}
parent->Res().capsuleSelectLadder->Draw(
screen, cursor,
j < parent->Game().state->capsules[i].MaxClass(), j);
- if (&parent->Game().state->capsules[i] == parent->Game().state->capsule
+ if (i == parent->Game().state->capsule
&& parent->Game().state->capsules[i].CurrentClass() == j) {
parent->Res().capsuleSelectCursor->Draw(screen, cursor);
}
return parent->Height();
}
+Capsule &CapsuleChangeMenu::GetCapsule() {
+ return parent->GetCapsule();
+}
+
const Capsule &CapsuleChangeMenu::GetCapsule() const {
return parent->GetCapsule();
}