Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r6105 r6417  
    4444#include "util/Convert.h"
    4545#include "util/Math.h"
    46 #include "util/UTFStringConversions.h"
     46#include "util/DisplayStringConversions.h"
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
     
    6161    SetConsoleCommand(InGameConsole, closeConsole, true);
    6262
    63     InGameConsole* InGameConsole::singletonPtr_s = 0;
    6463    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
    6564
     
    6867    */
    6968    InGameConsole::InGameConsole()
    70         : shell_(new Shell("InGameConsole", true, true))
     69        : shell_(new Shell("InGameConsole", true))
     70        , bShowCursor_(false)
    7171        , consoleOverlay_(0)
    7272        , consoleOverlayContainer_(0)
     
    218218        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
    219219
     220        // create noise
     221        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
     222        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
     223        this->consoleOverlayNoise_->setPosition(5,0);
     224        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
     225        // comment following line to disable noise
     226        this->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_);
     227
    220228        // create the text lines
    221229        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
     
    229237            this->consoleOverlayTextAreas_[i]->setLeft(8);
    230238            this->consoleOverlayTextAreas_[i]->setCaption("");
    231             this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
     239            this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]);
    232240        }
    233241
     
    240248        this->consoleOverlayCursor_->setLeft(7);
    241249        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
    242         this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
    243 
    244         // create noise
    245         this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
    246         this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
    247         this->consoleOverlayNoise_->setPosition(5,0);
    248         this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
    249         // comment following line to disable noise
    250         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
     250        this->consoleOverlayNoise_->addChild(this->consoleOverlayCursor_);
    251251
    252252        this->windowResized(this->getWindowWidth(), this->getWindowWidth());
     
    268268    void InGameConsole::linesChanged()
    269269    {
    270         std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();
     270        Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
    271271        int max = 0;
    272272        for (int i = 1; i < LINES; ++i)
     
    282282
    283283        for (int i = LINES - 1; i > max; --i)
    284             this->print("", i, true);
     284            this->print("", Shell::None, i, true);
    285285
    286286        for (int i = max; i >= 1; --i)
    287287        {
    288288            --it;
    289             this->print(*it, i, true);
     289            this->print(it->first, it->second, i, true);
    290290        }
    291291    }
     
    297297    {
    298298        if (LINES > 1)
    299             this->print(*this->shell_->getNewestLineIterator(), 1);
     299            this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
    300300    }
    301301
     
    316316    {
    317317        if (LINES > 0)
    318             this->print(this->shell_->getInput(), 0);
    319 
    320         if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
     318            this->print(this->shell_->getInput(), Shell::Input, 0);
     319
     320        if (this->shell_->getInput().empty())
    321321            this->inputWindowStart_ = 0;
    322322    }
     
    340340    void InGameConsole::executed()
    341341    {
    342         this->shell_->addOutputLine(this->shell_->getInput());
     342        this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
    343343    }
    344344
     
    358358        @brief Used to control the actual scrolling and the cursor.
    359359    */
    360     void InGameConsole::update(const Clock& time)
     360    void InGameConsole::preUpdate(const Clock& time)
    361361    {
    362362        if (this->scroll_ != 0)
     
    456456        @param s String to be printed
    457457    */
    458     void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
    459     {
    460         char level = 0;
    461         if (text.size() > 0)
    462             level = text[0];
    463 
     458    void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift)
     459    {
    464460        std::string output = text;
    465 
    466         if (level >= -1 && level <= 5)
    467             output.erase(0, 1);
    468 
    469461        if (LINES > index)
    470462        {
    471             this->colourLine(level, index);
     463            this->colourLine(type, index);
    472464
    473465            if (index > 0)
     
    477469                {
    478470                    ++linesUsed;
    479                     this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
     471                    this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output.substr(0, this->maxCharsPerLine_)));
    480472                    output.erase(0, this->maxCharsPerLine_);
    481473                    output.insert(0, 1, ' ');
    482474                    if (linesUsed > numLinesShifted_ || alwaysShift)
    483475                        this->shiftLines();
    484                     this->colourLine(level, index);
     476                    this->colourLine(type, index);
    485477                }
    486                 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
     478                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
    487479                this->displayedText_ = output;
    488480                this->numLinesShifted_ = linesUsed;
     
    502494                  this->inputWindowStart_ = 0;
    503495                this->displayedText_ = output;
    504                 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
     496                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
    505497            }
    506498        }
     
    559551    }
    560552
    561     void InGameConsole::colourLine(int colourcode, int index)
    562     {
    563         if (colourcode == -1)
    564         {
    565             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
    566             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
    567         }
    568         else if (colourcode == 1)
    569         {
    570             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
    571             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
    572         }
    573         else if (colourcode == 2)
    574         {
    575             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
    576             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
    577         }
    578         else if (colourcode == 3)
    579         {
    580             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.50, 0.50, 0.95, 1.00));
    581             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
    582         }
    583         else if (colourcode == 4)
    584         {
    585             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
    586             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
    587         }
    588         else if (colourcode == 5)
    589         {
    590             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
    591             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
    592         }
    593         else
    594         {
    595             this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
    596             this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
    597         }
     553    void InGameConsole::colourLine(Shell::LineType type, int index)
     554    {
     555        ColourValue colourTop, colourBottom;
     556        switch (type)
     557        {
     558        case Shell::Error:   colourTop = ColourValue(0.95, 0.25, 0.25, 1.00);
     559                          colourBottom = ColourValue(1.00, 0.50, 0.50, 1.00); break;
     560
     561        case Shell::Warning: colourTop = ColourValue(0.95, 0.50, 0.20, 1.00);
     562                          colourBottom = ColourValue(1.00, 0.70, 0.50, 1.00); break;
     563
     564        case Shell::Info:    colourTop = ColourValue(0.50, 0.50, 0.95, 1.00);
     565                          colourBottom = ColourValue(0.80, 0.80, 1.00, 1.00); break;
     566
     567        case Shell::Debug:   colourTop = ColourValue(0.65, 0.48, 0.44, 1.00);
     568                          colourBottom = ColourValue(1.00, 0.90, 0.90, 1.00); break;
     569
     570        case Shell::Verbose: colourTop = ColourValue(0.40, 0.20, 0.40, 1.00);
     571                          colourBottom = ColourValue(0.80, 0.60, 0.80, 1.00); break;
     572
     573        case Shell::Ultra:   colourTop = ColourValue(0.21, 0.69, 0.21, 1.00);
     574                          colourBottom = ColourValue(0.80, 1.00, 0.80, 1.00); break;
     575
     576        case Shell::Command: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
     577                          colourBottom = ColourValue(0.90, 0.90, 0.90, 0.90); break;
     578
     579        case Shell::Hint:    colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
     580                          colourBottom = ColourValue(0.90, 0.90, 0.90, 1.00); break;
     581
     582        default:             colourTop = ColourValue(0.90, 0.90, 0.90, 1.00);
     583                          colourBottom = ColourValue(1.00, 1.00, 1.00, 1.00); break;
     584        }
     585
     586        this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
     587        this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
    598588    }
    599589
  • code/trunk/src/orxonox/overlays/InGameConsole.h

    r6105 r6417  
    5252        void setConfigValues();
    5353
    54         void update(const Clock& time);
     54        void preUpdate(const Clock& time);
    5555
    5656        static void openConsole();
     
    7272
    7373        void shiftLines();
    74         void colourLine(int colourcode, int index);
     74        void colourLine(Shell::LineType type, int index);
    7575        void setCursorPosition(unsigned int pos);
    76         void print(const std::string& text, int index, bool alwaysShift = false);
     76        void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false);
    7777
    7878        void windowResized(unsigned int newWidth, unsigned int newHeight);
  • code/trunk/src/orxonox/overlays/Map.cc

    r5929 r6417  
    4949#include <OgreViewport.h>
    5050
     51#include "util/StringUtils.h"
    5152#include "core/ConsoleCommand.h"
    5253#include "core/CoreIncludes.h"
     
    9495
    9596        //Getting Scene Manager (Hack)
    96         if( !sManager_ )
    97         {
    98             ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
    99             this->sManager_ = it->getSceneManager();
    100         }
     97        ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
     98        this->sManager_ = it->getSceneManager();
    10199        if( !Map::getMapSceneManager() )
    102100        {
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r6057 r6417  
    3939#include <OgrePanelOverlayElement.h>
    4040#include <OgreRenderWindow.h>
     41#include <OgreMaterialManager.h>
     42#include <OgreTechnique.h>
     43#include <OgrePass.h>
    4144
    4245#include "util/Convert.h"
    4346#include "util/Exception.h"
    44 #include "util/StringUtils.h"
    4547#include "core/GameMode.h"
    4648#include "core/CoreIncludes.h"
     
    8385        // Get aspect ratio from the render window. Later on, we get informed automatically
    8486        this->windowAspectRatio_ = static_cast<float>(this->getWindowWidth()) / this->getWindowHeight();
    85         this->sizeCorrectionChanged();
    86 
    87         this->changedVisibility();
    88 
    89         setSize(Vector2(1.0f, 1.0f));
    90         setPickPoint(Vector2(0.0f, 0.0f));
    91         setPosition(Vector2(0.0f, 0.0f));
    92         setRotation(Degree(0.0));
    93         setAspectCorrection(false);
     87
     88        this->size_ = Vector2(1.0f, 1.0f);
     89        this->pickPoint_= Vector2(0.0f, 0.0f);
     90        this->position_ = Vector2(0.0f, 0.0f);
     91        this->angle_ = Degree(0.0);
     92        this->bCorrectAspect_ = false;
     93        this->rotState_ = Horizontal;
     94        this->angleChanged(); // updates all other values as well
     95
    9496        setBackgroundMaterial("");
    9597    }
     
    143145
    144146        if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
    145             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
     147            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
    146148
    147149        OrxonoxOverlay::overlays_s[this->getName()] = this;
     
    151153    void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
    152154    {
    153         if (this->background_ && material != "")
     155        if (this->background_ && !material.empty())
    154156            this->background_->setMaterialName(material);
    155157    }
     
    168170    {
    169171        SUPER( OrxonoxOverlay, changedVisibility );
    170        
     172
    171173        if (!this->overlay_)
    172174            return;
     
    309311        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
    310312        if (it != overlays_s.end())
    311             (*it).second->scale(Vector2(scale, scale));
     313            it->second->scale(Vector2(scale, scale));
    312314    }
    313315
     
    324326        if (it != overlays_s.end())
    325327        {
    326             OrxonoxOverlay* overlay= (*it).second;
     328            OrxonoxOverlay* overlay= it->second;
    327329            if(overlay->isVisible())
    328330                overlay->hide();
     
    343345        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
    344346        if (it != overlays_s.end())
    345             (*it).second->scroll(scroll);
     347            it->second->scroll(scroll);
    346348    }
    347349
     
    357359        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
    358360        if (it != overlays_s.end())
    359             (*it).second->rotate(angle);
     361            it->second->rotate(angle);
    360362    }
    361363
     
    370372        }
    371373    }
     374
     375    void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
     376        Ogre::MaterialPtr ptr = this->background_->getMaterial();
     377        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
     378        tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
     379    }
    372380}
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r6057 r6417  
    155155        static void rotateOverlay(const std::string& name, const Degree& angle);
    156156
     157        void setBackgroundMaterial(const std::string& material);
     158        const std::string& getBackgroundMaterial() const;
     159
     160        void setBackgroundAlpha(float alpha);
     161
    157162        virtual void changedVisibility();
    158163
     
    172177        inline OverlayGroup* getOverlayGroup() const
    173178            { return this->group_; }
    174         virtual void changedOverlayGroup() 
     179        virtual void changedOverlayGroup()
    175180            { this->changedVisibility(); }
    176181
     
    180185        virtual void sizeChanged();
    181186        virtual void positionChanged();
    182 
    183         void setBackgroundMaterial(const std::string& material);
    184         const std::string& getBackgroundMaterial() const;
    185187
    186188        Ogre::Overlay* overlay_;                   //!< The overlay the entire class is about.
     
    205207        BaseObject* owner_;
    206208        OverlayGroup* group_;
     209        Ogre::Pass* backgroundAlphaPass_;
    207210  };
    208211
  • code/trunk/src/orxonox/overlays/OverlayGroup.cc

    r6054 r6417  
    144144    {
    145145        SUPER( OverlayGroup, changedVisibility );
    146        
     146
    147147        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    148148            (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
Note: See TracChangeset for help on using the changeset viewer.