Jump to content
Sign in to follow this  
zapat

UI variables disappearing?

Recommended Posts

THE BACKGROUND:

I have a pretty complex menu, with lots of dynamic content and buttons.

in my menu.hpp I set PLGRMUI_menuDisplay variable to remember the menuId by

onLoad = "uiNamespace setVariable ['PLGRMUI_menuDisplay', _this select 0];";

So I can manipulate the UI when being opened.

After creating the menu by createDialog, I set dynamic content by referring to eg. PLGRMUI_menuDisplay displayCtrl 1003;

with uiNamespace do

with uiNamespace do    
{
 (PLGRMUI_menuDisplay displayCtrl 1003) ctrlSetTooltip "blahblah";
  //looots of similiar settings
};

THE PROBLEM:

every once in a while, when opening the menu I get error: undefined variable PLGRMUI_menuDisplay. in everchanging lines of the sqf which sets the dynamic content.

NOT content related. PLGRMUI_menuDisplay should stay until next opening of the menu, shouldn't it?

It seems that if creating the menu takes more than x time, PLGRMUI_menuDisplay becomes nil.

Every help is much appreciated.

Share this post


Link to post
Share on other sites

not sure how you use your code, but what about:

private "_var";

_var = (uiNamespace getVariable "PLGRMUI_menuDisplay");

with uiNamespace do    
{
 (_var displayCtrl 1003) ctrlSetTooltip "blahblah";
  //looots of similiar settings
}; 

Share this post


Link to post
Share on other sites

Thanks JTS,

It is working with

disableserialization and using local _var!

Anyhow, UInamespace variables seem to disappear after a while.

Share this post


Link to post
Share on other sites
Anyhow, UInamespace variables seem to disappear after a while.

hm. Don't know anything about it. I don't had problems with that, playing 2 hours :D

Share this post


Link to post
Share on other sites

This might be a race condition. If so, then simply waiting for the variable to exist should fix it:

with uiNamespace do    
{
   waitUntil not isNil { PLGRMUI_menuDisplay };
   (PLGRMUI_menuDisplay displayCtrl 1003) ctrlSetTooltip "blahblah";
   //looots of similiar settings
};

Share this post


Link to post
Share on other sites

Just stumbled on this thread last night while working on a dialog - the last post works perfectly. There is an error in the syntax though so if it helps anyone else, then try:

with uiNamespace do    
{
   waitUntil {not isNil {PLGRMUI_menuDisplay}};
   (PLGRMUI_menuDisplay displayCtrl 1003) ctrlSetTooltip "blahblah";
   //looots of similiar settings
};

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  

×