[1390] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[1402] | 29 | #include <iostream> |
---|
[1434] | 30 | #include <map> |
---|
[1402] | 31 | |
---|
[1390] | 32 | #include "ArgumentCompletionFunctions.h" |
---|
[1434] | 33 | #include "CoreIncludes.h" |
---|
| 34 | #include "Identifier.h" |
---|
| 35 | #include "ConfigValueContainer.h" |
---|
| 36 | #include "TclThreadManager.h" |
---|
| 37 | #include "util/String.h" |
---|
[1390] | 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
| 41 | namespace autocompletion |
---|
| 42 | { |
---|
[1430] | 43 | ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)() |
---|
[1390] | 44 | { |
---|
[1430] | 45 | return std::list<std::pair<std::string, std::string> >(); |
---|
[1390] | 46 | } |
---|
[1434] | 47 | |
---|
| 48 | ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)() |
---|
| 49 | { |
---|
| 50 | std::list<std::pair<std::string, std::string> > classlist; |
---|
| 51 | |
---|
| 52 | for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it) |
---|
| 53 | if ((*it).second->hasConfigValues()) |
---|
| 54 | classlist.push_back(std::pair<std::string, std::string>(getLowercase((*it).first), (*it).second->getName())); |
---|
| 55 | |
---|
| 56 | return classlist; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& classname) |
---|
| 60 | { |
---|
| 61 | std::list<std::pair<std::string, std::string> > configvalues; |
---|
| 62 | std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname); |
---|
| 63 | |
---|
| 64 | if (identifier != Identifier::getIdentifierMapEnd() && (*identifier).second->hasConfigValues()) |
---|
| 65 | { |
---|
| 66 | for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it) |
---|
| 67 | configvalues.push_back(std::pair<std::string, std::string>(getLowercase((*it).first), (*it).second->getName())); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | return configvalues; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& varname, const std::string& classname) |
---|
| 74 | { |
---|
| 75 | std::list<std::pair<std::string, std::string> > oldvalue; |
---|
| 76 | std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname)); |
---|
| 77 | if (identifier != Identifier::getLowercaseIdentifierMapEnd()) |
---|
| 78 | { |
---|
| 79 | std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); |
---|
| 80 | if (variable != (*identifier).second->getLowercaseConfigValueMapEnd()) |
---|
| 81 | { |
---|
| 82 | std::string valuestring = (*variable).second->toString(); |
---|
| 83 | oldvalue.push_back(std::pair<std::string, std::string>(valuestring, valuestring)); |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | return oldvalue; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)() |
---|
| 90 | { |
---|
| 91 | return TclThreadManager::getInstance().getThreadList(); |
---|
| 92 | } |
---|
[1390] | 93 | } |
---|
| 94 | } |
---|