Jump to content
DÄZ

[RESOLVED] display the time on a GUI

Recommended Posts

hi, i was trying to display the mission time on a GUI.

I can display a text, no worries! For now, whatever I try, it does not work!

 

DAZ_BCM_test_time.hpp:

class DAZ_BCM_test_time
{
	idd = 1984;
	movingEnable = true;											
	controlsBackground[] = {IGUIBack_2200, IGUIBack_2201};
	onLoad = "" ; 
	objects[] = {};
	controls[]=
{
	RscText_1000
};

class IGUIBack_2200: DAZ_BCM_IGUIBack
{
	idc = 2200;
	moving = 1;

	x = 5 * GUI_GRID_W + GUI_GRID_X;
	y = -5.5 * GUI_GRID_H + GUI_GRID_Y;
	w = 30 * GUI_GRID_W;
	h = 1 * GUI_GRID_H;
};
class IGUIBack_2201: DAZ_BCM_IGUIBack2
{
	idc = 2201;
	moving = 1;

	x = 5 * GUI_GRID_W + GUI_GRID_X;
	y = -4.5 * GUI_GRID_H + GUI_GRID_Y;
	w = 30 * GUI_GRID_W;
	h = 34 * GUI_GRID_H;
};
class RscText_1000: DAZ_BCM_RscText
{
	idc = 1000;

	onLoad = "ExecVM 'time.sqf';";
	x = 17 * GUI_GRID_W + GUI_GRID_X;
	y = -5.5 * GUI_GRID_H + GUI_GRID_Y;
	w = 7.5 * GUI_GRID_W;
	h = 1 * GUI_GRID_H;
};
};

 

time.sqf:

disableSerialization;

_display = findDisplay 1984;
_control = _display displayCtrl 1000;

_formatedTime = [time/3600,"HH:MM:SS"] call BIS_fnc_timeToString;
_stringfinal = "Temps écoulé depuis le début de la mission:"+ " " + "<t color='#26fc0a'>" + _formatedTime + "</t>";
_control ctrlSetStructuredText parsetext _stringfinal;

 

thank you in advance

Share this post


Link to post
Share on other sites

Something like this?

_control ctrlSetStructuredText parseText format ["Time remaining: %1", _formatedTime];

 

  • Like 1

Share this post


Link to post
Share on other sites

still not working, thanks

Share this post


Link to post
Share on other sites

Works for me. Put this in debug:

[] spawn
{
	disableSerialization;
	_time = [time/3600,"HH:MM:SS"] call BIS_fnc_timeToString;
	_display = findDisplay 46 createDisplay "RscDisplayEmpty";
	_text = _display ctrlCreate ["RscStructuredText", 100];
	_text ctrlSetPosition [0, 0, 0.4, 0.04]; // I didn't use safeZone as I was just quickly testing!
	_text ctrlSetStructuredText parseText format ["Time remaining: %1", _time];
	_text ctrlCommit 0;
	waitUntil
	{
		_time = [time/3600,"HH:MM:SS"] call BIS_fnc_timeToString;
		_text ctrlSetStructuredText parseText format ["Time remaining: %1", _time];
		sleep 1;
		false;
	};
};

 

  • Like 2

Share this post


Link to post
Share on other sites

thank you it works well in the debug, how to integrate in the GUI?

Share this post


Link to post
Share on other sites

Make your UI. I assume you know how to do this since I saw your =DAZ= GUI POWER PLANT in sig. In the onLoad put:

[] execVM ""something.sqf"";
onLoad = "someScriptHandle = [] execVM ""something.sqf"";";
// or use single quotes
[] execVM 'something.sqf';
onLoad = "someScriptHandle = [] execVM 'something.sqf';";

Inside something.sqf:

waitUntil
{
	_time = [time/3600,"HH:MM:SS"] call BIS_fnc_timeToString;
	(findDisplay 1984 displayCtrl 1000) ctrlSetStructuredText parseText format ["Mission uptime: %1", _time];
	sleep 1;
	false;
};

You can also make a function and use spawn/call/etc instead of execVM command. You may also want to terminate the time update when you close the UI. Something like this:

onUnload = "terminate someScriptHandle;";

(from Wiki)

Note: The given script will not terminate immediately upon terminate command execution, it will do so the next time the script is processed by the scheduler.

You can also do a manual check using if statement or something to check if display is open or whatever.

  • Like 2

Share this post


Link to post
Share on other sites

still does not work in the GUI, I have no display, I have to do something wrong.

Share this post


Link to post
Share on other sites

the ctrlSetText it works !!! :evil:

 

		_dialog = findDisplay 1984;
		
		_time = "test time";
		(_dialog displayCtrl 1000) ctrlSetText _time;

 

  • Like 1

Share this post


Link to post
Share on other sites

With RscText yes. For RscStructuredText use ctrlSetStructuredText as shown above.

  • Thanks 1

Share this post


Link to post
Share on other sites
12 minutes ago, HazJ said:

With RscText yes. For RscStructuredText use ctrlSetStructuredText as shown above.

 

yessss, you have enlightened me, It works now. thank you, friend

 

just use the class RscStructuredText and not RscText of define.hpp :don11:

https://community.bistudio.com/wiki/DialogControls-Text#CT_STRUCTURED_TEXT.3D13

 

//class RscText_1000: DAZ_BCM_RscText // <-- bad class
class RscText_1000: MyRscStructuredText
{
	idc = 1000;

	onLoad = "ExecVM 'time.sqf';";
	x = 17 * GUI_GRID_W + GUI_GRID_X;
	y = -5.5 * GUI_GRID_H + GUI_GRID_Y;
	w = 7.5 * GUI_GRID_W;
	h = 1 * GUI_GRID_H;
};
};

 

resolved, thank

  • 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

×