Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7248 in orxonox.OLD for branches


Ignore:
Timestamp:
Mar 24, 2006, 7:03:22 PM (19 years ago)
Author:
rennerc
Message:

removed some more iniParsers

Location:
branches/preferences/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/preferences/src/lib/event/event_handler.cc

    r7166 r7248  
    8888 * this has to be called before the use of the event handler
    8989*/
    90 void EventHandler::init(IniParser* iniParser)
     90void EventHandler::init()
    9191{
    9292  if (this->keyMapper == NULL)
    9393  {
    9494    this->keyMapper = new KeyMapper();
    95     this->keyMapper->loadKeyBindings(iniParser);
     95    this->keyMapper->loadKeyBindings();
    9696  }
    9797}
  • branches/preferences/src/lib/event/event_handler.h

    r7164 r7248  
    1515// FORWARD DECLARATION
    1616class EventListener;
    17 class IniParser;
    1817
    1918//! The one Event Handler from Orxonox
     
    2423  /** @returns a Pointer to the only object of this Class */
    2524  inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
    26   void init(IniParser* iniParser);
     25  void init();
    2726
    2827  /** @param state: to which the event handler shall change */
  • branches/preferences/src/lib/event/key_mapper.cc

    r7221 r7248  
    2525#include "globals.h"
    2626#include "parser/ini_parser/ini_parser.h"
     27#include "util/preferences.h"
    2728#include "key_names.h"
    2829#include "debug.h"
     
    145146
    146147  iniParser->firstVar();
    147   while(iniParser->getCurrentName() != "")
     148  while( iniParser->getCurrentName() != "" )
    148149  {
    149150    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     
    164165
    165166  iniParser->firstVar();
    166   while(iniParser->getCurrentName() != "")
     167  while( iniParser->getCurrentName() != "" )
    167168  {
    168169    PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     
    170171    this->mapKeys(iniParser->getCurrentName(), index);
    171172    iniParser->nextVar();
     173  }
     174}
     175
     176void KeyMapper::loadKeyBindings()
     177{
     178  if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_PLAYER "1"))
     179  {
     180    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
     181    return;
     182  }
     183  int* index;
     184
     185  std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_PLAYER "1");
     186  for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
     187  {
     188    PRINTF(0)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, "").c_str());
     189    // map the name to an sdl index
     190    index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, ""));
     191    // map the index to a internal name
     192    this->mapKeys(*it, index);
     193  }
     194
     195
     196  // PARSE MISC SECTION
     197  if( !Preferences::getInstance()->sectionExists (CONFIG_SECTION_MISC_KEYS))
     198  {
     199    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_MISC_KEYS "\n");
     200    return;
     201  }
     202
     203  keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_MISC_KEYS);
     204  for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
     205  {
     206    PRINTF(3)("MISC: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, "").c_str());
     207    index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, ""));
     208    this->mapKeys(*it, index);
    172209  }
    173210}
  • branches/preferences/src/lib/event/key_mapper.h

    r7221 r7248  
    2929  virtual ~KeyMapper();
    3030
    31   void loadKeyBindings(const std::string& fileName = "" );
     31  void loadKeyBindings(const std::string& fileName );
     32  void loadKeyBindings();
    3233  void loadKeyBindings(IniParser* iniParser);
    3334
  • branches/preferences/src/lib/util/preferences.cc

    r7244 r7248  
    6767
    6868      break;
     69    }
     70  }
     71
     72  return false;
     73}
     74
     75/**
     76 * Check if this section exists
     77 * @param section name of the section
     78 * @param name name of the item to check
     79 * @return true if the item exists
     80 */
     81bool Preferences::sectionExists( const std::string& section )
     82{
     83  std::list<prefSection>::const_iterator it = data.begin();
     84
     85  for ( ; it!=data.end(); it++)
     86  {
     87    if ( it->sectionName == section )
     88    {
     89      return true;
    6990    }
    7091  }
     
    285306}
    286307
    287 
     308/**
     309 * list all keys in section
     310 * @param section section
     311 * @return list of keys
     312 */
     313std::list< std::string > Preferences::listKeys( const std::string section )
     314{
     315  std::list<std::string> lst;
     316 
     317  std::list<prefSection>::const_iterator it = data.begin();
     318
     319  for ( ; it!=data.end(); it++)
     320  {
     321    if ( it->sectionName == section )
     322    {
     323      std::list<prefItem>::const_iterator it2 = it->items.begin();
     324
     325      for ( ; it2!=it->items.end(); it2++)
     326      {
     327        lst.push_back( it2->name );
     328      }
     329
     330      break;
     331    }
     332  }
     333
     334  return lst;
     335}
     336
     337
  • branches/preferences/src/lib/util/preferences.h

    r7244 r7248  
    3636
    3737   //check if this entry exists
     38   bool sectionExists(const std::string& section );
    3839   bool exists(const std::string& section, const std::string& name);
    3940
     
    5253   bool save();
    5354
    54 
    5555   void debug();
     56   
     57   std::list<std::string> listKeys( const std::string section );
    5658
    5759
  • branches/preferences/src/orxonox.cc

    r7247 r7248  
    7878  this->setName("orxonox-main");
    7979
    80   this->iniParser = NULL;
    81 
    8280  this->argc = 0;
    8381  this->argv = NULL;
     
    115113  // output-buffer
    116114  delete ShellBuffer::getInstance();
    117 
    118   // orxonox class-stuff
    119   delete this->iniParser;
    120115
    121116  SDL_QuitSubSystem(SDL_INIT_TIMER);
     
    176171  else
    177172    this->configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE);
    178   this->iniParser = new IniParser(this->configFileName);
     173
    179174  PRINTF(3)("Parsed Config File: '%s'\n", this->configFileName);
    180175}
     
    261256  PRINT(3)("> Initializing input\n");
    262257
    263   EventHandler::getInstance()->init(this->iniParser);
     258  EventHandler::getInstance()->init();
    264259  EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE);
    265260
     
    300295  // init the resource manager
    301296  std::string dataPath;
    302   if ((dataPath = this->iniParser->getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= "")
     297  if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, ""))!= "")
    303298  {
    304299    if (!ResourceManager::getInstance()->setDataDir(dataPath) &&
  • branches/preferences/src/orxonox.h

    r7221 r7248  
    3232  Orxonox ();
    3333
    34   void parseIniFile(const std::string& fileName);
    35 
    3634  int initResources ();
    3735  int initVideo ();
     
    4644  static Orxonox*   singletonRef;            //!< singleton reference to orxonox
    4745
    48   IniParser*        iniParser;               //!< Reference to the ini-parser used in orxonox
    4946  std::string       configFileName;          //!< Filename of the configuration-file.
    5047  GameLoader*       gameLoader;              //!< The gameLoader
Note: See TracChangeset for help on using the changeset viewer.