From: Daniel Karbach Date: Tue, 18 Dec 2012 20:53:25 +0000 (+0100) Subject: more intuitive horizontal capsule class navigation X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=5cbe0ba11d6fe180f49101547f05e7fe586d55c0;p=l2e.git more intuitive horizontal capsule class navigation --- diff --git a/src/common/Capsule.cpp b/src/common/Capsule.cpp index 0085147..f886724 100644 --- a/src/common/Capsule.cpp +++ b/src/common/Capsule.cpp @@ -99,6 +99,16 @@ void Capsule::PreviousClass() { } } +void Capsule::SetClass(int index) { + curClass = index; + if (curClass < 0 ) { + curClass = 0; + } + if (curClass >= maxClass) { + curClass = maxClass - 1; + } +} + Sprite *Capsule::BattleSprite() { return GetClass().battleSprite; diff --git a/src/common/Capsule.h b/src/common/Capsule.h index f168506..f68ba53 100644 --- a/src/common/Capsule.h +++ b/src/common/Capsule.h @@ -42,6 +42,8 @@ public: void UpgradeClass(); void NextClass(); void PreviousClass(); + int ClassIndex() const { return curClass; } + void SetClass(int index); Uint16 MaxHealth() const; diff --git a/src/menu/CapsuleChangeMenu.cpp b/src/menu/CapsuleChangeMenu.cpp index 912f81a..24b7187 100644 --- a/src/menu/CapsuleChangeMenu.cpp +++ b/src/menu/CapsuleChangeMenu.cpp @@ -70,6 +70,7 @@ void CapsuleChangeMenu::HandleEvents(const Input &input) { } void CapsuleChangeMenu::NextCapsule() { + int storedClass = parent->Game().state->GetCapsule().ClassIndex(); int &index = parent->Game().state->capsule; ++index; index %= parent->Game().state->NumCapsules(); @@ -78,9 +79,11 @@ void CapsuleChangeMenu::NextCapsule() { ++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(); @@ -89,6 +92,7 @@ void CapsuleChangeMenu::PreviousCapsule() { --index; if (index < 0) index += parent->Game().state->NumCapsules(); } + parent->Game().state->GetCapsule().SetClass(storedClass); } void CapsuleChangeMenu::NextClass() {