X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FAnimation.cc;h=ba34bc5d9f95cae0bc86fa0aba1242cf73cf4626;hp=bd31f9b5dc26a8248952d8d7b5d5028bc6e45a63;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/Animation.cc b/src/Animation.cc index bd31f9b..ba34bc5 100644 --- a/src/Animation.cc +++ b/src/Animation.cc @@ -10,26 +10,26 @@ **************************************************************************/ #include +#include #include -#include -#include -#include -#include +#include +#include +#include #include "Animation.hh" /** * The collection of nested animation classes. The animation - * implementation consists of an Impl class which is allocated and + * implementation consists of an impl class which is allocated and * initialized with the interface object. This class contains the specific * fields which are required to run a single instance of an animation. The * sequence data is loaded in a different class which can be shared amongst * multiple animation implementation instances. */ -class Animation::Impl +class Animation::impl { public: @@ -39,7 +39,7 @@ public: * animation which wants to use these loaded sequences. */ - class Data : public Mf::Manager + class Data : public moof::manager { public: @@ -55,7 +55,7 @@ public: public: unsigned mIndex; ///< Frame index. - Mf::Scalar mDuration; ///< Frame duration. + moof::scalar mDuration; ///< Frame duration. /** * Construction is initialization. The frame data is loaded @@ -63,7 +63,7 @@ public: * animation file. */ - Frame(const Mf::Script::Slot& table) : + Frame(const moof::script::slot& table) : mIndex(0), mDuration(1.0) { @@ -83,7 +83,7 @@ public: public: std::vector mFrames; ///< List of frames. - Mf::Scalar mDelay; ///< Scale frame durations. + moof::scalar mDelay; ///< Scale frame durations. bool mLoop; ///< Does the sequence repeat? std::string mNext; ///< Next sequence name. @@ -94,7 +94,7 @@ public: * the frame's constructor which loads each individual frame. */ - Sequence(const Mf::Script::Slot& table) : + Sequence(const moof::script::slot& table) : mDelay(0.0), mLoop(true) { @@ -104,21 +104,21 @@ public: // TODO - sequence class/type not yet implemented - Mf::Script::Slot frameTable = table.pushField("frames"); - if (frameTable.isTable()) + moof::script::slot frameTable = table.push_field("frames"); + if (frameTable.is_table()) { int max = frameTable.length(); for (int index = 1; index <= max; ++index) { - Mf::Script::Slot top = frameTable.pushField(index); + moof::script::slot top = frameTable.push_field(index); - if (top.isTable()) + if (top.is_table()) { mFrames.push_back(Frame(top)); } else { - Mf::logWarning << "invalid frame at index " + moof::log_warning << "invalid frame at index " << index << std::endl; } } @@ -136,30 +136,30 @@ public: void init(const std::string& name) { - Mf::Script script; + moof::script script; std::string path(name); - if (!Animation::getPath(path)) + if (!Animation::find_path(path)) { - Mf::Error(Mf::Error::RESOURCE_NOT_FOUND).raise(); + throw std::runtime_error("cannot find resource " + name); } - script.importBaseLibrary(); - importLogFunctions(script); + script.import_base_library(); + moof::log::import(script); importAnimationBindings(script); - if (script.doFile(path) != Mf::Script::SUCCESS) + if (script.do_file(path) != moof::script::success) { std::string str; script[-1].get(str); - Mf::logWarning(str); + moof::log_warning(str); } } - int defineSequence(Mf::Script& script) + int defineSequence(moof::script& script) { - Mf::Script::Slot name = script[1].requireString(); - Mf::Script::Slot table = script[2].requireTable(); + moof::script::slot name = script[1].require_string(); + moof::script::slot table = script[2].require_table(); std::string nameStr; name.get(nameStr); @@ -170,19 +170,19 @@ public: } - void importAnimationBindings(Mf::Script& script) + void importAnimationBindings(moof::script& script) { - script.importFunction("DefineSequence", + script.import_function("DefineSequence", boost::bind(&Data::defineSequence, this, _1)); - 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); + script.globals().set_field("ATTACK", 1); + script.globals().set_field("CHARGE", 2); + script.globals().set_field("FLY", 3); + script.globals().set_field("HIT", 4); + script.globals().set_field("JUMP", 5); + script.globals().set_field("RUN", 6); + script.globals().set_field("STAND", 7); } @@ -194,8 +194,8 @@ public: * Construction is intialization. */ - Impl(const std::string& name) : - mData(Data::getInstance(name)), + impl(const std::string& name) : + mData(Data::instance(name)), mCurrentSequence(0), mFrameCounter(0), mFrameIndex(0), @@ -236,7 +236,7 @@ public: * the animation essentially starts over again. */ - void update(Mf::Scalar t, Mf::Scalar dt) + void update(moof::scalar t, moof::scalar dt) { if (!mCurrentSequence) return; @@ -273,26 +273,26 @@ public: Data::Sequence* mCurrentSequence; ///< Active sequence. unsigned mFrameCounter; ///< Current frame. unsigned mFrameIndex; ///< Index of current frame. - Mf::Scalar mTimeAccum; ///< Time accumulation. - Mf::Scalar mFrameDuration; ///< Scaled frame duration. + moof::scalar mTimeAccum; ///< Time accumulation. + moof::scalar mFrameDuration; ///< Scaled frame duration. }; Animation::Animation(const std::string& name) : // pass through - mImpl(new Animation::Impl(name)) {} + impl_(new Animation::impl(name)) {} void Animation::startSequence(const std::string& name) { // pass through - mImpl->startSequence(name); + impl_->startSequence(name); } -void Animation::update(Mf::Scalar t, Mf::Scalar dt) +void Animation::update(moof::scalar t, moof::scalar dt) { // pass through - mImpl->update(t, dt); + impl_->update(t, dt); } @@ -303,7 +303,7 @@ void Animation::update(Mf::Scalar t, Mf::Scalar dt) unsigned Animation::getFrame() const { - return mImpl->mFrameIndex; + return impl_->mFrameIndex; } @@ -312,8 +312,8 @@ unsigned Animation::getFrame() const * the "animations" subdirectory of any of the search directories. */ -bool Animation::getPath(std::string& name) +bool Animation::find_path(std::string& name) { - return Mf::Resource::getPath(name, "animations/", "lua"); + return moof::resource::find_path(name, "animations/", "lua"); }