Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 10, 2008, 1:37:36 AM (16 years ago)
Author:
rgrieder
Message:

merged gui back to trunk.
update the media repository!

Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r1747 r1755  
    115115            // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
    116116            // called automatically by the GraphicsEngine.
    117             this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
    118                 GraphicsEngine::getSingleton().getWindowHeight());
     117            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
     118                GraphicsEngine::getInstance().getWindowHeight());
    119119
    120120            this->changedVisibility();
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r1747 r1755  
    4646#include "core/ConsoleCommand.h"
    4747#include "core/input/InputManager.h"
     48#include "core/input/SimpleInputState.h"
     49#include "core/input/InputBuffer.h"
    4850#include "GraphicsEngine.h"
    4951
     
    5658    SetConsoleCommand(InGameConsole, closeConsole, true);
    5759
     60    InGameConsole* InGameConsole::singletonRef_s = 0;
     61
    5862    /**
    5963        @brief Constructor: Creates and initializes the InGameConsole.
    6064    */
    61     InGameConsole::InGameConsole() :
    62         consoleOverlay_(0), consoleOverlayContainer_(0),
    63         consoleOverlayNoise_(0), consoleOverlayCursor_(0), consoleOverlayBorder_(0),
    64         consoleOverlayTextAreas_(0)
     65    InGameConsole::InGameConsole()
     66        : consoleOverlay_(0)
     67        , consoleOverlayContainer_(0)
     68        , consoleOverlayNoise_(0)
     69        , consoleOverlayCursor_(0)
     70        , consoleOverlayBorder_(0)
     71        , consoleOverlayTextAreas_(0)
    6572    {
    6673        RegisterObject(InGameConsole);
     74
     75        assert(singletonRef_s == 0);
     76        singletonRef_s = this;
    6777
    6878        this->bActive_ = false;
     
    8292    InGameConsole::~InGameConsole(void)
    8393    {
    84         this->destroy();
    85     }
    86 
    87     /**
    88         @brief Returns a reference to the only existing instance of InGameConsole.
    89     */
    90     InGameConsole& InGameConsole::getInstance()
    91     {
    92         static InGameConsole instance;
    93         return instance;
    94     }
    95 
    96     /**
    97         @brief Sets the config values, describing the size of the console.
    98     */
    99     void InGameConsole::setConfigValues()
    100     {
    101         SetConfigValue(relativeWidth, 0.8);
    102         SetConfigValue(relativeHeight, 0.4);
    103         SetConfigValue(blinkTime, 0.5);
    104         SetConfigValue(scrollSpeed_, 3.0f);
    105         SetConfigValue(noiseSize_, 1.0f);
    106         SetConfigValue(cursorSymbol_, '|');
    107     }
    108 
    109     /**
    110         @brief Initializes the InGameConsole.
    111     */
    112     void InGameConsole::initialise()
    113     {
    114         // create overlay and elements
    115         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    116 
    117         // create actual overlay
    118         this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
    119 
    120         // create a container
    121         this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
    122         this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
    123         this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
    124         this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
    125         this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
    126 
    127         // create BorderPanel
    128         this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
    129         this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
    130         this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
    131         this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
    132         this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
    133         this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
    134         this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
    135         this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
    136         this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
    137         this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
    138         this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
    139 
    140         // create a new font to match the requested size exactly
    141         Ogre::FontPtr font = static_cast<Ogre::FontPtr>
    142             (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
    143         font->setType(Ogre::FT_TRUETYPE);
    144         font->setSource("Monofur.ttf");
    145         font->setTrueTypeSize(18);
    146         // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
    147         font->setTrueTypeResolution(192);
    148         font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
    149         font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
    150 
    151         // create the text lines
    152         this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
    153         for (int i = 0; i < LINES; i++)
    154         {
    155             this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
    156             this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
    157             this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
    158             this->consoleOverlayTextAreas_[i]->setCharHeight(18);
    159             this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
    160             this->consoleOverlayTextAreas_[i]->setLeft(8);
    161             this->consoleOverlayTextAreas_[i]->setCaption("");
    162             this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
    163         }
    164 
    165         // create cursor (also a text area overlay element)
    166         this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
    167         this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
    168         this->consoleOverlayCursor_->setFontName("MonofurConsole");
    169         this->consoleOverlayCursor_->setCharHeight(18);
    170         this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
    171         this->consoleOverlayCursor_->setLeft(7);
    172         this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
    173         this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
    174 
    175         // create noise
    176         this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
    177         this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
    178         this->consoleOverlayNoise_->setPosition(5,0);
    179         this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
    180         // comment following line to disable noise
    181         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    182 
    183         this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
    184 
    185         // move overlay "above" the top edge of the screen
    186         // we take -1.2 because the border makes the panel bigger
    187         this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
    188 
    189         Shell::getInstance().addOutputLevel(true);
    190 
    191         COUT(4) << "Info: InGameConsole initialized" << std::endl;
    192     }
    193 
    194     /**
    195         @brief Destroys all the elements if necessary.
    196     */
    197     void InGameConsole::destroy()
    198     {
     94        this->deactivate();
     95
     96        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
     97        InputManager::getInstance().requestDestroyState("console");
     98
    19999        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    200100        if (ovMan)
     
    224124            this->consoleOverlayTextAreas_ = 0;
    225125        }
     126
     127        singletonRef_s = 0;
     128    }
     129
     130    /**
     131        @brief Sets the config values, describing the size of the console.
     132    */
     133    void InGameConsole::setConfigValues()
     134    {
     135        SetConfigValue(relativeWidth, 0.8);
     136        SetConfigValue(relativeHeight, 0.4);
     137        SetConfigValue(blinkTime, 0.5);
     138        SetConfigValue(scrollSpeed_, 3.0f);
     139        SetConfigValue(noiseSize_, 1.0f);
     140        SetConfigValue(cursorSymbol_, '|');
     141    }
     142
     143    /**
     144        @brief Initializes the InGameConsole.
     145    */
     146    void InGameConsole::initialise()
     147    {
     148        // create the corresponding input state
     149        InputManager::getInstance().createInputState<SimpleInputState>("console", 40)
     150            ->setKeyHandler(Shell::getInstance().getInputBuffer());
     151
     152        // create overlay and elements
     153        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     154
     155        // create actual overlay
     156        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
     157
     158        // create a container
     159        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
     160        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
     161        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
     162        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
     163        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
     164
     165        // create BorderPanel
     166        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
     167        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
     168        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
     169        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
     170        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
     171        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
     172        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
     173        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
     174        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
     175        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
     176        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
     177
     178        // create a new font to match the requested size exactly
     179        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
     180            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
     181        font->setType(Ogre::FT_TRUETYPE);
     182        font->setSource("Monofur.ttf");
     183        font->setTrueTypeSize(18);
     184        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
     185        font->setTrueTypeResolution(192);
     186        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
     187        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
     188
     189        // create the text lines
     190        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
     191        for (int i = 0; i < LINES; i++)
     192        {
     193            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
     194            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
     195            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
     196            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
     197            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
     198            this->consoleOverlayTextAreas_[i]->setLeft(8);
     199            this->consoleOverlayTextAreas_[i]->setCaption("");
     200            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
     201        }
     202
     203        // create cursor (also a text area overlay element)
     204        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
     205        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
     206        this->consoleOverlayCursor_->setFontName("MonofurConsole");
     207        this->consoleOverlayCursor_->setCharHeight(18);
     208        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
     209        this->consoleOverlayCursor_->setLeft(7);
     210        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
     211        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
     212
     213        // create noise
     214        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
     215        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
     216        this->consoleOverlayNoise_->setPosition(5,0);
     217        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
     218        // comment following line to disable noise
     219        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
     220
     221        this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
     222
     223        // move overlay "above" the top edge of the screen
     224        // we take -1.2 because the border makes the panel bigger
     225        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
     226
     227        Shell::getInstance().addOutputLevel(true);
     228
     229        COUT(4) << "Info: InGameConsole initialized" << std::endl;
    226230    }
    227231
     
    453457                if (output.size() > this->maxCharsPerLine_)
    454458                {
    455                     if (Shell::getInstance().getInputBuffer().getCursorPosition() < this->inputWindowStart_)
    456                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition();
    457                     else if (Shell::getInstance().getInputBuffer().getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
    458                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition() - this->maxCharsPerLine_ + 1;
     459                    if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
     460                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
     461                    else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
     462                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
    459463
    460464                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
     
    476480        {
    477481            this->bActive_ = true;
    478             InputManager::setInputState(InputManager::IS_CONSOLE);
     482            InputManager::getInstance().requestEnterState("console");
    479483            Shell::getInstance().registerListener(this);
    480484
     
    498502        {
    499503            this->bActive_ = false;
    500             InputManager::setInputState(InputManager::IS_NORMAL);
     504            InputManager::getInstance().requestLeaveState("console");
    501505            Shell::getInstance().unregisterListener(this);
    502506
  • code/trunk/src/orxonox/overlays/console/InGameConsole.h

    r1747 r1755  
    3737
    3838#include "core/Shell.h"
    39 #include "objects/Tickable.h"
     39#include "core/OrxonoxClass.h"
    4040#include "tools/WindowEventListener.h"
    4141
     
    4343namespace orxonox
    4444{
    45     class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener
     45    class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener
    4646    {
    47         public: // functions
    48             void initialise();
    49             void destroy();
    50             void setConfigValues();
     47    public: // functions
     48        InGameConsole();
     49        ~InGameConsole();
    5150
    52             virtual void tick(float dt);
     51        void initialise();
     52        void destroy();
     53        void setConfigValues();
    5354
    54             static InGameConsole& getInstance();
     55        virtual void tick(float dt);
    5556
    56             static void openConsole();
    57             static void closeConsole();
     57        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     58        static InGameConsole* getInstancePtr() { return singletonRef_s; }
    5859
    59         private: // functions
    60             InGameConsole();
    61             InGameConsole(const InGameConsole& other) {}
    62             ~InGameConsole();
     60        static void openConsole();
     61        static void closeConsole();
    6362
    64             void activate();
    65             void deactivate();
     63    private: // functions
     64        InGameConsole(const InGameConsole& other) {}
    6665
    67             void linesChanged();
    68             void onlyLastLineChanged();
    69             void lineAdded();
    70             void inputChanged();
    71             void cursorChanged();
    72             void exit();
     66        void activate();
     67        void deactivate();
    7368
    74             void shiftLines();
    75             void colourLine(int colourcode, int index);
    76             void setCursorPosition(unsigned int pos);
    77             void print(const std::string& text, int index, bool alwaysShift = false);
     69        void linesChanged();
     70        void onlyLastLineChanged();
     71        void lineAdded();
     72        void inputChanged();
     73        void cursorChanged();
     74        void exit();
    7875
    79             void windowResized(int newWidth, int newHeight);
     76        void shiftLines();
     77        void colourLine(int colourcode, int index);
     78        void setCursorPosition(unsigned int pos);
     79        void print(const std::string& text, int index, bool alwaysShift = false);
    8080
    81             static Ogre::UTFString convert2UTF(std::string s);
     81        void windowResized(int newWidth, int newHeight);
    8282
    83         private: // variables
    84             bool bActive_;
    85             int windowW_;
    86             int windowH_;
    87             int desiredTextWidth_;
    88             unsigned int maxCharsPerLine_;
    89             unsigned int numLinesShifted_;
    90             int scroll_;
    91             float cursor_;
    92             unsigned int inputWindowStart_;
    93             bool bShowCursor_;
    94             std::string displayedText_;
    95             Ogre::Overlay* consoleOverlay_;
    96             Ogre::OverlayContainer* consoleOverlayContainer_;
    97             Ogre::PanelOverlayElement* consoleOverlayNoise_;
    98             Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
    99             Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
    100             Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
     83        static Ogre::UTFString convert2UTF(std::string s);
    10184
    102             // config values
    103             float relativeWidth;
    104             float relativeHeight;
    105             float blinkTime;
    106             float scrollSpeed_;
    107             float noiseSize_;
    108             char cursorSymbol_;
     85    private: // variables
     86        bool bActive_;
     87        int windowW_;
     88        int windowH_;
     89        int desiredTextWidth_;
     90        unsigned int maxCharsPerLine_;
     91        unsigned int numLinesShifted_;
     92        int scroll_;
     93        float cursor_;
     94        unsigned int inputWindowStart_;
     95        bool bShowCursor_;
     96        std::string displayedText_;
     97        Ogre::Overlay* consoleOverlay_;
     98        Ogre::OverlayContainer* consoleOverlayContainer_;
     99        Ogre::PanelOverlayElement* consoleOverlayNoise_;
     100        Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
     101        Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
     102        Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
     103
     104        // config values
     105        float relativeWidth;
     106        float relativeHeight;
     107        float blinkTime;
     108        float scrollSpeed_;
     109        float noiseSize_;
     110        char cursorSymbol_;
     111
     112        static InGameConsole* singletonRef_s;
    109113    };
    110114}
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

    r1625 r1755  
    4949    void DebugFPSText::tick(float dt)
    5050    {
    51         float fps = GraphicsEngine::getSingleton().getAverageFramesPerSecond();
     51        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5252        this->text_->setCaption(this->getCaption() + convertToString(fps));
    5353    }
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc

    r1625 r1755  
    4949    void DebugRTRText::tick(float dt)
    5050    {
    51         float rtr = GraphicsEngine::getSingleton().getAverageTickTime();
     51        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5252        this->text_->setCaption(this->getCaption() + convertToString(rtr));
    5353    }
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r1626 r1755  
    5454            float v = ship->getVelocity().length();
    5555            float value = v / ship->getMaxSpeed();
    56                         if (value != this->getValue())
     56            if (value != this->getValue())
    5757                this->setValue(value);
    5858        }
Note: See TracChangeset for help on using the changeset viewer.