Using templates as a way to duplicate

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
arn
Just popping in
Just popping in
Posts: 7
Joined: Tue Jan 13, 2009 02:10

Using templates as a way to duplicate

Postby arn » Tue Jan 13, 2009 15:06

There is a way to use templates in CEGUI? . I mean, load several windows from a .layout file, and duplicate these windows for several purposes.

For example, I want to reutilize a ok-cancel dialog (with two buttons on it), But I would like to have several dialogs, each one with it's own purpose and linked also to different events in my application.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Tue Jan 13, 2009 16:53

Sounds like you want to copy a CEGUI window? Try this thread: http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3584

dmail
Quite a regular
Quite a regular
Posts: 46
Joined: Mon Nov 27, 2006 16:49

Re: Using templates as a way to duplicate

Postby dmail » Tue Jan 13, 2009 17:56

arn wrote:For example, I want to reutilize a ok-cancel dialog (with two buttons on it), But I would like to have several dialogs, each one with it's own purpose and linked also to different events in my application.

Yes this is something I do with these sort of dialog boxes.
The layout just has the ok/cancel button and a text box attached to a window and the class which wraps it:
The constructor
-loads the layout
-attaches two functors, one for ok and one for cancel.(these are not CEGUI event functors yet a functor to another class instance)
-sets the window message text
-registers the events
-attaches the window to the root
The destructor.
-detaches the window from the root
-de-registers the events
-unloads the layout

As there is ever only one instance of the window there is no problems with window duplicate names and this window is ok to load and unload as it is never shown in time critical situations (it is in essence a blocking operation)

User avatar
arn
Just popping in
Just popping in
Posts: 7
Joined: Tue Jan 13, 2009 02:10

Postby arn » Tue Jan 13, 2009 18:34

Yes, I want to copy a whole tree, Unfortunately I have to deal also with the naming issue, because I want several copies working at the same time. I think it is not so difficult to do an appropiate algorithm for it.

While that kind of copying is not part of CEGUI itself, I have to code by myself.

Thanks anyway

earthsruler
Quite a regular
Quite a regular
Posts: 74
Joined: Mon Apr 28, 2008 23:21
Location: Australia

Postby earthsruler » Tue Jan 13, 2009 23:00

Window* loadWindowLayout(const String& filename, bool generateRandomPrefix);

You can use that function of the window manager to load the same layout with different prefixes. The only problem is that you then cant rely on the names defined within the layout file cause they could now have a random prefix.

ER.

User avatar
arn
Just popping in
Just popping in
Posts: 7
Joined: Tue Jan 13, 2009 02:10

Postby arn » Wed Jan 14, 2009 02:27

If I used that method, I wouldn't identify the windows inside.

Can I rely on the order that the windows exist inside the layout?

In any case, which class loadWindowLayout method belongs to?

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Jan 14, 2009 08:11

Hi,

you might want to check this post: http://www.cegui.org.uk/phpBB2/viewtopi ... =deep+copy

It explains a little about deep copying of widget trees.

In any case, which class loadWindowLayout method belongs to?


Thas would be the WindowManager.

HTH.
Check out my released snake game using Cegui!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests