Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10651 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
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"
[9869]16#include "debug_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  {
[9869]50    ObjectListDeclaration(Shell);
[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
84  private:
[7757]85    void updateResolution(unsigned int width);
[7738]86    void repositionText();
87    void applyTextSettings(Text* text);
88    void applySettings();
[5120]89    // helpers //
[7316]90    Vector2D calculateLinePosition(unsigned int lineNumber);
[5113]91
[5068]92  private:
[5180]93    // GENERAL
[9869]94    DebugBuffer*                shellBuffer;            //!< The local ShellBuffer.
[7762]95
[5781]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].
[7221]101    std::string                 fontFile;               //!< The file containing the font.
[7738]102    Material                    backgroundMaterial;     //!< A material for the background.
[5068]103
[5175]104    // HANDLING TEXT INPUT
[7341]105    ShellInput                  shellInput;             //!< The inputLine of the Shell.
[5180]106    // BUFFER
[5781]107    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
[7737]108    std::list<MultiLineText*>   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
[7744]109
[7762]110    unsigned long               linesProcessed;         //!< How many Lines have been processed.
111
[7315]112    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
[7374]113  };
[1853]114
[7374]115}
116
[5068]117#endif /* _SHELL_H */
Note: See TracBrowser for help on using the repository browser.