Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/2d-recalc/src/lib/shell/shell.h @ 5679

Last change on this file since 5679 was 5380, checked in by bensch, 19 years ago

orxonox/trunk: some 2d-adaptions

File size: 3.8 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
[5068]15#include <stdarg.h>
16
[5372]17#define         SHELL_DEFAULT_FONT              "fonts/dpquake_.ttf"
[5374]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.8f, 0.8f
[5253]20
[4838]21// FORWARD DECLARATION
[5068]22class Text;
[5179]23class ShellInput;
[5372]24class Material;
[5118]25template<class T> class tIterator;
[3543]26
[5068]27//! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
28/**
29 * the major idea is, that all the Output can be redirected to the Shell,
30 * and does not have to be displayed to the opening Shell, this is good,
31 * for developers using Windows, where all output is otherwise redirected
32 * to stdout.txt
33 *
34 * Furthermore the Shell should enable us, to input some simple commands
[5246]35 * Each Class can check itself in to the Shell, and listen for commands.
[5068]36 *
[5246]37 * more info: @see ShellCommand
38 * @see shell_command.h
39 * @see shell_buffer.h
40 * @see shell_input.h
41 *
42 * !! note in order to keep shellbuffer to a minimal (it is included with
43 * !! debug.h) Display of it inside the Shell is located here !!
[5068]44 */
[5069]45class Shell : public Element2D, public EventListener {
[3543]46
[5068]47  public:
[5206]48    Shell();
[5068]49    virtual ~Shell();
[2036]50
[5113]51    void activate();
52    void deactivate();
[5197]53    /** @returns true if the Shell is active, false otherwise. */
[5176]54    inline bool isActive() const { return this->bActive; };
[1853]55
[5251]56    void setFont(const char* fontFile);
[5113]57    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
[5372]58    void setTextColor(float r, float g, float b, float a);
59    void setBackgroundColor(float r, float g, float b, float a);
[5374]60    void setBackgroundImage(const char* fileName);
[5372]61
62    void resetValues();
[5113]63    void rebuildText();
[3245]64
[5175]65    // BUFFERS
[5113]66    void setBufferDisplaySize(unsigned int bufferDisplaySize);
[5118]67    void printToDisplayBuffer(const char* 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
81  private:
[5120]82    // helpers //
83    Vector calculateLinePosition(unsigned int lineNumber);
[5113]84
[5183]85    //     void testI (int i);
86    //     void testS (const char* s);
87    //     void testB (bool b);
88    //     void testF (float f);
89    //     void testSF (const char* s, float f);
90
[5068]91  private:
[5180]92    // GENERAL
[5246]93    bool                     bActive;                //!< If the shell is active.
[5380]94    float                    shellHeight;            //!< The hight of the Shell in Pixels.
95    float                    lineSpacing;            //!< The Spacing between lines.
96    float                    textSize;               //!< The size of the text.
[5372]97    float                    textColor[4];           //!< The text's color [r,g,b,a].
[5251]98    char*                    fontFile;               //!< The file containing the font.
[5372]99    Material*                backgroundMaterial;     //!< A material for the background.
[5068]100
[5175]101    // HANDLING TEXT INPUT
[5197]102    ShellInput*              shellInput;             //!< The inputLine of the Shell.
[5180]103    // BUFFER
[5246]104    unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
105    Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
106    int                      bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
[5247]107    tIterator<char>*         bufferIterator;         //!< used to move through and print the Buffer
[1853]108};
109
[5068]110#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.