]> Dogcows Code - chaz/yoink/blobdiff - src/Main.cc
remove some unused stlplus modules
[chaz/yoink] / src / Main.cc
index a674bbcb0dd9675a560cd2e6564f8c17da1aa7b4..8b011638735b48061d32fdafcdbf8096095bbfaa 100644 (file)
@@ -1,26 +1,26 @@
 
-/*]  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>
@@ -53,7 +53,6 @@ Main::Main(moof::settings& settings) :
 #endif
 }
 
-
 void Main::update(moof::scalar t, moof::scalar dt)
 {
        yoink.update(t, dt);
@@ -78,35 +77,31 @@ void Main::handle_event(const moof::event& event)
 
        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:
@@ -152,7 +147,6 @@ std::string Main::config_paths()
        return path;
 }
 
-
 void Main::setup_opengl()
 {
        glEnable(GL_TEXTURE_2D);
@@ -187,27 +181,26 @@ void Main::setup_opengl()
        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[])
@@ -220,27 +213,14 @@ 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()
@@ -297,18 +277,16 @@ int main(int argc, char* argv[])
        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;
 }
 
This page took 0.021406 seconds and 4 git commands to generate.