LordJonas wrote:Any chance of you posting a link to the code? I'm very interested in the integration with CEGUI...
For now I don't want to share the whole code because it's quite poorly written
Atm my CEGUI stuff is almost all hard coded in the main, here's an excerpt :
Code: Select all
/*
* This will create and initialise the following objects :
*- CEGUI::IrrlichtRenderer
*- CEGUI::IrrlichtResourceProvider
*- CEGUI::IrrlichtImageCodec
*- CEGUI::System
*/
/*IrrlichtRenderer& guiRenderer = */IrrlichtRenderer::bootstrapSystem(*device);
IrrlichtResourceProvider * IRprovider = static_cast<IrrlichtResourceProvider*>(System::getSingleton().getResourceProvider());
IRprovider->setResourceGroupDirectory("schemes",resourcesPath+"schemes");
IRprovider->setResourceGroupDirectory("imagesets",resourcesPath+"imagesets");
IRprovider->setResourceGroupDirectory("fonts",resourcesPath+"fonts");
IRprovider->setResourceGroupDirectory("layouts",resourcesPath+"layouts");
IRprovider->setResourceGroupDirectory("looknfeels",resourcesPath+"looknfeel");
IRprovider->setResourceGroupDirectory("lua_scripts",resourcesPath+"lua_scripts");
ImageManager::setImagesetDefaultResourceGroup("imagesets");
Font::setDefaultResourceGroup("fonts");
Scheme::setDefaultResourceGroup("schemes");
WidgetLookManager::setDefaultResourceGroup("looknfeels");
WindowManager::setDefaultResourceGroup("layouts");
ScriptModule::setDefaultResourceGroup("lua_scripts");
CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
Font* CEGUIFont = &(CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-10.font"));
System::getSingleton().getDefaultGUIContext().setDefaultFont( "DejaVuSans-10" );
System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
System::getSingleton().getDefaultGUIContext().getMouseCursor().setVisible(true);
//creating the root window which is invisible
WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
System::getSingleton().getDefaultGUIContext().setRootWindow(myRoot);
//menu
Window* myMenu = wmgr.createWindow( "DefaultWindow", "menu" );
myRoot->getRootWindow()->addChild(myMenu);
myMenu->setVisible(false);
myMenu->deactivate();
//interface
Window* myInterface = wmgr.createWindow( "DefaultWindow", "interface" );
myRoot->getRootWindow()->addChild(myInterface);
//creating a test window
FrameWindow* fWnd = static_cast<FrameWindow*>(wmgr.createWindow( "TaharezLook/FrameWindow", "testWindow" ));
//add the new window to the menu
myMenu->addChild(fWnd);
// position a quarter of the way in from the top-left of parent.
//UDim(scale,offset) | scale in %, offset in pixels
fWnd->setPosition( UVector2( UDim( 0.25, 0 ), UDim( 0.25, 0 ) ) );
// set size to be half the size of the parent
fWnd->setSize( USize( UDim( 0.5, 0 ), UDim( 0.5, 0 ) ) );
fWnd->setText( "Hello World!" );
//the menu window can't be modified by the mouse
myMenu->setMousePassThroughEnabled(true);
Basically here I create the root window and then I bind to it 2 other windows, the menu window (when all the windows pop up in my video) and the interface window (the "in-game" window). Then I attach to the menu window a standard window "hello world".
To interact with the windows you need to add some code in the Irrlicht event manager (I basically have the same as in the tutorials):
Code: Select all
case irr::KEY_KEY_0:
CEGUI::System::getSingleton().getDefaultGUIContext().injectChar(0x0030);
return true;
case irr::KEY_BACK:
CEGUI::System::getSingleton().getDefaultGUIContext().injectKeyDown(CEGUI::Key::Backspace);
//for now the keyup is here (put it into the Irrlicht keyup)
CEGUI::System::getSingleton().getDefaultGUIContext().injectKeyUp(CEGUI::Key::Backspace);
return true;
For the mouse it's almost the same mechanism, when you click it triggers the Irrlicht event manager to change a mousestate struct (that you need to code and holds the mouse buttons states) and then use for example :
Code: Select all
System::getSingleton().getDefaultGUIContext().injectMouseButtonDown(LeftButton);
Last but not least, don't forget to call :
Code: Select all
CEGUI::System::getSingleton().injectTimePulse(deltaTime*0.001);
You need to read
http://www.cegui.org.uk/wiki/index.php/ ... ll_Widgets to understand how it works but it's not up to date.
I have another video focusing more on physics this time (I know the quality is pretty bad) :
https://www.youtube.com/watch?v=1YYqM8z1jtU