Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5204 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Sep 18, 2005, 1:37:58 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Shell now has a real nice help function

Location:
trunk/src/lib/shell
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell.cc

    r5201 r5204  
    4040SHELL_COMMAND(deactivate, Shell, deactivate)
    4141    ->describe("Deactivates the Shell. (moves it into background)")
    42     ->setAlias("deactivate");
    43 
     42    ->setAlias("hide");
    4443
    4544/**
  • trunk/src/lib/shell/shell.h

    r5197 r5204  
    22 * @file shell.h
    33 * Definition of a on-screen-shell
    4 */
     4 *
     5 * @todo check for smooth deletion process
     6 */
    57
    68#ifndef _SHELL_H
  • trunk/src/lib/shell/shell_command.cc

    r5203 r5204  
    212212    ShellCommandClass::commandClassList = new tList<ShellCommandClass>;
    213213    ShellCommand<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debugDyn);
     214  }
     215}
     216
     217void ShellCommandClass::help(const char* className)
     218{
     219  if (className == NULL)
     220    return;
     221  if (likely(ShellCommandClass::commandClassList != NULL))
     222  {
     223    tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();
     224    ShellCommandClass* elemCL = itCL->firstElement();
     225    while(elemCL != NULL)
     226    {
     227      if (elemCL->className && !strcasecmp(className, elemCL->className))
     228      {
     229        PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());
     230        tIterator<ShellCommandBase>* iterator = elemCL->commandList->getIterator();
     231        const ShellCommandBase* elem = iterator->firstElement();
     232        while(elem != NULL)
     233        {
     234          PRINT(0)("  command:'%s' : params:%d: ", elem->getName(), elem->paramCount);
     235          for (unsigned int i = 0; i< elem->paramCount; i++)
     236            PRINT(0)("%s ", ShellCommandBase::paramToString(elem->parameters[i]));
     237          if (elem->description != NULL)
     238            PRINT(0)("- %s", elem->description);
     239          PRINT(0)("\n");
     240          elem = iterator->nextElement();
     241        }
     242        delete iterator;
     243
     244        delete itCL;
     245        return;
     246      }
     247      elemCL = itCL->nextElement();
     248    }
     249    delete itCL;
     250    PRINTF(3)("Class %s not found in Command's classes\n", className);
     251  }
     252  else
     253  {
     254    PRINTF(1)("List of commandClasses does not exist");
    214255  }
    215256}
     
    413454          if (objectList != NULL)
    414455          {
    415             elemAL->getCommand()->executeCommand(objectList->firstElement(), executionString+inputSplits.getOffset(1));
     456            if (inputSplits.getCount() > 1)
     457              elemAL->getCommand()->executeCommand(objectList->firstElement(), executionString+inputSplits.getOffset(1));
     458            else
     459              elemAL->getCommand()->executeCommand(objectList->firstElement(), "");
    416460            delete itAL;
    417461            return true;
     
    441485      delete itCL;
    442486    }
    443 
    444487
    445488    if (classID != CL_NULL && inputSplits.getCount() >= 2 && objectList != NULL)
     
    484527        }
    485528        delete itCMD;
    486 
    487       }
    488 
    489     }
    490 
    491 
    492   }
    493 
     529      }
     530    }
     531  }
    494532}
    495533
  • trunk/src/lib/shell/shell_command.h

    r5197 r5204  
    22 * @file shell_command.h
    33 * Definition of a on-screen-shell
     4 * @todo simple way to supply Default Values with the macro.
    45*/
    56
     
    5960    static void unregisterAllCommands();
    6061
     62    static void help (const char* className);
     63
    6164  private:
    6265    ShellCommandClass(const char* className);
     
    310313    {
    311314//      if (parameters != NULL)
    312       SubString sub(parameters);
     315      SubString sub(parameters, true);
    313316//! FUNCTOR_LIST is the List of Executive Functions
    314317#define FUNCTOR_LIST(x) ShellCommandExecute ## x
  • trunk/src/lib/shell/shell_input.cc

    r5202 r5204  
    177177 * prints out some nice help about the Shell
    178178 */
    179 void ShellInput::help()
    180 {
    181   PRINT(0)("Help for the most important Shell-commands\n");
    182   PRINT(0)("F1 - HELP; F2 - DEBUG; ` - open/close shell\n");
    183   PRINT(0)("input order:\n");
    184   PRINT(0)("ClassName [objectName] function [parameter1, [parameter2 ...]]  or\n");
    185   PRINT(0)("Alias [parameter]\n");
     179void ShellInput::help(const char* className, const char* functionName)
     180{
     181  if (strlen(className) == 0)
     182  {
     183    PRINT(0)("Help for the most important Shell-commands\n");
     184    PRINT(0)("F1 - HELP; F2 - DEBUG; ` - open/close shell\n");
     185    PRINT(0)("input order:\n");
     186    PRINT(0)("ClassName [objectName] function [parameter1, [parameter2 ...]]  or\n");
     187    PRINT(0)("Alias [parameter]\n");
     188    PRINT(0)("- Also try 'help className'");
     189  }
     190  else if (strlen (className) > 0 && strlen (functionName) == 0)
     191  {
     192    ShellCommandClass::help(className);
     193    //PRINTF(1)("%s::%s\n", className, functionName);
     194  }
    186195}
    187196
  • trunk/src/lib/shell/shell_input.h

    r5202 r5204  
    3232  void setRepeatDelay(float repeatDelay, float repeatRate);
    3333  bool executeCommand();
    34   void help();
     34  void help(const char* className = "", const char* function = "");
    3535
    3636  virtual void tick(float dt);
Note: See TracChangeset for help on using the changeset viewer.