Jump to content
Guest

[SOLVED] Can't fill a dialog by calling a function

Recommended Posts

Guest

Hi to everyone. My problem is that I wanna fill my dialog by calling a funcion after creating it, but it doesn't work at all. I mean, the dialog is created but empty. Here's my code:

 

When I wanna create the dialog I use ["INIT"] call my_function;

disableSerialization;

private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1600;
private _cat = _ui displayCtrl 1601;

private _categories = "true" configClasses (getMissionConfig "HG_DefaultShop");


actDialog = {

	lbClear _list;
	
	_num = _this select 0;

	private _object = getText( _categories select _numCat >> "displayName");
    
	_cat ctrlSetText _objeto;

	//Some lb commands.
};

switch (_this select 0) do {

	case "INIT": {

		createDialog "MyDialog";

		_num = 0;

		[_num] call actDialog;
    };
};

I hope u guys can help me! Thanks!!

Share this post


Link to post
Share on other sites

I see the problem put the code in actDialog:

 

private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1600;
private _cat = _ui displayCtrl 1601;

private _categories = "true" configClasses (getMissionConfig "HG_DefaultShop");

If you are calling that code above before createDialog it wont work

 

Also I don't know how this can work unless you have set the variable your self:

 

private _ui = uiNamespace getVariable "MyDialog"; 

Do you have setvariable somewhere?

Share this post


Link to post
Share on other sites
Guest
3 minutes ago, gc8 said:

I see the problem put the code in actDialog:

 


private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1600;
private _cat = _ui displayCtrl 1601;

private _categories = "true" configClasses (getMissionConfig "HG_DefaultShop");

 

Hahahaha, thanks, that was a dumb mistake but every day I learn something new.

Share this post


Link to post
Share on other sites
Guest
19 hours ago, gc8 said:

I see the problem put the code in actDialog:

 


private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1600;
private _cat = _ui displayCtrl 1601;

private _categories = "true" configClasses (getMissionConfig "HG_DefaultShop");

If you are calling that code above before createDialog it wont work

 

Also I don't know how this can work unless you have set the variable your self:

 


private _ui = uiNamespace getVariable "MyDialog"; 

Do you have setvariable somewhere?

 I've another question relative to that. In my shop.hpp I have this:

class MyDialog
{
	idd = -1; 
	onLoad = "uiNamespace setVariable ['MyDialog', _this select 0];"; 
	onUnLoad = "uiNamespace setVariable ['MyDialog', nil]; ";

	//etc...
};

An then on my fn_shop.sqf I've this:


_whatShop = if(!dialog) then {_this select 3};

disableSerialization;

private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1500;
private _cat = _ui displayCtrl 1000;
private _button = _ui displayCtrl 1603;
private _edit = _ui displayCtrl 1400;
private _info = _ui displayCtrl 1100;
private _check1 = _ui displayCtrl 2800;
private _check2 = _ui displayCtrl 2801;

//etc...

My question is: ¿Why does Arma says that my variable _ui is not define? Thanks :)

 

PS: I use and addaction to call my .sqf (this addAction["Shop","call brad_fnc_shop", FirstShop" ,0,true,true, "", '', 3.5];  

Share this post


Link to post
Share on other sites

 

When do you call the

private _ui = uiNamespace getVariable "MyDialog"; 

code?

 

 

Share this post


Link to post
Share on other sites
Guest
2 minutes ago, gc8 said:

 

When do you call the


private _ui = uiNamespace getVariable "MyDialog"; 

code?

 

 

Here it is.

class MyDialog
{
	idd = -1; // ID
	onLoad = "uiNamespace setVariable ['MyDialog', _this select 0];"; 
	onUnLoad = "uiNamespace setVariable ['MyDialog', nil]; ";
	
	class controls {
		
		class Background1: IGUIBack
		{
			idc = 2200;
			x = 0.392726 * safezoneW + safezoneX;
			y = 0.2599 * safezoneH + safezoneY;
			w = 0.22899 * safezoneW;
			h = 0.4964 * safezoneH;

			colorBackground[] = {0,0,0,0.7};
			colorShadow[] = {0,0,0,0.5};
		};
      	//etc...
    };
};

 

Share this post


Link to post
Share on other sites

No I mean that getVariable not setVariable code :)

Share this post


Link to post
Share on other sites
Guest
5 minutes ago, gc8 said:

No I mean that getVariable not setVariable code :)

_whatShop = if(!dialog) then {_this select 3};

disableSerialization;

private _ui = uiNamespace getVariable "MyDialog"; 
private _list = _ui displayCtrl 1500;
private _cat = _ui displayCtrl 1000;
private _button = _ui displayCtrl 1603;
private _edit = _ui displayCtrl 1400;
private _info = _ui displayCtrl 1100;
private _check1 = _ui displayCtrl 2800;
private _check2 = _ui displayCtrl 2801;

//etc...

The other code is not important because I have it among comments (/* the rest of the code */). So the error is in there or maybe, in the addaction.

this addAction["Shop","call brad_fnc_shop", "FirstShop" ,0,true,true, "", '', 3.5];   

 

Share this post


Link to post
Share on other sites

That's still not what I meant, where is all that code called from? It would make it clearer if you just posted the whole sqf file...

Share this post


Link to post
Share on other sites
Guest
1 minute ago, gc8 said:

That's still not what I meant, where is all that code called from? It would make it clearer if you just posted the whole sqf file...

That code is call from the addaction witch is in an unit.

Share this post


Link to post
Share on other sites
4 minutes ago, _Brad said:

That code is call from the addaction witch is in an unit.

 

But where is createDialog "MyDialog"; called?

 

what I would do is call createDialog then have small sleep so that uiNamespace variable is ready before calling any more code

Share this post


Link to post
Share on other sites
Guest
1 minute ago, gc8 said:

 

But where is createDialog "MyDialog"; called?

 

what I would do is call createDialog then have small sleep so that uiNamespace variable is ready before calling any more code

That was the thing, createDialog "MyDialog" was under all that uiNamespace stuff. I guess I've to put it over that. Right? Thanks :)

Share this post


Link to post
Share on other sites
1 minute ago, _Brad said:

That was the thing, createDialog "MyDialog" was under all that uiNamespace stuff. I guess I've to put it over that. Right? Thanks :)

 

yes createdialog first

  • Like 1

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

×