Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/GUIManager.cc

    r11052 r11071  
    3232#include <fstream>
    3333#include <memory>
    34 #include <boost/bind.hpp>
     34#include <functional>
    3535#include <OgreRenderQueue.h>
    3636#include <OgreRenderWindow.h>
     
    119119namespace orxonox
    120120{
     121    namespace arg = std::placeholders;
     122
    121123    static void key_esc()
    122124        { GUIManager::getInstance().keyESC(); }
     
    126128    {
    127129    public:
    128         void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
     130        virtual void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) override
    129131        {
    130132            OutputLevel orxonoxLevel = level::debug_output;
     
    145147
    146148        /// Carbon copy from CEGUIDefaultLogger.cpp with a bugfix for Windows
    147         void setLogFilename(const CEGUI::String& filename, bool append = false)
     149        virtual void setLogFilename(const CEGUI::String& filename, bool append = false) override
    148150        {
    149151            // Close current log file (if any)
     
    169171                d_caching = false;
    170172
    171                 std::vector<std::pair<CEGUI::String, CEGUI::LoggingLevel> >::iterator it = d_cache.begin();
     173                std::vector<std::pair<CEGUI::String, CEGUI::LoggingLevel>>::iterator it = d_cache.begin();
    172174
    173175                while (it != d_cache.end())
     
    230232    public:
    231233        /// Callback from Ogre invoked before other stuff in our target queue is rendered
    232         void renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)
     234        virtual void renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue) override
    233235        {
    234236            if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty())
     
    252254    static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
    253255
    254     GUIManager* GUIManager::singletonPtr_s = 0;
     256    GUIManager* GUIManager::singletonPtr_s = nullptr;
    255257    /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen"; //Alternative: Orxonox (not fully complete yet, see the graphics menu)
    256258
     
    265267            ArgumentCompletionList names;
    266268            const std::vector<std::string> guis = GUIManager::getInstance().getLoadedGUIs();
    267             for (size_t i = 0; i < guis.size(); ++i)
    268                 names.push_back(ArgumentCompletionListElement(guis[i], getLowercase(guis[i])));
     269            for (const std::string gui : guis)
     270                names.push_back(ArgumentCompletionListElement(gui, getLowercase(gui)));
    269271            return names;
    270272        }
     
    291293    */
    292294    GUIManager::GUIManager(const std::pair<int, int>& mousePosition)
    293         : guiRenderer_(NULL)
    294         , resourceProvider_(NULL)
     295        : guiRenderer_(nullptr)
     296        , resourceProvider_(nullptr)
    295297#ifndef ORXONOX_OLD_CEGUI
    296         , rqListener_(NULL)
    297         , imageCodec_(NULL)
    298 #endif
    299         , luaState_(NULL)
    300         , scriptModule_(NULL)
    301         , guiSystem_(NULL)
    302         , ceguiLogger_(NULL)
    303         , rootWindow_(NULL)
    304         , hudRootWindow_(NULL)
    305         , menuRootWindow_(NULL)
    306         , camera_(NULL)
     298        , rqListener_(nullptr)
     299        , imageCodec_(nullptr)
     300#endif
     301        , luaState_(nullptr)
     302        , scriptModule_(nullptr)
     303        , guiSystem_(nullptr)
     304        , ceguiLogger_(nullptr)
     305        , rootWindow_(nullptr)
     306        , hudRootWindow_(nullptr)
     307        , menuRootWindow_(nullptr)
     308        , camera_(nullptr)
    307309        , destructionHelper_(this)
    308310    {
     
    353355
    354356        // Create our own logger to specify the filepath
    355         std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
     357        std::unique_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
    356358        ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log");
    357359        ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
     
    360362        // Create the CEGUI system singleton
    361363#ifdef ORXONOX_OLD_CEGUI
    362         guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_);
     364        guiSystem_ = new System(guiRenderer_, resourceProvider_, nullptr, scriptModule_);
    363365        // Add functions that have been renamed in newer versions
    364366        luaState_->doString("CEGUI.SchemeManager.create = CEGUI.SchemeManager.loadScheme");
     
    366368        luaState_->doString("CEGUI.ImagesetManager.createFromImageFile= CEGUI.ImagesetManager.createImagesetFromImageFile");
    367369#else
    368         guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, 0, imageCodec_, scriptModule_);
     370        guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, nullptr, imageCodec_, scriptModule_);
    369371#endif
    370372
     
    474476    {
    475477        assert(guiSystem_);
    476         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
     478        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectTimePulse, arg::_1, time.getDeltaTime()));
    477479    }
    478480
     
    490492    {
    491493#ifdef ORXONOX_OLD_CEGUI
    492         if (camera == NULL)
    493             this->guiRenderer_->setTargetSceneManager(0);
     494        if (camera == nullptr)
     495            this->guiRenderer_->setTargetSceneManager(nullptr);
    494496        else
    495497            this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
    496498#else
    497         if (camera_ != NULL && camera_->getSceneManager() != NULL)
     499        if (camera_ != nullptr && camera_->getSceneManager() != nullptr)
    498500            camera_->getSceneManager()->removeRenderQueueListener(rqListener_);
    499         if (camera != NULL && camera->getSceneManager() != NULL)
     501        if (camera != nullptr && camera->getSceneManager() != nullptr)
    500502            camera->getSceneManager()->addRenderQueueListener(rqListener_);
    501503#endif
     
    672674    {
    673675#if CEGUI_VERSION >= 0x000800
    674         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
    675         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText()));
    676 #else
    677         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
    678         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
     676        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyDown, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     677        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectChar, arg::_1, evt.getText()));
     678#else
     679        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyDown, arg::_1, evt.getKeyCode()));
     680        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectChar, arg::_1, evt.getText()));
    679681#endif
    680682    }
     
    683685    {
    684686#if CEGUI_VERSION >= 0x000800
    685         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
    686 #else
    687         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
     687        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyUp, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     688#else
     689        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyUp, arg::_1, evt.getKeyCode()));
    688690#endif
    689691    }
     
    701703    {
    702704#if CEGUI_VERSION >= 0x000800
    703         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id)));
    704 #else
    705         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
     705        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonDown, arg::_1, convertButton(id)));
     706#else
     707        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonDown, arg::_1, convertButton(id)));
    706708#endif
    707709    }
     
    719721    {
    720722#if CEGUI_VERSION >= 0x000800
    721         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id)));
    722 #else
    723         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
     723        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonUp, arg::_1, convertButton(id)));
     724#else
     725        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonUp, arg::_1, convertButton(id)));
    724726#endif
    725727    }
     
    728730    {
    729731#if CEGUI_VERSION >= 0x000800
    730         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y));
    731 #else
    732         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
     732        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y));
     733#else
     734        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y));
    733735#endif
    734736    }
     
    737739    {
    738740#if CEGUI_VERSION >= 0x000800
    739         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
    740 #else
    741         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
     741        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_));
     742#else
     743        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_));
    742744#endif
    743745    }
     
    749751    {
    750752#if CEGUI_VERSION >= 0x000800
    751         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1));
    752 #else
    753         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
     753        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseLeaves, arg::_1));
     754#else
     755        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseLeaves, arg::_1));
    754756#endif
    755757    }
     
    798800        terminate the whole program...
    799801    @note
    800         Your life gets easier if you use boost::bind to create the object/function.
     802        Your life gets easier if you use std::bind to create the object/function.
    801803    @param function
    802804        Any callable object/function that takes this->guiSystem_ as its only parameter.
     
    921923            return;
    922924
    923         CEGUI::Font* font = NULL;
     925        CEGUI::Font* font = nullptr;
    924926        CEGUI::XMLAttributes xmlAttributes;
    925927
     
    937939
    938940        font = CEGUI::FontManager::getSingleton().createFont("FreeType", xmlAttributes);
    939         if(font != NULL)
     941        if(font != nullptr)
    940942            font->load();
    941943#else
Note: See TracChangeset for help on using the changeset viewer.