src/Application.hh
author nireco
Sat, 31 Jan 2009 12:33:08 +0200
changeset 443 5d1119729f58
parent 418 194bc810a570
permissions -rw-r--r--
worm02 two pics to comment
#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 graphics_enabled;

        /**
         * --fullscreen and --resolution
         */
        DisplayConfig display;

        /**
         * --terrain-seed and --terrain-size
         */
        TerrainConfig terrain;

        /**
         * --log-level
         */
        EngineConfig engine;

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

        /**
         * --server
         */
        bool net_server;

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

        /**
         * Parse signed integer argument
         */
        int parse_arg_int (const std::string &arg_val, const char *arg_name);

        /**
         * Parse unsigned WIDTHxHEIGHT argument
         */
        PixelDimensions parse_arg_dimensions (const std::string &arg_val, const char *arg_name);

        /**
         * Parse a LogLevel
         */
        LogLevel parse_arg_loglevel (const std::string &arg_val, const char *arg_name);
        
        /**
         * Print out a list of display modes
         */
        void dump_display_modes (void);
        
        /**
         * Print out our project version and some configuration info
         */
        void dump_version (void);

    public:
        /**
         * Setup default values
         */
        Main (void);

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

#endif