Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7256 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Mar 30, 2006, 11:45:31 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the preferences back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/preferences . -r7233:HEAD
no conflicts… nice work

Location:
trunk/src/lib
Files:
15 edited
12 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/BuildLibs.am

    r7151 r7256  
    1515                $(LIB_PREFIX)/graphics/spatial_separation/libORXquadtree.a \
    1616                $(LIB_PREFIX)/parser/tinyxml/libtinyxml.a \
     17                $(LIB_PREFIX)/parser/preferences/libPrefsParser.a \
     18                $(LIB_PREFIX)/parser/cmdline_parser/libCmdLineParser.a \
    1719                $(LIB_PREFIX)/parser/ini_parser/libIniParser.a \
    1820                $(LIB_PREFIX)/shell/libORXshell.a \
    19                 $(LIB_PREFIX)/math/libORXmath.a
     21                $(LIB_PREFIX)/math/libORXmath.a \
     22                $(LIB_PREFIX)/libORXlibs.a
  • trunk/src/lib/Makefile.am

    r7221 r7256  
    2323                util/loading/factory.cc \
    2424                util/loading/dynamic_loader.cc \
     25                util/preferences.cc \
    2526                \
    2627                data/data_tank.cc
     
    3940                util/executor/executor_specials.h \
    4041                util/executor/functor_list.h \
     42                util/preferences.h \
    4143                \
    4244                util/loading/resource_manager.h \
  • trunk/src/lib/event/event_handler.cc

    r7166 r7256  
    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}
  • trunk/src/lib/event/event_handler.h

    r7164 r7256  
    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 */
  • trunk/src/lib/event/key_mapper.cc

    r7221 r7256  
    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(3)("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}
  • trunk/src/lib/event/key_mapper.h

    r7221 r7256  
    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
  • trunk/src/lib/graphics/graphics_engine.cc

    r7221 r7256  
    2929#include "debug.h"
    3030
    31 #include "parser/ini_parser/ini_parser.h"
     31#include "util/preferences.h"
    3232#include "substring.h"
    3333#include "text.h"
     
    150150/**
    151151 * loads the GraphicsEngine's settings from a given ini-file and section
    152  * @param iniParser the iniParser to load from
    153  * @param section the Section in the ini-file to load from
    154152 * @returns nothing usefull
    155153 */
    156 int GraphicsEngine::initFromIniFile(IniParser* iniParser)
     154int GraphicsEngine::initFromPreferences()
    157155{
    158156  // looking if we are in fullscreen-mode
    159   const std::string fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
     157  const std::string fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");
     158
    160159  if (fullscreen[0] == '1' || fullscreen == "true")
    161160    this->fullscreenFlag = SDL_FULLSCREEN;
    162161
    163162  // looking if we are in fullscreen-mode
    164   const std::string textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
     163  const std::string textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "0");
    165164  if (textures[0] == '1' || textures == "true")
    166165    Texture::setTextureEnableState(true);
     
    169168
    170169  // searching for a usefull resolution
    171   SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480").c_str(), 'x'); ///FIXME
     170  SubString resolution(Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_RESOLUTION, "640x480").c_str(), 'x'); ///FIXME
    172171  //resolution.debug();
    173172  MultiType x = resolution.getString(0), y = resolution.getString(1);
  • trunk/src/lib/graphics/graphics_engine.h

    r7221 r7256  
    2020// Forward Declaration
    2121class Text;
    22 class IniParser;
    2322class WorldEntity;
    2423class GraphicsEffect;
     
    3938
    4039    int init();
    41     int initFromIniFile(IniParser* iniParser);
     40    int initFromPreferences();
    4241
    4342    void setWindowName(const std::string& windowName, const std::string& icon);
  • trunk/src/lib/network/network_manager.cc

    r6695 r7256  
    8888 * @param hostName: the name of the destination host
    8989 */
    90 int NetworkManager::establishConnection(const char* name, unsigned int port)
     90int NetworkManager::establishConnection(const std::string & name, unsigned int port)
    9191{
    9292  IPaddress ipAddress;
    93   int error = SDLNet_ResolveHost(&ipAddress, name, port);
     93  int error = SDLNet_ResolveHost(&ipAddress, name.c_str(), port);
    9494  if( error == -1) {
    9595    printf("\n\nerror on address resolution, program inconsistency\n\n");
  • trunk/src/lib/network/network_manager.h

    r6981 r7256  
    3636    void shutdown();
    3737
    38     int establishConnection(const char* name, unsigned int port);
     38    int establishConnection( const std::string & name, unsigned int port);
    3939    int createServer(unsigned int port);
    4040
  • trunk/src/lib/parser/Makefile.am

    r5944 r7256  
    11SUBDIRS = \
    22          tinyxml \
    3           ini_parser
     3          ini_parser \
     4          preferences \
     5          cmdline_parser
    46
    57
  • trunk/src/lib/parser/ini_parser/ini_parser.cc

    r7221 r7256  
    392392}
    393393
     394/**
     395 * @brief edits the entry speciefied by entryName in sectionName/currentSection or creates it if it doesn't exist
     396 * @param entryName the Name of the Entry to add
     397 * @param value the value to assign to this entry
     398 * @param sectionName if NULL then this entry will be set to the currentSection
     399 * otherwise to the section refered to by sectionName.
     400 * If both are NULL no entry will be added
     401 * @return true if everything is ok false on error
     402 */
     403bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
     404{
     405  std::list<IniSection>::iterator section;
     406
     407  if (!sectionName.empty())
     408  {
     409    for (section = this->sections.begin(); section != this->sections.end(); section++)
     410      if ((*section).name == sectionName)
     411        break;
     412  }
     413  else
     414    section = this->currentSection;
     415
     416  if (section == this->sections.end())
     417  {
     418    IniSection sec;
     419    sec.comment = "";
     420    sec.name = sectionName;
     421    section = this->sections.insert(this->sections.end(), sec);
     422  }
     423
     424  if (section == this->sections.end())
     425  {
     426    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
     427    return false;
     428  }
     429  else
     430  {
     431    //try find item
     432    std::list<IniEntry>::iterator entry;
     433    for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
     434      if (entry->name == entryName )
     435        break;
     436
     437    //found it?
     438    if ( entry != section->entries.end() )
     439    {
     440      entry->value = value;
     441
     442      return true;
     443    }
     444
     445    //not found -> create it
     446    (*section).entries.push_back(IniEntry());
     447    (*section).entries.back().comment = "";
     448    (*section).entries.back().name = entryName;
     449    (*section).entries.back().value = value;
     450    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
     451    (*section).entries.back().name.c_str(),
     452    (*section).entries.back().value.c_str(),
     453    (*section).name);
     454    this->currentEntry = --(*section).entries.end();
     455    return true;
     456  }
     457}
     458
    394459
    395460/**
  • trunk/src/lib/parser/ini_parser/ini_parser.h

    r7221 r7256  
    6969    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );
    7070    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
     71    bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "");
    7172    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
    7273    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
  • trunk/src/lib/sound/sound_engine.cc

    r7225 r7256  
    2626#include "util/loading/resource_manager.h"
    2727#include "debug.h"
    28 #include "parser/ini_parser/ini_parser.h"
     28#include "util/preferences.h"
    2929#include "globals.h"
    3030
     
    9595/**
    9696 * loads the settings of the SoundEngine from an ini-file
    97  * @param iniParser the IniParser of the inifile
    9897 */
    99 void SoundEngine::loadSettings(IniParser* iniParser)
    100 {
    101   MultiType channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");
     98void SoundEngine::loadSettings()
     99{
     100  MultiType channels = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_AUDIO_CHANNELS, "32");
    102101  this->maxSourceCount = channels.getInt();
    103102
    104   MultiType effectsVolume = iniParser->getVar(CONFIG_NAME_EFFECTS_VOLUME, CONFIG_SECTION_AUDIO, "80");
     103  MultiType effectsVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_EFFECTS_VOLUME, "80");
    105104  this->effectsVolume = effectsVolume.getFloat()/100.0;
    106105
    107   MultiType musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "75");
     106  MultiType musicVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_MUSIC_VOLUME, "75");
    108107  this->musicVolume = musicVolume.getFloat()/100.0;
    109108}
  • trunk/src/lib/sound/sound_engine.h

    r7225 r7256  
    3131    inline static SoundEngine* getInstance() { if (!SoundEngine::singletonRef) SoundEngine::singletonRef = new SoundEngine();  return SoundEngine::singletonRef; };
    3232
    33     void loadSettings(IniParser* iniParser);
     33    void loadSettings();
    3434
    3535    SoundSource* createSource(const std::string& fileName, PNode* sourceNode = NULL);
Note: See TracChangeset for help on using the changeset viewer.