diff --git a/template/static_settings_addon/$PBOPREFIX$ b/template/static_settings_addon/$PBOPREFIX$ new file mode 100644 index 000000000..26fd0300c --- /dev/null +++ b/template/static_settings_addon/$PBOPREFIX$ @@ -0,0 +1 @@ +x\cba\addons\static_settings_addon diff --git a/template/static_settings_addon/CfgEventHandlers.hpp b/template/static_settings_addon/CfgEventHandlers.hpp new file mode 100644 index 000000000..f0a9f14d9 --- /dev/null +++ b/template/static_settings_addon/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/template/static_settings_addon/XEH_preInit.sqf b/template/static_settings_addon/XEH_preInit.sqf new file mode 100644 index 000000000..a45666c5d --- /dev/null +++ b/template/static_settings_addon/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +// frame after preInit, but before postInit +0 spawn { + { + #include "loadSettingsFile.sqf" + } call CBA_fnc_directCall; +}; + +ADDON = true; diff --git a/template/static_settings_addon/config.cpp b/template/static_settings_addon/config.cpp new file mode 100644 index 000000000..f1368fcce --- /dev/null +++ b/template/static_settings_addon/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + author = "$STR_CBA_Author"; + name = ECSTRING(settings,component); + url = "$STR_CBA_URL"; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"cba_settings"}; + version = VERSION; + authors[] = {"commy2"}; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/template/static_settings_addon/loadSettingsFile.sqf b/template/static_settings_addon/loadSettingsFile.sqf new file mode 100644 index 000000000..82e7c2220 --- /dev/null +++ b/template/static_settings_addon/loadSettingsFile.sqf @@ -0,0 +1,9 @@ + +// do nothing if auto loaded settings file is present +if (isClass (configFile >> "CfgPatches" >> "cba_auto_load_settings_file")) exitWith {}; + +private _source = ["client", "server"] select (isMultiplayer && isServer); +private _file = loadFile PATH_SETTINGS_FILE_PBO; + +[_file, _source] call EFUNC(settings,import); +diag_log text "[CBA] (settings): Settings file loaded from PBO."; diff --git a/template/static_settings_addon/script_component.hpp b/template/static_settings_addon/script_component.hpp new file mode 100644 index 000000000..5e7d63404 --- /dev/null +++ b/template/static_settings_addon/script_component.hpp @@ -0,0 +1,16 @@ +#define COMPONENT static_settings_addon +#include "\x\cba\addons\main\script_mod.hpp" + +//#define DEBUG_ENABLED_STATIC_SETTINGS_ADDON + +#ifdef DEBUG_ENABLED_STATIC_SETTINGS_ADDON + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_STATIC_SETTINGS_ADDON + #define DEBUG_SETTINGS DEBUG_SETTINGS_STATIC_SETTINGS_ADDON +#endif + +#include "\x\cba\addons\main\script_macros.hpp" + +#define PATH_SETTINGS_FILE_PBO QPATHTOF(userconfig\cba\settings.sqf) diff --git a/template/static_settings_addon/userconfig/cba/settings.sqf b/template/static_settings_addon/userconfig/cba/settings.sqf new file mode 100644 index 000000000..e69de29bb