Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 965


Ignore:
Timestamp:
Mar 30, 2008, 7:15:16 PM (16 years ago)
Author:
landauf
Message:

even smarter autocompletion

Location:
code/branches/core2/src/orxonox/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/CommandExecutor.cc

    r957 r965  
    9191    }
    9292
    93     void CommandEvaluation::setAdditionalParameter(const std::string& param)
    94     {
    95         this->additionalParameter_ = param;
    96     }
    97 
    9893    bool CommandEvaluation::isValid() const
    9994    {
     
    198193                {
    199194                    if (tokens.size() >= 2)
    200                         return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_);
     195                        return evaluation.shortcut_->parse(tokens.subSet(1).join() + evaluation.getAdditionalParameter());
    201196                    else
    202197                        return evaluation.shortcut_->parse(evaluation.additionalParameter_);
     
    212207                {
    213208                    if (tokens.size() >= 3)
    214                         return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_);
     209                        return evaluation.function_->parse(tokens.subSet(2).join() + evaluation.getAdditionalParameter());
    215210                    else
    216211                        return evaluation.function_->parse(evaluation.additionalParameter_);
     
    230225                    {
    231226                        if (tokens.size() >= 4)
    232                             return evaluation.configvalue_->set(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
     227                            return evaluation.configvalue_->set(tokens.subSet(3).join() + evaluation.getAdditionalParameter());
    233228                        else
    234229                            return evaluation.configvalue_->set(evaluation.additionalParameter_);
     
    237232                    {
    238233                        if (tokens.size() >= 4)
    239                             return evaluation.configvalue_->tset(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
     234                            return evaluation.configvalue_->tset(tokens.subSet(3).join() + evaluation.getAdditionalParameter());
    240235                        else
    241236                            return evaluation.configvalue_->tset(evaluation.additionalParameter_);
     
    445440                    CommandExecutor::createListOfPossibleFunctionClasses(CommandExecutor::getToken(0));
    446441                    CommandExecutor::createListOfPossibleShortcuts(CommandExecutor::getToken(0));
     442
     443                    // Check if there's only one possiblility
     444                    if ((CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.size() == 1) && (CommandExecutor::getEvaluation().listOfPossibleShortcuts_.size() == 0))
     445                    {
     446                        // There's only one possible class
     447                        CommandExecutor::getEvaluation().state_ = CS_Function;
     448                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(**CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin());
     449                        CommandExecutor::parse(**CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin() + " ", false);
     450                        return;
     451                    }
     452                    else if ((CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.size() == 0) && (CommandExecutor::getEvaluation().listOfPossibleShortcuts_.size() == 1))
     453                    {
     454                        if ((**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() != COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)
     455                         && (**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() != COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)
     456                         && (**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() != COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND))
     457                        {
     458                            // There's only one possible shortcut
     459                            CommandExecutor::getEvaluation().state_ = CS_Shortcut_Params;
     460                            CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin());
     461                        }
     462                        else if ((**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)
     463                              || (**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY))
     464                        {
     465                            // It's the 'set' or 'tset' keyword
     466                            CommandExecutor::getEvaluation().state_ = CS_ConfigValueClass;
     467                        }
     468                        else if (**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() != COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND)
     469                        {
     470                            // It's the 'bind' keyword
     471                            CommandExecutor::getEvaluation().state_ = CS_KeybindKey;
     472                        }
     473
     474                        CommandExecutor::parse(**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() + " ", false);
     475                        return;
     476                    }
     477
     478                    // It's ambiguous
    447479                    return;
    448480                }
     
    568600                        // No perfect match: Create the list of all possible functions and return
    569601                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getToken(1), CommandExecutor::getEvaluation().functionclass_);
     602
     603                        // Check if there's only one possiblility
     604                        if (CommandExecutor::getEvaluation().listOfPossibleFunctions_.size() == 1)
     605                        {
     606                            // There's only one possible function
     607                            CommandExecutor::getEvaluation().state_ = CS_Function_Params;
     608                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(**CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().functionclass_);
     609                            CommandExecutor::parse(CommandExecutor::getToken(0) + " " + **CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin() + " ", false);
     610                            return;
     611                        }
     612
     613                        // It's ambiguous
    570614                        return;
    571615                    }
     
    638682                        // No perfect match: Create the list of all possible classnames and return
    639683                        CommandExecutor::createListOfPossibleConfigValueClasses(CommandExecutor::getToken(1));
     684
     685                        // Check if there's only one possiblility
     686                        if (CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.size() == 1)
     687                        {
     688                            // There's only one possible classname
     689                            CommandExecutor::getEvaluation().state_ = CS_ConfigValue;
     690                            CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(**CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin());
     691                            CommandExecutor::parse(CommandExecutor::getToken(0) + " " + **CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin() + " ", false);
     692                            return;
     693                        }
     694
     695                        // It's ambiguous
    640696                        return;
    641697                    }
     
    690746                        // No perfect match: Create the list of all possible config values
    691747                        CommandExecutor::createListOfPossibleConfigValues(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_);
     748
     749                        // Check if there's only one possiblility
     750                        if (CommandExecutor::getEvaluation().listOfPossibleConfigValues_.size() == 1)
     751                        {
     752                            // There's only one possible config value
     753                            CommandExecutor::getEvaluation().state_ = CS_ConfigValueType;
     754                            CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(**CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin(), CommandExecutor::getEvaluation().configvalueclass_);
     755                            CommandExecutor::parse(CommandExecutor::getToken(0) + " " + CommandExecutor::getToken(1) + " " + **CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin() + " ", false);
     756                            return;
     757                        }
     758
     759                        // It's ambiguous
    692760                        return;
    693761                    }
  • code/branches/core2/src/orxonox/core/CommandExecutor.h

    r957 r965  
    7474
    7575            KeybindMode getKeybindMode();
    76             void setAdditionalParameter(const std::string& param);
    7776            bool isValid() const;
     77
     78            inline void setAdditionalParameter(const std::string& param)
     79                { this->additionalParameter_ = param; }
     80            inline std::string getAdditionalParameter() const
     81                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
    7882
    7983        private:
Note: See TracChangeset for help on using the changeset viewer.