Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/overlays/InGameConsole.cc @ 10262

Last change on this file since 10262 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 23.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Felix Schulthess
24 *   Co-authors:
25 *      Fabian 'x3n' Landau
26 *
27 */
28
29
30#include "InGameConsole.h"
31
32#include <algorithm>
33#include <string>
34#include <OgreOverlay.h>
35#include <OgreOverlayElement.h>
36#include <OgreOverlayManager.h>
37#include <OgreOverlayContainer.h>
38#include <OgreBorderPanelOverlayElement.h>
39#include <OgreTextAreaOverlayElement.h>
40#include <OgreFontManager.h>
41#include <OgreFont.h>
42
43#include "util/Clock.h"
44#include "util/Convert.h"
45#include "util/Math.h"
46#include "util/DisplayStringConversions.h"
47#include "util/ScopedSingletonManager.h"
48#include "util/output/MemoryWriter.h"
49#include "util/output/OutputManager.h"
50#include "core/CoreIncludes.h"
51#include "core/config/ConfigValueIncludes.h"
52#include "core/command/ConsoleCommand.h"
53#include "core/GUIManager.h"
54#include "core/input/InputManager.h"
55#include "core/input/InputState.h"
56#include "core/input/InputBuffer.h"
57#include "core/LuaState.h"
58
59namespace orxonox
60{
61    const int LINES = 30;
62    const float CHAR_WIDTH = 8.0f; // fix this please - determine the char-width dynamically
63
64    SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
65    SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
66
67    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
68
69    /**
70        @brief Constructor: Creates and initializes the InGameConsole.
71    */
72    InGameConsole::InGameConsole()
73        : shell_(new Shell("InGameConsole", true))
74        , bShowCursor_(false)
75        , consoleOverlay_(0)
76        , consoleOverlayContainer_(0)
77        , consoleOverlayNoise_(0)
78        , consoleOverlayCursor_(0)
79        , consoleOverlayBorder_(0)
80        , consoleOverlayTextAreas_(0)
81        , inputState_(0)
82    {
83        RegisterObject(InGameConsole);
84
85        this->bActive_ = false;
86        this->cursor_ = 0.0f;
87        this->cursorSymbol_ = '|';
88        this->inputWindowStart_ = 0;
89        this->numLinesShifted_ = LINES - 1;
90        // for the beginning, don't scroll
91        this->scroll_ = 0;
92
93        this->setConfigValues();
94        this->initialise();
95
96        // Output buffering is not anymore needed. Not the best solution to do
97        // this here, but there isn't much of another way.
98        OutputManager::getInstance().getMemoryWriter()->disable();
99    }
100
101    /**
102        @brief Destructor: Destroys the TextAreas.
103    */
104    InGameConsole::~InGameConsole()
105    {
106        this->deactivate();
107
108        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
109        InputManager::getInstance().destroyState("console");
110
111        // destroy the underlaying shell
112        delete this->shell_;
113
114        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
115        if (ovMan)
116        {
117            if (this->consoleOverlayNoise_)
118                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
119            if (this->consoleOverlayCursor_)
120                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
121            Ogre::FontManager::getSingleton().remove("MonofurConsole");
122            if (this->consoleOverlayBorder_)
123                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
124            if (this->consoleOverlayTextAreas_)
125            {
126                for (int i = 0; i < LINES; i++)
127                {
128                    if (this->consoleOverlayTextAreas_[i])
129                        Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
130                    this->consoleOverlayTextAreas_[i] = 0;
131                }
132
133            }
134            if (this->consoleOverlayContainer_)
135                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
136        }
137        if (this->consoleOverlayTextAreas_)
138        {
139            delete[] this->consoleOverlayTextAreas_;
140            this->consoleOverlayTextAreas_ = 0;
141        }
142
143        if (this->consoleOverlay_)
144            Ogre::OverlayManager::getSingleton().destroy(consoleOverlay_);
145    }
146
147    /**
148        @brief Sets the config values, describing the size of the console.
149    */
150    void InGameConsole::setConfigValues()
151    {
152        SetConfigValue(relativeWidth, 0.8);
153        SetConfigValue(relativeHeight, 0.4);
154        SetConfigValue(blinkTime, 0.5);
155        SetConfigValue(scrollSpeed_, 3.0f);
156        SetConfigValue(noiseSize_, 1.0f);
157        SetConfigValue(cursorSymbol_, '|');
158        SetConfigValue(bHidesAllInput_, false).callback(this, &InGameConsole::bHidesAllInputChanged);
159    }
160
161    /**
162        @brief Called whenever bHidesAllInput_ changes.
163    */
164    void InGameConsole::bHidesAllInputChanged()
165    {
166        if (inputState_)
167        {
168            if (bHidesAllInput_)
169            {
170                inputState_->setMouseHandler(&InputHandler::EMPTY);
171                inputState_->setJoyStickHandler(&InputHandler::EMPTY);
172            }
173            else
174            {
175                inputState_->setMouseHandler(0);
176                inputState_->setJoyStickHandler(0);
177            }
178        }
179    }
180
181    /**
182        @brief Initializes the InGameConsole.
183    */
184    void InGameConsole::initialise()
185    {
186        // create the corresponding input state
187        inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
188        inputState_->setKeyHandler(this->shell_->getInputBuffer());
189        bHidesAllInputChanged();
190
191        // create overlay and elements
192        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
193
194        // create actual overlay
195        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
196
197        // create a container
198        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
199        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
200        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
201        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
202        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
203
204        // create BorderPanel
205        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
206        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
207        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
208        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
209        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
210        this->consoleOverlayBorder_->setLeftBorderUV(0.0f, 0.49f, 0.5f, 0.51f);
211        this->consoleOverlayBorder_->setRightBorderUV(0.5f, 0.49f, 1.0f, 0.5f);
212        this->consoleOverlayBorder_->setBottomBorderUV(0.49f, 0.5f, 0.51f, 1.0f);
213        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0f, 0.5f, 0.5f, 1.0f);
214        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5f, 0.5f, 1.0f, 1.0f);
215        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
216
217        // create a new font to match the requested size exactly
218        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
219            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
220        font->setType(Ogre::FT_TRUETYPE);
221        font->setSource("Monofur.ttf");
222        font->setTrueTypeSize(18);
223        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
224        font->setTrueTypeResolution(192);
225        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
226        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
227
228        // create noise
229        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
230        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
231        this->consoleOverlayNoise_->setPosition(5,0);
232        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
233        // comment following line to disable noise
234        this->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_);
235
236        // create the text lines
237        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
238        for (int i = 0; i < LINES; i++)
239        {
240            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
241            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
242            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
243            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
244            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
245            this->consoleOverlayTextAreas_[i]->setLeft(8);
246            this->consoleOverlayTextAreas_[i]->setCaption("");
247            this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]);
248        }
249
250        // create cursor (also a text area overlay element)
251        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
252        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
253        this->consoleOverlayCursor_->setFontName("MonofurConsole");
254        this->consoleOverlayCursor_->setCharHeight(18);
255        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
256        this->consoleOverlayCursor_->setLeft(7);
257        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
258        this->consoleOverlayNoise_->addChild(this->consoleOverlayCursor_);
259
260        this->windowResized(this->getWindowWidth(), this->getWindowWidth());
261
262        // move overlay "above" the top edge of the screen
263        // we take -1.3 because the border makes the panel bigger
264        this->consoleOverlayContainer_->setTop(-1.3f * this->relativeHeight);
265
266        orxout(internal_info) << "InGameConsole initialized" << endl;
267    }
268
269    // ###############################
270    // ###  ShellListener methods  ###
271    // ###############################
272
273    /**
274        @brief Called if all output-lines have to be redrawn.
275    */
276    void InGameConsole::linesChanged()
277    {
278        Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
279        int max = 0;
280        for (int i = 1; i < LINES; ++i)
281        {
282            if (it != this->shell_->getEndIterator())
283            {
284                ++it;
285                max = i;
286            }
287            else
288                break;
289        }
290
291        for (int i = LINES - 1; i > max; --i)
292            this->print("", Shell::DebugOutput, i, true);
293
294        for (int i = max; i >= 1; --i)
295        {
296            --it;
297            this->print(it->first, it->second, i, true);
298        }
299    }
300
301    /**
302        @brief Called if a new output-line was added.
303    */
304    void InGameConsole::lineAdded()
305    {
306        this->numLinesShifted_ = 0;
307        this->shiftLines();
308        if (LINES > 1)
309            this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
310    }
311
312    /**
313        @brief Called if the text in the input-line has changed.
314    */
315    void InGameConsole::inputChanged()
316    {
317        if (LINES > 0)
318            this->print(this->shell_->getInput(), Shell::Input, 0);
319
320        if (this->shell_->getInput().empty())
321            this->inputWindowStart_ = 0;
322    }
323
324    /**
325        @brief Called if the position of the cursor in the input-line has changed.
326    */
327    void InGameConsole::cursorChanged()
328    {
329        unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_;
330        if (pos > maxCharsPerLine_)
331            pos = maxCharsPerLine_;
332
333        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
334        this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24.0f);
335    }
336
337    /**
338        @brief Called if a command is about to be executed
339    */
340    void InGameConsole::executed()
341    {
342        this->shell_->addOutput(this->shell_->getInput(), Shell::Command);
343    }
344
345    /**
346        @brief Called if the console gets closed.
347    */
348    void InGameConsole::exit()
349    {
350        this->deactivate();
351    }
352
353    // ###############################
354    // ###  other external calls   ###
355    // ###############################
356
357    /**
358        @brief Used to control the actual scrolling and the cursor.
359    */
360    void InGameConsole::preUpdate(const Clock& time)
361    {
362        if (this->scroll_ != 0)
363        {
364            float oldTop = this->consoleOverlayContainer_->getTop();
365
366            if (this->scroll_ > 0)
367            {
368                // scrolling down
369                // enlarge oldTop a little bit so that this exponential function
370                // reaches 0 before infinite time has passed...
371                float deltaScroll = (oldTop - 0.01f) * time.getDeltaTime() * this->scrollSpeed_;
372                if (oldTop - deltaScroll >= 0)
373                {
374                    // window has completely scrolled down
375                    this->consoleOverlayContainer_->setTop(0);
376                    this->scroll_ = 0;
377                }
378                else
379                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
380            }
381
382            else
383            {
384                // scrolling up
385                // note: +0.01 for the same reason as when scrolling down
386                float deltaScroll = (1.3f * this->relativeHeight + 0.01f + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
387                if (oldTop - deltaScroll <= -1.3 * this->relativeHeight)
388                {
389                    // window has completely scrolled up
390                    this->consoleOverlayContainer_->setTop(-1.3f * this->relativeHeight);
391                    this->scroll_ = 0;
392                    this->consoleOverlay_->hide();
393                }
394                else
395                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
396            }
397        }
398
399        if (this->bActive_)
400        {
401            this->cursor_ += time.getDeltaTime();
402            if (this->cursor_ >= this->blinkTime)
403            {
404                this->cursor_ = 0;
405                bShowCursor_ = !bShowCursor_;
406                if (bShowCursor_)
407                    this->consoleOverlayCursor_->show();
408                else
409                    this->consoleOverlayCursor_->hide();
410            }
411
412            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
413            float uRand = (rand() & 1023) / 1023.0f * 0.2f;
414            float vRand = (rand() & 1023) / 1023.0f * 0.2f;
415            this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
416        }
417    }
418
419    /**
420        @brief Resizes the console elements. Call if window size changes.
421    */
422    void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
423    {
424        this->windowW_ = newWidth;
425        this->windowH_ = newHeight;
426        this->consoleOverlayBorder_->setWidth((float)(int)(this->windowW_* this->relativeWidth));
427        this->consoleOverlayBorder_->setHeight((float)(int)(this->windowH_ * this->relativeHeight));
428        this->consoleOverlayNoise_->setWidth((float)(int)(this->windowW_ * this->relativeWidth) - 10.0f);
429        this->consoleOverlayNoise_->setHeight((float)(int)(this->windowH_ * this->relativeHeight) - 5.0f);
430        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
431
432        // now adjust the text lines...
433        this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 24;
434
435        if (LINES > 0)
436            this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
437        else
438            this->maxCharsPerLine_ = 10;
439
440        for (int i = 0; i < LINES; i++)
441        {
442            this->consoleOverlayTextAreas_[i]->setWidth((float)this->desiredTextWidth_);
443            this->consoleOverlayTextAreas_[i]->setTop((float)(int)(this->windowH_ * this->relativeHeight) - 24 - 14*i);
444        }
445
446        this->linesChanged();
447        this->cursorChanged();
448    }
449
450    // ###############################
451    // ###    internal methods     ###
452    // ###############################
453
454    /**
455        @brief Prints string to bottom line.
456        @param text The string to be printed
457        @param type The type of the text, defines the color
458        @param index The index of the text overlay in which the string will be displayed
459        @param alwaysShift If true the ohter lines in the console are always shifted by one line
460    */
461    void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift)
462    {
463        std::string output = text;
464        if (LINES > index)
465        {
466            this->colourLine(type, index);
467
468            if (index > 0)
469            {
470                unsigned int linesUsed = 1;
471                while (output.size() > this->maxCharsPerLine_)
472                {
473                    ++linesUsed;
474                    this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output.substr(0, this->maxCharsPerLine_)));
475                    output.erase(0, this->maxCharsPerLine_);
476                    output.insert(0, 1, ' ');
477                    if (linesUsed > numLinesShifted_ || alwaysShift)
478                        this->shiftLines();
479                    this->colourLine(type, index);
480                }
481                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
482                this->displayedText_ = output;
483                this->numLinesShifted_ = linesUsed;
484            }
485            else
486            {
487                if (output.size() > this->maxCharsPerLine_)
488                {
489                    if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
490                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition();
491                    else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
492                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
493
494                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
495                }
496                else
497                    this->inputWindowStart_ = 0;
498                this->displayedText_ = output;
499                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
500            }
501        }
502    }
503
504    /**
505        @brief Shows the InGameConsole.
506    */
507    void InGameConsole::activate()
508    {
509        if (!this->bActive_)
510        {
511            this->bActive_ = true;
512            InputManager::getInstance().enterState("console");
513            this->shell_->registerListener(this);
514
515            this->windowResized(this->windowW_, this->windowH_);
516            this->linesChanged();
517            this->cursorChanged();
518            this->consoleOverlay_->show();
519
520            // scroll down
521            this->scroll_ = 1;
522            // the rest is done by tick
523        }
524    }
525
526    /**
527    @brief Hides the InGameConsole.
528    */
529    void InGameConsole::deactivate()
530    {
531        if (this->bActive_)
532        {
533            this->bActive_ = false;
534            GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed.
535            InputManager::getInstance().leaveState("console");
536            this->shell_->unregisterListener(this);
537
538            // scroll up
539            this->scroll_ = -1;
540            // the rest is done by tick
541        }
542    }
543
544    /**
545        @brief Shifts all output lines one line up
546    */
547    void InGameConsole::shiftLines()
548    {
549        for (unsigned int i = LINES - 1; i > 1; --i)
550        {
551            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
552            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
553            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
554        }
555    }
556
557    void InGameConsole::colourLine(Shell::LineType type, int index)
558    {
559        ColourValue colourTop, colourBottom;
560        switch (type)
561        {
562            case Shell::Message:
563            case Shell::DebugOutput:     colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
564
565            case Shell::UserError:       colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;
566            case Shell::UserWarning:     colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;
567            case Shell::UserStatus:      colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;
568            case Shell::UserInfo:        colourTop = ColourValue(0.0f, 0.8f, 0.8f); break;
569
570            case Shell::InternalError:   colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;
571            case Shell::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;
572            case Shell::InternalStatus:  colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;
573            case Shell::InternalInfo:    colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;
574
575            case Shell::Verbose:         colourTop = ColourValue(0.3f, 0.3f, 0.9f); break;
576            case Shell::VerboseMore:     colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;
577            case Shell::VerboseUltra:    colourTop = ColourValue(0.1f, 0.1f, 0.5f); break;
578
579            case Shell::Command:         colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;
580            case Shell::Hint:            colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;
581            case Shell::Input:           colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
582
583            default:                     colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;
584        }
585
586        colourBottom = ColourValue(sqrt(colourTop.r), sqrt(colourTop.g), sqrt(colourTop.b));
587
588        this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
589        this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
590    }
591
592    // ################################
593    // ###      static methods      ###
594    // ################################
595
596    /**
597        @brief Activates the console.
598    */
599    /*static*/ void InGameConsole::openConsole()
600    {
601        InGameConsole::getInstance().activate();
602    }
603
604    /**
605        @brief Deactivates the console.
606    */
607    /*static*/ void InGameConsole::closeConsole()
608    {
609        GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()");  // Notify the SheetManager in lua, that the console has been closed, but not by ESC.
610        InGameConsole::getInstance().deactivate();
611    }
612
613}
Note: See TracBrowser for help on using the repository browser.