Changeset 7256 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Mar 30, 2006, 11:45:31 AM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 15 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/BuildLibs.am
r7151 r7256 15 15 $(LIB_PREFIX)/graphics/spatial_separation/libORXquadtree.a \ 16 16 $(LIB_PREFIX)/parser/tinyxml/libtinyxml.a \ 17 $(LIB_PREFIX)/parser/preferences/libPrefsParser.a \ 18 $(LIB_PREFIX)/parser/cmdline_parser/libCmdLineParser.a \ 17 19 $(LIB_PREFIX)/parser/ini_parser/libIniParser.a \ 18 20 $(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 23 23 util/loading/factory.cc \ 24 24 util/loading/dynamic_loader.cc \ 25 util/preferences.cc \ 25 26 \ 26 27 data/data_tank.cc … … 39 40 util/executor/executor_specials.h \ 40 41 util/executor/functor_list.h \ 42 util/preferences.h \ 41 43 \ 42 44 util/loading/resource_manager.h \ -
trunk/src/lib/event/event_handler.cc
r7166 r7256 88 88 * this has to be called before the use of the event handler 89 89 */ 90 void EventHandler::init( IniParser* iniParser)90 void EventHandler::init() 91 91 { 92 92 if (this->keyMapper == NULL) 93 93 { 94 94 this->keyMapper = new KeyMapper(); 95 this->keyMapper->loadKeyBindings( iniParser);95 this->keyMapper->loadKeyBindings(); 96 96 } 97 97 } -
trunk/src/lib/event/event_handler.h
r7164 r7256 15 15 // FORWARD DECLARATION 16 16 class EventListener; 17 class IniParser;18 17 19 18 //! The one Event Handler from Orxonox … … 24 23 /** @returns a Pointer to the only object of this Class */ 25 24 inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler(); return singletonRef; }; 26 void init( IniParser* iniParser);25 void init(); 27 26 28 27 /** @param state: to which the event handler shall change */ -
trunk/src/lib/event/key_mapper.cc
r7221 r7256 25 25 #include "globals.h" 26 26 #include "parser/ini_parser/ini_parser.h" 27 #include "util/preferences.h" 27 28 #include "key_names.h" 28 29 #include "debug.h" … … 145 146 146 147 iniParser->firstVar(); 147 while( iniParser->getCurrentName() != "")148 while( iniParser->getCurrentName() != "" ) 148 149 { 149 150 PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); … … 164 165 165 166 iniParser->firstVar(); 166 while( iniParser->getCurrentName() != "")167 while( iniParser->getCurrentName() != "" ) 167 168 { 168 169 PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); … … 170 171 this->mapKeys(iniParser->getCurrentName(), index); 171 172 iniParser->nextVar(); 173 } 174 } 175 176 void 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); 172 209 } 173 210 } -
trunk/src/lib/event/key_mapper.h
r7221 r7256 29 29 virtual ~KeyMapper(); 30 30 31 void loadKeyBindings(const std::string& fileName = "" ); 31 void loadKeyBindings(const std::string& fileName ); 32 void loadKeyBindings(); 32 33 void loadKeyBindings(IniParser* iniParser); 33 34 -
trunk/src/lib/graphics/graphics_engine.cc
r7221 r7256 29 29 #include "debug.h" 30 30 31 #include " parser/ini_parser/ini_parser.h"31 #include "util/preferences.h" 32 32 #include "substring.h" 33 33 #include "text.h" … … 150 150 /** 151 151 * loads the GraphicsEngine's settings from a given ini-file and section 152 * @param iniParser the iniParser to load from153 * @param section the Section in the ini-file to load from154 152 * @returns nothing usefull 155 153 */ 156 int GraphicsEngine::initFrom IniFile(IniParser* iniParser)154 int GraphicsEngine::initFromPreferences() 157 155 { 158 156 // 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 160 159 if (fullscreen[0] == '1' || fullscreen == "true") 161 160 this->fullscreenFlag = SDL_FULLSCREEN; 162 161 163 162 // 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"); 165 164 if (textures[0] == '1' || textures == "true") 166 165 Texture::setTextureEnableState(true); … … 169 168 170 169 // searching for a usefull resolution 171 SubString resolution( iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480").c_str(), 'x'); ///FIXME170 SubString resolution(Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_RESOLUTION, "640x480").c_str(), 'x'); ///FIXME 172 171 //resolution.debug(); 173 172 MultiType x = resolution.getString(0), y = resolution.getString(1); -
trunk/src/lib/graphics/graphics_engine.h
r7221 r7256 20 20 // Forward Declaration 21 21 class Text; 22 class IniParser;23 22 class WorldEntity; 24 23 class GraphicsEffect; … … 39 38 40 39 int init(); 41 int initFrom IniFile(IniParser* iniParser);40 int initFromPreferences(); 42 41 43 42 void setWindowName(const std::string& windowName, const std::string& icon); -
trunk/src/lib/network/network_manager.cc
r6695 r7256 88 88 * @param hostName: the name of the destination host 89 89 */ 90 int NetworkManager::establishConnection(const char*name, unsigned int port)90 int NetworkManager::establishConnection(const std::string & name, unsigned int port) 91 91 { 92 92 IPaddress ipAddress; 93 int error = SDLNet_ResolveHost(&ipAddress, name , port);93 int error = SDLNet_ResolveHost(&ipAddress, name.c_str(), port); 94 94 if( error == -1) { 95 95 printf("\n\nerror on address resolution, program inconsistency\n\n"); -
trunk/src/lib/network/network_manager.h
r6981 r7256 36 36 void shutdown(); 37 37 38 int establishConnection( const char*name, unsigned int port);38 int establishConnection( const std::string & name, unsigned int port); 39 39 int createServer(unsigned int port); 40 40 -
trunk/src/lib/parser/Makefile.am
r5944 r7256 1 1 SUBDIRS = \ 2 2 tinyxml \ 3 ini_parser 3 ini_parser \ 4 preferences \ 5 cmdline_parser 4 6 5 7 -
trunk/src/lib/parser/ini_parser/ini_parser.cc
r7221 r7256 392 392 } 393 393 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 */ 403 bool 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 394 459 395 460 /** -
trunk/src/lib/parser/ini_parser/ini_parser.h
r7221 r7256 69 69 bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" ); 70 70 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 = ""); 71 72 void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName); 72 73 const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const; -
trunk/src/lib/sound/sound_engine.cc
r7225 r7256 26 26 #include "util/loading/resource_manager.h" 27 27 #include "debug.h" 28 #include " parser/ini_parser/ini_parser.h"28 #include "util/preferences.h" 29 29 #include "globals.h" 30 30 … … 95 95 /** 96 96 * loads the settings of the SoundEngine from an ini-file 97 * @param iniParser the IniParser of the inifile98 97 */ 99 void SoundEngine::loadSettings( IniParser* iniParser)100 { 101 MultiType channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");98 void SoundEngine::loadSettings() 99 { 100 MultiType channels = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_AUDIO_CHANNELS, "32"); 102 101 this->maxSourceCount = channels.getInt(); 103 102 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"); 105 104 this->effectsVolume = effectsVolume.getFloat()/100.0; 106 105 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"); 108 107 this->musicVolume = musicVolume.getFloat()/100.0; 109 108 } -
trunk/src/lib/sound/sound_engine.h
r7225 r7256 31 31 inline static SoundEngine* getInstance() { if (!SoundEngine::singletonRef) SoundEngine::singletonRef = new SoundEngine(); return SoundEngine::singletonRef; }; 32 32 33 void loadSettings( IniParser* iniParser);33 void loadSettings(); 34 34 35 35 SoundSource* createSource(const std::string& fileName, PNode* sourceNode = NULL);
Note: See TracChangeset
for help on using the changeset viewer.