00001 /* 00002 * CoreApp.h - Base application class that contains the minimal functionality 00003 * to support pentagram tools 00004 * 00005 * Copyright (C) 2002-2006 The Pentagram Team 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef COREAPP_H 00023 #define COREAPP_H 00024 00025 #include "intrinsics.h" 00026 #include "Args.h" 00027 #include "GameInfo.h" 00028 00029 class FileSystem; 00030 class ConfigFileManager; 00031 class SettingManager; 00032 struct GameInfo; 00033 00034 00035 #define GAME_IS_U8 (CoreApp::get_instance()->getGameInfo()->type == GameInfo::GAME_U8) 00036 #define GAME_IS_REMORSE (CoreApp::get_instance()->getGameInfo()->type == GameInfo::GAME_REMORSE) 00037 #define GAME_IS_REGRET (CoreApp::get_instance()->getGameInfo()->type == GameInfo::GAME_REGRET) 00038 #define GAME_IS_CRUSADER (GAME_IS_REMORSE || GAME_IS_REGRET) 00039 00040 00041 class CoreApp 00042 { 00043 public: 00044 ENABLE_RUNTIME_CLASSTYPE(); 00045 CoreApp(int argc, const char* const* argv); 00046 virtual ~CoreApp(); 00047 00048 static CoreApp* get_instance() { return application; }; 00049 00050 virtual void run()=0; // FIXME: Need stub 00051 virtual void paint()=0; // probably shouldn't exist 00052 virtual bool isPainting() { return false; } 00053 00054 virtual void ForceQuit() { isRunning=false; }; 00055 00058 void startup(); 00059 00061 GameInfo* getGameInfo() const { return gameinfo; } 00062 00064 GameInfo* getGameInfo(Pentagram::istring game) const; 00065 00066 virtual void helpMe(); 00067 00068 bool help() const { return oHelp; }; 00069 bool quiet() const { return oQuiet; }; 00070 bool vquiet() const { return oVQuiet; }; 00071 00072 protected: 00073 00076 virtual void DeclareArgs(); 00077 00078 bool isRunning; 00079 00080 std::map<Pentagram::istring, GameInfo*> games; 00081 GameInfo* gameinfo; 00082 00083 // minimal system 00084 FileSystem* filesystem; 00085 ConfigFileManager* configfileman; 00086 SettingManager* settingman; 00087 00088 Args parameters; 00089 00090 static CoreApp* application; 00091 00092 private: 00093 int argc; 00094 const char* const* argv; 00095 00097 virtual void sysInit(); 00098 00100 void ParseArgs(int argc, const char* const* argv); 00101 00106 bool getGameInfo(Pentagram::istring& game, GameInfo* gameinfo); 00107 00110 void setupGamePaths(); 00111 00112 00114 void setupVirtualPaths(); 00115 00117 void loadConfig(); 00118 00119 protected: 00120 void setupGameList(); 00121 00124 GameInfo* getDefaultGame(); 00125 00128 bool setupGame(GameInfo* info); 00129 00131 void killGame(); 00132 00133 std::string oGamename; 00134 bool oHelp; 00135 bool oQuiet; 00136 bool oVQuiet; 00137 }; 00138 00139 #endif 00140