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);
//Mf::Transition<Mf::Lerp>::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);
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();
}
break;
case SDL_QUIT:
- engine.clear();
+ Mf::engine.clear();
break;
}
std::cout << " Executable: " << argv[0] << std::endl
<< " Version: "VERSION << std::endl
-#if defined(__DATE__) && defined(__TIME__)
- << " Built: "__DATE__" "__TIME__ << std::endl
-#endif
+ << " Built: " << COMPILE_TIME << std::endl
<< " Compiler: "COMPILER_STRING << std::endl
<< " Assets: " << assets << std::endl
<< "Build options: "
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
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();