Skip to content

Commit

Permalink
read profile and mission stored values of SQF created settings
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed May 28, 2016
1 parent aa52b36 commit 517dcbc
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/settings/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Extended_PostInit_EventHandlers {

class Extended_DisplayLoad_EventHandlers {
class RscDisplayGameOptions {
ADDON = QUOTE(_this call COMPILE_FILE(gui_initDisplay));
ADDON = QUOTE(_this call COMPILE_FILE(gui\gui_initDisplay));
};
class Display3DEN {
ADDON = QUOTE(_this call COMPILE_FILE(init_3den));
Expand Down
2 changes: 1 addition & 1 deletion addons/settings/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class CfgPatches {
#include "CBA_Settings.hpp"
#include "Cfg3DEN.hpp"

#include "gui.hpp"
#include "gui\gui.hpp"
37 changes: 37 additions & 0 deletions addons/settings/fnc_create.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,43 @@ if (isNil "_defaultValue") exitWith {false};
GVAR(defaultSettings) setVariable [_setting, [_defaultValue, _addon, _settingType, _values, _valueNames, _displayName, _tooltip, _trailingDecimals]];
GVAR(allSettings) pushBackUnique _setting;

// read previous setting values from profile
(profileNamespace getVariable [QGVAR(profileSettings), []]) params [["_profileSettings", []], ["_profileValues", []], ["_profileForced", []]];

private _index = (_profileSettings apply {toLower _x}) find toLower _setting;

if (_index != -1) then {
private _value = _profileValues param [_index];
private _forced = _profileForced param [_index, false];

if !([_setting, _value] call FUNC(check)) then {
_value = [_setting, "default"] call FUNC(get);

[_setting, _value, _forced, "client"] call FUNC(set);
diag_log text format ["[CBA] (settings): Invalid value for setting %1. Fall back to default value.", str _setting];
};

GVAR(clientSettings) setVariable [_setting, [_value, _forced]];
if (isServer && {isMultiplayer}) then {
GVAR(serverSettings) setVariable [_setting, [_value, _forced], true];
};
};

private _missionSettingsVar = missionNamespace getVariable [QGVAR(3denSettings), "Scenario" get3DENMissionAttribute QGVAR(missionSettings)];
_missionSettingsVar params [["_missionSettings", []], ["_missionValues", []], ["_missionForced", []]];

_index = (_missionSettings apply {toLower _x}) find toLower _setting;

if (_index != -1) then {
private _value = _missionValues param [_index];
private _forced = _missionForced param [_index, false];

if !([_setting, _value] call FUNC(check)) then {
GVAR(missionSettings) setVariable [_setting, [_value, _forced]];
};
};

// refresh
if (isServer) then {
[QGVAR(refreshSetting), _setting] call CBA_fnc_globalEvent;
} else {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "script_component.hpp"

#define PREP(func) if (isNil QFUNC(func)) then {FUNC(func) = uiNamespace getVariable QFUNC(func)}
#include "XEH_PREP.sqf"
#include "..\XEH_PREP.sqf"
// --------------------------------------------------

call FUNC(init);
Expand Down
1 change: 1 addition & 0 deletions addons/settings/gui/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "..\script_component.hpp"

0 comments on commit 517dcbc

Please sign in to comment.