From 7346e0b98a1112d8a80dbb2852fae30c8904aa91 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 31 Jul 2016 11:26:50 +0200 Subject: [PATCH 1/2] add template for a settings inside a pbo --- template/repository_settings_file/$PBOPREFIX$ | 1 + .../CfgEventHandlers.hpp | 6 ++++++ .../repository_settings_file/XEH_preInit.sqf | 12 ++++++++++++ template/repository_settings_file/config.cpp | 17 +++++++++++++++++ .../loadSettingsFile.sqf | 9 +++++++++ .../script_component.hpp | 16 ++++++++++++++++ .../userconfig/cba/settings.sqf | 0 7 files changed, 61 insertions(+) create mode 100644 template/repository_settings_file/$PBOPREFIX$ create mode 100644 template/repository_settings_file/CfgEventHandlers.hpp create mode 100644 template/repository_settings_file/XEH_preInit.sqf create mode 100644 template/repository_settings_file/config.cpp create mode 100644 template/repository_settings_file/loadSettingsFile.sqf create mode 100644 template/repository_settings_file/script_component.hpp create mode 100644 template/repository_settings_file/userconfig/cba/settings.sqf diff --git a/template/repository_settings_file/$PBOPREFIX$ b/template/repository_settings_file/$PBOPREFIX$ new file mode 100644 index 000000000..769bcc3cc --- /dev/null +++ b/template/repository_settings_file/$PBOPREFIX$ @@ -0,0 +1 @@ +x\cba\addons\repository_settings_file diff --git a/template/repository_settings_file/CfgEventHandlers.hpp b/template/repository_settings_file/CfgEventHandlers.hpp new file mode 100644 index 000000000..f0a9f14d9 --- /dev/null +++ b/template/repository_settings_file/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/template/repository_settings_file/XEH_preInit.sqf b/template/repository_settings_file/XEH_preInit.sqf new file mode 100644 index 000000000..a45666c5d --- /dev/null +++ b/template/repository_settings_file/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/repository_settings_file/config.cpp b/template/repository_settings_file/config.cpp new file mode 100644 index 000000000..f1368fcce --- /dev/null +++ b/template/repository_settings_file/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/repository_settings_file/loadSettingsFile.sqf b/template/repository_settings_file/loadSettingsFile.sqf new file mode 100644 index 000000000..82e7c2220 --- /dev/null +++ b/template/repository_settings_file/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/repository_settings_file/script_component.hpp b/template/repository_settings_file/script_component.hpp new file mode 100644 index 000000000..05add84da --- /dev/null +++ b/template/repository_settings_file/script_component.hpp @@ -0,0 +1,16 @@ +#define COMPONENT repository_settings_file +#include "\x\cba\addons\main\script_mod.hpp" + +//#define DEBUG_ENABLED_REPOSITORY_SETTINGS_FILE + +#ifdef DEBUG_ENABLED_REPOSITORY_SETTINGS_FILE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_REPOSITORY_SETTINGS_FILE + #define DEBUG_SETTINGS DEBUG_SETTINGS_REPOSITORY_SETTINGS_FILE +#endif + +#include "\x\cba\addons\main\script_macros.hpp" + +#define PATH_SETTINGS_FILE_PBO QPATHTOF(userconfig\cba\settings.sqf) diff --git a/template/repository_settings_file/userconfig/cba/settings.sqf b/template/repository_settings_file/userconfig/cba/settings.sqf new file mode 100644 index 000000000..e69de29bb From b52d257a7cec637da1eeb98fb1421389d8af5633 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 6 Aug 2016 14:32:47 +0200 Subject: [PATCH 2/2] change name to 'static_settings_addon' --- template/repository_settings_file/$PBOPREFIX$ | 1 - .../script_component.hpp | 16 ---------------- template/static_settings_addon/$PBOPREFIX$ | 1 + .../CfgEventHandlers.hpp | 0 .../XEH_preInit.sqf | 0 .../config.cpp | 0 .../loadSettingsFile.sqf | 0 .../static_settings_addon/script_component.hpp | 16 ++++++++++++++++ .../userconfig/cba/settings.sqf | 0 9 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 template/repository_settings_file/$PBOPREFIX$ delete mode 100644 template/repository_settings_file/script_component.hpp create mode 100644 template/static_settings_addon/$PBOPREFIX$ rename template/{repository_settings_file => static_settings_addon}/CfgEventHandlers.hpp (100%) rename template/{repository_settings_file => static_settings_addon}/XEH_preInit.sqf (100%) rename template/{repository_settings_file => static_settings_addon}/config.cpp (100%) rename template/{repository_settings_file => static_settings_addon}/loadSettingsFile.sqf (100%) create mode 100644 template/static_settings_addon/script_component.hpp rename template/{repository_settings_file => static_settings_addon}/userconfig/cba/settings.sqf (100%) diff --git a/template/repository_settings_file/$PBOPREFIX$ b/template/repository_settings_file/$PBOPREFIX$ deleted file mode 100644 index 769bcc3cc..000000000 --- a/template/repository_settings_file/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -x\cba\addons\repository_settings_file diff --git a/template/repository_settings_file/script_component.hpp b/template/repository_settings_file/script_component.hpp deleted file mode 100644 index 05add84da..000000000 --- a/template/repository_settings_file/script_component.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#define COMPONENT repository_settings_file -#include "\x\cba\addons\main\script_mod.hpp" - -//#define DEBUG_ENABLED_REPOSITORY_SETTINGS_FILE - -#ifdef DEBUG_ENABLED_REPOSITORY_SETTINGS_FILE - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_REPOSITORY_SETTINGS_FILE - #define DEBUG_SETTINGS DEBUG_SETTINGS_REPOSITORY_SETTINGS_FILE -#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/$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/repository_settings_file/CfgEventHandlers.hpp b/template/static_settings_addon/CfgEventHandlers.hpp similarity index 100% rename from template/repository_settings_file/CfgEventHandlers.hpp rename to template/static_settings_addon/CfgEventHandlers.hpp diff --git a/template/repository_settings_file/XEH_preInit.sqf b/template/static_settings_addon/XEH_preInit.sqf similarity index 100% rename from template/repository_settings_file/XEH_preInit.sqf rename to template/static_settings_addon/XEH_preInit.sqf diff --git a/template/repository_settings_file/config.cpp b/template/static_settings_addon/config.cpp similarity index 100% rename from template/repository_settings_file/config.cpp rename to template/static_settings_addon/config.cpp diff --git a/template/repository_settings_file/loadSettingsFile.sqf b/template/static_settings_addon/loadSettingsFile.sqf similarity index 100% rename from template/repository_settings_file/loadSettingsFile.sqf rename to template/static_settings_addon/loadSettingsFile.sqf 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/repository_settings_file/userconfig/cba/settings.sqf b/template/static_settings_addon/userconfig/cba/settings.sqf similarity index 100% rename from template/repository_settings_file/userconfig/cba/settings.sqf rename to template/static_settings_addon/userconfig/cba/settings.sqf