Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Which is more efficient? (https://forums.graalonline.com/forums/showthread.php?t=78620)

DustyPorViva 02-07-2008 10:55 PM

Which is more efficient?
 
I was reading the other thread about the news thing...
Anyways, which is more efficient, letting a GUI be closed(and destroyed) and recreating it whenever it's needed or having it hide on being closed, and simply showing it when needed?
I'm asking because I'm not sure how exactly GUI's are handled and if having one destroyed is quite the same as one that's not visible. So I guess this is a question for those a bit in the knowing about the behind-the-scenes stuff.

cbk1994 02-07-2008 11:04 PM

Well, storing it won't take CPU, but memory.

Destroying it and then recreating it would take CPU but in spikes.

Twinny 02-07-2008 11:30 PM

I always use the destroy/recreate method when I'm working on it....then just forget to take it out ^^

napo_p2p 02-07-2008 11:52 PM

I'm not so sure, either. I normally just create them then change the visible flag. I believe the scripted RC does this also.

Skyld 02-08-2008 12:10 AM

Quote:

Originally Posted by napo_p2p (Post 1374055)
I'm not so sure, either. I normally just create them then change the visible flag. I believe the scripted RC does this also.

The Scripted RC's main window with RC chat is created when you first start to use it, hidden when you use the X button or F6, rather than destroyed, and brought back as needed. All of the other windows are destroyed, and are recreated as necessary.

zokemon 02-08-2008 12:29 AM

You can notice that all of the default built-in guis are never destroyed but are in fact hidden.

coreys 02-08-2008 01:07 AM

It usually depends for me. If it's a Gui that can change a lot, I generally don't destroy it, so I won't have to use a lot of processing bringing it back. Otherwise I do destroy and recreate it.

Admins 02-08-2008 02:31 AM

If you hide it and show it again later then the position and size are the same, which is often better than recreating it and the user needs to move it again if it's not at the good place. You can use showtop() to make the window appear on top, un-minimize and get the input focus.
Normally creating and hiding windows is not a big problem, they might take a few kbytes in memory but should not be a speed problem. There are many default windows (playerlist, F5, F2 etc.) which are created in invisible state when you login to the login server. For stuff like PM windows it needs to create new windows of course, and is then also destroying them when you close them.
So I would say if you only need the window one time then destroy it afterwards, and if you plan to open it several times then just hide and reopen it next time.

zokemon 02-08-2008 08:47 AM

Exactly. For something like an inventory or a player chat system, you should most likely just be hiding/showing it. Something that creates a separate GUI for each instance should just be created/destroyed.

I also sometimes go in the middle and show/hide a main gui but destroy its contents for GUIs that are ambiguous.


All times are GMT +2. The time now is 11:25 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.