Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: ShellBuffer gets polled from the Shell, and does not put the other way round

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#include "shell_buffer.h"
17#include "material.h"
18
19#define         SHELL_DEFAULT_FONT              "fonts/final_frontier.ttf"
20#define         SHELL_DEFAULT_TEXT_COLOR        0.0f, 1.0f, 0.0f, 1.0f
21#define         SHELL_DEFAULT_BACKGROUND_COLOR  0.0f, 0.0f, 0.0f, 1.0f
22
23// FORWARD DECLARATION
24class MultiLineText;
25class ShellInput;
26class Material;
27
28//! Namespace of the Shell of ORXONOX.
29namespace OrxShell
30{
31  //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
32  /**
33   * the major idea is, that all the Output can be redirected to the Shell,
34   * and does not have to be displayed to the opening Shell, this is good,
35   * for developers using Windows, where all output is otherwise redirected
36   * to stdout.txt
37   *
38   * Furthermore the Shell should enable us, to input some simple commands
39   * Each Class can check itself in to the Shell, and listen for commands.
40   *
41   * more info:
42   * @see ShellCommand
43   * @see shell_command.h
44   * @see shell_buffer.h
45   * @see shell_input.h
46   * @see shell_completion.h
47   */
48  class Shell : public Element2D, public EventListener
49  {
50
51  public:
52    Shell();
53    virtual ~Shell();
54
55    void activate();
56    void deactivate();
57    /** @returns true if the Shell is active, false otherwise. */
58    inline bool isActive() const { return this->bActive; };
59
60    void setFont(const std::string& fontFile);
61    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
62    void setTextColor(float r, float g, float b, float a);
63    void setBackgroundColor(float r, float g, float b, float a);
64    void setBackgroundImage(const std::string& fileName);
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 tick(float dt);
79    virtual void draw() const;
80
81
82    void debug() const;
83
84    void testShell() const;
85  private:
86    void updateResolution(unsigned int width);
87    void repositionText();
88    void applyTextSettings(Text* text);
89    void applySettings();
90    // helpers //
91    Vector2D calculateLinePosition(unsigned int lineNumber);
92
93  private:
94    // GENERAL
95    ShellBuffer*                shellBuffer;            //!< The local ShellBuffer.
96
97    bool                        bActive;                //!< If the shell is active.
98    unsigned int                shellHeight;            //!< The hight of the Shell in Pixels.
99    unsigned int                lineSpacing;            //!< The Spacing between lines.
100    unsigned int                textSize;               //!< The size of the text.
101    float                       textColor[4];           //!< The text's color [r,g,b,a].
102    std::string                 fontFile;               //!< The file containing the font.
103    Material                    backgroundMaterial;     //!< A material for the background.
104
105    // HANDLING TEXT INPUT
106    ShellInput                  shellInput;             //!< The inputLine of the Shell.
107    // BUFFER
108    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
109    std::list<MultiLineText*>   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
110
111    unsigned long               linesProcessed;         //!< How many Lines have been processed.
112
113    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
114  };
115
116}
117
118#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.