X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMainLayer.cc;h=568f0cd0ebe84b2185945895692d5045c89c7454;hp=faa462299eb33fdad55aba49a71e85fb00d32c44;hb=a295f8def17036c8071b56e181364f99a377cae7;hpb=2d77fb5fb3480f522658f30af6addd5146530517 diff --git a/src/MainLayer.cc b/src/MainLayer.cc index faa4622..568f0cd 100644 --- a/src/MainLayer.cc +++ b/src/MainLayer.cc @@ -52,12 +52,12 @@ MainLayer::MainLayer() { - mDispatchHandler = Mf::Engine::getInstance().addHandler("video.newcontext", + mDispatchHandler = Mf::engine.addHandler("video.newcontext", boost::bind(&MainLayer::contextRecreated, this)); setupGL(); } -void MainLayer::pushed(Mf::Engine& engine) +void MainLayer::pushedOntoEngine() { //Mf::Scalar coeff[] = {0.0, 1.0}; //Mf::Lerp interp(coeff, 0.25); @@ -67,20 +67,21 @@ void MainLayer::pushed(Mf::Engine& engine) //Mf::Transition::alloc(gameLayer, Mf::LayerP(), interp); //engine->push(transition); //engine->push(GameLayer::alloc()); - engine.push(TitleLayer::alloc()); + Mf::engine.push(TitleLayer::alloc()); } -void MainLayer::update(Mf::Engine& engine, Mf::Scalar t, Mf::Scalar dt) +void MainLayer::update(Mf::Scalar t, Mf::Scalar dt) { - if (engine.getSize() == 1) + if (Mf::engine.getSize() == 1) { // this is the only layer left on the stack - //engine.push(TitleLayer::alloc()); + //Mf::engine.push(TitleLayer::alloc()); + Mf::engine.clear(); } } -void MainLayer::draw(Mf::Engine& engine, Mf::Scalar alpha) const +void MainLayer::draw(Mf::Scalar alpha) const { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -91,22 +92,22 @@ void MainLayer::draw(Mf::Engine& engine, Mf::Scalar alpha) const glLoadIdentity(); } -bool MainLayer::handleEvent(Mf::Engine& engine, const Mf::Event& event) +bool MainLayer::handleEvent(const Mf::Event& event) { switch (event.type) { case SDL_KEYUP: if (event.key.keysym.sym == SDLK_ESCAPE) { - engine.clear(); + Mf::engine.clear(); } else if (event.key.keysym.sym == SDLK_f) { - engine.getVideo()->toggleFull(); + Mf::engine.getVideo()->toggleFull(); } else if (event.key.keysym.sym == SDLK_l) { - Mf::VideoP video = engine.getVideo(); + Mf::VideoP video = Mf::engine.getVideo(); video->toggleCursorGrab(); video->toggleCursorVisible(); } @@ -117,7 +118,7 @@ bool MainLayer::handleEvent(Mf::Engine& engine, const Mf::Event& event) break; case SDL_QUIT: - engine.clear(); + Mf::engine.clear(); break; } @@ -270,16 +271,28 @@ int main(int argc, char* argv[]) atexit(goodbye); -#if YOINK_LOGLEVEL >= 4 - Mf::setLogLevel(Mf::LOG_DEBUG); -#elif YOINK_LOGLEVEL >= 3 - Mf::setLogLevel(Mf::LOG_INFO); + // make sure the engine started up okay + if (Mf::engine.getError().isError()) + { + Mf::ModalDialog dialog; + dialog.title = PACKAGE_STRING; + dialog.text1 = "Fatal Error"; + dialog.text2 = getErrorString(Mf::engine.getError()); + dialog.type = Mf::ModalDialog::CRITICAL; + dialog.run(); + + return 1; + } + + +#if YOINK_LOGLEVEL >= 3 + Mf::Log::setLevel(Mf::Log::INFO); #elif YOINK_LOGLEVEL >= 2 - Mf::setLogLevel(Mf::LOG_SCRIPT); + Mf::Log::setLevel(Mf::Log::WARNING); #elif YOINK_LOGLEVEL >= 1 - Mf::setLogLevel(Mf::LOG_ERROR); + Mf::Log::setLevel(Mf::Log::ERROR); #elif YOINK_LOGLEVEL - Mf::setLogLevel(Mf::LOG_NONE); + Mf::Log::setLevel(Mf::Log::NONE); #endif @@ -326,18 +339,17 @@ int main(int argc, char* argv[]) try { - Mf::Engine& app = Mf::Engine::getInstance(); - app.setVideo(Mf::Video::alloc(PACKAGE_STRING, iconFile)); - app.push(MainLayer::alloc()); + Mf::engine.setVideo(Mf::Video::alloc(PACKAGE_STRING, iconFile)); + Mf::engine.push(MainLayer::alloc()); - app.run(); + Mf::engine.run(); } - catch (const Mf::Exception& e) + catch (const Mf::Error& error) { Mf::ModalDialog dialog; dialog.title = PACKAGE_STRING; dialog.text1 = "Unhandled Exception"; - dialog.text2 = getErrorString(e); + dialog.text2 = getErrorString(error); dialog.type = Mf::ModalDialog::CRITICAL; dialog.run();