Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add template for a settings file inside a pbo #451

Merged
merged 3 commits into from
Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions template/static_settings_addon/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\cba\addons\static_settings_addon
6 changes: 6 additions & 0 deletions template/static_settings_addon/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
12 changes: 12 additions & 0 deletions template/static_settings_addon/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 17 additions & 0 deletions template/static_settings_addon/config.cpp
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions template/static_settings_addon/loadSettingsFile.sqf
Original file line number Diff line number Diff line change
@@ -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.";
16 changes: 16 additions & 0 deletions template/static_settings_addon/script_component.hpp
Original file line number Diff line number Diff line change
@@ -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)
Empty file.