diff --git a/.hemtt/hooks/pre_build/01_set_version.rhai b/.hemtt/hooks/pre_build/01_set_version.rhai index d58e08323..28bc30a64 100644 --- a/.hemtt/hooks/pre_build/01_set_version.rhai +++ b/.hemtt/hooks/pre_build/01_set_version.rhai @@ -9,6 +9,6 @@ HEMTT_VFS.join("addons").join("main_a3").join("CfgMods.hpp").create_file().write print("addons/main_a3/CfgMods.hpp version set"); let scriptversion = HEMTT_VFS.join("addons").join("main").join("script_version.hpp").open_file().read(); -scriptversion.replace("000000", HEMTT.project().version().build()); // TODO date %y%m%d (eg. 220912) +scriptversion.replace("000000", HEMTT.project().version().build().to_string()); // TODO date %y%m%d (eg. 220912) HEMTT_VFS.join("addons").join("main").join("script_version.hpp").create_file().write(scriptversion); print("addons/main/script_version.hpp build set"); diff --git a/.hemtt/project.toml b/.hemtt/project.toml index 37ecca5ef..238b9d4ca 100644 --- a/.hemtt/project.toml +++ b/.hemtt/project.toml @@ -9,14 +9,14 @@ include = [ "LICENSE.md", "logo_cba_ca.paa", "meta.cpp", - "userconfig", + "userconfig/**", ] [version] git_hash = 0 [asc] -enabled = true +enabled = false exclude = [ "/initsettings.sqf", "/initkeybinds.sqf", @@ -32,5 +32,5 @@ exclude = [ [hemtt.config] preset = "Hemtt" -#[hemtt.release] -#folder = "CBA_A3" +[hemtt.release] +folder = "CBA_A3" diff --git a/addons/diagnostic/fnc_isDebugConsoleAllowed.sqf b/addons/diagnostic/fnc_isDebugConsoleAllowed.sqf index 76601b29f..01bc31afa 100644 --- a/addons/diagnostic/fnc_isDebugConsoleAllowed.sqf +++ b/addons/diagnostic/fnc_isDebugConsoleAllowed.sqf @@ -5,5 +5,5 @@ if (str missionConfigFile == "A3\Missions_F_Bootcamp\Scenarios\Arsenal.VR\descri if (!isMultiplayer && {getNumber (missionConfigFile >> "enableDebugConsoleSP") == 1}) exitWith {true}; call { - #include "\a3\functions_f\Debug\fn_isDebugConsoleAllowed.sqf"; + #include "\a3\functions_f\debug\fn_isDebugConsoleAllowed.sqf"; }; diff --git a/addons/ui/RscDisplayOptionsLayout.hpp b/addons/ui/RscDisplayOptionsLayout.hpp index 80dfc8b11..945e2150b 100644 --- a/addons/ui/RscDisplayOptionsLayout.hpp +++ b/addons/ui/RscDisplayOptionsLayout.hpp @@ -12,7 +12,7 @@ class RscDisplayOptionsLayout { onMouseButtonUp = "with uiNamespace do {['mouseButtonUp',_this,''] call RscDisplayOptionsLayout_script;};"; }; #define ADD_ELEMENT(var1) class Element##var1: Element022 {\ - idc = QUOTE(12##var1);\ + idc = 12##var1;\ } ADD_ELEMENT(023); ADD_ELEMENT(024); diff --git a/addons/xeh/fnc_endLoadingScreen.sqf b/addons/xeh/fnc_endLoadingScreen.sqf index 47f848749..11abb2c29 100644 --- a/addons/xeh/fnc_endLoadingScreen.sqf +++ b/addons/xeh/fnc_endLoadingScreen.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" private _return = call { - #include "\a3\functions_f\Misc\fn_endLoadingScreen.sqf" + #include "\a3\functions_f\misc\fn_endLoadingScreen.sqf" }; isNil { diff --git a/addons/xeh/fnc_initDisplay.sqf b/addons/xeh/fnc_initDisplay.sqf index b6d7947d6..3520626fe 100644 --- a/addons/xeh/fnc_initDisplay.sqf +++ b/addons/xeh/fnc_initDisplay.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" call { - #include "\a3\functions_f\GUI\fn_initDisplay.sqf" + #include "\a3\functions_f\gui\fn_initDisplay.sqf" }; params [["_event", "", [""]], ["_args", []], ["_className", "", [""]]]; diff --git a/addons/xeh/fnc_startLoadingScreen.sqf b/addons/xeh/fnc_startLoadingScreen.sqf index ca026c78e..4f4c72353 100644 --- a/addons/xeh/fnc_startLoadingScreen.sqf +++ b/addons/xeh/fnc_startLoadingScreen.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" private _return = call { - #include "\a3\functions_f\Misc\fn_startLoadingScreen.sqf" + #include "\a3\functions_f\misc\fn_startLoadingScreen.sqf" }; isNil { diff --git a/include/a3/functions_f/debug/fn_isdebugconsoleallowed.sqf b/include/a3/functions_f/debug/fn_isDebugConsoleAllowed.sqf similarity index 100% rename from include/a3/functions_f/debug/fn_isdebugconsoleallowed.sqf rename to include/a3/functions_f/debug/fn_isDebugConsoleAllowed.sqf diff --git a/include/a3/functions_f/gui/fn_initDisplay.sqf b/include/a3/functions_f/gui/fn_initDisplay.sqf new file mode 100644 index 000000000..b552313c7 --- /dev/null +++ b/include/a3/functions_f/gui/fn_initDisplay.sqf @@ -0,0 +1,151 @@ +/* + Author: + Karel Moricky, improved by Killzone_Kid + + Description: + Initialize displays during preStart or init GUI display and run its script + The config class of the display is available in "BIS_fnc_initDisplay_configClass" stored on display + Example: _display getVariable "BIS_fnc_initDisplay_configClass"; + Display is also stored in uiNamespace variable with config class name + Example: uiNamespace getVariable "RscAvCamera"; + + Parameter(s): + ARRAY - [] init displays during preStart + or + 0: STRING - mode, can be "onLoad" or "onUnload" + 1: ARRAY - params passed from "onLoad" or "onUnload" event handler, contains only DISPLAY + 2: STRING - display class + 3: STRING - script path from CfgScriptPaths + + Returns: + NOTHING +*/ + +#define CONFIG_CLASS_VAR "BIS_fnc_initDisplay_configClass" +#define INIT_GAME_VAR "BIS_initGame" + +// init displays during preStart (moved from BIS_fnc_initDisplays) +if (_this isEqualTo []) exitWith +{ + { + { + if (getNumber (_x >> "scriptIsInternal") isEqualTo 0) then //--- Ignore internal scripts, they're recompiled first time they're opened + { + _scriptName = getText (_x >> "scriptName"); + _scriptPath = getText (_x >> "scriptPath"); + + if (_scriptName isEqualTo "" || _scriptPath isEqualTo "") exitWith + { + [ + 'Undefined param(s) [scriptPath: "%2", scriptName: "%3"] while trying to init display "%1"', + configName _x, + _scriptPath, + _scriptName + ] + call BIS_fnc_logFormat; + }; + + _script = _scriptName + "_script"; + + if (uiNamespace getVariable [_script, 0] isEqualType {}) exitWith {}; //--- already compiled + + uiNamespace setVariable + [ + _script, + compileScript [ + format ["%1%2.sqf", getText (configFile >> "CfgScriptPaths" >> _scriptPath), _scriptName], + true, // final + format ["scriptName '%1'; _fnc_scriptName = '%1'; ", _scriptName] // prefix + ] + ]; + }; + } + forEach ("isText (_x >> 'scriptPath')" configClasses _x); + } + forEach + [ + configFile, + configFile >> "RscTitles", + configFile >> "RscInGameUI", + configFile >> "Cfg3DEN" >> "Attributes" + ]; + + nil +}; + +//--- Register/unregister display +with uiNamespace do +{ + params + [ + ["_mode", "", [""]], + ["_params", []], + ["_class", "", [""]], + ["_path", "default", [""]], + ["_register", true, [true, 0]] + ]; + + _display = _params param [0, displayNull]; + if (isNull _display) exitWith {nil}; + + if (_register isEqualType true) then {_register = parseNumber _register}; + if (_register > 0) then + { + _varDisplays = _path + "_displays"; + _displays = (uiNamespace getVariable [_varDisplays, []]) - [displayNull]; + + if (_mode == "onLoad") exitWith + { + //--- Register current display + _display setVariable [CONFIG_CLASS_VAR, _class]; + uiNamespace setVariable [_class, _display]; + + _displays pushBackUnique _display; + uiNamespace setVariable [_varDisplays, _displays]; + + if !(uiNamespace getVariable [INIT_GAME_VAR, false]) then + { + //--- tell loading screen it can stop using ARMA 3 logo which is shown only before main menu + //--- and start using the classic terrain picture + uiNamespace setVariable [INIT_GAME_VAR, _path == "GUI" && {ctrlIdd _x >= 0} count _displays > 1]; + }; + + [missionNamespace, "OnDisplayRegistered", [_display, _class]] call BIS_fnc_callScriptedEventHandler; + }; + + if (_mode == "onUnload") exitWith + { + //--- Unregister current display + _displays = _displays - [_display]; + uiNamespace setVariable [_varDisplays, _displays]; + + [missionNamespace, "OnDisplayUnregistered", [_display, _class]] call BIS_fnc_callScriptedEventHandler; + }; + + }; + + //--- Call script in public version + if (!cheatsEnabled) exitWith + { + [_mode, _params, _class] call (uiNamespace getVariable (_class + "_script")); + nil + }; + + //--- Recompile in the internal version + uinamespace setvariable + [ + _class + "_script", + compileScript [ + format ["%1%2.sqf", getText (configFile >> "CfgScriptPaths" >> _path), _class], + true, // final + format ["scriptName '%1'; _fnc_scriptName = '%1'; ", _class] // prefix + ] + ]; + + //--- Call script in internal version + if !(uiNamespace getVariable ["BIS_disableUIscripts", false]) then + { + [_mode, _params, _class] call (uiNamespace getVariable (_class + "_script")); + nil + }; +}; \ No newline at end of file diff --git a/include/a3/functions_f/misc/fn_endLoadingScreen.sqf b/include/a3/functions_f/misc/fn_endLoadingScreen.sqf new file mode 100644 index 000000000..52c88dd1c --- /dev/null +++ b/include/a3/functions_f/misc/fn_endLoadingScreen.sqf @@ -0,0 +1,33 @@ +/* + Author: Karel Moricky + + Description: + Unregister a loading screen. When none other remains, end the loading. + + Parameter(s): + 0: STRING - screen ID, used in BIS_fnc_endLoadingScreen + + Returns: + BOOL - true when unregistered +*/ + +with uinamespace do { + private ["_id","_ids"]; + + _id = _this param [0,"",[""]]; + _ids = missionnamespace getvariable ["BIS_fnc_startLoadingScreen_ids",[]]; + + if (_id in _ids) then { + _ids = _ids - [_id]; + missionnamespace setvariable ["BIS_fnc_startLoadingScreen_ids",_ids]; + if (count _ids == 0) then { + endloadingscreen; + -1 call bis_fnc_progressloadingscreen; + }; + //["End '%1' loading screen for %2",_id,profilename] call bis_fnc_logFormat; + true + } else { + ["Loading screen '%1' did not start yet.",_id] call bis_fnc_error; + false + }; +}; \ No newline at end of file diff --git a/include/a3/functions_f/misc/fn_startLoadingScreen.sqf b/include/a3/functions_f/misc/fn_startLoadingScreen.sqf new file mode 100644 index 000000000..a8fe08067 --- /dev/null +++ b/include/a3/functions_f/misc/fn_startLoadingScreen.sqf @@ -0,0 +1,34 @@ +/* + Author: Karel Moricky + + Description: + Register a loading screen. Start the loading when it's the first one registered. + + Parameter(s): + 0: STRING - screen ID, will be used in BIS_fnc_endLoadingScreen + 1 (Optional): STRING - loading screen layout + + Returns: + BOOL - true when registered +*/ +disableserialization; +with uinamespace do { + private ["_id","_rsc","_ids"]; + _id = _this param [0,"",[""]]; + _text = _this param [1,"",[""]]; + _rsc = _this param [2,"",[""]]; + _ids = missionnamespace getvariable ["BIS_fnc_startLoadingScreen_ids",[]]; + + if !(_id in _ids) then { + //--- Array has to be adjusted before loading screen starts, otherwise the rest of the script can be delayed + _ids set [count _ids,_id]; + missionnamespace setvariable ["BIS_fnc_startLoadingScreen_ids",_ids]; + startloadingscreen [_text,_rsc]; + progressloadingscreen (uinamespace getvariable ["BIS_fnc_progressloadingscreen_progress",0]); + //["Start '%1' loading screen for %2",_id,profilename] call bis_fnc_logFormat; + true + } else { + //["Loading screen '%1' already started.",_id] call bis_fnc_error; + false + }; +};