From 517dcbc5e621567a156370fffbc990110dc4c686 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 28 May 2016 21:51:49 +0200 Subject: [PATCH] read profile and mission stored values of SQF created settings --- addons/settings/CfgEventHandlers.hpp | 2 +- addons/settings/config.cpp | 2 +- addons/settings/fnc_create.sqf | 37 +++++++++++++++++++ addons/settings/{ => gui}/gui.hpp | 0 addons/settings/{ => gui}/gui_createMenu.sqf | 0 .../{ => gui}/gui_createMenu_button.sqf | 0 .../{ => gui}/gui_createMenu_color.sqf | 0 .../{ => gui}/gui_createMenu_default.sqf | 0 .../{ => gui}/gui_createMenu_force.sqf | 0 .../{ => gui}/gui_createMenu_list.sqf | 0 .../{ => gui}/gui_createMenu_slider.sqf | 0 addons/settings/{ => gui}/gui_initDisplay.sqf | 2 +- addons/settings/gui/script_component.hpp | 1 + 13 files changed, 41 insertions(+), 3 deletions(-) rename addons/settings/{ => gui}/gui.hpp (100%) rename addons/settings/{ => gui}/gui_createMenu.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_button.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_color.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_default.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_force.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_list.sqf (100%) rename addons/settings/{ => gui}/gui_createMenu_slider.sqf (100%) rename addons/settings/{ => gui}/gui_initDisplay.sqf (99%) create mode 100644 addons/settings/gui/script_component.hpp diff --git a/addons/settings/CfgEventHandlers.hpp b/addons/settings/CfgEventHandlers.hpp index 610d98641..6af958894 100644 --- a/addons/settings/CfgEventHandlers.hpp +++ b/addons/settings/CfgEventHandlers.hpp @@ -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)); diff --git a/addons/settings/config.cpp b/addons/settings/config.cpp index 1f7fe059e..be2239d65 100644 --- a/addons/settings/config.cpp +++ b/addons/settings/config.cpp @@ -18,4 +18,4 @@ class CfgPatches { #include "CBA_Settings.hpp" #include "Cfg3DEN.hpp" -#include "gui.hpp" +#include "gui\gui.hpp" diff --git a/addons/settings/fnc_create.sqf b/addons/settings/fnc_create.sqf index d4b09b12a..b32b8a69d 100644 --- a/addons/settings/fnc_create.sqf +++ b/addons/settings/fnc_create.sqf @@ -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 { diff --git a/addons/settings/gui.hpp b/addons/settings/gui/gui.hpp similarity index 100% rename from addons/settings/gui.hpp rename to addons/settings/gui/gui.hpp diff --git a/addons/settings/gui_createMenu.sqf b/addons/settings/gui/gui_createMenu.sqf similarity index 100% rename from addons/settings/gui_createMenu.sqf rename to addons/settings/gui/gui_createMenu.sqf diff --git a/addons/settings/gui_createMenu_button.sqf b/addons/settings/gui/gui_createMenu_button.sqf similarity index 100% rename from addons/settings/gui_createMenu_button.sqf rename to addons/settings/gui/gui_createMenu_button.sqf diff --git a/addons/settings/gui_createMenu_color.sqf b/addons/settings/gui/gui_createMenu_color.sqf similarity index 100% rename from addons/settings/gui_createMenu_color.sqf rename to addons/settings/gui/gui_createMenu_color.sqf diff --git a/addons/settings/gui_createMenu_default.sqf b/addons/settings/gui/gui_createMenu_default.sqf similarity index 100% rename from addons/settings/gui_createMenu_default.sqf rename to addons/settings/gui/gui_createMenu_default.sqf diff --git a/addons/settings/gui_createMenu_force.sqf b/addons/settings/gui/gui_createMenu_force.sqf similarity index 100% rename from addons/settings/gui_createMenu_force.sqf rename to addons/settings/gui/gui_createMenu_force.sqf diff --git a/addons/settings/gui_createMenu_list.sqf b/addons/settings/gui/gui_createMenu_list.sqf similarity index 100% rename from addons/settings/gui_createMenu_list.sqf rename to addons/settings/gui/gui_createMenu_list.sqf diff --git a/addons/settings/gui_createMenu_slider.sqf b/addons/settings/gui/gui_createMenu_slider.sqf similarity index 100% rename from addons/settings/gui_createMenu_slider.sqf rename to addons/settings/gui/gui_createMenu_slider.sqf diff --git a/addons/settings/gui_initDisplay.sqf b/addons/settings/gui/gui_initDisplay.sqf similarity index 99% rename from addons/settings/gui_initDisplay.sqf rename to addons/settings/gui/gui_initDisplay.sqf index 9608a4823..b1a9e065a 100644 --- a/addons/settings/gui_initDisplay.sqf +++ b/addons/settings/gui/gui_initDisplay.sqf @@ -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); diff --git a/addons/settings/gui/script_component.hpp b/addons/settings/gui/script_component.hpp new file mode 100644 index 000000000..fcf9da986 --- /dev/null +++ b/addons/settings/gui/script_component.hpp @@ -0,0 +1 @@ +#include "..\script_component.hpp"