Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8884 was 8858, checked in by landauf, 13 years ago

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

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