Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/ConfigFileManager.cc

    r5929 r6417  
    5151        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    5252        {
    53             std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
    54             if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
    55                 return (*variable).second->set(value);
     53            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
     54            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
     55                return variable->second->set(value);
    5656        }
    5757        return false;
     58    }
     59
     60    std::string getConfig(const std::string& classname, const std::string& varname)
     61    {
     62        return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true);
    5863    }
    5964
     
    6368        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    6469        {
    65             std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
    66             if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
    67                 return (*variable).second->tset(value);
     70            std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
     71            if (variable != identifier->second->getLowercaseConfigValueMapEnd())
     72                return variable->second->tset(value);
    6873        }
    6974        return false;
     
    9499            this->value_ = value;
    95100        else
    96             this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
     101            this->value_ = '"' + addSlashes(stripEnclosingQuotes(value)) + '"';
    97102    }
    98103
     
    107112    std::string ConfigFileEntryValue::getFileEntry() const
    108113    {
    109         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    110             return (this->name_ + "=" + this->value_);
    111         else
    112             return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
     114        if (this->additionalComment_.empty())
     115            return (this->name_ + '=' + this->value_);
     116        else
     117            return (this->name_ + '=' + this->value_ + " " + this->additionalComment_);
    113118    }
    114119
     
    119124    std::string ConfigFileEntryVectorValue::getFileEntry() const
    120125    {
    121         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    122             return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
    123         else
    124             return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
     126        if (this->additionalComment_.empty())
     127            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + ']' + '=' + this->value_);
     128        else
     129            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + "]=" + this->value_ + ' ' + this->additionalComment_);
    125130    }
    126131
     
    166171    std::string ConfigFileSection::getFileEntry() const
    167172    {
    168         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    169             return ("[" + this->name_ + "]");
    170         else
    171             return ("[" + this->name_ + "] " + this->additionalComment_);
     173        if (this->additionalComment_.empty())
     174            return ('[' + this->name_ + ']');
     175        else
     176            return ('[' + this->name_ + "] " + this->additionalComment_);
    172177    }
    173178
     
    246251                std::getline(file, line);
    247252
    248                 std::string temp = getStripped(line);
     253                const std::string& temp = getStripped(line);
    249254                if (!isEmpty(temp) && !isComment(temp))
    250255                {
     
    256261                    {
    257262                        // New section
    258                         std::string comment = line.substr(pos2 + 1);
     263                        const std::string& comment = line.substr(pos2 + 1);
    259264                        if (isComment(comment))
    260265                            newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
     
    288293                                commentposition = getNextCommentPosition(line, commentposition + 1);
    289294                            }
    290                             std::string value = "", comment = "";
     295                            std::string value, comment;
    291296                            if (commentposition == std::string::npos)
    292297                            {
     
    377382        {
    378383            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
    379             if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())
     384            if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues())
    380385            {
    381386                // The section exists, delete comment
     
    384389                for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
    385390                {
    386                     std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());
    387                     if (it4 != (*it2).second->getConfigValueMapEnd())
     391                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName());
     392                    if (it4 != it2->second->getConfigValueMapEnd())
    388393                    {
    389394                        // The config-value exists, delete comment
     
    459464                if (it->second->hasConfigValues())
    460465                {
    461                     for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)
     466                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2)
    462467                        it2->second->update();
    463468
Note: See TracChangeset for help on using the changeset viewer.