Jump to content
gc8

Control commit problem

Recommended Posts

Hello,

I'm doing some GUI work and I wanted to fade away text but I also wanted to move the text. This obviously is a problem because I need to make two ctrlCommit calls, one for moving the control and second later for the fading to happen. Does anyone have ideas how to properly do both?

 

thx!

 

Edit: Actually I don't have this problem anymore... My code had bug and it works now. I just call one commit for the pos and then later another for the fade

Share this post


Link to post
Share on other sites

Came back to this problem where I want to both move the control let's say for 5 seconds and at the same time fade it out in 8 seconds, but I don't know if this is possible?

Share this post


Link to post
Share on other sites
// Example from my project
((uiNamespace getVariable "disp_hud") displayCtrl IDC_HUD_NUMCAPPERS) ctrlSetFade 0;
((uiNamespace getVariable "disp_hud") displayCtrl IDC_HUD_NUMCAPPERS) ctrlCommit 0.25;
((uiNamespace getVariable "disp_hud") displayCtrl IDC_HUD_CAPBAR) ctrlSetFade 0;
((uiNamespace getVariable "disp_hud") displayCtrl IDC_HUD_CAPBAR) ctrlCommit 0.25;

I have uiNamespace set in onLoad like so:

onLoad = "uiNamespace setVariable [""disp_hud"", param [0]];";

IDCs refer to the correct IDC numbers. You can just put the numbers there if you prefer. I use macros as just easier to remember and change them in future. Another way of doing it would be:

((findDisplay IDD) displayCtrl IDC) ctrlSetFade 0;
((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.25;
((findDisplay IDD) displayCtrl IDC) ctrlSetFade 0;
((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.25;

Adjust IDD and IDC accordingly.

 

EDIT: If you are going to use the same ctrlXXX command then you can use a forEach to stop repeating code. You can also pass nested array with IDC and time if there are different.

{
	((findDisplay IDD) displayCtrl _x) ctrlSetFade 0;
	((findDisplay IDD) displayCtrl _x) ctrlCommit 0.25;
} forEach
[
	IDC,
	IDC
];
{
	_x params ["_idc", "_delay"];
	((findDisplay IDD) displayCtrl _idc) ctrlSetFade 0;
	((findDisplay IDD) displayCtrl _idc) ctrlCommit _delay;
} forEach
[
	[IDC, 0.25],
	[IDC, 1]
];

 

Share this post


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

Came back to this problem where I want to both move the control let's say for 5 seconds and at the same time fade it out in 8 seconds, but I don't know if this is possible?

 

Have you tried doing the fade in steps like so (pseudo):

ctrlSetFade 0.5

ctrlSetPos x, y

ctrlCommit 5

 

Wait until ctrlCommited 

 

ctrlSetFade 0

ctrlCommit 5

 

Of course you'd have find the appropriate value for the first fade but linearConversion can help with that. 

Share this post


Link to post
Share on other sites

Yeah. As @mrcurry said. I forgot the ctrlSetPosition part.

waitUntil {ctrlCommitted _ctrl};

Then the fade part. Though honestly, you may not need it if you are using different values apart.

Share this post


Link to post
Share on other sites

Thx guys. The problem really is that I want to move and fade control at the same time but the commit time for these two operations is different

 

1 hour ago, HazJ said:

((findDisplay IDD) displayCtrl IDC) ctrlSetFade 0; ((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.25; ((findDisplay IDD) displayCtrl IDC) ctrlSetFade 0; ((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.25;

 

I don't understand this code, it's doing the same thing twice? Or does the commit command stack the transformations?

 

Share this post


Link to post
Share on other sites

Change IDD and IDCs accordingly. Anyway, I originally misread that you wanted pos too. Just have pos then fade.

((findDisplay IDD) displayCtrl IDC) ctrlSetPosition [0, 0, 0, 0];
((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.25;
((findDisplay IDD) displayCtrl IDC) ctrlSetFade 0;
((findDisplay IDD) displayCtrl IDC) ctrlCommit 0.35;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@HazJ I guess that last code that you posted works why else would you post it. I just didn't know you can call ctrlCommits like that. Does that really set position in 0.25 second and after that fade in 0.35 seconds?

Share this post


Link to post
Share on other sites

10 seconds apart. Yes. Not in. They start together.

Share this post


Link to post
Share on other sites

So you can have multiple commits at the same time

Share this post


Link to post
Share on other sites

Yes.

Share this post


Link to post
Share on other sites

Ok thanks just making sure :)

 

 

Share this post


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

So you can have multiple commits at the same time


Will not do much good to you if you execute it on the same control as was suggested :face_palm:

Use ctrls group to move control and fade the actual control
 

disableSerialization;

_ctrlGrp = findDisplay 46 ctrlCreate ["RscControlsGroup", -1];
_ctrlTxt = findDisplay 46 ctrlCreate ["RscText", -1, _ctrlGrp];

_ctrlGrp ctrlSetPosition [0,0,0.5,0.05];
_ctrlGrp ctrlCommit 0;
_ctrlGrp ctrlSetPosition [0.5,0,0.5,0.05];

_ctrlTxt ctrlSetPosition [0,0,0.5,0.05];
_ctrlTxt ctrlCommit 0;
_ctrlTxt ctrlSetText "Do not listen to people";
_ctrlTxt ctrlSetFade 1;

_ctrlGrp ctrlCommit 2;
_ctrlTxt ctrlCommit 3;

 

  • Confused 1

Share this post


Link to post
Share on other sites

@killzone_kid

Who said anything about the same control? What stupid people? Oh, you mean people who are helping? There is no real need for control group. More work for no actual good reason.

I said "adjust accordingly".

_ctrlTxt ctrlSetText "Read people's posts before acting all smug";

 

Share this post


Link to post
Share on other sites

Much as I miss Killzonekid's technical input into the community, I don't miss his shitty attitude.

 

  • Like 2

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

×