Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5129 in orxonox.OLD for trunk


Ignore:
Timestamp:
Aug 25, 2005, 10:52:11 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: minor extension-addition to the Shell.

Location:
trunk/src
Files:
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r5100 r5129  
    3434orxonox_SOURCES = orxonox.cc \
    3535                  util/shell.cc \
     36                  util/shell_command.cc \
    3637                  util/loading/game_loader.cc \
    3738                  util/track/track_manager.cc \
     
    101102                 util/state.h \
    102103                 util/shell.h \
     104                 util/shell_command.h \
    103105                 util/user_control.h \
    104106                 util/resource_manager.h \
  • trunk/src/Makefile.in

    r5100 r5129  
    5454PROGRAMS = $(bin_PROGRAMS)
    5555am_orxonox_OBJECTS = orxonox-orxonox.$(OBJEXT) orxonox-shell.$(OBJEXT) \
    56         orxonox-game_loader.$(OBJEXT) orxonox-track_manager.$(OBJEXT) \
    57         orxonox-track_node.$(OBJEXT) orxonox-pilot_node.$(OBJEXT) \
    58         orxonox-animation.$(OBJEXT) orxonox-animation3d.$(OBJEXT) \
     56        orxonox-shell_command.$(OBJEXT) orxonox-game_loader.$(OBJEXT) \
     57        orxonox-track_manager.$(OBJEXT) orxonox-track_node.$(OBJEXT) \
     58        orxonox-pilot_node.$(OBJEXT) orxonox-animation.$(OBJEXT) \
     59        orxonox-animation3d.$(OBJEXT) \
    5960        orxonox-animation_player.$(OBJEXT) \
    6061        orxonox-fast_factory.$(OBJEXT) \
     
    122123@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-satellite.Po \
    123124@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-shell.Po \
     125@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-shell_command.Po \
    124126@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-skybox.Po \
    125127@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-skysphere.Po \
     
    292294orxonox_SOURCES = orxonox.cc \
    293295                  util/shell.cc \
     296                  util/shell_command.cc \
    294297                  util/loading/game_loader.cc \
    295298                  util/track/track_manager.cc \
     
    359362                 util/state.h \
    360363                 util/shell.h \
     364                 util/shell_command.h \
    361365                 util/user_control.h \
    362366                 util/resource_manager.h \
     
    528532@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-satellite.Po@am__quote@
    529533@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-shell.Po@am__quote@
     534@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-shell_command.Po@am__quote@
    530535@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-skybox.Po@am__quote@
    531536@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-skysphere.Po@am__quote@
     
    595600@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    596601@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-shell.obj `if test -f 'util/shell.cc'; then $(CYGPATH_W) 'util/shell.cc'; else $(CYGPATH_W) '$(srcdir)/util/shell.cc'; fi`
     602
     603orxonox-shell_command.o: util/shell_command.cc
     604@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-shell_command.o -MD -MP -MF "$(DEPDIR)/orxonox-shell_command.Tpo" -c -o orxonox-shell_command.o `test -f 'util/shell_command.cc' || echo '$(srcdir)/'`util/shell_command.cc; \
     605@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-shell_command.Tpo" "$(DEPDIR)/orxonox-shell_command.Po"; else rm -f "$(DEPDIR)/orxonox-shell_command.Tpo"; exit 1; fi
     606@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='util/shell_command.cc' object='orxonox-shell_command.o' libtool=no @AMDEPBACKSLASH@
     607@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-shell_command.Po' tmpdepfile='$(DEPDIR)/orxonox-shell_command.TPo' @AMDEPBACKSLASH@
     608@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     609@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-shell_command.o `test -f 'util/shell_command.cc' || echo '$(srcdir)/'`util/shell_command.cc
     610
     611orxonox-shell_command.obj: util/shell_command.cc
     612@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-shell_command.obj -MD -MP -MF "$(DEPDIR)/orxonox-shell_command.Tpo" -c -o orxonox-shell_command.obj `if test -f 'util/shell_command.cc'; then $(CYGPATH_W) 'util/shell_command.cc'; else $(CYGPATH_W) '$(srcdir)/util/shell_command.cc'; fi`; \
     613@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-shell_command.Tpo" "$(DEPDIR)/orxonox-shell_command.Po"; else rm -f "$(DEPDIR)/orxonox-shell_command.Tpo"; exit 1; fi
     614@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='util/shell_command.cc' object='orxonox-shell_command.obj' libtool=no @AMDEPBACKSLASH@
     615@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-shell_command.Po' tmpdepfile='$(DEPDIR)/orxonox-shell_command.TPo' @AMDEPBACKSLASH@
     616@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     617@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-shell_command.obj `if test -f 'util/shell_command.cc'; then $(CYGPATH_W) 'util/shell_command.cc'; else $(CYGPATH_W) '$(srcdir)/util/shell_command.cc'; fi`
    597618
    598619orxonox-game_loader.o: util/loading/game_loader.cc
  • trunk/src/lib/graphics/light.cc

    r4836 r5129  
    2222#include "glincl.h"
    2323#include "vector.h"
    24 #include "debug.h"
    2524#include "tinyxml.h"
    2625#include "load_param.h"
    2726#include "factory.h"
     27#include "debug.h"
    2828
    2929using namespace std;
  • trunk/src/lib/physics/physics_engine.cc

    r5115 r5129  
    1717
    1818#include "physics_engine.h"
    19 
    20 #include "debug.h"
    2119
    2220#include "list.h"
  • trunk/src/util/loading/load_param.h

    r5113 r5129  
    1616/*!
    1717 * @file load_param.h
    18   * A Class and macro-functions, that makes our lives easy to load-in parameters
    19 */
     18 * A Class and macro-functions, that makes our lives easy to load-in parameters
     19 */
    2020
    2121#ifndef _LOAD_PARAM_H
     
    2323
    2424#include "base_object.h"
    25 #include "vector.h"
     25
    2626#include "factory.h"
    2727#include "debug.h"
  • trunk/src/util/shell.cc

    r5128 r5129  
    1717
    1818#include "shell.h"
     19#include "shell_command.h"
    1920
    2021#include "text_engine.h"
     
    2223#include "graphics_engine.h"
    2324#include "event_handler.h"
    24 
    25 #include "load_param.h"
     25#include "debug.h"
    2626#include "class_list.h"
    2727
    2828#include "key_names.h"
    29 #include "debug.h"
    3029#include <stdarg.h>
    3130#include <stdio.h>
     
    4847  this->buffer = new tList<char>;
    4948  this->bufferIterator = this->buffer->getIterator();
     49
     50  this->inputHistory = new tList<char>;
     51  //this->commandList = new tList<ShellCommand>;
    5052
    5153  this->textSize = 15;
     
    7375  for (int i = 1; i < SDLK_LAST; i++)
    7476    evh->subscribe(this, ES_SHELL, i);
     77
     78
     79//  this->registerCommand("clear", Shell::)
    7580}
    7681
     
    105110  Shell::singletonRef = NULL;
    106111}
    107 
    108112
    109113/**
     
    448452  this->addBufferLineStatic("Execute Command: %s\n", this->inputLine);
    449453
     454  char* newCommand = new char[strlen(this->inputLine)+1];
     455  strcpy(newCommand, this->inputLine);
     456  this->inputHistory->add(newCommand);
     457
    450458  if (!strcmp(this->inputLine, "clear"))
    451459  {
     
    501509    else if (event.type == SDLK_RETURN)
    502510      this->executeCommand();
     511    /*
     512    else if (event.type == SDLK_UP)
     513    {
     514//      this->flushInputLine();
     515      tIterator<char>* iterator = this->commandList->getIterator();
     516      char* command = iterator->lastElement();
     517      while (command)
     518      {
     519        if (!strcmp (command, inputLine))
     520        {
     521          inputLine = iterator->prevElement();
     522          return;
     523        }
     524        command = iterator->prevElement();
     525      }
     526      inputLine = iterator->lastElement();
     527    }
     528    */
    503529    else if (likely(event.type < 127))
    504530    {
  • trunk/src/util/shell.h

    r5127 r5129  
    3737    /** @returns a Pointer to the only object of this Class */
    3838    inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
    39 
    4039
    4140    void activate();
     
    8281    bool generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);
    8382
    84     const tList<const char>* Shell::createCompleteList(const tList<const char>* inputList, const char* classNameBegin);
    85     const tList<const char>* Shell::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin);
     83    const tList<const char>* createCompleteList(const tList<const char>* inputList, const char* classNameBegin);
     84    const tList<const char>* createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin);
    8685
    8786    // helpers //
     
    9190  private:
    9291    Shell();
    93     static Shell*          singletonRef;           //!< The singleton-reference to the only memeber of this class.
     92    static Shell*            singletonRef;           //!< The singleton-reference to the only memeber of this class.
    9493
    95     unsigned int           bufferSize;             //!< The Size of the buffer
    96     unsigned int           bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
     94    unsigned int             bufferSize;             //!< The Size of the buffer
     95    unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
    9796
    98     Text*                  inputLineText;          //!< The inputLine of the Shell
    99     char*                  inputLine;              //!< the Char-Array of the Buffer
    100     float                  repeatRate;             //!< The Repeat-Delay.
    101     float                  repeatDelay;            //!< The delay of the first Character of a given Character.
    102     float                  delayed;                //!< how much of the delay is remaining.
    103     int                    pressedKey;             //!< the pressed key that will be repeated.
     97    Text*                    inputLineText;          //!< The inputLine of the Shell
     98    char*                    inputLine;              //!< the Char-Array of the Buffer
     99    float                    repeatRate;             //!< The Repeat-Delay.
     100    float                    repeatDelay;            //!< The delay of the first Character of a given Character.
     101    float                    delayed;                //!< how much of the delay is remaining.
     102    int                      pressedKey;             //!< the pressed key that will be repeated.
    104103
    105     tList<char>*           buffer;                 //!< A list of stored char-arrays(strings) to store the history
    106     tIterator<char>*       bufferIterator;         //!< An iterator for the Shells main buffer.
     104    tList<char>*             buffer;                 //!< A list of stored char-arrays(strings) to store the history
     105    tIterator<char>*         bufferIterator;         //!< An iterator for the Shells main buffer.
    107106
    108     Text**                 bufferText;             //!< A list of stored bufferTexts for the display of the buffer
    109     unsigned int           textSize;               //!< The size of the text.
    110     unsigned int           lineSpacing;            //!< The Spacing between lines.
    111     unsigned int           shellHeight;            //!< The hight of the Shell in Pixels
    112     bool                   bActive;                //!< if the shell is active;
     107    tList<char>*             inputHistory;           //!< The history of given commands.
    113108
    114     char                   bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    115     char                   keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
    116     bool                   keepBuffer;
     109    Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer
     110    unsigned int             textSize;               //!< The size of the text.
     111    unsigned int             lineSpacing;            //!< The Spacing between lines.
     112    unsigned int             shellHeight;            //!< The hight of the Shell in Pixels
     113    bool                     bActive;                //!< if the shell is active;
     114
     115    char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
     116    char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
     117    bool                     keepBuffer;
    117118
    118119    // completion
    119     tList<const char>*    completionList;          //!< A list of completions, that are io.
     120    tList<const char>*       completionList;          //!< A list of completions, that are io.
    120121};
    121122
  • trunk/src/util/shell_command.cc

    r5128 r5129  
    1616//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
    1717
    18 #include "shell.h"
     18#include "shell_command.h"
    1919
    20 #include "text_engine.h"
    2120#include "list.h"
    22 #include "graphics_engine.h"
    23 #include "event_handler.h"
    24 
    25 #include "load_param.h"
     21#include "debug.h"
    2622#include "class_list.h"
    2723
    2824#include "key_names.h"
    29 #include "debug.h"
    3025#include <stdarg.h>
    3126#include <stdio.h>
     
    3328using namespace std;
    3429
     30ShellCommandBase::ShellCommandBase(const char* commandName, ClassID classID)
     31{
     32  this->classID = classID;
     33  this->commandName = new char[strlen(commandName)+1];
     34  strcpy(this->commandName, commandName);
    3535
    36 /**
    37  * standard constructor
    38  */
    39 Shell::Shell ()
    40 {
    41   this->setClassID(CL_SHELL, "Shell");
    42   this->setName("Shell");
    43 
    44   this->keepBufferArray[0] = '\0';
    45   this->keepBuffer = false;
    46 
    47   this->bActive = false;
    48   this->buffer = new tList<char>;
    49   this->bufferIterator = this->buffer->getIterator();
    50 
    51   this->textSize = 15;
    52   this->lineSpacing = 5;
    53 
    54   //this->bufferSize = 0;
    55   this->bufferText = NULL;
    56   this->setBufferSize(100);
    57   this->bufferDisplaySize = 10;
    58   this->setAbsCoor2D(3, -400);
    59   this->delayed = 0;
    60   this->setRepeatDelay(.3, .05);
    61   this->pressedKey = SDLK_FIRST;
    62 
    63   this->inputLineText = NULL;
    64   this->inputLine = new char[1];
    65   this->inputLine[0] = '\0';
    66 
    67   this->rebuildText();
    68   this->completionList = NULL;
    69 
    70   // EVENT-Handler subscription of '`' to all States, and all other keyboard commands to ES_SEHLL
    71   EventHandler* evh = EventHandler::getInstance();
    72   evh->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
    73   for (int i = 1; i < SDLK_LAST; i++)
    74     evh->subscribe(this, ES_SHELL, i);
    75 }
    76 
    77 Shell* Shell::singletonRef = NULL;
    78 
    79 /**
    80  * standard deconstructor
    81  */
    82 Shell::~Shell ()
    83 {
    84   // delete the displayable Buffers
    85   for (int i = 0; i < this->bufferDisplaySize; i++)
    86     delete this->bufferText[i];
    87   delete[] this->bufferText;
    88 
    89   // delete the inputLine
    90   delete this->inputLineText;
    91   delete this->inputLine;
    92 
    93   // delete all the Chars in the Buffers
    94   char* charElem = this->bufferIterator->firstElement();
    95   while (charElem != NULL)
    96   {
    97     delete charElem;
    98     charElem = this->bufferIterator->nextElement();
    99   }
    100   delete this->bufferIterator;
    101 
    102 //  if (this->completionList != NULL)
    103     //delete this->completionList;
    104 
    105   Shell::singletonRef = NULL;
    106 }
    107 
    108 
    109 /**
    110  * activates the shell
    111  *
    112  * This also feeds the Last few lines from the main buffers into the displayBuffer
    113  */
    114 void Shell::activate()
    115 {
    116   if (this->bActive == true)
    117     PRINTF(3)("The shell is already active\n");
    118   this->bActive = true;
    119 
    120   EventHandler::getInstance()->setState(ES_SHELL);
    121   this->setRelCoorSoft2D(0, 0, 1, 5);
    122 
    123   this->bufferIterator->lastElement();
    124   for (int i = 0; i < this->bufferDisplaySize; i++)
    125     this->bufferText[i]->setText(this->bufferIterator->prevElement());
    126 }
    127 
    128 /**
    129  * deactiveates the Shell.
    130  */
    131 void Shell::deactivate()
    132 {
    133   if (this->bActive == false)
    134     PRINTF(3)("The shell is already inactive\n");
    135   this->bActive = false;
    136 
    137   EventHandler::getInstance()->setState(ES_GAME);
    138   this->setRelCoorSoft2D(0, -400, 1, 5);
    139 
    140 }
    141 
    142 /**
    143  * sets the size of the text and spacing
    144  * @param textSize the size of the Text in Pixels
    145  * @param lineSpacing the size of the Spacing between two lines in pixels
    146  *
    147  * this also rebuilds the entire Text, inputLine and displayBuffer,
    148  * to be accurate again.
    149  */
    150 void Shell::setTextSize(unsigned int textSize, unsigned int lineSpacing)
    151 {
    152   this->textSize = textSize;
    153   this->lineSpacing = lineSpacing;
    154 
    155   this->rebuildText();
    156 }
    157 
    158 /**
    159  * rebuilds the Text's
    160  *
    161  * use this function, if you changed the Font/Size or something else.
    162  */
    163 void Shell::rebuildText()
    164 {
    165   if (this->inputLineText == NULL)
    166     delete this->inputLineText;
    167   this->inputLineText = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_RENDER_DYNAMIC);
    168   this->inputLineText->setColor(1, 0, 0);
    169   this->inputLineText->setAlignment(TEXT_ALIGN_LEFT);
    170   this->inputLineText->setText(NULL);
    171   this->inputLineText->setParent2D(this);
    172   this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
    173 
    174   this->setBufferDisplaySize(this->bufferDisplaySize);
    175 }
    176 
    177 /**
    178  * sets The count of Lines to display in the buffer.
    179  * @param bufferDisplaySize the count of lines to display in the Shell-Buffer.
    180  */
    181 void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
    182 {
    183   if (this->bufferText != NULL)
    184   {
    185     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    186       delete this->bufferText[i];
    187     delete[] this->bufferText;
    188   }
    189 
    190   this->bufferText = new Text*[bufferDisplaySize];
    191   for (unsigned int i = 0; i < bufferDisplaySize; i++)
    192   {
    193     this->bufferText[i] = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_RENDER_DYNAMIC);
    194     this->bufferText[i]->setColor(1, 0, 0);
    195     this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    196     this->bufferText[i]->setRelCoor2D(calculateLinePosition(i));
    197     this->bufferText[i]->setText(NULL);
    198     this->bufferText[i]->setParent2D(this);
    199   }
    200   this->bufferDisplaySize = bufferDisplaySize;
    201 
    202   this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    203 }
    204 
    205 /**
    206  * deletes all the Buffers
    207  */
    208 void Shell::flushBuffers()
    209 {
    210   // remove all chars from the BufferTexts.
    211   if (this->bufferText)
    212     for (int i = 0; i < this->bufferDisplaySize; i++)
    213     {
    214       this->bufferText[i]->setText(NULL, true);
    215     }
    216 
    217   // delete all the Chars in the Buffers
    218   tIterator<char>* charIterator = this->buffer->getIterator();
    219   char* charElem = charIterator->firstElement();
    220   while (charElem != NULL)
    221   {
    222     delete charElem;
    223 
    224     charElem = charIterator->nextElement();
    225   }
    226   delete charIterator;
    227   delete this->buffer;
    228   this->buffer = new tList<char>;
    229 }
    230 
    231 /**
    232  * adds a new Line to the List of Buffers
    233  * @param line the Line as in the first argument in printf
    234  * @param args the arguments as a va_list
    235  */
    236 bool Shell::addBufferLineStatic(const char* line, ...)
    237 {
    238   va_list arguments;
    239   va_start(arguments, line);
    240 
    241 #if DEBUG < 3
    242   if (Shell::singletonRef == NULL)
    243 #endif
    244 
    245   vprintf(line, arguments);
    246 #if DEBUG < 3
    247   else
    248 #else
    249   if (Shell::singletonRef != NULL)
    250 #endif
    251     Shell::singletonRef->addBufferLine(line, arguments);
    252   return true;
    253 }
    254 
    255 /**
    256  * add a Line to the List of Buffers
    257  * @param line
    258  * @param arguments
    259  *
    260  * This function Adds one line to the buffer.
    261  * and displays the line as the First Line of the display-buffer
    262  */
    263 void Shell::addBufferLine(const char* line, va_list arguments)
    264 {
    265    vsprintf(this->bufferArray, line, arguments);
    266 
    267    char* inputEnd;
    268    char* newLineBegin;
    269    char* newLineEnd;
    270 
    271    // check if we have something left in the buffers
    272    if (unlikely(this->keepBuffer))
    273    {
    274      strcat(this->keepBufferArray, this->bufferArray);
    275      inputEnd = this->keepBufferArray + strlen(this->keepBufferArray);
    276      newLineBegin = this->keepBufferArray;
    277      this->keepBuffer = false;
    278    }
    279    else
    280    {
    281      inputEnd = this->bufferArray + strlen(this->bufferArray);
    282      newLineBegin = this->bufferArray;
    283    }
    284 
    285    // adding all the new Lines
    286    while (newLineBegin < inputEnd)
    287    {
    288      newLineEnd = strchr(newLineBegin, '\n');
    289      if (newLineEnd != NULL && *newLineEnd == '\n')
    290        *newLineEnd = '\0';
    291      else
    292      {
    293 //       newLineEnd = newLineBegin + strlen(newLineBegin);
    294        strcpy(this->keepBufferArray, newLineBegin);
    295        this->keepBuffer = true;
    296        break;
    297      }
    298 
    299      char* addLine = new char[strlen(newLineBegin)+1];
    300      strcpy(addLine, newLineBegin);
    301 
    302      this->buffer->add(addLine);
    303 
    304      if (this->buffer->getSize() > this->bufferSize)
    305      {
    306        delete this->buffer->firstElement();
    307        this->buffer->remove(this->buffer->firstElement());
    308      }
    309 
    310      if (this->bActive)
    311      {
    312        this->printToDisplayBuffer(addLine);
    313      }
    314      newLineBegin = newLineEnd+1;
    315    }
    316 }
    317 
    318 /**
    319  * prints out some text to the input-buffers
    320  * @param text the text to output.
    321  */
    322 void Shell::printToDisplayBuffer(const char* text)
    323 {
    324   if(likely(bufferText != NULL))
    325   {
    326     Text* lastText = this->bufferText[this->bufferDisplaySize-1];
    327 
    328     Text* swapText;
    329     Text* moveText = this->bufferText[0];
    330     this->bufferText[0]->setRelCoorSoft2D(this->calculateLinePosition(1),10);
    331     for (unsigned int i = 1; i < this->bufferDisplaySize; i++)
    332     {
    333       if ( i < this->bufferDisplaySize-1)
    334         this->bufferText[i]->setRelCoorSoft2D(this->calculateLinePosition(i+1),5);
    335       swapText = this->bufferText[i];
    336       this  ->bufferText[i] = moveText;
    337       moveText = swapText;
    338     }
    339     lastText->setRelCoor2D(this->calculateLinePosition(0));
    340     this->bufferText[0] = lastText;
    341 
    342     this->bufferText[0]->setText(text, true);
    343   }
    344 }
    345 
    346 /**
    347  * moves the buffer around lineCount lines upwards (negative values move down)
    348  * @param lineCount the Count of lines to move upwards
    349  *
    350  * @todo
    351  */
    352 void Shell::moveBuffer(int lineCount)
    353 {
    354 }
    355 
    356 /**
    357  * @param lineNumber the n-th line from the bottom
    358  * @returns the Buffer at Line lineNumber
    359  */
    360 const char* Shell::getBufferLine(unsigned int lineNumber)
    361 {
    362   tIterator<char>* charIterator = this->buffer->getIterator();
    363   char* charElem = charIterator->firstElement();
    364 
    365   int i = 1;
    366   while (charElem != NULL)
    367   {
    368     if (i++ < lineNumber)
    369     {
    370       delete charIterator;
    371       return charElem;
    372     }
    373 
    374     charElem = charIterator->nextElement();
    375   }
    376   delete charIterator;
    377 }
    378 
    379 /**
    380  * deletes the InputLine
    381  */
    382 void Shell::flushInputLine()
    383 {
    384   if (likely(this->inputLine != NULL))
    385   {
    386     delete[] this->inputLine;
    387   }
    388   this->inputLine = new char[1];
    389   *this->inputLine = '\0';
    390   this->inputLineText->setText(this->inputLine, true);
    391 }
    392 
    393 /**
    394  * adds one character to the inputLine
    395  * @param character the character to add to the inputLine
    396  */
    397 void Shell::addCharacter(char character)
    398 {
    399   char* addCharLine = new char[strlen(inputLine)+2];
    400 
    401   sprintf(addCharLine, "%s%c", this->inputLine, character);
    402   delete this->inputLine;
    403   this->inputLine = addCharLine;
    404   this->inputLineText->setText(inputLine, true);
    405 }
    406 
    407 /**
    408  * adds multiple Characters to thr inputLine
    409  * @param characters a '\0' terminated char-array to add to the InputLine
    410  */
    411 void Shell::addCharacters(const char* characters)
    412 {
    413   char* addCharLine = new char[strlen(inputLine)+strlen(characters)+1];
    414 
    415   sprintf(addCharLine, "%s%s", this->inputLine, characters);
    416   delete this->inputLine;
    417   this->inputLine = addCharLine;
    418   this->inputLineText->setText(inputLine);
    419 }
    420 
    421 /**
    422  * removes characterCount characters from the InputLine
    423  * @param characterCount the count of Characters to remove from the input Line
    424  */
    425 void Shell::removeCharacters(unsigned int characterCount)
    426 {
    427   if (strlen(this->inputLine) == 0)
    428     return;
    429 
    430   if (characterCount > strlen(this->inputLine))
    431     characterCount = strlen(this->inputLine);
    432 
    433   char* removeCharLine = new char[strlen(inputLine)-characterCount+1];
    434 
    435   strncpy(removeCharLine, this->inputLine, strlen(inputLine)-characterCount);
    436   removeCharLine[strlen(inputLine)-characterCount] = '\0';
    437   delete this->inputLine;
    438   this->inputLine = removeCharLine;
    439   this->inputLineText->setText(inputLine);
    440 }
    441 
    442 /**
    443  * executes the command stored in the inputLine
    444  * @return true if the command was commited successfully, false otherwise
    445  */
    446 bool Shell::executeCommand()
    447 {
    448   this->addBufferLineStatic("Execute Command: %s\n", this->inputLine);
    449 
    450   if (!strcmp(this->inputLine, "clear"))
    451   {
    452     this->flushBuffers();
    453     this->addBufferLine("orxonox - shell\n ==================== \n", NULL);
    454   }
    455 
    456   this->flushInputLine();
    457 
    458   return false;
    459 }
    460 
    461 /**
    462  * sets the Repeate-delay and rate
    463  * @param repeatDelay the Delay it takes, to repeate a key
    464  * @param repeatRate the rate to repeate a pressed key
    465  */
    466 void Shell::setRepeatDelay(float repeatDelay, float repeatRate)
    467 {
    468   this->repeatDelay = repeatDelay;
    469   this->repeatRate = repeatRate;
    470 
    471 }
    472 
    473 /**
    474  * listens for some event
    475  * @param event the Event happened
    476  */
    477 void Shell::process(const Event &event)
    478 {
    479   if (event.bPressed)
    480   {
    481     PRINTF(4)("Shell received command %s\n", SDLKToKeyname(event.type));
    482     if (event.type == SDLK_BACKQUOTE)
    483     {
    484       if (EventHandler::getInstance()->getState() == ES_GAME)
    485         this->activate();
    486       else
    487         this->deactivate();
    488     }
    489     else if (event.type == SDLK_F1)
    490       this->help();
    491     else if (event.type == SDLK_F2)
    492       this->debug();
    493     else if (event.type == SDLK_TAB)
    494       this->autoComplete();
    495     else if (event.type == SDLK_BACKSPACE)
    496     {
    497       this->delayed = this->repeatDelay;
    498       this->pressedKey = SDLK_BACKSPACE;
    499       this->removeCharacters(1);
    500     }
    501     else if (event.type == SDLK_RETURN)
    502       this->executeCommand();
    503     else if (likely(event.type < 127))
    504     {
    505       Uint8 *keystate = SDL_GetKeyState(NULL);
    506       this->delayed = this->repeatDelay;
    507       if (unlikely( keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT] ))
    508       {
    509         this->pressedKey = event.type-32;
    510         this->addCharacter(event.type-32);
    511       }
    512       else
    513       {
    514         this->pressedKey = event.type;
    515         this->addCharacter(event.type);
    516       }
    517     }
    518   }
    519   else // if(!event.bPressed)
    520   {
    521     if (this->pressedKey == event.type || (this->pressedKey == event.type - 32))
    522     {
    523       this->pressedKey = SDLK_FIRST;
    524       this->delayed = 0.0;
    525     }
    526   }
    527 }
    528 
    529 /**
    530  * ticks the Shell for dt Seconds
    531  * @param dt the elapsed time since the last tick();
    532  */
    533 void Shell::tick(float dt)
    534 {
    535   if (this->delayed > 0.0)
    536     this->delayed -= dt;
    537   else if (this->pressedKey != SDLK_FIRST )
    538   {
    539     this->delayed = this->repeatRate;
    540     if (this->pressedKey == SDLK_BACKSPACE)
    541       this->removeCharacters(1);
    542     else if (pressedKey < 127)
    543       this->addCharacter(this->pressedKey);
    544   }
    545 }
    546 
    547 /**
    548  * displays the Shell
    549  */
    550 void Shell::draw() const
    551 {
    552   glPushMatrix();
    553   // transform for alignment.
    554   // setting the Blending effects
    555 
    556   glColor4f(0.0f, 0.0f, 0.8f, .4);
    557   glEnable(GL_BLEND);
    558   glDisable(GL_TEXTURE_2D);
    559   glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    560 
    561 //  glBindTexture(GL_TEXTURE_2D, this->texture);
    562   glBegin(GL_QUADS);
    563 
    564 //  glTexCoord2f(this->texCoord.minU, this->texCoord.minV);
    565   glVertex2f(this->getAbsCoor2D().x,   this->getAbsCoor2D().y  );
    566 
    567 //  glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
    568   glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y  );
    569 
    570 //  glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
    571   glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    572 
    573 //  glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
    574   glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    575 
    576   glEnd();
    577 }
    578 
    579 
    580 /**
    581  * autocompletes the Shell's inputLine
    582  * @returns true, if a result was found, false otherwise
    583  *
    584  * @todo implement it!!
    585  */
    586 bool Shell::autoComplete()
    587 {
    588   //PRINTF(3)("AutoCompletion not implemented yet\n");
    589 
    590   char* completionLine = new char[strlen(inputLine)+1];
    591   strcpy(completionLine, this->inputLine);
    592 
    593   char* commandBegin = strrchr(completionLine, ' ');
    594   if (commandBegin == NULL)
    595     commandBegin = completionLine;
    596   else
    597   {
    598     if(commandBegin >= completionLine + strlen(completionLine))
    599       commandBegin = completionLine + strlen(completionLine);
    600     else
    601       commandBegin++;
    602   }
    603 
    604   char* objectStart;
    605   if (objectStart = strstr(commandBegin, "::"))
    606   {
    607     char* classIdentity = new char[objectStart - commandBegin +1];
    608     strncpy(classIdentity, commandBegin, objectStart - commandBegin);
    609     classIdentity[objectStart - commandBegin] = '\0';
    610     this->objectComplete(objectStart+2, ClassList::StringToID(classIdentity));
    611     delete[] classIdentity;
    612   }
    613   else
    614     this->classComplete(commandBegin);
    615 
    616   delete[] completionLine;
    617 }
    618 
    619 /**
    620  * autocompletes a className
    621  * @param classBegin the Beginning of a String to autoComplete
    622  * @return true on success, false otherwise
    623  */
    624 bool Shell::classComplete(const char* classBegin)
    625 {
    626   if (unlikely(classBegin == NULL))
    627     return false;
    628   const tList<const char>* clList = ClassList::getClassList();
    629   if (clList != NULL)
    630   {
    631     const tList<const char>* classList = this->createCompleteList(clList, classBegin);
    632     if (classList != NULL)
    633       this->generalComplete(classList, classBegin, "%s::", "::");
    634     else
    635       return false;
    636   }
    637   else
    638     return false;
    639   return true;
    640 }
    641 
    642 /**
    643  * autocompletes an ObjectName
    644  * @param objectBegin the beginning string of a Object
    645  * @param classID the ID of the Class to search for.
    646  * @return true on success, false otherwise
    647  */
    648 bool Shell::objectComplete(const char* objectBegin, long classID)
    649 {
    650   printf("%s\n", objectBegin);
    651 
    652   if (unlikely(objectBegin == NULL))
    653     return false;
    654   tList<BaseObject>* boList = ClassList::getList(classID);
    655   if (boList != NULL)
    656   {
    657     printf("\n", boList->firstElement()->getName());
    658     const tList<const char>* objectList = this->createCompleteList(boList, objectBegin);
    659     if (objectList != NULL)
    660       this->generalComplete(objectList, objectBegin, "%s");
    661     else
    662       return false;
    663   }
    664   else
    665     return false;
    666   return true;
    667 }
    668 
    669 bool Shell::functionComplete(const char* functionBegin)
    670 {
    671 }
    672 
    673 /**
    674  * completes the inputline on grounds of an inputList
    675  * @param stringList the List to parse through
    676  * @param begin the String to search in the inputList, and to extend with it.
    677  * @param displayAs how to display the found value to the user, printf-style, !!with only one %s!! ex.: "::%s::"
    678  * @param addBack what should be added at the end of the completion
    679  * @param addFront what should be added to the front of one finished completion
    680  * @return true if ok, false otherwise
    681  */
    682 bool Shell::generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront)
    683 {
    684   if (stringList->getSize() == 0)
    685     return false;
    686 
    687   const char* addString = stringList->firstElement();
    688   unsigned int addLength = 0;
    689   unsigned int inputLenght = strlen(begin);
    690 
    691   if (addString != NULL)
    692     addLength = strlen(addString);
    693   tIterator<const char>* charIterator = stringList->getIterator();
    694   const char* charElem = charIterator->firstElement();
    695   while (charElem != NULL)
    696   {
    697     PRINTF(0)(displayAs, charElem);
    698     for (unsigned int i = inputLenght; i < addLength; i++)
    699       if (addString[i] != charElem[i])
    700     {
    701       addLength = i;
    702       break;
    703     }
    704     charElem = charIterator->nextElement();
    705   }
    706   delete charIterator;
    707 
    708   if (addLength >= inputLenght)
    709   {
    710     char* adder = new char[addLength+1];
    711     strncpy(adder, addString, addLength);
    712     adder[addLength] = '\0';
    713     this->removeCharacters(inputLenght);
    714     this->addCharacters(adder);
    715     if (addBack != NULL && stringList->getSize() == 1)
    716       this->addCharacters("::");
    717     delete[] adder;
    718   }
    719   return true;
    720 }
    721 
    722 /**
    723  * searches for classes, which beginn with classNameBegin
    724  * @param inputList the List to parse through
    725  * @param classNameBegin the beginning string
    726  * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
    727  * !! The strings MUST NOT be deleted !!
    728  */
    729 const tList<const char>* Shell::createCompleteList(const tList<const char>* inputList, const char* classNameBegin)
    730 {
    731   if (inputList == NULL || classNameBegin == NULL)
    732     return NULL;
    733   unsigned int searchLength = strlen(classNameBegin);
    734   if (this->completionList != NULL)
    735     delete this->completionList;
    736   this->completionList = new tList<const char>;
    737 
    738 //  tList<const char>* classList = ClassList::getClassList();
    739 
    740   tIterator<const char>* iterator = inputList->getIterator();
    741   const char* enumString = iterator->firstElement();
    742   while (enumString != NULL)
    743   {
    744     if (strlen(enumString)>searchLength+1 &&
    745         !strncasecmp(enumString, classNameBegin, searchLength))
    746     {
    747       this->completionList->add(enumString);
    748     }
    749     enumString = iterator->nextElement();
    750   }
    751   delete iterator;
    752 
    753   return this->completionList;
    754 }
    755 
    756 /**
    757  * searches for classes, which beginn with classNameBegin
    758  * @param inputList the List to parse through
    759  * @param classNameBegin the beginning string
    760  * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
    761  * !! The strings MUST NOT be deleted !!
    762  */
    763 const tList<const char>* Shell::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin)
    764 {
    765   if (inputList == NULL || classNameBegin == NULL)
    766     return NULL;
    767   unsigned int searchLength = strlen(classNameBegin);
    768   if (this->completionList != NULL)
    769     delete this->completionList;
    770   this->completionList = new tList<const char>;
    771 
    772   tIterator<BaseObject>* iterator = inputList->getIterator();
    773   BaseObject* enumBO = iterator->firstElement();
    774   while (enumBO != NULL)
    775   {
    776     if (enumBO->getName() != NULL &&
    777         strlen(enumBO->getName())>searchLength+1 &&
    778         !strncasecmp(enumBO->getName(), classNameBegin, searchLength))
    779     {
    780       this->completionList->add(enumBO->getName());
    781     }
    782     enumBO = iterator->nextElement();
    783   }
    784   delete iterator;
    785 
    786   return this->completionList;
    787 }
    788 
    789 void Shell::help() const
    790 {
    791   PRINT(0)("Help for the most important Shell-commands\n");
    792   PRINT(0)("F1 - HELP; F2 - DEBUG; ` - open/close shell\n");
    793   PRINT(0)("input order:\n");
    794   PRINT(0)("ClassName::objectName function [parameter1, [parameter2 ...]]  or\n");
    795   PRINT(0)("Command [parameter]\n");
    796 }
    797 
    798 
    799 ///////////////////////
    800 // HELPER FUNCTIONS  //
    801 ///////////////////////
    802 Vector Shell::calculateLinePosition(unsigned int lineNumber)
    803 {
    804   return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) + this->textSize, 0);
     36  ShellCommandBase::commandList->add(this);
    80537}
    80638
    80739
    80840
    809 /**
    810  * displays some nice output from the Shell
    811  */
    812 void Shell::debug() const
     41tList<ShellCommandBase>* ShellCommandBase::commandList = NULL;
     42
     43bool ShellCommandBase::isRegistered(const char* commandName, ClassID classID)
    81344{
    814   PRINT(3)("Debugging output to console (not this shell)\n");
     45  if (ShellCommandBase::commandList == NULL)
     46  {
     47    ShellCommandBase::commandList = new tList<ShellCommandBase>;
     48    return false;
     49  }
    81550
    816   if (this->pressedKey != SDLK_FIRST)
    817     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
     51  tIterator<ShellCommandBase>* iterator = ShellCommandBase::commandList->getIterator();
     52  ShellCommandBase* elem = iterator->firstElement();
     53  while(elem != NULL)
     54  {
     55    if (classID == elem->classID && !strcmp(commandName, elem->commandName))
     56    {
     57//      PRINTF(2)("Command already registered\n");
     58      delete iterator;
     59      return true;
     60    }
     61    elem = iterator->nextElement();
     62  }
     63  delete iterator;
     64  return true;
     65}
    81866
    81967
    820   char* tmpChar = this->bufferIterator->firstElement();
    821   while(tmpChar != NULL)
    822   {
    823     printf(tmpChar);
    824     tmpChar = this->bufferIterator->nextElement();
    825   }
    826 }
  • trunk/src/util/shell_command.h

    r5127 r5129  
    11/*!
    2  * @file shell.h
     2 * @file shell_command.h
    33 * Definition of a on-screen-shell
    44*/
    55
    6 #ifndef _SHELL_H
    7 #define _SHELL_H
     6#ifndef _SHELL_COMMAND_H
     7#define _SHELL_COMMAND_H
    88
    9 #include "element_2d.h"
    10 #include "event_listener.h"
     9#include "base_object.h"
    1110
    1211#include <stdarg.h>
    1312
    14 #define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
     13typedef enum ShellParameterType
     14{
     15  ShellParameterNull,
     16  ShellParameterChar,
     17  ShellParameterString,
     18  ShellParameterInt,
     19  ShellParameterUInt,
     20  ShellParameterFloat,
     21  /* ... */
     22};
    1523
    1624// FORWARD DECLARATION
    17 class Text;
    1825template<class T> class tList;
    1926template<class T> class tIterator;
     27#define MAX_SHELL_COMMAND_SIZE
    2028
    21 //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
    22 /**
    23  * the major idea is, that all the Output can be redirected to the Shell,
    24  * and does not have to be displayed to the opening Shell, this is good,
    25  * for developers using Windows, where all output is otherwise redirected
    26  * to stdout.txt
    27  *
    28  * Furthermore the Shell should enable us, to input some simple commands
    29  * Each Class can tell check itself in to the Shell, and listen for commands.
    30  *
    31  * @todo implement what is written above :/
    32  */
    33 class Shell : public Element2D, public EventListener {
     29class ShellCommandBase
     30{
     31  public:
     32    static bool execute (const char* executionString);
    3433
    35   public:
    36     virtual ~Shell();
    37     /** @returns a Pointer to the only object of this Class */
    38     inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
     34  protected:
     35    ShellCommandBase(const char* commandName, ClassID classID);
    3936
    40 
    41     void activate();
    42     void deactivate();
    43 
    44     void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
    45     void rebuildText();
    46 
    47     // BUFFER //
    48     void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
    49     void setBufferDisplaySize(unsigned int bufferDisplaySize);
    50     void flushBuffers();
    51     static bool addBufferLineStatic(const char* line, ...);
    52     void addBufferLine(const char* line, va_list arg);
    53     void printToDisplayBuffer(const char* text);
    54     void moveBuffer(int lineCount);
    55     const char* getBufferLine(unsigned int lineNumber);
    56 
    57     // InputLine
    58     void flushInputLine();
    59     void addCharacter(char character);
    60     void addCharacters(const char* characters);
    61     void removeCharacters(unsigned int characterCount = 1);
    62     bool executeCommand();
    63 
    64     void setRepeatDelay(float repeatDelay, float repeatRate);
    65 
    66     // EventListener
    67     virtual void process(const Event &event);
    68 
    69     // Element2D-functions
    70     void tick(float dt);
    71     virtual void draw() const;
    72 
    73     void help() const;
    74     void debug() const;
    75 
    76   private:
    77     bool autoComplete();
    78     bool classComplete(const char* classBegin);
    79     bool objectComplete(const char* objectBegin, long classID);
    80     bool functionComplete(const char* functionBegin);
    81 
    82     bool generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);
    83 
    84     const tList<const char>* Shell::createCompleteList(const tList<const char>* inputList, const char* classNameBegin);
    85     const tList<const char>* Shell::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin);
    86 
    87     // helpers //
    88     Vector calculateLinePosition(unsigned int lineNumber);
     37    static bool isRegistered(const char* commandName, ClassID classID);
    8938
    9039
    9140  private:
    92     Shell();
    93     static Shell*          singletonRef;           //!< The singleton-reference to the only memeber of this class.
     41    char*                            commandName;         //!< The name of the Command when executed
     42    long                             classID;             //!< The ID of the Class asociated to this Command
    9443
    95     unsigned int           bufferSize;             //!< The Size of the buffer
    96     unsigned int           bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters)
    9744
    98     Text*                  inputLineText;          //!< The inputLine of the Shell
    99     char*                  inputLine;              //!< the Char-Array of the Buffer
    100     float                  repeatRate;             //!< The Repeat-Delay.
    101     float                  repeatDelay;            //!< The delay of the first Character of a given Character.
    102     float                  delayed;                //!< how much of the delay is remaining.
    103     int                    pressedKey;             //!< the pressed key that will be repeated.
    104 
    105     tList<char>*           buffer;                 //!< A list of stored char-arrays(strings) to store the history
    106     tIterator<char>*       bufferIterator;         //!< An iterator for the Shells main buffer.
    107 
    108     Text**                 bufferText;             //!< A list of stored bufferTexts for the display of the buffer
    109     unsigned int           textSize;               //!< The size of the text.
    110     unsigned int           lineSpacing;            //!< The Spacing between lines.
    111     unsigned int           shellHeight;            //!< The hight of the Shell in Pixels
    112     bool                   bActive;                //!< if the shell is active;
    113 
    114     char                   bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    115     char                   keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
    116     bool                   keepBuffer;
    117 
    118     // completion
    119     tList<const char>*    completionList;          //!< A list of completions, that are io.
     45    static tList<ShellCommandBase>*  commandList;         //!< A list of availiable commands.
    12046};
    12147
    122 #endif /* _SHELL_H */
     48//! keeps information about a ShellCommand
     49template<class T> class ShellCommand : public ShellCommandBase
     50{
     51  public:
     52    static void registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
     53
     54    static void unregisterCommand(const char* commandNaame, ClassID classID);
     55
     56  private:
     57    ShellCommand(const char* command, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
     58
     59
     60  public:
     61    void*                functionPointer;     //!< The pointer to the function of the Class (or static pointer if ClassID == CL_NULL )
     62    T*                   Object;              //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )
     63};
     64
     65template<class T>
     66    ShellCommand<T>::ShellCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
     67  : ShellCommandBase (command, classID)
     68{
     69
     70}
     71
     72template<class T>
     73    void ShellCommand<T>::registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
     74{
     75  if (isRegistered() == true)
     76    return;
     77  else
     78  {
     79    ShellCommand<T>* newCommand = new ShellCommand<T>(command);
     80    elem->functionPointer = pointerToFunction;
     81    elem->parameter1 = param1Type;
     82    elem->Object = Object;
     83
     84
     85  }
     86}
     87
     88#endif /* _SHELL_COMMAND_H */
  • trunk/src/util/track/track_manager.cc

    r5122 r5129  
    1919
    2020#include "base_object.h"
     21#include "load_param.h"
    2122#include "p_node.h"
    2223#include "track_node.h"
     
    2526#include "text_engine.h"
    2627#include "t_animation.h"
    27 #include "load_param.h"
    2828
    2929
Note: See TracChangeset for help on using the changeset viewer.