Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/test/src/lib/shell/shell.h @ 10230

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

orxonox/trunk: Windows runs again without any segfaults
it seems, that windows links object files differently… and extremely strange

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 "debug_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    ObjectListDeclaration(Shell);
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  private:
85    void updateResolution(unsigned int width);
86    void repositionText();
87    void applyTextSettings(Text* text);
88    void applySettings();
89    // helpers //
90    Vector2D calculateLinePosition(unsigned int lineNumber);
91
92  private:
93    // GENERAL
94    DebugBuffer*                shellBuffer;            //!< The local ShellBuffer.
95
96    bool                        bActive;                //!< If the shell is active.
97    unsigned int                shellHeight;            //!< The hight of the Shell in Pixels.
98    unsigned int                lineSpacing;            //!< The Spacing between lines.
99    unsigned int                textSize;               //!< The size of the text.
100    float                       textColor[4];           //!< The text's color [r,g,b,a].
101    std::string                 fontFile;               //!< The file containing the font.
102    Material                    backgroundMaterial;     //!< A material for the background.
103
104    // HANDLING TEXT INPUT
105    ShellInput                  shellInput;             //!< The inputLine of the Shell.
106    // BUFFER
107    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
108    std::list<MultiLineText*>   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
109
110    unsigned long               linesProcessed;         //!< How many Lines have been processed.
111
112    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
113  };
114
115}
116
117#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.