hello!
I am trying to do such a basic thing as copying a window. How do I do it? :O
I have a CEGUI::Pushbutton that I want to duplicate.
How to clone/copy windows
Moderators: CEGUI MVP, CEGUI Team
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Re: How to clone/copy windows
Hi,
Such a basic thing is not possible out of the box You'd need a copy method which copies all your properties and such. Something like this:
This should compile pretty well i hope Of course, wrap some try-catch handlers and all that. And maybe you want an argument to specify your own copy name, instead my "_copy" example. Copying properties like this is more expensive then copying members, but this is the most generic, since different window types support different kinds of properties.
HTH.
Such a basic thing is not possible out of the box You'd need a copy method which copies all your properties and such. Something like this:
Code: Select all
//------------------------------------------------------------------------
Window* CopyWindow( const CEGUI::Window* pSource )
{
// create window of same type, but different name
Window* copy = CEGUI::WindowManager::getSingleton().createWindow(pSource->getType(), pSource->getName() + "_copy");
// Copy the properties
CEGUI::PropertySet::Iterator propertyIt = pSource->getPropertyIterator();
while (!propertyIt.isAtEnd())
{
const CEGUI::String propertyName = propertyIt.getCurrentKey();
copy->setProperty(propertyName, pSource->getProperty(propertyName));
propertyIt++;
}
return copy;
}
This should compile pretty well i hope Of course, wrap some try-catch handlers and all that. And maybe you want an argument to specify your own copy name, instead my "_copy" example. Copying properties like this is more expensive then copying members, but this is the most generic, since different window types support different kinds of properties.
HTH.
Check out my released snake game using Cegui!
Re: How to clone/copy windows
As this is something which is rather common, have there been any thoughts of adding a clone() member to CEGUI::Window?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: How to clone/copy windows
I have not given it any thought, no. I'll add a ticket for a feature request.
CE.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Who is online
Users browsing this forum: No registered users and 7 guests