Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7749 was 7744, checked in by bensch, 19 years ago

trunk: the Buffer is moving pretty smoothly :)

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