[Orxonox-commit 2527] r7232 - code/branches/consolecommands3/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Fri Aug 27 20:41:22 CEST 2010
Author: landauf
Date: 2010-08-27 20:41:22 +0200 (Fri, 27 Aug 2010)
New Revision: 7232
Modified:
code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
Log:
hide commands and command groups from auto-completion if they are inactive/denied/hidden
Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc 2010-08-27 17:39:37 UTC (rev 7231)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc 2010-08-27 18:41:22 UTC (rev 7232)
@@ -56,14 +56,23 @@
return ArgumentCompletionList();
}
+ bool groupIsVisible(const std::map<std::string, _ConsoleCommand*>& group)
+ {
+ for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)
+ if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
+ return true;
+
+ return false;
+ }
+
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)()
{
ArgumentCompletionList groupList;
const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& commands = _ConsoleCommand::getCommands();
for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
- // todo: check if active / not hidden / not denied
- groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
+ if (groupIsVisible(it_group->second))
+ groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.find("");
if (it_group != commands.end())
@@ -71,8 +80,8 @@
groupList.push_back(ArgumentCompletionListElement("\n"));
for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
- // todo: check if active / not hidden / not denied
- groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+ if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
+ groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
}
return groupList;
@@ -92,8 +101,8 @@
if (it_group != _ConsoleCommand::getCommands().end())
{
for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
- // todo: check if active / not hidden / not denied
- commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+ if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
+ commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
}
return commandList;
More information about the Orxonox-commit
mailing list