Skip to content

Commit

Permalink
Merge pull request #437 from CBATeam/settingsChanges
Browse files Browse the repository at this point in the history
Rework Settings
  • Loading branch information
Killswitch00 committed Aug 6, 2016
2 parents 1919eef + d6ef65b commit f67f547
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 12 deletions.
8 changes: 7 additions & 1 deletion addons/settings/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
diag_log text "[CBA] (settings): No server settings after postInit phase.";
};

//Event to read modules
["CBA_beforeSettingsInitialized", []] call CBA_fnc_localEvent;

GVAR(ready) = true;
{
[QGVAR(refreshSetting), _x] call CBA_fnc_localEvent;
} forEach GVAR(allSettings);
} forEach GVAR(allSettings);

diag_log text format ["[CBA] (settings): Settings Initialized"];
["CBA_settingsInitialized", []] call CBA_fnc_localEvent;
} call CBA_fnc_execNextFrame;

// --- autosave mission and server presets
Expand Down
14 changes: 14 additions & 0 deletions addons/settings/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ if (isServer) then {
}] call CBA_fnc_addEventHandler;
};

// event to modify mission settings
[QGVAR(setSettingMission), {
params ["_setting", "_value", ["_forced", false, [false]]];

if ([_setting, "mission"] call FUNC(isForced)) exitWith {
diag_log text format ["[CBA] (settings): Setting %1 already forced, ignoring setSettingMission.", _setting];
};
if (!([_setting, _value] call FUNC(check))) exitWith {
diag_log text format ["[CBA] (settings): Value %1 is invalid for setting %2.", _value, _setting];
};

GVAR(missionSettings) setVariable [_setting, [_value, _forced]];
}] call CBA_fnc_addEventHandler;

ADDON = true;
2 changes: 1 addition & 1 deletion addons/settings/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ if (!isNil "_settingInfo") then {
if (isServer) then {
[QGVAR(refreshSetting), _setting] call CBA_fnc_globalEvent;
} else {
[QGVAR(refreshSetting), _setting] call CBA_fnc_localEvent;
[QGVAR(refreshSetting), _setting] call CBA_fnc_localEvent;
};

0
2 changes: 1 addition & 1 deletion addons/settings/fnc_isForced.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ switch (toLower _source) do {
GET_FORCED(clientSettings,_setting);
};
case ("server"): {
GET_FORCED(serverSettings,_setting);
GET_FORCED(serverSettings,_setting) || {(!GET_FORCED(missionSettings,_setting)) && {(isMultiplayer && {NAMESPACE_GETVAR(GVAR(defaultSettings),_setting,[]) param [7, false]})}};
};
case ("mission"): {
GET_FORCED(missionSettings,_setting);
Expand Down
4 changes: 2 additions & 2 deletions addons/settings/fnc_isOverwritten.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ switch (toLower _source) do {
[_setting, "mission"] call FUNC(isForced) || {[_setting, "server"] call FUNC(isForced)}
};
case ("server"): {
false
(!([_setting, "server"] call FUNC(isForced))) && {[_setting, "mission"] call FUNC(isForced)}
};
case ("mission"): {
[_setting, "server"] call FUNC(isForced)
(!([_setting, "mission"] call FUNC(isForced))) || {[_setting, "server"] call FUNC(isForced)}
};
default {nil};
};
5 changes: 0 additions & 5 deletions addons/settings/gui_createMenu_force.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ private _data = [_setting, _source];
_ctrlSettingForce setVariable [QGVAR(linkedControls), _linkedControls];
_ctrlSettingForce setVariable [QGVAR(data), _data];

if (_isGlobal) then {
_ctrlSettingForce ctrlSetChecked true;
_ctrlSettingForce ctrlEnable false;
};

_ctrlSettingForce ctrlAddEventHandler ["CheckedChanged", {
params ["_control", "_state"];

Expand Down
5 changes: 3 additions & 2 deletions addons/settings/script_component.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#define COMPONENT settings
#include "\x\cba\addons\main\script_mod.hpp"
#include "\x\cba\addons\main\script_macros.hpp"

#include "\a3\ui_f\hpp\defineDIKCodes.inc"
#include "\a3\ui_f\hpp\defineCommonGrids.inc"
Expand All @@ -15,6 +14,8 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_SETTINGS
#endif

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

#define IDC_ADDONS_GROUP 4301
#define IDC_BTN_CONFIGURE_ADDONS 4302
#define IDC_BTN_CLIENT 9000
Expand Down Expand Up @@ -76,7 +77,7 @@
#define NAMESPACE_GETVAR(namespace,varname,default) ([namespace getVariable varname] param [0, default])

#define GET_VALUE(namespace,setting) ((GVAR(namespace) getVariable setting) param [0])
#define GET_FORCED(namespace,setting) ((NAMESPACE_GETVAR(GVAR(namespace),setting,[]) param [1, false]) || {isMultiplayer && {NAMESPACE_GETVAR(GVAR(defaultSettings),setting,[]) param [7, false]}})
#define GET_FORCED(namespace,setting) (NAMESPACE_GETVAR(GVAR(namespace),setting,[]) param [1, false])

#define GET_TEMP_NAMESPACE(source) ([ARR_3(GVAR(clientSettingsTemp),GVAR(serverSettingsTemp),GVAR(missionSettingsTemp))] param [[ARR_3('client','server','mission')] find toLower source])
#define SET_TEMP_NAMESPACE_VALUE(setting,value,source) GET_TEMP_NAMESPACE(source) setVariable [ARR_2(setting,[ARR_2(value,(GET_TEMP_NAMESPACE(source) getVariable setting) param [1])])]
Expand Down
9 changes: 9 additions & 0 deletions addons/settings/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@
</Key>
<Key ID="STR_cba_settings_Default">
<English>Default</English>
<Czech>Výchozí</Czech>
<German>Voreinst.</German>
<Russian>По умолчанию</Russian>
<Polish>Domyślnie</Polish>
<Italian>Predefinito</Italian>
<Spanish>Predet.</Spanish>
<French>Par défaut</French>
<Japanese>デフォルト</Japanese>
<Korean>기본값</Korean>
<Portuguese>Padrão</Portuguese>
</Key>
<Key ID="STR_cba_settings_overwritten_tooltip">
<English>Setting is overwritten. Check 'Server' or 'Mission' tab.</English>
Expand Down

0 comments on commit f67f547

Please sign in to comment.