Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7374 was 7374, checked in by bensch, 18 years ago

orxonox/trunk: added new Files shell_completion_plugin for the new Plugin Structure.
Also created the first namespace: OrxShell

File size: 3.9 KB
Line 
1/*!
2 * @file shell.h
3 * Definition of a on-screen-shell
4 *
5 * @todo Buffer Display in different Colors for different debug mode.
6 * @todo choose color of the Font and the background.
7 */
8
9#ifndef _SHELL_H
10#define _SHELL_H
11
12#include "element_2d.h"
13#include "event_listener.h"
14
15#include "shell_input.h"
16
17#define         SHELL_DEFAULT_FONT              "fonts/dpquake_.ttf"
18#define         SHELL_DEFAULT_TEXT_COLOR        1.0f, 0.0f, 0.0f, 1.0f
19#define         SHELL_DEFAULT_BACKGROUND_COLOR  0.0f, 0.0f, 0.0f, 1.0f
20
21// FORWARD DECLARATION
22class Text;
23class ShellInput;
24class Material;
25
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  {
48
49  public:
50    Shell();
51    virtual ~Shell();
52
53    void activate();
54    void deactivate();
55    /** @returns true if the Shell is active, false otherwise. */
56    inline bool isActive() const { return this->bActive; };
57
58    void setFont(const std::string& fontFile);
59    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
60    void setTextColor(float r, float g, float b, float a);
61    void setBackgroundColor(float r, float g, float b, float a);
62    void setBackgroundImage(const std::string& fileName);
63
64    void resetValues();
65
66    // BUFFERS
67    void setBufferDisplaySize(unsigned int bufferDisplaySize);
68    void printToDisplayBuffer(const std::string& text);
69    void moveDisplayBuffer(int lineCount);
70
71    void flush();
72
73    void clear();
74
75    // EventListener
76    virtual void process(const Event &event);
77    // Element2D-functions
78    virtual void draw() const;
79
80    void debug() const;
81
82  private:
83    // helpers //
84    Vector2D calculateLinePosition(unsigned int lineNumber);
85
86    //     void testI (int i);
87    //     void testS (const std::string& s);
88    //     void testB (bool b);
89    //     void testF (float f);
90    //     void testSF (const std::string& s, float f);
91
92  private:
93    // GENERAL
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].
99    std::string                 fontFile;               //!< The file containing the font.
100    Material*                   backgroundMaterial;     //!< A material for the background.
101
102    // HANDLING TEXT INPUT
103    ShellInput                  shellInput;             //!< The inputLine of the Shell.
104    // BUFFER
105    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
106    std::list<Text*>            bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
107    int                         bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
108    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
109  };
110
111}
112
113#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.