Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell.h @ 7484

Last change on this file since 7484 was 7426, checked in by bensch, 19 years ago

orxonox/trunk: ShellFont can be changed in threads :)

File size: 3.9 KB
RevLine 
[4838]1/*!
[5068]2 * @file shell.h
3 * Definition of a on-screen-shell
[5204]4 *
[5208]5 * @todo Buffer Display in different Colors for different debug mode.
[5372]6 * @todo choose color of the Font and the background.
[5204]7 */
[1853]8
[5068]9#ifndef _SHELL_H
10#define _SHELL_H
[1853]11
[5068]12#include "element_2d.h"
[5069]13#include "event_listener.h"
[1853]14
[7341]15#include "shell_input.h"
[5068]16
[7375]17#define         SHELL_DEFAULT_FONT              "fonts/final_frontier.ttf"
[7377]18#define         SHELL_DEFAULT_TEXT_COLOR        0.0f, 1.0f, 0.0f, 1.0f
[5513]19#define         SHELL_DEFAULT_BACKGROUND_COLOR  0.0f, 0.0f, 0.0f, 1.0f
[5253]20
[4838]21// FORWARD DECLARATION
[5068]22class Text;
[5179]23class ShellInput;
[5372]24class Material;
[3543]25
[7374]26namespace OrxShell
27{
28  //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
29  /**
30   * the major idea is, that all the Output can be redirected to the Shell,
31   * and does not have to be displayed to the opening Shell, this is good,
32   * for developers using Windows, where all output is otherwise redirected
33   * to stdout.txt
34   *
35   * Furthermore the Shell should enable us, to input some simple commands
36   * Each Class can check itself in to the Shell, and listen for commands.
37   *
38   * more info: @see ShellCommand
39   * @see shell_command.h
40   * @see shell_buffer.h
41   * @see shell_input.h
42   *
43   * !! note in order to keep shellbuffer to a minimal (it is included with
44   * !! debug.h) Display of it inside the Shell is located here !!
45   */
46  class Shell : public Element2D, public EventListener
47  {
[3543]48
[5068]49  public:
[5206]50    Shell();
[5068]51    virtual ~Shell();
[2036]52
[5113]53    void activate();
54    void deactivate();
[5197]55    /** @returns true if the Shell is active, false otherwise. */
[5176]56    inline bool isActive() const { return this->bActive; };
[1853]57
[7221]58    void setFont(const std::string& fontFile);
[5113]59    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
[5372]60    void setTextColor(float r, float g, float b, float a);
61    void setBackgroundColor(float r, float g, float b, float a);
[7221]62    void setBackgroundImage(const std::string& fileName);
[5372]63
[5175]64    // BUFFERS
[5113]65    void setBufferDisplaySize(unsigned int bufferDisplaySize);
[7221]66    void printToDisplayBuffer(const std::string& text);
[5246]67    void moveDisplayBuffer(int lineCount);
68
[5183]69    void flush();
[3245]70
[5130]71    void clear();
72
[5069]73    // EventListener
74    virtual void process(const Event &event);
[5068]75    // Element2D-functions
76    virtual void draw() const;
77
78    void debug() const;
79
80  private:
[7426]81    void resetValues();
82    void resetText(Text* text, unsigned int position);
[5120]83    // helpers //
[7316]84    Vector2D calculateLinePosition(unsigned int lineNumber);
[5113]85
[5183]86    //     void testI (int i);
[7221]87    //     void testS (const std::string& s);
[5183]88    //     void testB (bool b);
89    //     void testF (float f);
[7221]90    //     void testSF (const std::string& s, float f);
[5183]91
[5068]92  private:
[5180]93    // GENERAL
[5781]94    bool                        bActive;                //!< If the shell is active.
95    unsigned int                shellHeight;            //!< The hight of the Shell in Pixels.
96    unsigned int                lineSpacing;            //!< The Spacing between lines.
97    unsigned int                textSize;               //!< The size of the text.
98    float                       textColor[4];           //!< The text's color [r,g,b,a].
[7221]99    std::string                 fontFile;               //!< The file containing the font.
[5781]100    Material*                   backgroundMaterial;     //!< A material for the background.
[5068]101
[5175]102    // HANDLING TEXT INPUT
[7341]103    ShellInput                  shellInput;             //!< The inputLine of the Shell.
[5180]104    // BUFFER
[5781]105    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
[7341]106    std::list<Text*>            bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
[5781]107    int                         bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
[7315]108    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
[7374]109  };
[1853]110
[7374]111}
112
[5068]113#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.