X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FAnimation.cc;h=bd31f9b5dc26a8248952d8d7b5d5028bc6e45a63;hp=6df85562b7252505229c22838ae9beda7fbdbbda;hb=4107dd30ca1a4c7d1a5cd6c0999b9afb5adff779;hpb=58c1f9a499d3bb80ea2869b29c714f61e656d48d diff --git a/src/Animation.cc b/src/Animation.cc index 6df8556..bd31f9b 100644 --- a/src/Animation.cc +++ b/src/Animation.cc @@ -63,17 +63,12 @@ public: * animation file. */ - Frame(Mf::Script& script, Mf::Script::Slot table) : + Frame(const Mf::Script::Slot& table) : mIndex(0), mDuration(1.0) { - table.pushField("index"); - script[-1].get(mIndex); - script.pop(); - - table.pushField("duration"); - script[-1].get(mDuration); - script.pop(); + table.get(mIndex, "index"); + table.get(mDuration, "duration"); } }; @@ -99,46 +94,36 @@ public: * the frame's constructor which loads each individual frame. */ - Sequence(Mf::Script& script, Mf::Script::Slot table) : + Sequence(const Mf::Script::Slot& table) : mDelay(0.0), mLoop(true) { - table.pushField("delay"); - script[-1].get(mDelay); - script.pop(); - - table.pushField("loop"); - script[-1].get(mLoop); - script.pop(); - - table.pushField("next"); - script[-1].get(mNext); - script.pop(); + table.get(mDelay, "delay"); + table.get(mLoop, "loop"); + table.get(mNext, "next"); // TODO - sequence class/type not yet implemented - table.pushField("frames"); - Mf::Script::Slot frameTable = script.getTop(); + Mf::Script::Slot frameTable = table.pushField("frames"); if (frameTable.isTable()) { - Mf::Script::Slot top = script[-1]; - int index = 1; - - for (;;) + int max = frameTable.length(); + for (int index = 1; index <= max; ++index) { - script.push(index); - frameTable.pushField(); + Mf::Script::Slot top = frameTable.pushField(index); if (top.isTable()) { - mFrames.push_back(Frame(script, top)); + mFrames.push_back(Frame(top)); + } + else + { + Mf::logWarning << "invalid frame at index " + << index << std::endl; } - else break; - - ++index; } } - script.pop(); + frameTable.remove(); } }; @@ -179,8 +164,7 @@ public: std::string nameStr; name.get(nameStr); - mSequences.insert(std::make_pair(nameStr, - Sequence(script, table))); + mSequences.insert(std::make_pair(nameStr, Sequence(table))); return 0; } @@ -192,13 +176,13 @@ public: boost::bind(&Data::defineSequence, this, _1)); - script.push(1); script.set("ATTACK"); - script.push(2); script.set("CHARGE"); - script.push(3); script.set("FLY"); - script.push(4); script.set("HIT"); - script.push(5); script.set("JUMP"); - script.push(6); script.set("RUN"); - script.push(7); script.set("STAND"); + script.globals().setField("ATTACK", 1); + script.globals().setField("CHARGE", 2); + script.globals().setField("FLY", 3); + script.globals().setField("HIT", 4); + script.globals().setField("JUMP", 5); + script.globals().setField("RUN", 6); + script.globals().setField("STAND", 7); }