]> git.localhorst.tv Git - l2e.git/commitdiff
added capsule wheel and table
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 16 Dec 2012 21:45:19 +0000 (22:45 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 16 Dec 2012 21:45:19 +0000 (22:45 +0100)
12 files changed:
src/common/Capsule.cpp
src/common/Capsule.h
src/common/GameState.h
src/main.cpp
src/menu/CapsuleChangeMenu.cpp
src/menu/CapsuleChangeMenu.h
src/menu/CapsuleMenu.cpp
src/menu/Resources.cpp
src/menu/Resources.h
test-data/capsule-sprites.png [new file with mode: 0644]
test-data/capsules.l2s
test-data/test.l2s

index 8fa1ca92e030ea5722aa94affce1c668aa7d0de3..302af8f774197d022f676570a045ca97bd32bbf9 100644 (file)
@@ -23,6 +23,8 @@ Capsule::Capsule()
 : name("")
 , alignment("")
 
+, alignmentSprite(0)
+
 , maxHealth(0)
 
 , level(1)
@@ -33,7 +35,7 @@ Capsule::Capsule()
 
 , classes(0)
 , numClasses(0)
-, curClass(0)
+, curClass(-1)
 , maxClass(0) {
 
 }
@@ -78,6 +80,11 @@ int Capsule::NextLevel() const {
        }
 }
 
+void Capsule::UpgradeClass() {
+       ++maxClass;
+       ++curClass;
+}
+
 
 Sprite *Capsule::BattleSprite() {
        return GetClass().battleSprite;
@@ -136,6 +143,9 @@ void Capsule::CreateTypeDescription() {
        td.AddField("name", FieldDescription(((char *)&c.name) - ((char *)&c), Interpreter::STRING_ID).SetReferenced());
        td.AddField("alignment", FieldDescription(((char *)&c.alignment) - ((char *)&c), Interpreter::STRING_ID).SetReferenced());
 
+       td.AddField("alignmentCursor", FieldDescription(((char *)&c.alignmentCursor) - ((char *)&c), Interpreter::VECTOR_ID));
+       td.AddField("alignmentSprite", FieldDescription(((char *)&c.alignmentSprite) - ((char *)&c), Sprite::TYPE_ID).SetReferenced());
+
        td.AddField("maxHealth", FieldDescription(((char *)&c.maxHealth) - ((char *)&c), Interpreter::NUMBER_ID));
 
        td.AddField("stats", FieldDescription(((char *)&c.stats) - ((char *)&c), Stats::TYPE_ID));
index 8d4791d20b2e4d20c2ed8c59dda9882115ce7bae..c70d07fdf28cb41368160f3dfb314208dcf2e68a 100644 (file)
@@ -7,6 +7,7 @@ namespace graphics {
 }
 
 #include "../common/Stats.h"
+#include "../geometry/Vector.h"
 
 #include <SDL.h>
 
@@ -31,6 +32,15 @@ public:
        const Spell *Attack2() const;
        const Spell *Attack3() const;
 
+       int NumClasses() const { return numClasses; }
+       int MaxClass() const { return maxClass; }
+       int CurrentClass() const { return curClass; }
+
+       const geometry::Vector<int> &AlignmentOffset() const { return alignmentCursor; }
+       const graphics::Sprite *AlignmentSprite() const { return alignmentSprite; }
+
+       void UpgradeClass();
+
        Uint16 MaxHealth() const;
 
        Stats GetStats() const;
@@ -75,6 +85,9 @@ private:
        const char *name;
        const char *alignment;
 
+       geometry::Vector<int> alignmentCursor;
+       const graphics::Sprite *alignmentSprite;
+
        int maxHealth;
 
        Stats stats;
index 4e2570d8fb8ea90c336169cb8e6a6b1c2ebf161e..4080630a21e84e79681c7a029dc8c5fa2bda8c0e 100644 (file)
@@ -14,10 +14,12 @@ struct GameState {
        GameState();
 
        Hero heroes[7];
+       int NumHeroes() const { return 7; }
        Hero *party[4];
        int partySize;
 
        Capsule capsules[7];
+       int NumCapsules() const { return 7; }
        Capsule *capsule;
 
        Inventory inventory;
index 2ecd30ab6705e1fb77e98d360b2a2bfa76687559..ca54210181f34e52b8a9e0c2f17060b985a8a5c9 100644 (file)
@@ -196,8 +196,9 @@ int main(int argc, char **argv) {
                gameState.party[3] = &gameState.heroes[3];
                gameState.partySize = 4;
 
-               gameState.capsules[0] = *caster.GetCapsule("flash");
-               gameState.capsule = gameState.capsules;
+               gameState.capsules[1] = *caster.GetCapsule("flash");
+               gameState.capsules[1].UpgradeClass();
+               gameState.capsule = &gameState.capsules[1];
 
                GameConfig gameConfig;
                gameConfig.state = &gameState;
index 3b161ad9df6ff6e0839a90c70166c52ce50a66f2..cac2056aecab713fe075f0c5fb3205010cb0b996 100644 (file)
@@ -10,6 +10,7 @@
 #include "../common/GameState.h"
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
+#include "../graphics/Texture.h"
 
 using app::Input;
 using common::Capsule;
@@ -69,18 +70,76 @@ void CapsuleChangeMenu::Render(SDL_Surface *screen) {
                        12 * font.CharWidth(),
                        2 * font.CharHeight() - font.CharHeight() / 8);
        // TODO: wheel offset: top left, center, or center bottom?
-       const Vector<int> wheelOffset;
+       const Vector<int> wheelOffset(
+                       6 * font.CharWidth(),
+                       19 * font.CharHeight() - font.CharHeight() / 8);
+       const Vector<int> classesOffset(
+                       12 * font.CharWidth(),
+                       13 * font.CharHeight() - font.CharHeight() / 8);
        const Vector<int> menuOffset(
-                               font.CharWidth(),
-                               24 * font.CharHeight() - font.CharHeight() / 8);
+                       font.CharWidth(),
+                       24 * font.CharHeight() - font.CharHeight() / 8);
 
        parent->RenderBackground(screen);
        parent->RenderCapsule(screen, offset + capsuleOffset);
        parent->RenderInfo(screen, offset + infoOffset);
        parent->RenderWheel(screen, offset + wheelOffset);
+       RenderClasses(screen, offset + classesOffset);
        parent->RenderMenu(screen, offset + menuOffset);
 }
 
+void CapsuleChangeMenu::RenderClasses(SDL_Surface *screen, const Vector<int> &offset) const {
+       Vector<int> cursor(offset);
+
+       int numClasses = 0;
+       for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+               if (numClasses < parent->Game().state->capsules[i].NumClasses()) {
+                       numClasses = parent->Game().state->capsules[i].NumClasses();
+               }
+       }
+
+       parent->Res().capsuleSelectTopLeft->Draw(screen, cursor);
+       cursor.Y() += parent->Res().capsuleSelectTopLeft->Height();
+       Vector<int> target(
+                       cursor.X() + parent->Res().capsuleSelectTopLeft->Width(),
+                       cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+       parent->Res().capsuleSelectLeftRepeat->Render(screen, cursor, target);
+       cursor.Y() = target.Y();
+       parent->Res().capsuleSelectBottomLeft->Draw(screen, cursor);
+       cursor.X() += parent->Res().capsuleSelectTopLeft->Width();
+
+       for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+               cursor.Y() = offset.Y();
+               parent->Res().capsuleSelectTopRepeat->Draw(screen, cursor);
+               cursor.Y() += parent->Res().capsuleSelectTopRepeat->Height();
+               for (int j = numClasses - 1; j >= 0; --j) {
+                       parent->Res().capsuleSelectLadder->Draw(
+                                       screen, cursor,
+                                       j < parent->Game().state->capsules[i].MaxClass(), j);
+                       if (&parent->Game().state->capsules[i] == parent->Game().state->capsule
+                                       && parent->Game().state->capsules[i].CurrentClass() == j) {
+                               parent->Res().capsuleSelectCursor->Draw(screen, cursor);
+                       }
+                       cursor.Y() += parent->Res().capsuleSelectLadder->Height();
+               }
+               parent->Res().capsuleSelectBottomRepeat->Draw(screen, cursor);
+               if (parent->Game().state->capsules[i].AlignmentSprite()) {
+                       parent->Game().state->capsules[i].AlignmentSprite()->Draw(screen, cursor);
+               }
+               cursor.X() += parent->Res().capsuleSelectLadder->Width();
+       }
+
+       cursor.Y() = offset.Y();
+       parent->Res().capsuleSelectTopRight->Draw(screen, cursor);
+       cursor.Y() += parent->Res().capsuleSelectTopRight->Height();
+       target = Vector<int>(
+                       cursor.X() + parent->Res().capsuleSelectTopRight->Width(),
+                       cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+       parent->Res().capsuleSelectRightRepeat->Render(screen, cursor, target);
+       cursor.Y() = target.Y();
+       parent->Res().capsuleSelectBottomRight->Draw(screen, cursor);
+}
+
 
 int CapsuleChangeMenu::Width() const {
        return parent->Width();
index 5ac40fbc734c3f6efc84d57eca5406354d1b3fb7..0f8888f56f3fc2088f3e8062b933cddca6b8bde8 100644 (file)
@@ -21,6 +21,8 @@ public:
        virtual void UpdateWorld(float deltaT);
        virtual void Render(SDL_Surface *);
 
+       void RenderClasses(SDL_Surface *, const geometry::Vector<int> &) const;
+
 public:
        int Width() const;
        int Height() const;
index dd61dbde091360378dafdde71572bf297f402e0c..5a800a39294fd7d9a0ae699173c34a977e4a0de1 100644 (file)
@@ -97,7 +97,9 @@ void CapsuleMenu::Render(SDL_Surface *screen) {
                        12 * font.CharWidth(),
                        2 * font.CharHeight() - font.CharHeight() / 8);
        // TODO: wheel offset: top left, center, or center bottom?
-       const Vector<int> wheelOffset;
+       const Vector<int> wheelOffset(
+                       6 * font.CharWidth(),
+                       19 * font.CharHeight() - font.CharHeight() / 8);
        const Vector<int> statsOffset(
                        12 * font.CharWidth(),
                        15 * font.CharHeight() - font.CharHeight() / 8);
@@ -177,7 +179,8 @@ void CapsuleMenu::RenderInfo(SDL_Surface *screen, const Vector<int> &offset) con
 }
 
 void CapsuleMenu::RenderWheel(SDL_Surface *screen, const Vector<int> &offset) const {
-       // later
+       Res().capsuleAlignmentWheel->DrawCenter(screen, offset);
+       Res().capsuleAlignmentCursor->DrawCenter(screen, offset + Game().state->capsule->AlignmentOffset());
 }
 
 void CapsuleMenu::RenderStats(SDL_Surface *screen, const Vector<int> &offset) const {
index 74e4ccd89512e3f458023bb4cd9235da79b2ed31..548afc3572aae5496cd428c7b25ca9636454e44d 100644 (file)
@@ -122,6 +122,20 @@ Resources::Resources()
 
 , capsuleNameCharSelectTemplate(0)
 
+, capsuleSelectTopLeft(0)
+, capsuleSelectTopRight(0)
+, capsuleSelectTopRepeat(0)
+, capsuleSelectBottomLeft(0)
+, capsuleSelectBottomRight(0)
+, capsuleSelectBottomRepeat(0)
+, capsuleSelectLeftRepeat(0)
+, capsuleSelectRightRepeat(0)
+, capsuleSelectLadder(0)
+, capsuleSelectCursor(0)
+
+, capsuleAlignmentWheel(0)
+, capsuleAlignmentCursor(0)
+
 { }
 
 
@@ -231,6 +245,20 @@ void Resources::CreateTypeDescription() {
        td.AddField("capsuleNotHungryText", FieldDescription(((char *)&r.capsuleNotHungryText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
 
        td.AddField("capsuleNameSelect", FieldDescription(((char *)&r.capsuleNameCharSelectTemplate) - ((char *)&r), CharSelect::TYPE_ID).SetReferenced().SetDescription("properties of the letter array for changing the capsule name"));
+
+       td.AddField("capsuleSelectTopLeft", FieldDescription(((char *)&r.capsuleSelectTopLeft) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectTopRight", FieldDescription(((char *)&r.capsuleSelectTopRight) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectTopRepeat", FieldDescription(((char *)&r.capsuleSelectTopRepeat) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectBottomLeft", FieldDescription(((char *)&r.capsuleSelectBottomLeft) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectBottomRight", FieldDescription(((char *)&r.capsuleSelectBottomRight) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectBottomRepeat", FieldDescription(((char *)&r.capsuleSelectBottomRepeat) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectLeftRepeat", FieldDescription(((char *)&r.capsuleSelectLeftRepeat) - ((char *)&r), Texture::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectRightRepeat", FieldDescription(((char *)&r.capsuleSelectRightRepeat) - ((char *)&r), Texture::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectLadder", FieldDescription(((char *)&r.capsuleSelectLadder) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleSelectCursor", FieldDescription(((char *)&r.capsuleSelectCursor) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+
+       td.AddField("capsuleAlignmentWheel", FieldDescription(((char *)&r.capsuleAlignmentWheel) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("capsuleAlignmentCursor", FieldDescription(((char *)&r.capsuleAlignmentCursor) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
 }
 
 void Resources::Construct(void *data) {
index 6fc064167d3ca901508e57d8eaef0dbff1ab31bb..1f6d2077912d41fd57ca4792b8602ed7375c2f60 100644 (file)
@@ -110,6 +110,20 @@ struct Resources {
 
        graphics::CharSelect *capsuleNameCharSelectTemplate;
 
+       graphics::Sprite *capsuleSelectTopLeft;
+       graphics::Sprite *capsuleSelectTopRight;
+       graphics::Sprite *capsuleSelectTopRepeat;
+       graphics::Sprite *capsuleSelectBottomLeft;
+       graphics::Sprite *capsuleSelectBottomRight;
+       graphics::Sprite *capsuleSelectBottomRepeat;
+       graphics::Texture *capsuleSelectLeftRepeat;
+       graphics::Texture *capsuleSelectRightRepeat;
+       graphics::Sprite *capsuleSelectLadder;
+       graphics::Sprite *capsuleSelectCursor;
+
+       graphics::Sprite *capsuleAlignmentWheel;
+       graphics::Sprite *capsuleAlignmentCursor;
+
        Resources();
 
        static void CreateTypeDescription();
diff --git a/test-data/capsule-sprites.png b/test-data/capsule-sprites.png
new file mode 100644 (file)
index 0000000..9884464
Binary files /dev/null and b/test-data/capsule-sprites.png differ
index a4f525ec444f0595956ec09610217dd8c6d05f13..866e76f43828e4fd12990349a27a9bd53de6f4c6 100644 (file)
@@ -6,6 +6,12 @@ Sprite flashSprite {
 export Capsule flash {
        name: "Flash",
        alignment: "LIGHT",
+       alignmentCursor: <-32, 0>,
+       alignmentSprite: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <0, 96>
+       },
        maxHealth: 5,
        stats: Stats {
                atp: 12,
@@ -17,6 +23,101 @@ export Capsule flash {
                mgr: 11
        },
        classes: [ CapsuleClass
+               {
+                       name: "1 TODO",
+                       tribe: "Shaggy",
+                       battleSprite: flashSprite,
+                       meleeAnimation: SimpleAnimation {
+                               sprite: Sprite {
+                                       image: :"melee-maxim.png",
+                                       size: <96,96>
+                               },
+                               frametime: 66, // two "frames"
+                               framecount: 4
+                       },
+                       attackAnimation: ComplexAnimation {
+                               sprite: flashSprite,
+                               frametime: fourFramesTime,
+                               repeat: false,
+                               frames:
+                               [ ComplexAnimationFrame
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> },
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> }
+                               ]
+                       }
+               },
+               {
+                       name: "2 TODO",
+                       tribe: "Sprite",
+                       battleSprite: flashSprite,
+                       meleeAnimation: SimpleAnimation {
+                               sprite: Sprite {
+                                       image: :"melee-maxim.png",
+                                       size: <96,96>
+                               },
+                               frametime: 66, // two "frames"
+                               framecount: 4
+                       },
+                       attackAnimation: ComplexAnimation {
+                               sprite: flashSprite,
+                               frametime: fourFramesTime,
+                               repeat: false,
+                               frames:
+                               [ ComplexAnimationFrame
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> },
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> }
+                               ]
+                       },
+                       healthBoost: 208,
+                       statBoost: Stats {
+                               atp:  38,
+                               dfp:  71,
+                               str:  24,
+                               agl:  78,
+                               int: 195,
+                               gut:  12, // TODO: this is probably higher, but clipped at 199
+                               mgr: 135
+                       }
+               },
+               {
+                       name: "3 TODO",
+                       tribe: "Cupid",
+                       battleSprite: flashSprite,
+                       meleeAnimation: SimpleAnimation {
+                               sprite: Sprite {
+                                       image: :"melee-maxim.png",
+                                       size: <96,96>
+                               },
+                               frametime: 66, // two "frames"
+                               framecount: 4
+                       },
+                       attackAnimation: ComplexAnimation {
+                               sprite: flashSprite,
+                               frametime: fourFramesTime,
+                               repeat: false,
+                               frames:
+                               [ ComplexAnimationFrame
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> },
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> }
+                               ]
+                       },
+                       healthBoost: 208,
+                       statBoost: Stats {
+                               atp:  38,
+                               dfp:  71,
+                               str:  24,
+                               agl:  78,
+                               int: 195,
+                               gut:  12, // TODO: this is probably higher, but clipped at 199
+                               mgr: 135
+                       }
+               },
                {
                        name: "4",
                        tribe: "Twinkle",
@@ -51,6 +152,41 @@ export Capsule flash {
                                gut:  12, // TODO: this is probably higher, but clipped at 199
                                mgr: 135
                        }
+               },
+               {
+                       name: "M TODO",
+                       tribe: "Twinkle",
+                       battleSprite: flashSprite,
+                       meleeAnimation: SimpleAnimation {
+                               sprite: Sprite {
+                                       image: :"melee-maxim.png",
+                                       size: <96,96>
+                               },
+                               frametime: 66, // two "frames"
+                               framecount: 4
+                       },
+                       attackAnimation: ComplexAnimation {
+                               sprite: flashSprite,
+                               frametime: fourFramesTime,
+                               repeat: false,
+                               frames:
+                               [ ComplexAnimationFrame
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> },
+                                       { column: 0, row: 1, disposition: < 0, -16> },
+                                       { column: 0, row: 0, disposition: < 0, -16> }
+                               ]
+                       },
+                       healthBoost: 208,
+                       statBoost: Stats {
+                               atp:  38,
+                               dfp:  71,
+                               str:  24,
+                               agl:  78,
+                               int: 195,
+                               gut:  12, // TODO: this is probably higher, but clipped at 199
+                               mgr: 135
+                       }
                }
        ]
 }
index 44ffc60d39d27c1c43979a14db7429f3f59d6e13..c691e17f55f14dc1223e3b7e7b6b9f0fb7328336 100644 (file)
@@ -884,5 +884,64 @@ export MenuResources menuResources {
                chars: "0123456789ABCDEabcdeFGHIJfghijKLMNOklmnoPQRSTpqrstUVWXYuvwxyZ!?  z!?  ",
                width: 10,
                groupX: 5
+       },
+       capsuleSelectTopLeft: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 8>,
+               offset: <64, 0>
+       },
+       capsuleSelectTopRight: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 8>,
+               offset: <128, 0>
+       },
+       capsuleSelectTopRepeat: Texture {
+               image: :"capsule-sprites.png",
+               size: <32, 8>,
+               offset: <96, 0>
+       },
+       capsuleSelectBottomLeft: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <0, 32>
+       },
+       capsuleSelectBottomRight: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <128, 64>
+       },
+       capsuleSelectBottomRepeat: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <0, 64>
+       },
+       capsuleSelectLeftRepeat: Texture {
+               image: :"capsule-sprites.png",
+               size: <32, 32>
+       },
+       capsuleSelectRightRepeat: Texture {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <128, 32>
+       },
+       capsuleSelectLadder: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 24>,
+               offset: <64, 8>
+       },
+       capsuleSelectCursor: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 24>,
+               offset: <128, 8>
+       },
+       capsuleAlignmentWheel: Sprite {
+               image: :"capsule-sprites.png",
+               size: <128, 128>,
+               offset: <0, 128>
+       },
+       capsuleAlignmentCursor: Sprite {
+               image: :"capsule-sprites.png",
+               size: <32, 32>,
+               offset: <128, 128>
        }
 }