Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5068 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Aug 18, 2005, 3:51:43 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added Shell Class to the utils.
This class should enable us to print all the output from orxonox directly onto the screen.
Also it should allow inputting some little Commands, so that we have more force over our little project :)

Also added a new Function to tList, removeLast, that is very quick in deleting the last element, as this is used inside of the Shell (deleting the Last Element is a major issue)

Location:
orxonox/trunk/src
Files:
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r5040 r5068  
    4646                  util/loading/load_param.cc \
    4747                  util/state.cc \
     48                  util/shell.cc \
    4849                  util/user_control.cc \
    4950                  story_entities/story_entity.cc \
     
    99100                 util/garbage_collector.h \
    100101                 util/state.h \
     102                 util/shell.h \
    101103                 util/user_control.h \
    102104                 util/resource_manager.h \
  • orxonox/trunk/src/Makefile.in

    r5040 r5068  
    6262        orxonox-resource_manager.$(OBJEXT) orxonox-factory.$(OBJEXT) \
    6363        orxonox-load_param.$(OBJEXT) orxonox-state.$(OBJEXT) \
    64         orxonox-user_control.$(OBJEXT) orxonox-story_entity.$(OBJEXT) \
    65         orxonox-campaign.$(OBJEXT) orxonox-world.$(OBJEXT) \
    66         orxonox-world_entity.$(OBJEXT) orxonox-camera.$(OBJEXT) \
    67         orxonox-player.$(OBJEXT) orxonox-npc.$(OBJEXT) \
    68         orxonox-environment.$(OBJEXT) orxonox-skysphere.$(OBJEXT) \
    69         orxonox-skybox.$(OBJEXT) orxonox-terrain.$(OBJEXT) \
    70         orxonox-satellite.$(OBJEXT) \
     64        orxonox-shell.$(OBJEXT) orxonox-user_control.$(OBJEXT) \
     65        orxonox-story_entity.$(OBJEXT) orxonox-campaign.$(OBJEXT) \
     66        orxonox-world.$(OBJEXT) orxonox-world_entity.$(OBJEXT) \
     67        orxonox-camera.$(OBJEXT) orxonox-player.$(OBJEXT) \
     68        orxonox-npc.$(OBJEXT) orxonox-environment.$(OBJEXT) \
     69        orxonox-skysphere.$(OBJEXT) orxonox-skybox.$(OBJEXT) \
     70        orxonox-terrain.$(OBJEXT) orxonox-satellite.$(OBJEXT) \
    7171        orxonox-character_attributes.$(OBJEXT) \
    7272        orxonox-test_entity.$(OBJEXT) orxonox-weapon_manager.$(OBJEXT) \
     
    121121@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-resource_manager.Po \
    122122@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-satellite.Po \
     123@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-shell.Po \
    123124@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-skybox.Po \
    124125@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-skysphere.Po \
     
    303304                  util/loading/load_param.cc \
    304305                  util/state.cc \
     306                  util/shell.cc \
    305307                  util/user_control.cc \
    306308                  story_entities/story_entity.cc \
     
    356358                 util/garbage_collector.h \
    357359                 util/state.h \
     360                 util/shell.h \
    358361                 util/user_control.h \
    359362                 util/resource_manager.h \
     
    523526@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-resource_manager.Po@am__quote@
    524527@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-satellite.Po@am__quote@
     528@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-shell.Po@am__quote@
    525529@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-skybox.Po@am__quote@
    526530@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-skysphere.Po@am__quote@
     
    782786@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    783787@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-state.obj `if test -f 'util/state.cc'; then $(CYGPATH_W) 'util/state.cc'; else $(CYGPATH_W) '$(srcdir)/util/state.cc'; fi`
     788
     789orxonox-shell.o: util/shell.cc
     790@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-shell.o -MD -MP -MF "$(DEPDIR)/orxonox-shell.Tpo" -c -o orxonox-shell.o `test -f 'util/shell.cc' || echo '$(srcdir)/'`util/shell.cc; \
     791@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-shell.Tpo" "$(DEPDIR)/orxonox-shell.Po"; else rm -f "$(DEPDIR)/orxonox-shell.Tpo"; exit 1; fi
     792@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='util/shell.cc' object='orxonox-shell.o' libtool=no @AMDEPBACKSLASH@
     793@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-shell.Po' tmpdepfile='$(DEPDIR)/orxonox-shell.TPo' @AMDEPBACKSLASH@
     794@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     795@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-shell.o `test -f 'util/shell.cc' || echo '$(srcdir)/'`util/shell.cc
     796
     797orxonox-shell.obj: util/shell.cc
     798@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-shell.obj -MD -MP -MF "$(DEPDIR)/orxonox-shell.Tpo" -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`; \
     799@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-shell.Tpo" "$(DEPDIR)/orxonox-shell.Po"; else rm -f "$(DEPDIR)/orxonox-shell.Tpo"; exit 1; fi
     800@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='util/shell.cc' object='orxonox-shell.obj' libtool=no @AMDEPBACKSLASH@
     801@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-shell.Po' tmpdepfile='$(DEPDIR)/orxonox-shell.TPo' @AMDEPBACKSLASH@
     802@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     803@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`
    784804
    785805orxonox-user_control.o: util/user_control.cc
  • orxonox/trunk/src/defs/class_id.h

    r5040 r5068  
    192192  CL_NUMBER                     =    0x00000b0c,
    193193  CL_FAST_FACTORY               =    0x00000c01,
     194  CL_SHELL                      =    0x00000c11,
    194195
    195196
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.cc

    r4862 r5068  
    5555
    5656  this->setVisibility(true);
     57  this->setActiveness(true);
    5758  this->setPosition2D(0,0);
    5859  this->setAlignment(E2D_ALIGN_NONE);
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.h

    r4862 r5068  
    6969    /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
    7070    inline void setVisibility(bool visible) { this->visible = visible; };
     71    /** @param active true if the Element should be active, false otherwise (will not be ticked) */
     72    inline void setActiveness(bool active) { this->active = active; };
     73
    7174
    7275    /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
     
    7679    /** @returns the visibility state */
    7780    inline bool isVisible() { return this->visible; };
     81    /** @returns the active-State */
     82    inline bool isActive() { return this->active; };
    7883
    7984    virtual void tick(float dt);
     
    9196
    9297  private:
    93     bool                    visible;
    94     E2D_LAYER               layer;
     98    bool                    visible;          //!< If the given Element2D is visible.
     99    bool                    active;           //!< If the given Element2D is active.
     100    E2D_LAYER               layer;            //!< What layer this Element2D is on.
    95101};
    96102
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.cc

    r4955 r5068  
    105105    while (elem != NULL)
    106106    {
    107       elem->tick(dt);
     107      if (elem->isActive())
     108        elem->tick(dt);
    108109      elem = iterator->nextElement();
    109110    }
  • orxonox/trunk/src/lib/util/list.h

    r4836 r5068  
    11/*!
    2   \file list.h
    3   \brief a File that includes a List-template
    4 */
     2 * @file list.h
     3 * a File that includes a List-template
     4 */
    55
    66#ifndef _LIST_H
     
    132132  void add(T* entity);
    133133  void remove(T* entity);
     134  void removeLast();
    134135  void flush();
    135136  T* firstElement();
     
    214215{
    215216  this->currentEl = this->first;
    216   listElement<T>* te;
    217217  while( this->currentEl != NULL)
    218218    {
     
    233233}
    234234
     235/**
     236 * removes the Last Element of the List
     237 */
     238 template<class T>
     239     inline void tList<T>::removeLast()
     240{
     241  if (this->last == NULL)
     242    return;
     243  else if (this->last == this->first)
     244  {
     245    delete this->first;
     246    this->first = NULL;
     247    this->last = NULL;
     248    this->size--;
     249  }
     250  else
     251  {
     252    listElement<T>* delLast = this->last;
     253    this->last->prev->next = NULL;
     254    this->last = this->last->prev;
     255    delete delLast;
     256  }
     257}
    235258
    236259/**
  • orxonox/trunk/src/util/shell.cc

    r5065 r5068  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    1616//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
    1717
    18 #include "proto_class.h"
     18#include "shell.h"
    1919
    2020using namespace std;
     
    2323/**
    2424 * standard constructor
    25  * @todo this constructor is not jet implemented - do it
    26 */
    27 ProtoClass::ProtoClass ()
     25 */
     26Shell::Shell ()
    2827{
    29    this->setClassID(CL_PROTO_ID, "ProtoClass");
     28   this->setClassID(CL_SHELL, "Shell");
     29}
    3030
    31    /* If you make a new class, what is most probably the case when you write this file
    32       don't forget to:
    33        1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
    3531
    36       Advanced Topics:
    37       - if you want to let your object be managed via the ObjectManager make sure to read
    38         the object_manager.h header comments. You will use this most certanly only if you
    39         make many objects of your class, like a weapon bullet.
    40    */
     32Shell* Shell::singletonRef = NULL;
     33
     34/**
     35 * standard deconstructor
     36 */
     37Shell::~Shell ()
     38{
     39  // delete what has to be deleted here
     40
     41  Shell::singletonRef = NULL;
     42}
     43
     44
     45
     46
     47void setBufferDisplaySize(unsigned int bufferDisplaySize);
     48
     49/**
     50 * deletes all the Buffers
     51 */
     52void Shell::flushBuffers()
     53{
     54
     55}
     56
     57/**
     58 * adds a new Line to the List of Buffers
     59 * @param line the Line as in the first argument in printf
     60 * @param args the arguments as a va_list
     61 */
     62void Shell::addBufferLine(const char* line, va_list args)
     63{
     64}
     65
     66/**
     67 * moves the buffer around lineCount lines upwards (negative values move down)
     68 * @param lineCount the Count of lines to move upwards
     69 */
     70void Shell::moveBuffer(int lineCount)
     71{
     72}
     73
     74/**
     75 * @param lineNumber the n-th line from the bottom
     76 * @returns the Buffer at Line lineNumber
     77 */
     78const char* Shell::getBufferLine(unsigned int lineNumber)
     79{
    4180}
    4281
    4382
    4483/**
    45  * standard deconstructor
    46 */
    47 ProtoClass::~ProtoClass ()
     84 * deletes the InputLine
     85 */
     86void Shell::flushInputLine()
    4887{
    49   // delete what has to be deleted here
    5088}
     89
     90/**
     91 * adds one character to the inputLine
     92 * @param character the character to add to the inputLine
     93 */
     94void Shell::addCharacter(char character)
     95{
     96}
     97
     98/**
     99 * adds multiple Characters to thr inputLine
     100 * @param characters a '\0' terminated char-array to add to the InputLine
     101 */
     102void Shell::addCharacters(const char* characters)
     103{
     104}
     105
     106/**
     107 * removes characterCount characters from the InputLine
     108 * @param characterCount the count of Characters to remove from the input Line
     109 */
     110void Shell::removeCharacters(unsigned int characterCount)
     111{
     112}
     113
     114
     115/**
     116 * ticks the Shell for dt Seconds
     117 * @param dt the elapsed time since the last tick();
     118 */
     119void Shell::tick(float dt)
     120{
     121}
     122
     123/**
     124 * displays the Shell
     125 */
     126void Shell::draw() const
     127{
     128}
     129
     130
     131/**
     132 * autocompletes the Shell's inputLine
     133 * @returns true, if a result was found, false otherwise
     134 */
     135bool Shell::autoComplete()
     136{
     137
     138}
     139
     140/**
     141 * displays some nice output from the Shell
     142 */
     143void Shell::debug() const
     144{
     145
     146}
  • orxonox/trunk/src/util/shell.h

    r5065 r5068  
    11/*!
    2  * @file proto_class.h
    3  * @brief Definition of ...
     2 * @file shell.h
     3 * Definition of a on-screen-shell
    44*/
    55
    6 #ifndef _PROTO_CLASS_H
    7 #define _PROTO_CLASS_H
     6#ifndef _SHELL_H
     7#define _SHELL_H
    88
    9 #include "base_object.h"
     9#include "element_2d.h"
     10
     11#include <stdio.h>
     12#include <stdarg.h>
     13
    1014
    1115// FORWARD DECLARATION
     16class Text;
     17template<class T> class tList;
     18
     19//! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
     20/**
     21 * the major idea is, that all the Output can be redirected to the Shell,
     22 * and does not have to be displayed to the opening Shell, this is good,
     23 * for developers using Windows, where all output is otherwise redirected
     24 * to stdout.txt
     25 *
     26 * Furthermore the Shell should enable us, to input some simple commands
     27 * Each Class can tell check itself in to the Shell, and listen for commands.
     28 *
     29 * @todo implement what is written above :/
     30 */
     31class Shell : public Element2D {
     32
     33  public:
     34    virtual ~Shell();
     35    /** @returns a Pointer to the only object of this Class */
     36    inline static Shell* getInstance(void) { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
    1237
    1338
     39    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
    1440
    15 //! A class for ...
    16 class ProtoClass : public BaseObject {
     41    void setBufferDisplaySize(unsigned int bufferDisplaySize);
    1742
    18  public:
    19   ProtoClass();
    20   virtual ~ProtoClass();
     43    // BUFFER //
     44    void flushBuffers();
     45    void addBufferLine(const char* Line, va_list args);
     46    void moveBuffer(int lineCount);
     47    const char* getBufferLine(unsigned int lineNumber);
     48
     49  // inputLine
     50    void flushInputLine();
     51    void addCharacter(char character);
     52    void addCharacters(const char* characters);
     53    void removeCharacters(unsigned int characterCount = 1);
    2154
    2255
    23  private:
     56    // Element2D-functions
     57    void tick(float dt);
     58    virtual void draw() const;
    2459
     60    void debug() const;
     61
     62  private:
     63    bool autoComplete();
     64
     65
     66  private:
     67    Shell();
     68    static Shell*          singletonRef;
     69
     70    unsigned int           bufferSize;
     71    unsigned int           bufferDisplaySize;
     72
     73    char*                  inputLine;
     74
     75    tList<const char>*     buffer;
     76
     77    tList<Text>*           bufferText;             //!< A list of sored bufferLines of the Shell
     78    Text*                  inputLineText;          //!< The inputLine of the Shell
    2579};
    2680
    27 #endif /* _PROTO_CLASS_H */
     81#endif /* _SHELL_H */
  • orxonox/trunk/src/world_entities/skysphere.cc

    r4836 r5068  
    1 
    21/*
    32   orxonox - the future of 3D-vertical-scrollers
Note: See TracChangeset for help on using the changeset viewer.