Skip to content

Commit

Permalink
Merge pull request #450 from CBATeam/optional-file-to-load-userconfig…
Browse files Browse the repository at this point in the history
…-settings

add optional pbo to load settings from userconfig file
  • Loading branch information
Killswitch00 committed Aug 6, 2016
2 parents c07e153 + b21acec commit f0793e1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/settings/fnc_import.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ _info = _info call FUNC(parse);
SET_TEMP_NAMESPACE_FORCED(_setting,_force,_source);
} forEach _info;

call FUNC(gui_refresh);
if (!isNull (uiNamespace getVariable [QGVAR(display), displayNull])) then {
call FUNC(gui_refresh);
};
1 change: 1 addition & 0 deletions optionals/auto_load_settings_file/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\cba\addons\auto_load_settings_file
6 changes: 6 additions & 0 deletions optionals/auto_load_settings_file/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 optionals/auto_load_settings_file/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 optionals/auto_load_settings_file/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"
14 changes: 14 additions & 0 deletions optionals/auto_load_settings_file/loadSettingsFile.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

if (isFilePatchingEnabled) then {
private _source = ["client", "server"] select (isMultiplayer && isServer);
private _file = loadFile PATH_SETTINGS_FILE;

if (_file != "") then {
[_file, _source] call EFUNC(settings,import);
diag_log text "[CBA] (settings): Settings file loaded.";
} else {
diag_log text "[CBA] (settings): Settings file not loaded. File empty or does not exist.";
};
} else {
diag_log text "[CBA] (settings): Cannot load settings file. File patching disabled. Use -filePatching flag.";
};
16 changes: 16 additions & 0 deletions optionals/auto_load_settings_file/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#define COMPONENT auto_load_settings_file
#include "\x\cba\addons\main\script_mod.hpp"

//#define DEBUG_ENABLED_AUTO_LOAD_SETTINGS_FILE

#ifdef DEBUG_ENABLED_AUTO_LOAD_SETTINGS_FILE
#define DEBUG_MODE_FULL
#endif

#ifdef DEBUG_SETTINGS_AUTO_LOAD_SETTINGS_FILE
#define DEBUG_SETTINGS DEBUG_SETTINGS_AUTO_LOAD_SETTINGS_FILE
#endif

#include "\x\cba\addons\main\script_macros.hpp"

#define PATH_SETTINGS_FILE "userconfig\cba\settings.sqf"

0 comments on commit f0793e1

Please sign in to comment.