]> Dogcows Code - chaz/yoink/blobdiff - src/Tilemap.cc
cade lab fixes
[chaz/yoink] / src / Tilemap.cc
index 655475222c45e89754b1e37a39389fce4c84348a..dc3785aa0068d5ba9c3e17f8765d120c8704707e 100644 (file)
 
 *******************************************************************************/
 
-#include <Moof/Mippleton.hh>
+#include <Moof/Library.hh>
 #include <Moof/OpenGL.hh>
 #include <Moof/Script.hh>
 
 #include "Tilemap.hh"
 
 
-struct Tilemap::Impl : public Mf::Mippleton<Impl>
+struct Tilemap::Impl : public Mf::Library<Impl>
 {
        Impl(const std::string& name) :
-               Mf::Mippleton<Impl>(name),
-               magFilter_(GL_NEAREST),
-               minFilter_(GL_NEAREST),
-               nTilesS_(1),
-               nTilesT_(1),
-               wrapS_(GL_CLAMP),
-               wrapT_(GL_CLAMP)
+               Mf::Library<Impl>(name),
+               mMagFilter(GL_NEAREST),
+               mMinFilter(GL_NEAREST),
+               mTilesS(1),
+               mTilesT(1),
+               mWrapS(GL_CLAMP),
+               mWrapT(GL_CLAMP)
        {
                loadFromFile();
        }
@@ -66,53 +66,53 @@ struct Tilemap::Impl : public Mf::Mippleton<Impl>
                std::string filePath = Tilemap::getPath(getName());
 
                script.importStandardLibraries();
-               importLogScript(script);
+               importLogFunctions(script);
                bindScriptConstants(script);
 
                if (script.doFile(filePath) != Mf::Script::SUCCESS)
                {
                        std::string str;
                        script[-1].get(str);
-                       Mf::logScript("%s", str.c_str());
+                       Mf::logWarning(str);
                        return;         // TODO needs a better exit strategy
                }
 
-               Mf::logInfo("loading tiles from tilemap %s", filePath.c_str());
+               Mf::logInfo << "loading tiles from tilemap " << filePath << std::endl;
 
-               Mf::Script::Value globals = script.getGlobalTable();
-               Mf::Script::Value top = script[-1];
+               Mf::Script::Slot globals = script.getGlobalTable();
+               Mf::Script::Slot top = script[-1];
 
                globals.pushField("tiles_s");
-               top.get(nTilesS_);
+               top.get(mTilesS);
 
                globals.pushField("tiles_t");
-               top.get(nTilesT_);
+               top.get(mTilesT);
 
                globals.pushField("min_filter");
-               top.get(minFilter_);
+               top.get(mMinFilter);
 
                globals.pushField("mag_filter");
-               top.get(magFilter_);
+               top.get(mMagFilter);
 
                globals.pushField("wrap_s");
-               top.get(wrapS_);
+               top.get(mWrapS);
 
                globals.pushField("wrap_t");
-               top.get(wrapT_);
+               top.get(mWrapT);
        }
 
 
        bool getTileCoords(Tilemap::Index index, Mf::Scalar coords[8]) const
        {
                // make sure the index represents a real tile
-               if (index >= nTilesS_ * nTilesT_) return false;
+               if (index >= mTilesS * mTilesT) return false;
 
-               Mf::Scalar w = 1.0 / Mf::Scalar(nTilesS_);
-               Mf::Scalar h = 1.0 / Mf::Scalar(nTilesT_);
+               Mf::Scalar w = 1.0 / Mf::Scalar(mTilesS);
+               Mf::Scalar h = 1.0 / Mf::Scalar(mTilesT);
 
-               coords[0] = Mf::Scalar(index % nTilesS_) * w;
-               coords[1] = (Mf::Scalar(nTilesT_ - 1) -
-                               Mf::Scalar(index / nTilesS_)) * h;
+               coords[0] = Mf::Scalar(index % mTilesS) * w;
+               coords[1] = (Mf::Scalar(mTilesT - 1) -
+                               Mf::Scalar(index / mTilesS)) * h;
                coords[2] = coords[0] + w;
                coords[3] = coords[1];
                coords[4] = coords[2];
@@ -124,30 +124,30 @@ struct Tilemap::Impl : public Mf::Mippleton<Impl>
        }
 
 
-       GLuint          magFilter_;
-       GLuint          minFilter_;
-       unsigned        nTilesS_;
-       unsigned        nTilesT_;
-       GLuint          wrapS_;
-       GLuint          wrapT_;
+       GLuint          mMagFilter;
+       GLuint          mMinFilter;
+       unsigned        mTilesS;
+       unsigned        mTilesT;
+       GLuint          mWrapS;
+       GLuint          mWrapT;
 };
 
 
 Tilemap::Tilemap(const std::string& name) :
        Texture(name),
-       impl_(Tilemap::Impl::getInstance(name))
+       mImpl(Tilemap::Impl::getInstance(name))
 {
-       setMinFilter(impl_->minFilter_);
-       setMagFilter(impl_->magFilter_);
-       setWrapS(impl_->wrapS_);
-       setWrapT(impl_->wrapT_);
+       setMinFilter(mImpl->mMinFilter);
+       setMagFilter(mImpl->mMagFilter);
+       setWrapS(mImpl->mWrapS);
+       setWrapT(mImpl->mWrapT);
 }
 
 
 bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8]) const
 {
        // pass through
-       return impl_->getTileCoords(index, coords);
+       return mImpl->getTileCoords(index, coords);
 }
 
 bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8],
This page took 0.02662 seconds and 4 git commands to generate.