Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2008, 12:12:18 AM (16 years ago)
Author:
landauf
Message:
  • added input buffer: this class captures key-input (at the moment it's using OIS directly, later it will use the InputHandler) and writes it into a string - other classes can listen to changes and can read and modify the string.
  • fixed some bugs in CommandExecutor
  • fixed a small bug (or changed a questionable feature) in Functor
File:
1 edited

Legend:

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

    r953 r955  
    4949    // CommandEvaluation //
    5050    ///////////////////////
     51    CommandEvaluation::CommandEvaluation()
     52    {
     53        this->processedCommand_ = "";
     54        this->additionalParameter_ = "";
     55
     56        this->functionclass_ = 0;
     57        this->configvalueclass_ = 0;
     58        this->shortcut_ = 0;
     59        this->function_ = 0;
     60        this->configvalue_ = 0;
     61        this->key_ = 0;
     62
     63        this->errorMessage_ = "";
     64        this->state_ = CS_Uninitialized;
     65    }
     66
    5167    KeybindMode CommandEvaluation::getKeybindMode()
    5268    {
     
    156172    bool CommandExecutor::execute(const std::string& command)
    157173    {
    158         if (CommandExecutor::getEvaluation().processedCommand_ != command)
     174        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    159175            CommandExecutor::parse(command);
    160176
     
    169185        switch (evaluation.state_)
    170186        {
     187            case CS_Uninitialized:
     188                break;
    171189            case CS_Empty:
    172190                break;
     
    227245    std::string CommandExecutor::complete(const std::string& command)
    228246    {
    229         if (CommandExecutor::getEvaluation().processedCommand_ != command)
     247        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    230248            CommandExecutor::parse(command);
    231249
     
    246264        switch (evaluation.state_)
    247265        {
     266            case CS_Uninitialized:
     267                break;
    248268            case CS_Empty:
    249                 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(temp));
     269                return (CommandExecutor::getCommonBegin(temp));
    250270                break;
    251271            case CS_FunctionClass_Or_Shortcut_Or_Keyword:
     
    258278                break;
    259279            case CS_Function:
    260                 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_));
     280                if (tokens.size() >= 1)
     281                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_);
    261282                break;
    262283            case CS_Function_Params:
     
    267288                break;
    268289            case CS_ConfigValueClass:
    269                 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_));
     290                if (tokens.size() >= 1)
     291                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_);
    270292                break;
    271293            case CS_ConfigValue:
    272                 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_));
     294                if (tokens.size() >= 2)
     295                    return tokens[0] + " " + tokens[1] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_);
    273296                break;
    274297            case CS_ConfigValueType:
     
    279302                break;
    280303            case CS_KeybindKey:
    281                 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_));
     304                if (tokens.size() >= 1)
     305                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_);
    282306                break;
    283307            case CS_KeybindCommand:
     
    296320    std::string CommandExecutor::hint(const std::string& command)
    297321    {
    298         if (CommandExecutor::getEvaluation().processedCommand_ != command)
     322        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    299323            CommandExecutor::parse(command);
    300324
     
    308332        switch (evaluation.state_)
    309333        {
     334            case CS_Uninitialized:
     335                break;
    310336            case CS_Empty:
    311337                return (CommandExecutor::dump(evaluation.listOfPossibleShortcuts_) + "\n" + CommandExecutor::dump(evaluation.listOfPossibleFunctionClasses_));
     
    358384                break;
    359385            case CS_Error:
    360                 return "Error";
     386                return CommandExecutor::getEvaluation().errorMessage_;
    361387                break;
    362388        }
     
    381407        switch (CommandExecutor::getEvaluation().state_)
    382408        {
     409            case CS_Uninitialized:
     410                // Impossible
     411                break;
    383412            case CS_Empty:
    384413                if (CommandExecutor::argumentsGiven() == 0)
     
    635664                        {
    636665                            CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_);
    637                             if (CommandExecutor::getEvaluation().configvalueclass_ != 0)
     666                            if (CommandExecutor::getEvaluation().configvalue_ != 0)
    638667                            {
    639668                                // There is a perfect match: Add a whitespace and continue parsing
     
    791820            if ((*it).second->hasConsoleCommands())
    792821            {
    793                 if ((*it).first.find(getLowercase(fragment)) == 0)
     822                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    794823                {
    795824                    CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.push_back(&(*it).first);
     
    805834        for (std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
    806835        {
    807             if ((*it).first.find(getLowercase(fragment)) == 0)
     836            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    808837            {
    809838                CommandExecutor::getEvaluation().listOfPossibleShortcuts_.push_back(&(*it).first);
     
    818847        for (std::map<std::string, ExecutorStatic*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
    819848        {
    820             if ((*it).first.find(getLowercase(fragment)) == 0)
     849            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    821850            {
    822851                CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(&(*it).first);
     
    833862            if ((*it).second->hasConfigValues())
    834863            {
    835                 if ((*it).first.find(getLowercase(fragment)) == 0)
     864                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    836865                {
    837866                    CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.push_back(&(*it).first);
     
    847876        for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMapBegin(); it != identifier->getLowercaseConfigValueMapEnd(); ++it)
    848877        {
    849             if ((*it).first.find(getLowercase(fragment)) == 0)
     878            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    850879            {
    851880                CommandExecutor::getEvaluation().listOfPossibleConfigValues_.push_back(&(*it).first);
     
    908937        std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMap().find(getLowercase(name));
    909938        if (it != identifier->getLowercaseConfigValueMapEnd())
     939        {
    910940            return (*it).second;
     941        }
    911942
    912943        return 0;
Note: See TracChangeset for help on using the changeset viewer.