-/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+/*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
**] All rights reserved.
*
-* vi:ts=4 sw=4 tw=75
-*
* Distributable under the terms and conditions of the 2-clause BSD license;
* see the file COPYING for a complete text of the license.
*
-**************************************************************************/
+*****************************************************************************/
+#if HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <cstdlib> // atexit
+#include <cstdlib> // atexit
#include <exception>
#include <functional>
#include <iostream>
#include <string>
-#if PLATFORM_WIN32
-inline int isatty(int dummy) { return 0; }
-#else
+#if PLATFORM_POSIX
#include <termios.h>
+#else
+inline int isatty(int dummy) { return 0; }
#endif
#include <stlplus/portability/file_system.hpp>
#endif
}
-
void Main::update(moof::scalar t, moof::scalar dt)
{
yoink.update(t, dt);
switch (event.type)
{
- case SDL_KEYUP:
-
- if (event.key.keysym.sym == SDLK_f)
- {
- moof::video::current()->toggle_fullscreen();
- }
- else if (event.key.keysym.sym == SDLK_l)
- {
- moof::video::current()->toggle_cursor_captured();
- moof::video::current()->toggle_cursor_visible();
- }
- else if (event.key.keysym.sym == SDLK_ESCAPE)
- {
- stop();
- }
- break;
-
- case SDL_VIDEORESIZE:
-
- glViewport(0, 0, event.resize.w, event.resize.h);
- break;
-
- case SDL_QUIT:
-
+ case SDL_KEYUP:
+ if (event.key.keysym.sym == SDLK_f)
+ {
+ moof::video::current()->toggle_fullscreen();
+ }
+ else if (event.key.keysym.sym == SDLK_l)
+ {
+ moof::video::current()->toggle_cursor_captured();
+ moof::video::current()->toggle_cursor_visible();
+ }
+ else if (event.key.keysym.sym == SDLK_ESCAPE)
+ {
stop();
+ }
+ break;
+
+ case SDL_VIDEORESIZE:
+ glViewport(0, 0, event.resize.w, event.resize.h);
+ break;
+
+ case SDL_QUIT:
+ stop();
}
}
-
std::string Main::search_paths()
{
// Add search paths; they should be searched in this order:
return path;
}
-
void Main::setup_opengl()
{
glEnable(GL_TEXTURE_2D);
glLightfv(GL_LIGHT0, GL_SPECULAR, spec);
}
-
void Main::print_usage()
{
std::cout << "Usage: "
- << PACKAGE" [-h|--help] [-i|--info] [OPTION=VALUE]..."
- << std::endl
- << "The alien-smashing action game." << std::endl
- << std::endl
- << "Options:" << std::endl
- << " -h, --help" << std::endl
- << " show this help and exit" << std::endl
- << " -i, --info" << std::endl
- << " show version and build information" << std::endl
- << " detail=1|2|3" << std::endl
- << " the level of detail of game scenes" << std::endl
- << " fullscreen=true|false" << std::endl
- << " if true, uses the entire display" << std::endl
- << " framerate=num" << std::endl
- << " number of frames to draw per second" << std::endl
- << std::endl
- << "See documentation for more options." << std::endl;
+ << PACKAGE" [-h|--help] [-i|--info] [OPTION=VALUE]..."
+ << std::endl
+ << "The alien-smashing action game." << std::endl
+ << std::endl
+ << "Options:" << std::endl
+ << " -h, --help" << std::endl
+ << " show this help and exit" << std::endl
+ << " -i, --info" << std::endl
+ << " show version and build information" << std::endl
+ << " detail=1|2|3" << std::endl
+ << " the level of detail of game scenes" << std::endl
+ << " fullscreen=true|false" << std::endl
+ << " if true, uses the entire display" << std::endl
+ << " framerate=num" << std::endl
+ << " number of frames to draw per second" << std::endl
+ << std::endl
+ << "See documentation for more options." << std::endl;
}
void Main::print_info(int argc, char* argv[])
#endif
}
-void Main::print_option(const std::string& option, bool enabled)
-{
- if (isatty(1) == 1)
- {
- if (enabled) std::cout << "\033[1;94m";
- else std::cout << "\033[1m";
- }
- if (!enabled) std::cout << "-";
- std::cout << option;
- if (isatty(1) == 1) std::cout << "\033[0m";
- std::cout << " ";
-}
-
void hello()
{
if (isatty(1) == 1) std::cout << "\033[94m";
std::cout << std::endl << PACKAGE_STRING << std::endl
- << "Compiled " << __TIME__ " " __DATE__ << std::endl
- << "Send patches and bug reports to <"
- PACKAGE_BUGREPORT << ">." << std::endl << moof::log::endl;
+ << "Compiled " << __TIME__" "__DATE__ << std::endl
+ << "Send patches and bug reports to <"PACKAGE_BUGREPORT">."
+ << std::endl << moof::log::endl;
}
void goodbye()
catch (const std::exception& e)
{
moof::modal_dialog dialog(moof::modal_dialog::error,
- PACKAGE_STRING, "unhandled exception",
- e.what());
+ PACKAGE_STRING, "unhandled exception",
+ e.what());
dialog.run();
}
catch (const char* e)
{
moof::modal_dialog dialog(moof::modal_dialog::error,
- PACKAGE_STRING, "unhandled exception",
- e);
+ PACKAGE_STRING, "unhandled exception", e);
dialog.run();
}
-
return 1;
}