Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8420 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
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"
[7762]16#include "shell_buffer.h"
[7738]17#include "material.h"
[5068]18
[7375]19#define         SHELL_DEFAULT_FONT              "fonts/final_frontier.ttf"
[7377]20#define         SHELL_DEFAULT_TEXT_COLOR        0.0f, 1.0f, 0.0f, 1.0f
[5513]21#define         SHELL_DEFAULT_BACKGROUND_COLOR  0.0f, 0.0f, 0.0f, 1.0f
[5253]22
[4838]23// FORWARD DECLARATION
[7737]24class MultiLineText;
[5179]25class ShellInput;
[5372]26class Material;
[3543]27
[7753]28//! Namespace of the Shell of ORXONOX.
[7374]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   *
[7753]41   * more info:
42   * @see ShellCommand
[7374]43   * @see shell_command.h
44   * @see shell_buffer.h
45   * @see shell_input.h
[7753]46   * @see shell_completion.h
[7374]47   */
48  class Shell : public Element2D, public EventListener
49  {
[3543]50
[5068]51  public:
[5206]52    Shell();
[5068]53    virtual ~Shell();
[2036]54
[5113]55    void activate();
56    void deactivate();
[5197]57    /** @returns true if the Shell is active, false otherwise. */
[5176]58    inline bool isActive() const { return this->bActive; };
[1853]59
[7221]60    void setFont(const std::string& fontFile);
[5113]61    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
[5372]62    void setTextColor(float r, float g, float b, float a);
63    void setBackgroundColor(float r, float g, float b, float a);
[7221]64    void setBackgroundImage(const std::string& fileName);
[5372]65
[5175]66    // BUFFERS
[5113]67    void setBufferDisplaySize(unsigned int bufferDisplaySize);
[7221]68    void printToDisplayBuffer(const std::string& text);
[5246]69    void moveDisplayBuffer(int lineCount);
70
[5183]71    void flush();
[3245]72
[5130]73    void clear();
74
[5069]75    // EventListener
76    virtual void process(const Event &event);
[5068]77    // Element2D-functions
[7762]78    virtual void tick(float dt);
[5068]79    virtual void draw() const;
80
[7762]81
[5068]82    void debug() const;
83
[7750]84    void testShell() const;
[5068]85  private:
[7757]86    void updateResolution(unsigned int width);
[7738]87    void repositionText();
88    void applyTextSettings(Text* text);
89    void applySettings();
[5120]90    // helpers //
[7316]91    Vector2D calculateLinePosition(unsigned int lineNumber);
[5113]92
[5068]93  private:
[5180]94    // GENERAL
[7762]95    ShellBuffer*                shellBuffer;            //!< The local ShellBuffer.
96
[5781]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].
[7221]102    std::string                 fontFile;               //!< The file containing the font.
[7738]103    Material                    backgroundMaterial;     //!< A material for the background.
[5068]104
[5175]105    // HANDLING TEXT INPUT
[7341]106    ShellInput                  shellInput;             //!< The inputLine of the Shell.
[5180]107    // BUFFER
[5781]108    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
[7737]109    std::list<MultiLineText*>   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
[7744]110
[7762]111    unsigned long               linesProcessed;         //!< How many Lines have been processed.
112
[7315]113    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
[7374]114  };
[1853]115
[7374]116}
117
[5068]118#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.