[Orxonox-commit 5005] r9671 - in code/branches/libs/src: libraries/core orxonox/chat
landauf at orxonox.net
landauf at orxonox.net
Sun Sep 8 19:30:20 CEST 2013
Author: landauf
Date: 2013-09-08 19:30:20 +0200 (Sun, 08 Sep 2013)
New Revision: 9671
Modified:
code/branches/libs/src/libraries/core/GUIManager.cc
code/branches/libs/src/libraries/core/GUIManager.h
code/branches/libs/src/orxonox/chat/ChatInputHandler.cc
code/branches/libs/src/orxonox/chat/ChatInputHandler.h
Log:
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)
Modified: code/branches/libs/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/libs/src/libraries/core/GUIManager.cc 2013-09-08 15:34:34 UTC (rev 9670)
+++ code/branches/libs/src/libraries/core/GUIManager.cc 2013-09-08 17:30:20 UTC (rev 9671)
@@ -229,7 +229,11 @@
{
if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty())
{
+#if CEGUI_VERSION >= 0x000800
+ CEGUI::System::getSingleton().renderAllGUIContexts();
+#else
CEGUI::System::getSingleton().renderGUI();
+#endif
// Important workaround! (at least required by CEGUI 0.7.5)
// If we don't reset the scissor test, OGRE will only render overlays
@@ -353,7 +357,11 @@
}
// Align CEGUI mouse with OIS mouse
+#if CEGUI_VERSION >= 0x000800
+ guiSystem_->getDefaultGUIContext().injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
+#else
guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
+#endif
// Initialise the Lua framework and load the schemes
orxout(user_info) << "Loading user interface..." << endl;
@@ -365,9 +373,15 @@
this->hudRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "HUDRootWindow");
this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow");
// And connect them
+#if CEGUI_VERSION >= 0x000800
+ CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(this->rootWindow_);
+ this->rootWindow_->addChild(this->hudRootWindow_);
+ this->rootWindow_->addChild(this->menuRootWindow_);
+#else
CEGUI::System::getSingleton().setGUISheet(this->rootWindow_);
this->rootWindow_->addChildWindow(this->hudRootWindow_);
this->rootWindow_->addChildWindow(this->menuRootWindow_);
+#endif
// No background to start with (sets the alpha value to 0)
this->setBackgroundImage("");
@@ -434,7 +448,7 @@
void GUIManager::preUpdate(const Clock& time)
{
assert(guiSystem_);
- this->protectedCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
}
/**
@@ -609,13 +623,22 @@
void GUIManager::buttonPressed(const KeyEvent& evt)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
- this->protectedCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText()));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
+#endif
}
void GUIManager::buttonReleased(const KeyEvent& evt)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
+#endif
}
/**
@@ -629,7 +652,11 @@
*/
void GUIManager::buttonPressed(MouseButtonCode::ByEnum id)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id)));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
+#endif
}
/**
@@ -643,17 +670,29 @@
*/
void GUIManager::buttonReleased(MouseButtonCode::ByEnum id)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id)));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
+#endif
}
void GUIManager::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#endif
}
void GUIManager::mouseScrolled(int abs, int rel)
{
- this->protectedCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#endif
}
/**
@@ -661,7 +700,11 @@
*/
void GUIManager::mouseLeft()
{
- this->protectedCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
+#if CEGUI_VERSION >= 0x000800
+ this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1));
+#else
+ this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
+#endif
}
/**
@@ -713,12 +756,12 @@
@return
True if input was handled, false otherwise. A caught exception yields true.
*/
- template <typename FunctionType>
- bool GUIManager::protectedCall(FunctionType function)
+ template <typename FunctionType, typename ObjectType>
+ bool GUIManager::protectedCall(FunctionType function, ObjectType object)
{
try
{
- return function(this->guiSystem_);
+ return function(object);
}
catch (CEGUI::ScriptException& ex)
{
@@ -728,6 +771,20 @@
}
}
+ template <typename FunctionType>
+ bool GUIManager::protectedCeguiSystemCall(FunctionType function)
+ {
+ return this->protectedCall(function, this->guiSystem_);
+ }
+
+#if CEGUI_VERSION >= 0x000800
+ template <typename FunctionType>
+ bool GUIManager::protectedCeguiContextCall(FunctionType function)
+ {
+ return this->protectedCall(function, this->guiSystem_->getDefaultGUIContext());
+ }
+#endif
+
/**
@brief
Subscribe the input function to the input event for the input window.
@@ -783,7 +840,11 @@
*/
void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight)
{
+#if CEGUI_VERSION >= 0x000800
+ this->guiRenderer_->setDisplaySize(CEGUI::Sizef((float)newWidth, (float)newHeight));
+#else
this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
+#endif
}
/**
@@ -833,7 +894,11 @@
if(CEGUI::FontManager::getSingleton().isDefined(name)) // If a font with that name already exists.
return;
+ #if CEGUI_VERSION >= 0x000800
+ CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", CEGUI::ASM_Both, CEGUI::Sizef(800.0f, 600.0f));
+ #else
CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", true, 800.0f, 600.0f);
+ #endif
#endif
}
Modified: code/branches/libs/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/libs/src/libraries/core/GUIManager.h 2013-09-08 15:34:34 UTC (rev 9670)
+++ code/branches/libs/src/libraries/core/GUIManager.h 2013-09-08 17:30:20 UTC (rev 9671)
@@ -155,9 +155,17 @@
void executeCode(const std::string& str);
+ template <typename FunctionType, typename ObjectType>
+ bool protectedCall(FunctionType function, ObjectType object);
+
template <typename FunctionType>
- bool protectedCall(FunctionType function);
+ bool protectedCeguiSystemCall(FunctionType function);
+#if CEGUI_VERSION >= 0x000800
+ template <typename FunctionType>
+ bool protectedCeguiContextCall(FunctionType function);
+#endif
+
void changedCeguiOutputLevel();
// keyHandler functions
Modified: code/branches/libs/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/branches/libs/src/orxonox/chat/ChatInputHandler.cc 2013-09-08 15:34:34 UTC (rev 9670)
+++ code/branches/libs/src/orxonox/chat/ChatInputHandler.cc 2013-09-08 17:30:20 UTC (rev 9671)
@@ -30,12 +30,21 @@
#include <cassert>
#include <string>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUIListbox.h>
-#include <elements/CEGUIListboxItem.h>
-#include <elements/CEGUIListboxTextItem.h>
+#if CEGUI_VERSION >= 0x000800
+# include <CEGUI/Window.h>
+# include <CEGUI/WindowManager.h>
+# include <CEGUI/widgets/Listbox.h>
+# include <CEGUI/widgets/ListboxItem.h>
+# include <CEGUI/widgets/ListboxTextItem.h>
+#else
+# include <CEGUIWindow.h>
+# include <CEGUIWindowManager.h>
+# include <elements/CEGUIListbox.h>
+# include <elements/CEGUIListboxItem.h>
+# include <elements/CEGUIListboxTextItem.h>
+#endif
+
#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
@@ -117,11 +126,15 @@
this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home);
/* GET WINDOW POINTERS */
+#if CEGUI_VERSION >= 0x000800
+ input = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox/input" );
+ inputonly = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox-inputonly/input" );
+ CEGUI::Window *history = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->getChild( "orxonox/ChatBox/history" );
+#else
input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
-
- /* get pointer to the history window */
CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
+#endif
/* cast it to a listbox */
lb_history = dynamic_cast<CEGUI::Listbox*>(history);
@@ -140,21 +153,21 @@
// three loops: red tones, blue tones and green tones
// reds
for( i = 0; i < NumberOfColors/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ { this->text_colors[ i ] = CEGUIColour( red, green, blue );
green += 0.2f, blue += 0.2f;
}
// greens
red = 0.5, green = 1, blue = 0.5;
for( ; i < NumberOfColors*2/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ { this->text_colors[ i ] = CEGUIColour( red, green, blue );
red += 0.2f, blue += 0.2f;
}
// blues
red = 0.5, green = 0.5, blue = 1;
for( ; i < NumberOfColors; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ { this->text_colors[ i ] = CEGUIColour( red, green, blue );
red += 0.2f, green += 0.2f;
}
}
@@ -271,15 +284,21 @@
if( this->fullchat )
{
/* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
+#if CEGUI_VERSION >= 0x000800
+ sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().get().getWidth()/6), cursorpos, assembled.length() );
+#else
+ sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6), cursorpos, assembled.length() );
+#endif
this->input->setProperty( "Text", assembled.substr( disp_offset ) );
}
else
{
/* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
+#if CEGUI_VERSION >= 0x000800
+ sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().get().getWidth()/6), cursorpos, assembled.length() );
+#else
+ sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6), cursorpos, assembled.length() );
+#endif
this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
}
Modified: code/branches/libs/src/orxonox/chat/ChatInputHandler.h
===================================================================
--- code/branches/libs/src/orxonox/chat/ChatInputHandler.h 2013-09-08 15:34:34 UTC (rev 9670)
+++ code/branches/libs/src/orxonox/chat/ChatInputHandler.h 2013-09-08 17:30:20 UTC (rev 9671)
@@ -32,14 +32,27 @@
#include "OrxonoxPrereqs.h"
#include <string>
-#include <CEGUIForwardRefs.h>
-#include <CEGUIcolour.h>
+#if CEGUI_VERSION >= 0x000800
+# include <CEGUI/ForwardRefs.h>
+# include <CEGUI/Colour.h>
+#else
+# include <CEGUIForwardRefs.h>
+# include <CEGUIcolour.h>
+#endif
+
#include "util/Singleton.h"
#include "chat/ChatListener.h"
namespace orxonox // tolua_export
{ // tolua_export
+
+#if CEGUI_VERSION >= 0x000800
+ typedef CEGUI::Colour CEGUIColour;
+#else
+ typedef CEGUI::colour CEGUIColour;
+#endif
+
/* class to handle chat using an InputBuffer */
class _OrxonoxExport ChatInputHandler // tolua_export
: public Singleton<ChatInputHandler>, public ChatListener
@@ -54,7 +67,7 @@
/* colors for nickname coloring */
static const int NumberOfColors = 10;
- CEGUI::colour text_colors[ NumberOfColors ];
+ CEGUIColour text_colors[ NumberOfColors ];
/** input state */
InputState *inputState;
More information about the Orxonox-commit
mailing list