Skip to content

Commit

Permalink
Add initial loading notification when processing data
Browse files Browse the repository at this point in the history
  • Loading branch information
theace0296 committed May 21, 2022
1 parent ca97366 commit 1f45863
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 11 deletions.
11 changes: 11 additions & 0 deletions RandFramework/GUI/fn_createNotification.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ if !(isNull _ctrlGroup) then {
private _textControl = _ctrlGroup controlsGroupCtrl 1000;
_textControl ctrlSetStructuredText _text;
_textControl ctrlCommit 0;
private _ctrlGroupSize = ctrlPosition _ctrlGroup;
private _messageHeight = 0.00;
_textControl ctrlSetPosition [0, 0.01, _ctrlGroupSize select 2, (ctrlTextHeight _textControl) + 0.01];
_textControl ctrlCommit 0;
{
if !(_forEachIndex isEqualTo 1) then {
_messageHeight = _messageHeight + ((ctrlPosition _x) select 3);
};
} forEach ((allControls _display) select {(ctrlParentControlsGroup _x) isEqualTo _ctrlGroup});
_ctrlGroup ctrlSetPosition [0, 0, _mainCtrlGroupW, _messageHeight];
_ctrlGroup ctrlCommit 0;
} else {
_ctrlGroup = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _mainCtrlGroup];
uiNamespace setVariable [format["TRGM_VAR_notification_%1", _notificationIndex], _ctrlGroup];
Expand Down
33 changes: 30 additions & 3 deletions RandFramework/Global/init/fn_initGlobalVars.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ if (isNil "TRGM_VAR_LocationVersion") then { TRGM_VAR_LocationVersion = 3; publ
//// These must be declared BEFORE either initUnitVars or CUSTOM_MISSION_fnc_SetDefaultMissionSetupVars!!!
if (isNil "TRGM_VAR_AllFactionData" || {isNil "TRGM_VAR_AllFactionMap" || {isNil "TRGM_VAR_AvailableFactions"}}) then {
format["Get all faction data, called on %1", (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;

if (isServer) then {
TRGM_VAR_LoadingText = "Gathering available factions..."; publicVariable "TRGM_VAR_LoadingText";
TRGM_VAR_LoadingPercent = 15; publicVariable "TRGM_VAR_LoadingPercent";
};

private _WestFactionData = [WEST] call TRGM_GLOBAL_fnc_getFactionDataBySide;
private _EastFactionData = [EAST] call TRGM_GLOBAL_fnc_getFactionDataBySide;
private _GuerFactionData = [INDEPENDENT] call TRGM_GLOBAL_fnc_getFactionDataBySide;
Expand Down Expand Up @@ -69,7 +75,7 @@ if (isNil "TRGM_VAR_AllFactionData" || {isNil "TRGM_VAR_AllFactionMap" || {isNil

if (TRGM_VAR_bRecalculateFactionData || {count TRGM_VAR_AllFactions isEqualTo 0 || {{!(_x in TRGM_VAR_AllFactions)} count TRGM_VAR_AvailableFactions > 0}}) then {
format["Update saved faction data, called on %1", (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;
private _factionDataHandles = [];
TRGM_factionDataHandles = []; publicVariable "TRGM_factionDataHandles";
{
if !((_x select 0) in TRGM_VAR_AllFactions) then {
private _handle = [_x select 0, _x select 1] spawn {
Expand Down Expand Up @@ -104,11 +110,23 @@ if (isNil "TRGM_VAR_AllFactionData" || {isNil "TRGM_VAR_AllFactionMap" || {isNil
format["%1", _exception] call TRGM_GLOBAL_fnc_log;
}
};
_factionDataHandles = _factionDataHandles + [_handle];
TRGM_factionDataHandles = TRGM_factionDataHandles + [[_x select 0, _x select 1, _handle]]; publicVariable "TRGM_factionDataHandles";
};
} forEach TRGM_VAR_AvailableFactions;

waitUntil { { scriptDone _x; } count _factionDataHandles isEqualTo count _factionDataHandles; };
waitUntil {
sleep 0.1;
private _completedHandles = TRGM_factionDataHandles select { scriptDone (_x select 2); };
if (isServer && count TRGM_factionDataHandles > 0) then {
private _activeHandles = TRGM_factionDataHandles select { !(_x in _completedHandles); };
private _content = ["Loading data for: "] + (flatten (_activeHandles apply { [lineBreak, format[" %1", _x select 1]] }));
TRGM_VAR_LoadingText = composeText _content; publicVariable "TRGM_VAR_LoadingText";
if (TRGM_VAR_LoadingPercent < 60) then {
TRGM_VAR_LoadingPercent = ceil(15 + ((count _completedHandles / count TRGM_factionDataHandles) * 45)); publicVariable "TRGM_VAR_LoadingPercent";
};
};
count _completedHandles isEqualTo count TRGM_factionDataHandles;
};

TRGM_VAR_AllFactionData = [TRGM_VAR_AllFactionData, [], { _x select 1 }, "ASCEND"] call BIS_fnc_sortBy;
TRGM_VAR_AllFactions = (_WestFactionData + _EastFactionData + _GuerFactionData) apply { _x select 0 };
Expand All @@ -118,6 +136,10 @@ if (isNil "TRGM_VAR_AllFactionData" || {isNil "TRGM_VAR_AllFactionMap" || {isNil
profileNamespace setVariable ["TRGM_VAR_AllFactionMap", TRGM_VAR_AllFactionMap];
saveProfileNamespace;
} else {
if (isServer) then {
TRGM_VAR_LoadingText = "Loading Faction Data..."; publicVariable "TRGM_VAR_LoadingText";
TRGM_VAR_LoadingPercent = 60; publicVariable "TRGM_VAR_LoadingPercent";
};
format["Using saved faction data, called on %1", (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;
};

Expand All @@ -129,6 +151,11 @@ if (isNil "TRGM_VAR_AllFactionData" || {isNil "TRGM_VAR_AllFactionMap" || {isNil
format["Faction data calculated, called on %1", (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;
};

if (isServer) then {
TRGM_VAR_LoadingText = "Loading variables..."; publicVariable "TRGM_VAR_LoadingText";
TRGM_VAR_LoadingPercent = 70; publicVariable "TRGM_VAR_LoadingPercent";
};

// Custom Mission
TRGM_VAR_UseCustomMission = (["CustomMission", 0] call BIS_fnc_getParamValue) isEqualTo 1;
publicVariable "TRGM_VAR_UseCustomMission";
Expand Down
9 changes: 5 additions & 4 deletions RandFramework/Global/logging/fn_populateLoadingWait.sqf
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// private _fnc_scriptName = "TRGM_GLOBAL_fnc_populateLoadingWait";
params ["_percentage", ["_useCampaignLoading", false]];
params [["_percentage", 0], ["_useCampaignLoading", false], ["_customMessage", ""]];
if (isNil "TRGM_VAR_PopulateLoadingWait_percentage") then { TRGM_VAR_PopulateLoadingWait_percentage = 0; publicVariable "TRGM_VAR_PopulateLoadingWait_percentage"; };

if !(isServer) exitWith {};

sleep 0.1;

if (TRGM_VAR_PopulateLoadingWait_percentage > 100) exitWith {};

TRGM_VAR_PopulateLoadingWait_percentage = 5 + TRGM_VAR_PopulateLoadingWait_percentage;
Expand All @@ -21,8 +19,11 @@ TRGM_VAR_PopulateLoadingWait_percentage = ceil(TRGM_VAR_PopulateLoadingWait_perc
publicVariable "TRGM_VAR_PopulateLoadingWait_percentage";

private _message = ["Generating mission please wait...", "Generating new mission please wait..."] select (_useCampaignLoading);
if (_customMessage isNotEqualTo "") then {
_message = _customMessage;
};

[format["%1 %2 percent", _message, TRGM_VAR_PopulateLoadingWait_percentage], {TRGM_VAR_PopulateLoadingWait_percentage <= 100}, 100] call TRGM_GLOBAL_fnc_notifyGlobal;
[(composeText [_message, lineBreak, format["%1 percent", TRGM_VAR_PopulateLoadingWait_percentage]]), {TRGM_VAR_PopulateLoadingWait_percentage <= 100}, 100] call TRGM_GLOBAL_fnc_notifyGlobal;

if (TRGM_VAR_PopulateLoadingWait_percentage >= 100) then {
TRGM_VAR_PopulateLoadingWait_percentage = 101; publicVariable "TRGM_VAR_PopulateLoadingWait_percentage";
Expand Down
22 changes: 19 additions & 3 deletions init.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"Init.sqf" call TRGM_GLOBAL_fnc_log;

if (isNil "TRGM_VAR_LoadingPercent") then {TRGM_VAR_LoadingPercent = 10; publicVariable "TRGM_VAR_LoadingPercent";};
if (isNil "TRGM_VAR_LoadingText") then {TRGM_VAR_LoadingText = "Loading..."; publicVariable "TRGM_VAR_LoadingText";};
if (isNil "TRGM_VAR_serverFinishedInitGlobal") then {TRGM_VAR_serverFinishedInitGlobal = false; publicVariable "TRGM_VAR_serverFinishedInitGlobal";};

private _initVarsHandle = [] spawn TRGM_GLOBAL_fnc_initGlobalVars;
waitUntil { sleep 5; scriptDone _initVarsHandle; };
waitUntil {
sleep 0.1;
[TRGM_VAR_LoadingPercent, false, TRGM_VAR_LoadingText] call TRGM_GLOBAL_fnc_populateLoadingWait;
TRGM_VAR_serverFinishedInitGlobal && scriptDone _initVarsHandle;
};

if (isNil "TRGM_VAR_serverFinishedInitGlobal") then {TRGM_VAR_serverFinishedInitGlobal = false; publicVariable "TRGM_VAR_serverFinishedInitGlobal";};
waitUntil {TRGM_VAR_serverFinishedInitGlobal;};
[80, false, "Finding admin player..."] call TRGM_GLOBAL_fnc_populateLoadingWait;

if (isServer) then {
[] spawn {
Expand All @@ -15,6 +22,8 @@ if (isServer) then {
};
};

[90, false, "Finishing up..."] call TRGM_GLOBAL_fnc_populateLoadingWait;

TRGM_VAR_iTimeMultiplier call BIS_fnc_paramTimeAcceleration;

tf_give_personal_radio_to_regular_soldier = true; publicVariable "tf_give_personal_radio_to_regular_soldier";
Expand All @@ -35,6 +44,13 @@ call FHQ_fnc_ttiPostInit;
[(localize "STR_TRGM2_Init_TRGM2Engine"), (localize "STR_TRGM2_Init_ScriptsUsed"), localize "STR_TRGM2_TRGMSetUnitGlobalVars_ScriptsUsed"]
] call FHQ_fnc_ttAddBriefing;

[] spawn {
uiSleep 1;
[100, false, "Done"] call TRGM_GLOBAL_fnc_populateLoadingWait;
uiSleep 2;
TRGM_VAR_PopulateLoadingWait_percentage = 0; publicVariable "TRGM_VAR_PopulateLoadingWait_percentage";
};

waitUntil { TRGM_VAR_playerIsChoosingHQpos || TRGM_VAR_NeededObjectsAvailable; };

if (isServer && !TRGM_VAR_NeededObjectsAvailable) then {
Expand Down
10 changes: 9 additions & 1 deletion initplayerlocal.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
"Initplayerlocal.sqf" call TRGM_GLOBAL_fnc_log;

waitUntil {
sleep 1;
!(isNull player) && { player isEqualTo player };
};

if (isNil "TRGM_VAR_serverFinishedInitGlobal") then {TRGM_VAR_serverFinishedInitGlobal = false; publicVariable "TRGM_VAR_serverFinishedInitGlobal";};
waitUntil {TRGM_VAR_serverFinishedInitGlobal;};
waitUntil {
sleep 0.1;
TRGM_VAR_serverFinishedInitGlobal;
};

private _initVarsHandle = [] spawn TRGM_GLOBAL_fnc_initGlobalVars;
waitUntil { sleep 5; scriptDone _initVarsHandle; };
Expand Down

0 comments on commit 1f45863

Please sign in to comment.