- Timestamp:
- Apr 28, 2006, 12:03:54 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7411 r7412 295 295 } 296 296 297 ShellCommand* ShellCommand::completionPlugin(unsigned int parameter, const CompletorPlugin& completorPlugin) 298 { 299 if (this == NULL || this->executor == NULL) 300 return NULL; 301 302 if (parameter >= this->executor->getParamCount()) 303 { 304 PRINTF(1)("Parameter %d not inside of valid ParameterCount %d of Command %s::%s\n", 305 parameter, this->executor->getParamCount(), this->getName(), this->shellClass->getName()); 306 } 307 else 308 { 309 delete this->completors[parameter]; 310 this->completors[parameter] = completorPlugin.clone(); 311 } 312 return this; 313 } 314 315 297 316 /** 298 317 * @brief prints out nice information about the Shells Commands … … 331 350 332 351 352 353 /////////// 354 // ALIAS // 355 /////////// 356 333 357 /** 334 358 * @param aliasName the name of the Alias -
trunk/src/lib/shell/shell_command.h
r7411 r7412 62 62 friend class ShellCommandClass; 63 63 public: 64 //! an enumerator for different types the Shell parses.65 typedef enum {66 NullRecognition = 0,67 ClassRecognition = 1,68 ObjectRecognition = 2,69 FunctionRecognition = 4,70 AliasRecognition = 8,71 ParameterRecognition = 16,72 } RecognitionType;73 74 64 static bool execute (const std::string& executionString); 75 65 … … 79 69 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 80 70 const MultiType& value4 = MT_NULL); 71 ShellCommand* completionPlugin(unsigned int parameter, const CompletorPlugin& completorPlugin); 81 72 82 73 static ShellCommand* registerCommand(const std::string& commandName, const std::string& className, const Executor& executor); -
trunk/src/lib/shell/shell_completion.cc
r7409 r7412 114 114 if (sc != NULL) 115 115 { 116 std::vector<std::string> test; 117 sc->getCompletorPlugin(0)->addToCompleteList(test, inputSplits[inputSplits.size()-1]); 116 std::vector<std::string> completed; 117 sc->getCompletorPlugin(0)->addToCompleteList(completed, inputSplits[inputSplits.size()-1]); 118 for (unsigned int i = 0; i < completed.size(); i++) 119 this->completionList.push_back(CompletionElement(completed[i], ParamCompletion)); 118 120 } 119 121 } … … 256 258 !nocaseCmp(*string, completionBegin, searchLength)) 257 259 { 258 CompletionElement newElem; 259 newElem.name = (*string); 260 newElem.type = type; 261 this->completionList.push_back(newElem); 260 this->completionList.push_back(CompletionElement (*string, type)); 262 261 } 263 262 } … … 282 281 !nocaseCmp((*bo)->getName(), completionBegin, searchLength)) 283 282 { 284 CompletionElement newElem; 285 newElem.name = (*bo)->getName(); 286 newElem.type = type; 287 this->completionList.push_back(newElem); 283 this->completionList.push_back(CompletionElement((*bo)->getName(), type)); 288 284 } 289 285 } … … 316 312 case AliasCompletion: 317 313 return typeNames[4]; 314 case ParamCompletion: 315 return typeNames[5]; 318 316 } 319 317 } … … 326 324 "object", 327 325 "function", 328 "alias" 326 "alias", 327 "parameter", 329 328 }; 330 329 -
trunk/src/lib/shell/shell_completion.h
r7406 r7412 29 29 FunctionCompletion = 4, 30 30 AliasCompletion = 8, 31 ParamCompletion = 16, 31 32 } CompletionType; 32 33 … … 34 35 struct CompletionElement 35 36 { 37 CompletionElement(std::string name, CompletionType type) : name(name), type(type) {} 36 38 std::string name; //!< the Name of the Element to be completed. 37 39 CompletionType type; //!< the type of the Element -
trunk/src/lib/shell/shell_completion_plugin.cc
r7409 r7412 47 47 void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 48 48 { 49 printf("TEST\n"); 49 50 unsigned int inputLen = completionBegin.size(); 50 51 for (unsigned int i = 0; i < this->_size; ++i) 52 { 53 printf("%s\n", this->_stringArray[i].c_str()); 51 54 if (!nocaseCmp(this->_stringArray[i], completionBegin, inputLen)) 52 55 completionList.push_back(this->_stringArray[i]); 56 } 53 57 } 54 58 -
trunk/src/lib/util/helper_functions.cc
r7371 r7412 146 146 int nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len) 147 147 { 148 if (len == 0) 149 return 0; 148 150 std::string::const_iterator it1=s1.begin(); 149 151 std::string::const_iterator it2=s2.begin(); -
trunk/src/story_entities/game_world.cc
r7391 r7412 62 62 63 63 64 SHELL_COMMAND(speed, GameWorld, setSpeed); 65 SHELL_COMMAND(playmode, GameWorld, setPlaymode); 64 SHELL_COMMAND(speed, GameWorld, setSpeed) ->describe("set the Speed of the Level"); 65 SHELL_COMMAND(playmode, GameWorld, setPlaymode) 66 ->describe("Set the Playmode of the current Level") 67 ->completionPlugin(0, OrxShell::CompletorStringArray(Playable::playmodeNames, Playable::PlaymodeCount)); 68 66 69 SHELL_COMMAND_STATIC(togglePNodeVisibility, GameWorld, GameWorld::togglePNodeVisibility); 67 70 SHELL_COMMAND_STATIC(toggleBVVisibility, GameWorld, GameWorld::toggleBVVisibility); … … 292 295 this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode)) 293 296 { 294 PRINTF(3)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode) );297 PRINTF(3)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str()); 295 298 } 296 299 else 297 300 { 298 PRINTF(1)("Unable to set Playmode %d:%s\n", playmode, Playable::playmodeToString(playmode) );301 PRINTF(1)("Unable to set Playmode %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str()); 299 302 } 300 303 } -
trunk/src/world_entities/playable.cc
r7356 r7412 563 563 Playable::Playmode Playable::stringToPlaymode(const std::string& playmode) 564 564 { 565 if (playmode == "Vertical")565 if (playmode == Playable::playmodeNames[0]) 566 566 return Playable::Vertical; 567 if (playmode == "Horizontal")567 if (playmode == Playable::playmodeNames[1]) 568 568 return Playable::Horizontal; 569 if (playmode == "FromBehind")569 if (playmode == Playable::playmodeNames[2]) 570 570 return Playable::FromBehind; 571 if (playmode == "Full3D")571 if (playmode == Playable::playmodeNames[3]) 572 572 return Playable::Full3D; 573 573 … … 581 581 * @returns the String. 582 582 */ 583 const char*Playable::playmodeToString(Playable::Playmode playmode)583 const std::string& Playable::playmodeToString(Playable::Playmode playmode) 584 584 { 585 585 switch(playmode) 586 586 { 587 587 case Playable::Vertical: 588 return "Vertical";588 return Playable::playmodeNames[0]; 589 589 case Playable::Horizontal: 590 return "Horizontal";590 return Playable::playmodeNames[1]; 591 591 case Playable::FromBehind: 592 return "FromBehind";592 return Playable::playmodeNames[2]; 593 593 case Playable::Full3D: 594 return "Full3D";594 return Playable::playmodeNames[3]; 595 595 596 596 default: 597 return "Full3D"; 598 } 599 600 } 597 return Playable::playmodeNames[3]; 598 } 599 } 600 601 /** 602 * @brief PlaymodeNames 603 */ 604 const std::string Playable::playmodeNames[] = 605 { 606 "Vertical", 607 "Horizontal", 608 "FromBehind", 609 "Full3D" 610 }; -
trunk/src/world_entities/playable.h
r7351 r7412 33 33 FromBehind = 4, //!< Seen from behind (move in z-y) 34 34 Full3D = 8, //!< Full featured 3D-mode. (move in all directions x-y-z) 35 36 PlaymodeCount = 4, 35 37 } Playmode; 36 38 … … 87 89 // Transformations: 88 90 static Playable::Playmode stringToPlaymode(const std::string& playmode); 89 static const char* playmodeToString(Playable::Playmode playmode); 91 static const std::string& playmodeToString(Playable::Playmode playmode); 92 static const std::string playmodeNames[]; 93 90 94 protected: 91 95 Playable();
Note: See TracChangeset
for help on using the changeset viewer.