Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4766 in orxonox.OLD


Ignore:
Timestamp:
Jul 2, 2005, 11:54:41 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: cleaned up orxonox.cc a bit, and now one has the ability to choose the resolution in the GUI

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/globals.h

    r4176 r4766  
    22  \file globals.h
    33  \brief This file defines some default values.
    4  
     4
    55  no Class is defined here.
    66*/
     
    1111#define ORXONOX_STAFF "Patrick Boenzli - Captain\n" \
    1212                      "Benjamin Grauer - First Officer\n" \
    13                       "Christian Meyer - Engeneer\n" \
    14                       "Nico Bernold - Physics\n" \
    15                       "David Gruetter - The ProtoType\n" \
    16                       "many more\n"
     13                      "Christian Meyer - Engeneer\n" \
     14                      "Nico Bernold - Physics\n" \
     15                      "David Gruetter - The ProtoType\n" \
     16                      "many more...\n"
    1717
    18 #define DEFAULT_CONFIG_FILE "~/.orxonox/orxonox.conf"
    19 #define DEFAULT_DATA_DIR "/usr/share/orxonox/data/"
    20 #define DEFAULT_DATA_DIR_CHECKFILE "data.oxd"
     18#define   DEFAULT_CONFIG_FILE              "~/.orxonox/orxonox.conf"
     19#define   DEFAULT_LOCK_FILE                "~/.orxonox/orxonox.lock"
     20#define   DEFAULT_DATA_DIR                 "/usr/share/orxonox/data/"
     21#define   DEFAULT_DATA_DIR_CHECKFILE       "data.oxd"
    2122
    2223// Defines all the Sections of the Config (in Gui and ORxonox)
    2324//! Name of Section Misc in the config-File
    24 #define CONFIG_SECTION_MISC "misc"
    25 #define CONFIG_SECTION_MISC_KEYS "miscKeys"
    26 #define CONFIG_SECTION_PLAYER "player"
    27 #define CONFIG_SECTION_VIDEO "video"
    28 #define CONFIG_SECTION_VIDEO_ADVANCED "video_advanced"
    29 #define CONFIG_SECTION_AUDIO "audio"
    30 #define CONFIG_SECTION_EXEC "exec"
    31 #define CONFIG_SECTION_DATA "data"
     25#define   CONFIG_SECTION_MISC              "misc"
     26#define   CONFIG_SECTION_MISC_KEYS        "miscKeys"
     27#define   CONFIG_SECTION_PLAYER            "player"
     28#define   CONFIG_SECTION_VIDEO            "video"
     29#define   CONFIG_SECTION_VIDEO_ADVANCED    "video_advanced"
     30#define   CONFIG_SECTION_AUDIO            "audio"
     31#define   CONFIG_SECTION_EXEC              "exec"
     32#define   CONFIG_SECTION_DATA              "data"
    3233
    3334/*
     
    3536  Consider they may __not__ have any WhiteSpaces inside
    3637*/
    37 #define CONFIG_NAME_DATADIR "DataDir"
    38 #define CONFIG_NAME_AUTO_UPDATE "Auto-Update"
    39 #define CONFIG_NAME_FULLSCREEN "Fullscreen-mode"
    40 #define CONFIG_NAME_RESOLUTION "Resolution"
    41 #define CONFIG_NAME_WIREFRAME "WireFrame-mode"
    42 #define CONFIG_NAME_SHADOWS "Shadows"
    43 #define CONFIG_NAME_FOG "Fog"
    44 #define CONFIG_NAME_REFLECTIONS "Reflections"
    45 #define CONFIG_NAME_TEXTURES "TEXTURES"
    46 #define CONFIG_NAME_TEXTURE_DETAIL "Texture-Detail"
    47 #define CONFIG_NAME_MODEL_DETAIL "Model-Detail"
    48 #define CONFIG_NAME_PARTICLES_ENABLED "Particles Enabled"
    49 #define CONFIG_NAME_ANTI_ALIASING "Anti-Aliasing"
    50 #define CONFIG_NAME_FILTER_METHOD "Filtering-Method"
    51 #define CONFIG_NAME_DISABLE_AUDIO "Disable-Audio"
    52 #define CONFIG_NAME_MUSIC_VOLUME "Music-Volume"
    53 #define CONFIG_NAME_EFFECTS_VOLUME "Effects-Volume"
    54 #define CONFIG_NAME_SAVE_SETTINGS "Save-Settings"
    55 #define CONFIG_NAME_VERBOSE_MODE "Verbose-Mode"
    56 #define CONFIG_NAME_ALWAYS_SHOW_GUI "Always-Show-The-Gui"
    57 #define CONFIG_NAME_PLAYER_UP "Up"
    58 #define CONFIG_NAME_PLAYER_DOWN "Down"
    59 #define CONFIG_NAME_PLAYER_LEFT "Left"
    60 #define CONFIG_NAME_PLAYER_RIGHT "Right"
    61 #define CONFIG_NAME_PLAYER_FIRE "Fire"
    62 #define CONFIG_NAME_PLAYER_NEXT_WEAPON "Next"
    63 #define CONFIG_NAME_PLAYER_PREV_WEAPON "Prev"
    64 #define CONFIG_NAME_QUIT "Quit"
    65 #define CONFIG_NAME_PAUSE "Pause"
    66 #define CONFIG_NAME_NEXT_WORLD "Next-World"
    67 #define CONFIG_NAME_PREV_WORLD "Prev-World"
    68 #define CONFIG_NAME_VIEW0 "view0"
    69 #define CONFIG_NAME_VIEW1 "view1"
    70 #define CONFIG_NAME_VIEW2 "view2"
    71 #define CONFIG_NAME_VIEW3 "view3"
    72 #define CONFIG_NAME_VIEW4 "view4"
    73 #define CONFIG_NAME_VIEW5 "view5"
     38#define   CONFIG_NAME_DATADIR              "DataDir"
     39#define   CONFIG_NAME_AUTO_UPDATE          "Auto-Update"
     40#define   CONFIG_NAME_FULLSCREEN           "Fullscreen-mode"
     41#define   CONFIG_NAME_RESOLUTION           "Resolution"
     42#define   CONFIG_NAME_WIREFRAME            "WireFrame-mode"
     43#define   CONFIG_NAME_SHADOWS              "Shadows"
     44#define   CONFIG_NAME_FOG                  "Fog"
     45#define   CONFIG_NAME_REFLECTIONS          "Reflections"
     46#define   CONFIG_NAME_TEXTURES             "TEXTURES"
     47#define   CONFIG_NAME_TEXTURE_DETAIL       "Texture-Detail"
     48#define   CONFIG_NAME_MODEL_DETAIL         "Model-Detail"
     49#define   CONFIG_NAME_PARTICLES_ENABLED    "Particles Enabled"
     50#define   CONFIG_NAME_ANTI_ALIASING        "Anti-Aliasing"
     51#define   CONFIG_NAME_FILTER_METHOD        "Filtering-Method"
     52#define   CONFIG_NAME_DISABLE_AUDIO        "Disable-Audio"
     53#define   CONFIG_NAME_MUSIC_VOLUME         "Music-Volume"
     54#define   CONFIG_NAME_EFFECTS_VOLUME       "Effects-Volume"
     55#define   CONFIG_NAME_SAVE_SETTINGS        "Save-Settings"
     56#define   CONFIG_NAME_VERBOSE_MODE         "Verbose-Mode"
     57#define   CONFIG_NAME_ALWAYS_SHOW_GUI      "Always-Show-The-Gui"
     58// evenets
     59#define   CONFIG_NAME_PLAYER_UP            "Up"
     60#define   CONFIG_NAME_PLAYER_DOWN          "Down"
     61#define   CONFIG_NAME_PLAYER_LEFT          "Left"
     62#define   CONFIG_NAME_PLAYER_RIGHT         "Right"
     63#define   CONFIG_NAME_PLAYER_FIRE          "Fire"
     64#define   CONFIG_NAME_PLAYER_NEXT_WEAPON   "Next"
     65#define   CONFIG_NAME_PLAYER_PREV_WEAPON   "Prev"
     66#define   CONFIG_NAME_QUIT                 "Quit"
     67#define   CONFIG_NAME_PAUSE                "Pause"
     68#define   CONFIG_NAME_NEXT_WORLD           "Next-World"
     69#define   CONFIG_NAME_PREV_WORLD           "Prev-World"
     70#define   CONFIG_NAME_VIEW0                "view0"
     71#define   CONFIG_NAME_VIEW1                "view1"
     72#define   CONFIG_NAME_VIEW2                "view2"
     73#define   CONFIG_NAME_VIEW3                "view3"
     74#define   CONFIG_NAME_VIEW4                "view4"
     75#define   CONFIG_NAME_VIEW5                "view5"
    7476
    7577
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4747 r4766  
    9292  */
    9393    // setting up the Resolution
    94   this->setResolution(1000, 1000, 16);
     94  this->setResolution(550, 400, 16);
    9595
    9696  // TO DO: Create a cool icon and use it here
  • orxonox/trunk/src/orxonox.cc

    r4756 r4766  
    4343#include "cd_engine.h"
    4444
     45#include "substring.h"
    4546#include "class_list.h"
    4647
     
    5960{
    6061  this->setClassID(CL_ORXONOX, "Orxonox");
    61   this->setName("orxonox");
     62  this->setName("orxonox-main");
    6263
    6364  this->resourceManager = NULL;
    6465  this->objectManager = NULL;
    6566  this->eventHandler = NULL;
     67  this->iniParser = NULL;
    6668
    6769  this->argc = 0;
     
    7476Orxonox::~Orxonox ()
    7577{
    76   int i = 0;
    77   Orxonox::singletonRef = NULL;
     78  delete this->iniParser;
     79
    7880  delete GraphicsEngine::getInstance(); // deleting the Graphics
    7981  delete TextEngine::getInstance();
     
    8486  delete EventHandler::getInstance();
    8587  delete Factory::getFirst();
     88  delete SoundEngine::getInstance();
    8689
    8790  ClassList::debug(0);
    88 }
    89 
    90 /** \brief this is a singleton class to prevent duplicates */
    91 Orxonox* Orxonox::singletonRef = 0;
    92 
    93 /**
    94    \returns reference or new Object of Orxonox if not existent.
    95 */
    96 Orxonox* Orxonox::getInstance ()
    97 {
    98   if (singletonRef == NULL)
    99     singletonRef = new Orxonox();
    100   return singletonRef;
    101 }
    102 
    103 /**
    104    \brief this finds the config file
    105 
    106    Since the config file varies from user to user and since one may want to specify different config files
    107    for certain occasions or platforms this function finds the right config file for every occasion and stores
    108    it's path and name into configfilename
    109 */
    110 void Orxonox::getConfigFile (int argc, char** argv)
    111 {
    112   strcpy (configfilename, "~/.orxonox/orxonox.conf");
     91
     92  PRINT(3)("===================================================\n" \
     93      "Thanks for playing orxonox.\n" \
     94      "visit: http://www.orxonox.ethz.ch for new versions.\n" \
     95      "===================================================\n");
     96
     97  Orxonox::singletonRef = NULL;
     98}
     99
     100/**
     101 * @brief this is a singleton class to prevent duplicates
     102 */
     103Orxonox* Orxonox::singletonRef = NULL;
     104
     105/**
     106 * @brief this finds the config file
     107 * @returns the new config-fileName
     108 * Since the config file varies from user to user and since one may want to specify different config files
     109 * for certain occasions or platforms this function finds the right config file for every occasion and stores
     110 * it's path and name into configfilename
     111*/
     112const char* Orxonox::getConfigFile (int argc, char** argv)
     113{
     114  strcpy (this->configFileName, DEFAULT_CONFIG_FILE);
     115  this->iniParser = new IniParser(this->configFileName);
    113116}
    114117
     
    123126  // config file
    124127
    125   getConfigFile (argc, argv);
     128  // initialize the Config-file
     129  this->getConfigFile(argc, argv);
     130
     131
    126132  SDL_Init (SDL_INIT_TIMER);
    127133  // initialize everything
    128   printf("> Initializing resources\n");
    129134  if( initResources () == -1) return -1;
    130 
    131135  if( initVideo() == -1) return -1;
    132136  if( initSound() == -1) return -1;
    133   PRINT(3)("> Initializing input\n");
    134137  if( initInput() == -1) return -1;
    135   PRINT(3)("> Initializing networking\n");
    136138  if( initNetworking () == -1) return -1;
    137139  //printf("> Initializing world\n");
     
    149151
    150152  GraphicsEngine::getInstance();
    151   GraphicsEngine::getInstance()->setWindowName("orxonox " PACKAGE_VERSION, "orxonox " PACKAGE_VERSION);
    152 
    153   return 0;
    154 }
    155 
     153  GraphicsEngine::getInstance()->setWindowName(PACKAGE_NAME " " PACKAGE_VERSION, PACKAGE_NAME " " PACKAGE_VERSION);
     154
     155
     156  SubString resolution(this->iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
     157  GraphicsEngine::getInstance()->setResolution(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
     158
     159//  const char* fullscreen = this->iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, 0);
     160//  GraphicsEngine::getInstance()->setFullscreen(false);
     161
     162  return 0;
     163}
    156164
    157165/**
     
    168176
    169177/**
    170    \brief initializes input functions
     178 * @brief initializes input functions
    171179*/
    172180int Orxonox::initInput()
    173181{
     182  PRINT(3)("> Initializing input\n");
     183
    174184  this->eventHandler = EventHandler::getInstance();
    175185  this->eventHandler->init();
     
    180190
    181191/**
    182    \brief initializes network system
     192* @brief initializes network system
    183193*/
    184194int Orxonox::initNetworking()
    185195{
    186   printf("Not yet implemented\n");
    187   return 0;
    188 }
    189 
    190 
    191 /**
    192    \brief initializes and loads resource files
    193 */
    194 int Orxonox::initResources()
    195 {
    196    PRINT(3)("initializing ResourceManager\n");
    197    resourceManager = ResourceManager::getInstance();
     196  PRINT(3)("> Initializing networking\n");
     197
     198  printf("  ---Not yet implemented-FIXME--\n");
     199  return 0;
     200}
     201
     202
     203/**
     204 * @brief initializes and loads resource files
     205 */
     206 int Orxonox::initResources()
     207{
     208  PRINTF(3)("> Initializing resources\n");
     209
     210  PRINT(3)("initializing ResourceManager\n");
     211  resourceManager = ResourceManager::getInstance();
    198212
    199213  // create parser
    200    IniParser parser (DEFAULT_CONFIG_FILE);
    201    if( parser.getSection (CONFIG_SECTION_DATA) == -1)
    202    {
    203      PRINTF(1)("Could not find Section %s in %s\n", CONFIG_SECTION_DATA, DEFAULT_CONFIG_FILE);
    204      return -1;
    205    }
    206    char namebuf[256];
    207    char valuebuf[256];
    208    memset (namebuf, 0, 256);
    209    memset (valuebuf, 0, 256);
    210 
    211    while( parser.nextVar (namebuf, valuebuf) != -1)
    212    {
    213      if (!strcmp(namebuf, CONFIG_NAME_DATADIR))
    214      {
     214  if( this->iniParser->getSection (CONFIG_SECTION_DATA) == -1)
     215  {
     216    PRINTF(1)("Could not find Section %s in %s\n", CONFIG_SECTION_DATA, DEFAULT_CONFIG_FILE);
     217    return -1;
     218  }
     219  char namebuf[256];
     220  char valuebuf[256];
     221  memset (namebuf, 0, 256);
     222  memset (valuebuf, 0, 256);
     223
     224  while( this->iniParser->nextVar (namebuf, valuebuf) != -1)
     225  {
     226    if (!strcmp(namebuf, CONFIG_NAME_DATADIR))
     227    {
    215228          //  printf("Not yet implemented\n");
    216        if (!resourceManager->setDataDir(valuebuf))
    217        {
    218          PRINTF(1)("Data Could not be located\n");
    219          exit(-1);
    220        }
    221      }
    222 
    223      memset (namebuf, 0, 256);
    224      memset (valuebuf, 0, 256);
    225    }
    226 
    227    if (!resourceManager->checkDataDir(DEFAULT_DATA_DIR_CHECKFILE))
    228    {
    229      PRINTF(1)("The DataDirectory %s could not be verified\nPlease Change in File %s Section %s Entry %s to a suitable value\n",
    230      resourceManager->getDataDir(),
    231      DEFAULT_CONFIG_FILE,
    232      CONFIG_SECTION_DATA,
    233      CONFIG_NAME_DATADIR);
    234      exit(-1);
    235    }
     229      if (!resourceManager->setDataDir(valuebuf))
     230      {
     231        PRINTF(1)("Data Could not be located\n");
     232        exit(-1);
     233      }
     234    }
     235
     236    memset (namebuf, 0, 256);
     237    memset (valuebuf, 0, 256);
     238  }
     239
     240  if (!resourceManager->checkDataDir(DEFAULT_DATA_DIR_CHECKFILE))
     241  {
     242    PRINTF(1)("The DataDirectory %s could not be verified\n" \
     243              "  Please Change in File %s Section %s Entry %s to a suitable value\n",
     244              resourceManager->getDataDir(),
     245              DEFAULT_CONFIG_FILE,
     246              CONFIG_SECTION_DATA,
     247              CONFIG_NAME_DATADIR);
     248    exit(-1);
     249  }
    236250   //! \todo this is a hack and should be loadable
    237    resourceManager->addImageDir(ResourceManager::getInstance()->getFullName("maps/"));
    238    resourceManager->debug();
    239 
    240    PRINT(3)("initializing TextEngine\n");
    241    TextEngine::getInstance();
    242 
    243    PRINT(3)("initializing ObjectManager\n");
    244    this->objectManager = ObjectManager::getInstance();
    245 
    246    CDEngine::getInstance();
    247 
    248    return 0;
    249 }
    250 
    251 
    252 
     251  resourceManager->addImageDir(ResourceManager::getInstance()->getFullName("maps/"));
     252  resourceManager->debug();
     253
     254  PRINT(3)("initializing TextEngine\n");
     255  TextEngine::getInstance();
     256
     257  PRINT(3)("initializing ObjectManager\n");
     258  this->objectManager = ObjectManager::getInstance();
     259
     260  CDEngine::getInstance();
     261
     262  return 0;
     263}
    253264
    254265/**
     
    299310bool showGui = false;
    300311
     312
     313
     314/**********************************
     315*** ORXONOX MAIN STARTING POINT ***
     316**********************************/
    301317/**
    302318   \brief main function
     
    306322int main(int argc, char** argv)
    307323{
    308 
    309324  // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark.
    310325  int i;
     
    337352
    338353
     354
     355/**
     356 * starts orxonox
     357 * @param argc parameters count given to orxonox
     358 * @param argv parameters given to orxonox
     359 */
    339360int startOrxonox(int argc, char** argv)
    340361{
    341362  // checking for existence of the configuration-files
    342363  if (showGui ||
    343       !ResourceManager::isFile("~/.orxonox/orxonox.conf") ||
    344       ResourceManager::isFile("~/.orxonox/orxonox.lock"))
    345     {
    346       if (ResourceManager::isFile("~/.orxonox/orxonox.lock"))
    347         ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
     364      !ResourceManager::isFile(DEFAULT_CONFIG_FILE) ||
     365      ResourceManager::isFile(DEFAULT_LOCK_FILE))
     366    {
     367      if (ResourceManager::isFile(DEFAULT_LOCK_FILE))
     368        ResourceManager::deleteFile(DEFAULT_LOCK_FILE);
    348369
    349370      // starting the GUI
     
    359380  PRINT(0)(">>> Starting Orxonox <<<\n");
    360381
    361   ResourceManager::touchFile("~/.orxonox/orxonox.lock");
     382  ResourceManager::touchFile(DEFAULT_LOCK_FILE);
    362383
    363384  Orxonox *orx = Orxonox::getInstance();
  • orxonox/trunk/src/orxonox.h

    r4447 r4766  
    1 /*! 
     1/*!
    22    \file orxonox.h
    33    \brief Orxonox core functions
    4 */ 
     4*/
    55
    66#ifndef _ORXONOX_H
     
    1515class EventHandler;
    1616class Event;
     17class IniParser;
    1718
    1819//! Orxonox core singleton class
     
    2223
    2324 public:
    24   static Orxonox* getInstance ();
    2525  virtual ~Orxonox ();
     26  /** \returns a Pointer to the only object of this Class */
     27  inline static Orxonox* getInstance() { if (!singletonRef) singletonRef = new Orxonox();  return singletonRef; };
     28
    2629  int init (int argc, char** argv);
    2730
     
    3437  Orxonox ();
    3538
     39  void parseIniFile(const char* fileName);
     40
    3641  int initVideo ();
    3742  int initSound ();
     
    4045  int initResources ();
    4146
    42   void getConfigFile (int argc, char** argv);
     47  const char* getConfigFile (int argc, char** argv);
    4348
    4449 private:
    4550  static Orxonox*   singletonRef;            //!< singleton reference to orxonox
    4651
    47   char              configfilename[256];     //!< Filename of the configuration-file.
     52  IniParser*        iniParser;               //!< Reference to the ini-parser used in orxonox
     53  char              configFileName[256];     //!< Filename of the configuration-file.
    4854  GameLoader*       gameLoader;              //!< The gameLoader
    4955  ResourceManager*  resourceManager;         //!< The ResourceManager
    5056  ObjectManager*    objectManager;           //!< the object manager of the game
    5157  EventHandler*     eventHandler;            //!< the eventhandler of orxonox is created here
    52  
     58
    5359  unsigned int      argc;                    //!< Count of Arguments of orxonox
    5460  char**            argv;                    //!< Values of th Arguments of orxonox.
Note: See TracChangeset for help on using the changeset viewer.