Jump to content
Sign in to follow this  
Heeeere's johnny!

Is it possible to store and reload controls without having to recreate them?

Recommended Posts

Hey guyz,

seemingly, it's possible to store a created control into an array, like this:

allMyControls = [];
allMyControls pushBack (findDisplay 46 ctrlCreate ["RscButton", 12345]);

In that case, a button with the IDC 12345 will be visible as long as the display is visible. As soon as the display closes, the button disapplears (obviously), yet it's still in the array, but its IDC is now -1 and it wouldn't change back to its original one, even when the display it was added to is open again.

So the question is, if the control is stored in that array, can that somehow be readded to a display? Is it maybe possible to work some magic with uiNamespace?

I'd be glad for help!

Have a nice Play!

Johnny

Share this post


Link to post
Share on other sites

I'm not sure this is possible, I think when dialogs are closed all of the controls are deleted. Here's what I'm using in a current project:

{
ctrlEnable [_x, _this];
ctrlShow [_x, _this];
}forEach [1001,1002,1400,1401,1603,1604];

The only problem with this is that the dialog is still open, those controls are just hidden

Share this post


Link to post
Share on other sites

Yeah, I already thought about this too, but the problem begins when you want to open another display or when you've got a dialogue which you need to close in order to be fully functional again, gamewise.

Share this post


Link to post
Share on other sites

There's nothing up with it. It's just a needless overhead to create the control again and again, everytime it's needed even if it's allways the exact same element. There should be a possibility to add an existing control to a display/dialogue.

Share this post


Link to post
Share on other sites

Ok, but controls cease to exist if you close your dialog.

If you consider, this is not that bad design decision. You usually open dialogs when you don't shoot and such, so performance dips are not recognised.

However keeping unnecessary ui elements in memory is unnecessary.

Share this post


Link to post
Share on other sites

I know, it doesn't matter timely and it's "only" a discussion about performance and look as it might not look very smooth if a whole display is "puzzleing" together.

But if you take the code from my initial post, you'll see that the control actually remains in that array, even after the display is closed.

Share this post


Link to post
Share on other sites

The question is how it is stored in your array. Data remaining there doesn't necessarily mean that the control still exists.

My solution against the annoying puzzle-ing is that I hide it until it's all loaded. All you sense is the some frames delay, but you get that with default BIS dialogs as well, probably for the same reasons.

---------- Post added at 12:55 AM ---------- Previous post was at 12:49 AM ----------

Or for super fast, super smooth shows if it is this necessary, have a master rsc and hide/show elements on it together with a second layer of dialog which handle actions but not shows.

Overkill and totally not worth it, but smooth as hell. :-)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×