Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9671


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
Files:
4 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();
  • code/branches/libs/src/orxonox/chat/ChatInputHandler.cc

    r8858 r9671  
    3131#include <cassert>
    3232#include <string>
    33 #include <CEGUIWindow.h>
    34 #include <CEGUIWindowManager.h>
    35 #include <elements/CEGUIListbox.h>
    36 #include <elements/CEGUIListboxItem.h>
    37 #include <elements/CEGUIListboxTextItem.h>
     33
     34#if CEGUI_VERSION >= 0x000800
     35#   include <CEGUI/Window.h>
     36#   include <CEGUI/WindowManager.h>
     37#   include <CEGUI/widgets/Listbox.h>
     38#   include <CEGUI/widgets/ListboxItem.h>
     39#   include <CEGUI/widgets/ListboxTextItem.h>
     40#else
     41#   include <CEGUIWindow.h>
     42#   include <CEGUIWindowManager.h>
     43#   include <elements/CEGUIListbox.h>
     44#   include <elements/CEGUIListboxItem.h>
     45#   include <elements/CEGUIListboxTextItem.h>
     46#endif
    3847
    3948#include "util/ScopedSingletonManager.h"
     
    118127
    119128    /* GET WINDOW POINTERS */
     129#if CEGUI_VERSION >= 0x000800
     130    input = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox/input" );
     131    inputonly = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox-inputonly/input" );
     132    CEGUI::Window *history = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox/history" );
     133#else
    120134    input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
    121135    inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
    122 
    123     /* get pointer to the history window */
    124136    CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
     137#endif
    125138
    126139    /* cast it to a listbox */
     
    141154    // reds
    142155    for( i = 0; i < NumberOfColors/3; ++i )
    143     { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
     156    { this->text_colors[ i ] = CEGUIColour( red, green, blue );
    144157      green += 0.2f, blue += 0.2f;
    145158    }
     
    148161    red = 0.5, green = 1, blue = 0.5;
    149162    for( ; i < NumberOfColors*2/3; ++i )
    150     { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
     163    { this->text_colors[ i ] = CEGUIColour( red, green, blue );
    151164      red += 0.2f, blue += 0.2f;
    152165    }
     
    155168    red = 0.5, green = 0.5, blue = 1;
    156169    for( ; i < NumberOfColors; ++i )
    157     { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
     170    { this->text_colors[ i ] = CEGUIColour( red, green, blue );
    158171      red += 0.2f, green += 0.2f;
    159172    }
     
    272285    {
    273286      /* adjust curser position - magic number 5 for font width */
    274       sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
    275         cursorpos, assembled.length() );
     287#if CEGUI_VERSION >= 0x000800
     288      sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().get().getWidth()/6), cursorpos, assembled.length() );
     289#else
     290      sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6), cursorpos, assembled.length() );
     291#endif
    276292      this->input->setProperty( "Text", assembled.substr( disp_offset ) );
    277293    }
     
    279295    {
    280296      /* adjust curser position - magic number 5 for font width */
    281       sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
    282         cursorpos, assembled.length() );
     297#if CEGUI_VERSION >= 0x000800
     298      sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().get().getWidth()/6), cursorpos, assembled.length() );
     299#else
     300      sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6), cursorpos, assembled.length() );
     301#endif
    283302      this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
    284303    }
  • code/branches/libs/src/orxonox/chat/ChatInputHandler.h

    r8858 r9671  
    3333
    3434#include <string>
    35 #include <CEGUIForwardRefs.h>
    36 #include <CEGUIcolour.h>
     35
     36#if CEGUI_VERSION >= 0x000800
     37#   include <CEGUI/ForwardRefs.h>
     38#   include <CEGUI/Colour.h>
     39#else
     40#   include <CEGUIForwardRefs.h>
     41#   include <CEGUIcolour.h>
     42#endif
    3743
    3844#include "util/Singleton.h"
     
    4147namespace orxonox // tolua_export
    4248{ // tolua_export
     49
     50#if CEGUI_VERSION >= 0x000800
     51  typedef CEGUI::Colour CEGUIColour;
     52#else
     53  typedef CEGUI::colour CEGUIColour;
     54#endif
     55
    4356  /* class to handle chat using an InputBuffer */
    4457  class _OrxonoxExport ChatInputHandler  // tolua_export
     
    5568      /* colors for nickname coloring */
    5669      static const int NumberOfColors = 10;
    57       CEGUI::colour text_colors[ NumberOfColors ];
     70      CEGUIColour text_colors[ NumberOfColors ];
    5871
    5972      /** input state */
Note: See TracChangeset for help on using the changeset viewer.