Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 16, 2010, 11:22:36 AM (14 years ago)
Author:
rgrieder
Message:

Merged revisions 6430-6440 from the gamestate branch to the trunk.
This adds keybindings merging functionality.

(from log of r6437)
When running development builds, the keybinder will merge the local file and the one from the data folder.
Catch: if you want to remove a binding, you'll have to write "NoBinding" (not case sensitive) to override the default command

The keybind command already does that for you though.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r6417 r6536  
    3636#include "util/StringUtils.h"
    3737#include "Identifier.h"
     38#include "ConfigFileManager.h"
    3839#include "ConfigValueContainer.h"
    3940#include "TclThreadManager.h"
     
    9697        }
    9798
    98         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)()
     99        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)()
    99100        {
    100             ArgumentCompletionList classlist;
     101            ArgumentCompletionList sectionList;
    101102
    102             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    103                 if (it->second->hasConfigValues())
    104                     classlist.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
     103            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
     104            for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
     105                sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
    105106
    106             return classlist;
     107            return sectionList;
    107108        }
    108109
    109         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
     110        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section)
    110111        {
    111             ArgumentCompletionList configvalues;
    112             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     112            ArgumentCompletionList entryList;
     113            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
     114            const std::string& sectionLC = getLowercase(section);
    113115
    114             if (identifier != Identifier::getLowercaseStringIdentifierMapEnd() && identifier->second->hasConfigValues())
     116            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
     117            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
     118                entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
     119
     120            return entryList;
     121        }
     122
     123        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section)
     124        {
     125            ArgumentCompletionList oldValue;
     126            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
     127            const std::string& sectionLC = getLowercase(section);
     128            const std::string& entryLC = getLowercase(entry);
     129
     130            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
     131            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
    115132            {
    116                 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->second->getConfigValueMapBegin(); it != identifier->second->getConfigValueMapEnd(); ++it)
    117                     configvalues.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
     133                if (it->second.first == entryLC)
     134                {
     135                    const std::string& valuestring = it->second.second->toString();
     136                    oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
     137                }
    118138            }
    119139
    120             return configvalues;
    121         }
    122 
    123         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname)
    124         {
    125             ArgumentCompletionList oldvalue;
    126             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
    127             if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    128             {
    129                 std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
    130                 if (variable != identifier->second->getLowercaseConfigValueMapEnd())
    131                 {
    132                     const std::string& valuestring = variable->second->toString();
    133                     oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
    134                 }
    135             }
    136             return oldvalue;
     140            return oldValue;
    137141        }
    138142
Note: See TracChangeset for help on using the changeset viewer.