[4597] | 1 | /* |
---|
[4250] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[4285] | 12 | main-programmer: Benjamin Grauer |
---|
[4250] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[5546] | 16 | #include "load_param_description.h" |
---|
[5556] | 17 | |
---|
[5691] | 18 | #include "multi_type.h" |
---|
[8362] | 19 | #include "debug.h" |
---|
| 20 | |
---|
[4860] | 21 | /** |
---|
[4836] | 22 | * @param paramName the name of the parameter to load |
---|
[5546] | 23 | */ |
---|
[7221] | 24 | LoadParamDescription::LoadParamDescription(const std::string& paramName) |
---|
[9772] | 25 | : _name(paramName), _parameterCount(0) |
---|
[9765] | 26 | { } |
---|
[4254] | 27 | |
---|
[4256] | 28 | /** |
---|
[4836] | 29 | * removes all the alocated memory |
---|
[5546] | 30 | */ |
---|
[4746] | 31 | LoadParamDescription::~LoadParamDescription() |
---|
[9772] | 32 | {} |
---|
[4254] | 33 | |
---|
[4256] | 34 | /** |
---|
[4836] | 35 | * @param descriptionText The text to set as a description for this Parameter |
---|
[5546] | 36 | */ |
---|
[7221] | 37 | void LoadParamDescription::setDescription(const std::string& descriptionText) |
---|
[4255] | 38 | { |
---|
[9767] | 39 | this->_description = descriptionText; |
---|
[4255] | 40 | } |
---|
[4254] | 41 | |
---|
[9772] | 42 | void LoadParamDescription::setValues(unsigned int paramCount, |
---|
| 43 | const MultiType* const defaultValues, |
---|
| 44 | bool retVal) |
---|
| 45 | { |
---|
| 46 | this->_parameterCount = paramCount; |
---|
| 47 | for (unsigned int i = 0; i < paramCount; ++i) |
---|
| 48 | { |
---|
| 49 | this->_defaultValues.push_back(defaultValues[i].getString()); |
---|
| 50 | this->_types.push_back(MultiType::MultiTypeToString(defaultValues[i].getType())); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
[4256] | 56 | /** |
---|
[4836] | 57 | * prints out this parameter, its input method and the description (if availiable) |
---|
[5546] | 58 | */ |
---|
[4746] | 59 | void LoadParamDescription::print() const |
---|
[4255] | 60 | { |
---|
[9772] | 61 | PRINT(0)(" <%s>", this->_name.c_str()); |
---|
[9767] | 62 | for (unsigned int i = 0; i < this->_parameterCount; i++) |
---|
[5546] | 63 | { |
---|
| 64 | if (i > 0) |
---|
| 65 | PRINT(3)(","); |
---|
[5634] | 66 | // FIXME |
---|
| 67 | // switch (this->types[i]) |
---|
[9772] | 68 | // { |
---|
| 69 | // default: |
---|
| 70 | // PRINTF(3)("none"); |
---|
| 71 | // break; |
---|
| 72 | // case ParameterBool: |
---|
| 73 | // PRINT(3)("bool"); |
---|
| 74 | // break; |
---|
| 75 | // case ParameterChar: |
---|
| 76 | // PRINT(3)("char"); |
---|
| 77 | // break; |
---|
| 78 | // case ParameterString: |
---|
| 79 | // PRINT(3)("string"); |
---|
| 80 | // break; |
---|
| 81 | // case ParameterInt: |
---|
| 82 | // PRINT(3)("int"); |
---|
| 83 | // break; |
---|
| 84 | // case ParameterUInt: |
---|
| 85 | // PRINT(3)("Uint"); |
---|
| 86 | // break; |
---|
| 87 | // case ParameterFloat: |
---|
| 88 | // PRINT(3)("float"); |
---|
| 89 | // break; |
---|
| 90 | // case ParameterLong: |
---|
| 91 | // PRINT(3)("long"); |
---|
| 92 | // break; |
---|
| 93 | // case ParameterXML: |
---|
| 94 | // PRINT(3)("XML"); |
---|
| 95 | // break; |
---|
| 96 | // } |
---|
[5546] | 97 | } |
---|
[9772] | 98 | PRINT(0)("</%s>", this->_name.c_str()); |
---|
[9767] | 99 | if (!this->_description.empty()) |
---|
[9773] | 100 | PRINT(0)(" <!-- %s", this->_description.c_str()); |
---|
[4623] | 101 | // default values |
---|
[9767] | 102 | if (this->_parameterCount > 0) |
---|
[4623] | 103 | { |
---|
[9772] | 104 | PRINT(0)(" (Default: "); |
---|
[9767] | 105 | for (unsigned int i = 0; i < this->_parameterCount; i++) |
---|
[4623] | 106 | { |
---|
| 107 | if (i > 0) |
---|
[9772] | 108 | PRINT(0)(", "); |
---|
[9767] | 109 | if (this->_types[i] == "string") |
---|
[4625] | 110 | { // leave brackets !! |
---|
[9772] | 111 | PRINT(0)("\"%s\"", this->_defaultValues[i].c_str()); |
---|
[4625] | 112 | } |
---|
| 113 | else |
---|
| 114 | { |
---|
[9772] | 115 | PRINT(0)("%s", this->_defaultValues[i].c_str()); |
---|
[4625] | 116 | } |
---|
[4623] | 117 | } |
---|
[9772] | 118 | PRINT(0)(")"); |
---|
[4623] | 119 | } |
---|
[9773] | 120 | if (!this->_description.empty() || this->_parameterCount > 0) |
---|
| 121 | PRINT(0)(" -->"); |
---|
| 122 | |
---|
[9772] | 123 | PRINT(0)("\n"); |
---|
[4255] | 124 | } |
---|
[9768] | 125 | |
---|
| 126 | |
---|