src/Application.hh
author Tero Marttila <terom@fixme.fi>
Fri, 16 Jan 2009 00:42:02 +0200
changeset 397 13fa0546ef87
parent 389 e74c1820fbd2
child 408 e6cfc44266af
permissions -rw-r--r--
hopefully version stuff is now run properly on every make...
#ifndef APPLICATION_HH
#define APPLIATION_HH

#include "Engine.hh"
#include "Error.hh"

#include <ClanLib/core.h>
#include <ClanLib/application.h>

class ArgumentError : public Error {
    public:
        ArgumentError (const std::string &message) : Error(message) { }
};

/**
 * Our CL_ClanApplication. Provides our main function, handles argument parsing and interacts with Engine
 */
class Main : public CL_ClanApplication {
    private:
        // arguments
        CL_CommandLine args;
        
        /**
         * --graphics
         */
        bool arg_graphics;

        /**
         * --port
         */
        std::string arg_port;

        /**
         * --server
         */
        bool arg_server;

        /**
         * --connect
         */
        std::string arg_connect;

        /**
         * --fullscreen
         */
        bool arg_fullscreen;

        /**
         * --resolution
         */ 
        PixelCoordinate arg_resolution;

        /**
         * Set the arg_* members
         *
         * @return true if execution should proceed, false if execution should stop
         */
        bool parse_args (int argc, char **argv);

        /**
         * Parse and set --resolution/arg_resolution WIDTHxHEIGHT
         */
        void parse_arg_resolution (const std::string &val);
        
        /**
         * Print out a list of display modes
         */
        void dump_display_modes (void);
        
        /**
         * Print out our project version
         */
        void dump_version (void);

    public:
        /**
         * IT BEGAN IN AFRIKA
         */
        virtual int main (int argc, char **argv);
} app;

#endif