X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FGameLayer.cc;h=d68522ee1a8ef826c3730927342a19597135d536;hp=0be8eb744f9fe1720acbb7ac2d9753bbf431987f;hb=c78934a448d0126709fccec3d5a636b3baa87da4;hpb=e0c0a3b5e7337cde55e520801d2e59e03dc97d9c diff --git a/src/GameLayer.cc b/src/GameLayer.cc index 0be8eb7..d68522e 100644 --- a/src/GameLayer.cc +++ b/src/GameLayer.cc @@ -28,13 +28,13 @@ void GameLayer::loadSceneLoader() mState.script.importStandardLibraries(); importLogFunctions(mState.script); - std::string loaderPath = Scene::getPath("loader"); - if (loaderPath == "") + std::string path("loader"); + if (!Scene::getPath(path)) { throw Mf::Error(Mf::Error::RESOURCE_NOT_FOUND, "loader"); } - Mf::Script::Result status = mState.script.doFile(loaderPath); + Mf::Script::Result status = mState.script.doFile(path); if (status != Mf::Script::SUCCESS) { std::string str; @@ -43,8 +43,8 @@ void GameLayer::loadSceneLoader() throw Mf::Error(Mf::Error::SCRIPT_ERROR, str); } - mState.script.getGlobalTable().pushField("scenes"); - mState.script.getTop().get(mState.sceneList); + mState.script.globals().pushField("scenes"); + mState.script.top().get(mState.sceneList); if (mState.sceneList.size() == 0) { throw Mf::Error(Mf::Error::SCRIPT_ERROR, @@ -69,17 +69,14 @@ void GameLayer::advanceScene(Mf::Settings& settings) throw Mf::Error(Mf::Error::SCRIPT_ERROR, str); } - mState.script.getGlobalTable().pushField("Event"); - if (mState.script[-1].isTable()) + Mf::Script::Slot table = mState.script.globals().pushField("Event"); + if (table.isTable()) { - mState.script[-1].pushField("Think"); - mState.script.set("Think", Mf::Script::REGISTRY); - mState.script.pop(2); - } - else - { - mState.script.pop(); + mState.script.push("Think"); + table.pushField("Think"); + mState.script.registry().setField(); } + mState.script.pop(); } } @@ -149,7 +146,7 @@ void GameLayer::update(Mf::Scalar t, Mf::Scalar dt) void GameLayer::thinkTimer() { - mState.script.getRegistryTable().pushField("Think"); + mState.script.registry().pushField("Think"); if (mState.script[-1].isFunction()) mState.script.call(); else mState.script.pop(); } @@ -284,6 +281,8 @@ void GameLayer::setProjection() void GameLayer::setProjection(Mf::Scalar width, Mf::Scalar height) { - mState.camera.setProjection(cml::rad(45.0), width / height, 1.0, 200.0); + mState.camera.setProjection(cml::rad(45.0), + width / height, + SCALAR(1.0), SCALAR(200.0)); }