Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 8, 2013, 7:30:20 PM (11 years ago)
Author:
landauf
Message:

adjusted code to compile with cegui 0.8 and 0.7. see www.cegui.org.uk/wiki/index.php/Changes_and_Porting_Tips_for_0.8.0

doesn't run yet (lua scripts fail)

Location:
code/branches/libs/src/libraries/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/libs/src/libraries/core/GUIManager.cc

    r9670 r9671  
    230230            if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty())
    231231            {
     232#if CEGUI_VERSION >= 0x000800
     233                CEGUI::System::getSingleton().renderAllGUIContexts();
     234#else
    232235                CEGUI::System::getSingleton().renderGUI();
     236#endif
    233237
    234238                // Important workaround! (at least required by CEGUI 0.7.5)
     
    354358
    355359        // Align CEGUI mouse with OIS mouse
     360#if CEGUI_VERSION >= 0x000800
     361        guiSystem_->getDefaultGUIContext().injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
     362#else
    356363        guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
     364#endif
    357365
    358366        // Initialise the Lua framework and load the schemes
     
    366374        this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow");
    367375        // And connect them
     376#if CEGUI_VERSION >= 0x000800
     377        CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(this->rootWindow_);
     378        this->rootWindow_->addChild(this->hudRootWindow_);
     379        this->rootWindow_->addChild(this->menuRootWindow_);
     380#else
    368381        CEGUI::System::getSingleton().setGUISheet(this->rootWindow_);
    369382        this->rootWindow_->addChildWindow(this->hudRootWindow_);
    370383        this->rootWindow_->addChildWindow(this->menuRootWindow_);
     384#endif
    371385
    372386        // No background to start with (sets the alpha value to 0)
     
    435449    {
    436450        assert(guiSystem_);
    437         this->protectedCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
     451        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
    438452    }
    439453
     
    610624    void GUIManager::buttonPressed(const KeyEvent& evt)
    611625    {
    612         this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
    613         this->protectedCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
     626#if CEGUI_VERSION >= 0x000800
     627        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     628        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText()));
     629#else
     630        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
     631        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
     632#endif
    614633    }
    615634
    616635    void GUIManager::buttonReleased(const KeyEvent& evt)
    617636    {
    618         this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
     637#if CEGUI_VERSION >= 0x000800
     638        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     639#else
     640        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
     641#endif
    619642    }
    620643
     
    630653    void GUIManager::buttonPressed(MouseButtonCode::ByEnum id)
    631654    {
    632         this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
     655#if CEGUI_VERSION >= 0x000800
     656        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id)));
     657#else
     658        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
     659#endif
    633660    }
    634661
     
    644671    void GUIManager::buttonReleased(MouseButtonCode::ByEnum id)
    645672    {
    646         this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
     673#if CEGUI_VERSION >= 0x000800
     674        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id)));
     675#else
     676        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
     677#endif
    647678    }
    648679
    649680    void GUIManager::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    650681    {
    651         this->protectedCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
     682#if CEGUI_VERSION >= 0x000800
     683        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y));
     684#else
     685        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
     686#endif
    652687    }
    653688
    654689    void GUIManager::mouseScrolled(int abs, int rel)
    655690    {
    656         this->protectedCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
     691#if CEGUI_VERSION >= 0x000800
     692        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
     693#else
     694        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
     695#endif
    657696    }
    658697
     
    662701    void GUIManager::mouseLeft()
    663702    {
    664         this->protectedCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
     703#if CEGUI_VERSION >= 0x000800
     704        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1));
     705#else
     706        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
     707#endif
    665708    }
    666709
     
    714757        True if input was handled, false otherwise. A caught exception yields true.
    715758    */
    716     template <typename FunctionType>
    717     bool GUIManager::protectedCall(FunctionType function)
     759    template <typename FunctionType, typename ObjectType>
     760    bool GUIManager::protectedCall(FunctionType function, ObjectType object)
    718761    {
    719762        try
    720763        {
    721             return function(this->guiSystem_);
     764            return function(object);
    722765        }
    723766        catch (CEGUI::ScriptException& ex)
     
    728771        }
    729772    }
     773
     774    template <typename FunctionType>
     775    bool GUIManager::protectedCeguiSystemCall(FunctionType function)
     776    {
     777        return this->protectedCall(function, this->guiSystem_);
     778    }
     779
     780#if CEGUI_VERSION >= 0x000800
     781    template <typename FunctionType>
     782    bool GUIManager::protectedCeguiContextCall(FunctionType function)
     783    {
     784        return this->protectedCall(function, this->guiSystem_->getDefaultGUIContext());
     785    }
     786#endif
    730787
    731788    /**
     
    784841    void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight)
    785842    {
     843#if CEGUI_VERSION >= 0x000800
     844        this->guiRenderer_->setDisplaySize(CEGUI::Sizef((float)newWidth, (float)newHeight));
     845#else
    786846        this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
     847#endif
    787848    }
    788849
     
    834895            return;
    835896
     897    #if CEGUI_VERSION >= 0x000800
     898        CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", CEGUI::ASM_Both, CEGUI::Sizef(800.0f, 600.0f));
     899    #else
    836900        CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", true, 800.0f, 600.0f);
     901    #endif
    837902#endif
    838903    }
  • code/branches/libs/src/libraries/core/GUIManager.h

    r9670 r9671  
    156156        void executeCode(const std::string& str);
    157157
     158        template <typename FunctionType, typename ObjectType>
     159        bool protectedCall(FunctionType function, ObjectType object);
     160
    158161        template <typename FunctionType>
    159         bool protectedCall(FunctionType function);
     162        bool protectedCeguiSystemCall(FunctionType function);
     163
     164#if CEGUI_VERSION >= 0x000800
     165        template <typename FunctionType>
     166        bool protectedCeguiContextCall(FunctionType function);
     167#endif
    160168
    161169        void changedCeguiOutputLevel();
Note: See TracChangeset for help on using the changeset viewer.