| 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 | |
|---|
| 29 | #include "ConsoleCommand.h" |
|---|
| 30 | |
|---|
| 31 | namespace orxonox |
|---|
| 32 | { |
|---|
| 33 | ConsoleCommand::ConsoleCommand(FunctorStatic* functor, const std::string& name) : ExecutorStatic(functor, name) |
|---|
| 34 | { |
|---|
| 35 | this->accessLevel_ = AccessLevel::None; |
|---|
| 36 | this->autocompletionFunction_[0] = &autocompletion::fallback; |
|---|
| 37 | this->autocompletionFunction_[1] = &autocompletion::fallback; |
|---|
| 38 | this->autocompletionFunction_[2] = &autocompletion::fallback; |
|---|
| 39 | this->autocompletionFunction_[3] = &autocompletion::fallback; |
|---|
| 40 | this->autocompletionFunction_[4] = &autocompletion::fallback; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | ConsoleCommand& ConsoleCommand::setArgumentCompletionList(unsigned int param, const std::list<std::pair<std::string, std::string> >& (*function) (void)) |
|---|
| 44 | { |
|---|
| 45 | if (param < 5) |
|---|
| 46 | this->autocompletionFunction_[param] = function; |
|---|
| 47 | else |
|---|
| 48 | { |
|---|
| 49 | COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << ": index out of bound." << std::endl; |
|---|
| 50 | } |
|---|
| 51 | return (*this); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | const std::list<std::pair<std::string, std::string> >& ConsoleCommand::getArgumentCompletionList(unsigned int param) const |
|---|
| 55 | { |
|---|
| 56 | if (param < 5) |
|---|
| 57 | return (*this->autocompletionFunction_[param])(); |
|---|
| 58 | else |
|---|
| 59 | return autocompletion::fallback(); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListBegin(unsigned int param) const |
|---|
| 63 | { |
|---|
| 64 | std::cout << "3_1: param: " << param << "\n"; |
|---|
| 65 | if (param < 5) |
|---|
| 66 | { |
|---|
| 67 | std::cout << "3_2: >" << this->autocompletionFunction_[param] << "<\n"; |
|---|
| 68 | return (*this->autocompletionFunction_[param])().begin(); |
|---|
| 69 | } |
|---|
| 70 | else |
|---|
| 71 | { |
|---|
| 72 | std::cout << "3_3\n"; |
|---|
| 73 | return autocompletion::fallback().begin(); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListEnd(unsigned int param) const |
|---|
| 78 | { |
|---|
| 79 | std::cout << "4_1: param: " << param << "\n"; |
|---|
| 80 | if (param < 5) |
|---|
| 81 | { |
|---|
| 82 | std::cout << "4_2: >" << this->autocompletionFunction_[param] << "<\n"; |
|---|
| 83 | return (*this->autocompletionFunction_[param])().end(); |
|---|
| 84 | } |
|---|
| 85 | else |
|---|
| 86 | { |
|---|
| 87 | std::cout << "4_3\n"; |
|---|
| 88 | return autocompletion::fallback().end(); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | } |
|---|