Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into v3.8.0.180701
Browse files Browse the repository at this point in the history
* origin/master:
  XEH - Compatiblity for Encore (1.84) (#953)
  indicate settings that need a mission restart (#894)
  don't skip next PFH if current one is removed while iterating through (#950)
  change color of name of temporarily changed settings (#952)
  handle input gracefully in keybinding editKey ui function (#951)
  Update fnc_deleteEntity.sqf (#949)
  • Loading branch information
ViperMaul committed Jul 27, 2018
2 parents c311c64 + deb9b2e commit 0dd4d34
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 46 deletions.
1 change: 1 addition & 0 deletions addons/common/fnc_deleteEntity.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ switch (typeName _entity) do {
case "GROUP" : {
(units _entity) call CBA_fnc_deleteEntity;
{deleteWaypoint _x} forEach (wayPoints _entity);
if (isNull _entity) exitWith {};
if (local _entity) then {
deleteGroup _entity;
} else {
Expand Down
35 changes: 24 additions & 11 deletions addons/common/fnc_removePerFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Parameters:
_handle - The function handle you wish to remove. <NUMBER>
Returns:
None
true if removed successful, false otherwise <BOOLEAN>
Examples:
(begin example)
Expand All @@ -24,18 +24,31 @@ Author:

params [["_handle", -1, [0]]];

if (_handle < 0 || {_handle >= count GVAR(PFHhandles)}) exitWith {};

[{
params ["_handle"];

GVAR(perFrameHandlerArray) deleteAt (GVAR(PFHhandles) select _handle);
GVAR(PFHhandles) set [_handle, nil];
private _index = GVAR(PFHhandles) param [_handle];
if (isNil "_index") exitWith {false};

{
_x params ["", "", "", "", "", "_handle"];
GVAR(PFHhandles) set [_handle, _forEachIndex];
} forEach GVAR(perFrameHandlerArray);
GVAR(PFHhandles) set [_handle, nil];
(GVAR(perFrameHandlerArray) select _index) set [0, {}];

if (GVAR(perFrameHandlersToRemove) isEqualTo []) then {
{
{
GVAR(perFrameHandlerArray) set [_x, objNull];
} forEach GVAR(perFrameHandlersToRemove);

GVAR(perFrameHandlerArray) = GVAR(perFrameHandlerArray) - [objNull];
GVAR(perFrameHandlersToRemove) = [];

{
_x params ["", "", "", "", "", "_index"];
GVAR(PFHhandles) set [_index, _forEachIndex];
} forEach GVAR(perFrameHandlerArray);
} call CBA_fnc_execNextFrame;
};

GVAR(perFrameHandlersToRemove) pushBackUnique _index;
true
}, _handle] call CBA_fnc_directCall;

nil
1 change: 1 addition & 0 deletions addons/common/init_perFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define DELAY_MONITOR_THRESHOLD 1 // Frames

GVAR(perFrameHandlerArray) = [];
GVAR(perFrameHandlersToRemove) = [];
GVAR(lastTickTime) = diag_tickTime;

GVAR(waitAndExecArray) = [];
Expand Down
45 changes: 24 additions & 21 deletions addons/keybinding/fnc_gui_editKey.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,38 @@ _ctrlKeyList setVariable [QGVAR(defaultKeybind), _defaultKeybind];

// --- record keys
_display displayAddEventHandler ["KeyDown", {
params ["_display", "_key", "_shift", "_control", "_alt"];
private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS;
call {
params ["_display", "_key", "_shift", "_control", "_alt"];
private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS;

if (_key <= DIK_ESCAPE) exitWith {};
if (_key in [DIK_LSHIFT, DIK_RSHIFT, DIK_LCONTROL, DIK_RCONTROL, DIK_LMENU, DIK_RMENU]) exitWith {};
if (!isNil {_ctrlKeyList getVariable QGVAR(lock)}) exitWith {};
if (_key <= DIK_ESCAPE) exitWith {false};
if (_key in [DIK_LSHIFT, DIK_RSHIFT, DIK_LCONTROL, DIK_RCONTROL, DIK_LMENU, DIK_RMENU]) exitWith {true};
if (!isNil {_ctrlKeyList getVariable QGVAR(lock)}) exitWith {true};

private _keybind = [_key, [_shift, _control, _alt]];
private _keyName = _keybind call CBA_fnc_localizeKey;
private _keybind = [_key, [_shift, _control, _alt]];
private _keyName = _keybind call CBA_fnc_localizeKey;

// if key already in list, remove instead
private _doAdd = true;
// if key already in list, remove instead
private _doAdd = true;

for "_index" from 0 to (lbSize _ctrlKeyList - 1) do {
if (_ctrlKeyList lbData _index == str _keybind) exitWith {
_ctrlKeyList lbDelete _index;
_doAdd = false;
for "_index" from 0 to (lbSize _ctrlKeyList - 1) do {
if (_ctrlKeyList lbData _index == str _keybind) exitWith {
_ctrlKeyList lbDelete _index;
_doAdd = false;
};
};
};

if (_doAdd) then {
private _index = _ctrlKeyList lbAdd _keyName;
_ctrlKeyList lbSetData [_index, str _keybind];
_ctrlKeyList lbSetCurSel _index;
};
if (_doAdd) then {
private _index = _ctrlKeyList lbAdd _keyName;
_ctrlKeyList lbSetData [_index, str _keybind];
_ctrlKeyList lbSetCurSel _index;
};

_ctrlKeyList call (_ctrlKeyList getVariable QFUNC(showDuplicates));
_ctrlKeyList call (_ctrlKeyList getVariable QFUNC(showDuplicates));

_ctrlKeyList setVariable [QGVAR(lock), true];
_ctrlKeyList setVariable [QGVAR(lock), true];
true
};
}];

_display displayAddEventHandler ["KeyUp", {
Expand Down
Binary file added addons/settings/applies_ca.paa
Binary file not shown.
11 changes: 11 additions & 0 deletions addons/settings/fnc_gui_refresh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ private _controls = allControls _display select {ctrlIDC _x isEqualTo IDC_SETTIN
private _source = _x getVariable QGVAR(source);

private _value = GET_TEMP_NAMESPACE_VALUE(_setting,_source);
private _wasEdited = false;

if (isNil "_value") then {
_value = [_setting, _source] call FUNC(get);
} else {
_wasEdited = true;
};

[_x, _value] call (_x getVariable QFUNC(updateUI));
Expand All @@ -34,7 +37,15 @@ private _controls = allControls _display select {ctrlIDC _x isEqualTo IDC_SETTIN

if (isNil "_priority") then {
_priority = [_setting, _source] call FUNC(priority);
} else {
_wasEdited = true;
};

[_x, _priority] call (_x getVariable QFUNC(updateUI_priority));

// change color if setting was edited
if (_wasEdited) then {
private _ctrlSettingName = _x controlsGroupCtrl IDC_SETTING_NAME;
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
};
} forEach _controls;
3 changes: 3 additions & 0 deletions addons/settings/fnc_gui_saveTempData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ Author:
};
} forEach ["client", "mission", "server"];
} forEach GVAR(allSettings);

GVAR(awaitingRestart) = GVAR(awaitingRestartTemp);
nil
3 changes: 3 additions & 0 deletions addons/settings/fnc_gui_settingDefault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ _ctrlDefault ctrlAddEventHandler ["ButtonClick", {

private _controlsGroup = ctrlParentControlsGroup _ctrlDefault;
[_controlsGroup, _defaultValue] call (_controlsGroup getVariable QFUNC(updateUI));

private _ctrlSettingName = _controlsGroup controlsGroupCtrl IDC_SETTING_NAME;
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
}];

if (_currentValue isEqualTo _defaultValue) then {
Expand Down
43 changes: 35 additions & 8 deletions addons/settings/fnc_gui_settingOverwrite.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ _ctrlOverwriteClient setVariable [QFUNC(event), {
SET_TEMP_NAMESPACE_PRIORITY(_setting,_state,_source);

_controlsGroup call (_controlsGroup getVariable QFUNC(updateUI_locked));

private _ctrlSettingName = _controlsGroup controlsGroupCtrl IDC_SETTING_NAME;
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
}];

_controlsGroup setVariable [QFUNC(auto_check_overwrite), {
Expand All @@ -44,6 +47,9 @@ _controlsGroup setVariable [QFUNC(auto_check_overwrite), {
[_ctrlOverwriteClient, 1] call (_ctrlOverwriteClient getVariable QFUNC(event));
};
};

private _ctrlSettingName = _controlsGroup controlsGroupCtrl IDC_SETTING_NAME;
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
}];

_ctrlOverwriteMission ctrlAddEventHandler ["CheckedChanged", {
Expand All @@ -69,6 +75,9 @@ _ctrlOverwriteMission ctrlAddEventHandler ["CheckedChanged", {
};

_controlsGroup call (_controlsGroup getVariable QFUNC(updateUI_locked));

private _ctrlSettingName = _controlsGroup controlsGroupCtrl IDC_SETTING_NAME;
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
}];

// update overwrite checkboxes
Expand Down Expand Up @@ -104,30 +113,48 @@ _controlsGroup setVariable [QFUNC(updateUI_locked), {
private _ctrlLocked = _x controlsGroupCtrl IDC_SETTING_LOCKED;

if (_source isEqualTo _priority) then {
_ctrlLocked ctrlSetText "";
_ctrlLocked ctrlSetTooltip "";
if (toLower _setting in GVAR(awaitingRestartTemp)) then {
_ctrlLocked ctrlSetText ICON_NEED_RESTART;
_ctrlLocked ctrlSetTextColor COLOR_NEED_RESTART;
_ctrlLocked ctrlSetTooltip LLSTRING(need_restart);
} else {
_ctrlLocked ctrlSetText ICON_APPLIES;
_ctrlLocked ctrlSetTextColor COLOR_APPLIES;
_ctrlLocked ctrlSetTooltip LLSTRING(applies);
};
} else {
switch [_source, _priority] do {
case ["client", "server"];
case ["mission", "server"]: {
_ctrlLocked ctrlSetText QPATHTOF(locked_ca.paa);
_ctrlLocked ctrlSetText ICON_OVERWRITTEN;
_ctrlLocked ctrlSetTextColor COLOR_OVERWRITTEN;
_ctrlLocked ctrlSetTooltip LLSTRING(overwritten_by_server_tooltip);
};
case ["client", "mission"];
case ["server", "mission"]: {
_ctrlLocked ctrlSetText QPATHTOF(locked_ca.paa);
_ctrlLocked ctrlSetText ICON_OVERWRITTEN;
_ctrlLocked ctrlSetTextColor COLOR_OVERWRITTEN;
_ctrlLocked ctrlSetTooltip LLSTRING(overwritten_by_mission_tooltip);
};
case ["mission", "client"]: {
_ctrlLocked ctrlSetText QPATHTOF(locked_ca.paa);
_ctrlLocked ctrlSetText ICON_OVERWRITTEN;
_ctrlLocked ctrlSetTextColor COLOR_OVERWRITTEN;
_ctrlLocked ctrlSetTooltip LLSTRING(overwritten_by_client_tooltip);
};
case ["server", "client"]: {
if (isServer) then {
_ctrlLocked ctrlSetText "";
_ctrlLocked ctrlSetTooltip "";
if (toLower _setting in GVAR(awaitingRestartTemp)) then {
_ctrlLocked ctrlSetText ICON_NEED_RESTART;
_ctrlLocked ctrlSetTextColor COLOR_NEED_RESTART;
_ctrlLocked ctrlSetTooltip LLSTRING(need_restart);
} else {
_ctrlLocked ctrlSetText ICON_APPLIES;
_ctrlLocked ctrlSetTextColor COLOR_APPLIES;
_ctrlLocked ctrlSetTooltip LLSTRING(applies);
};
} else {
_ctrlLocked ctrlSetText QPATHTOF(locked_ca.paa);
_ctrlLocked ctrlSetText ICON_OVERWRITTEN;
_ctrlLocked ctrlSetTextColor COLOR_OVERWRITTEN;
_ctrlLocked ctrlSetTooltip LLSTRING(overwritten_by_client_tooltip_server);
};
};
Expand Down
8 changes: 7 additions & 1 deletion addons/settings/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Parameters:
_valueInfo - Extra properties of the setting depending of _settingType. See examples below <ANY>
_isGlobal - 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) <ARRAY>
_script - Script to execute when setting is changed. (optional) <CODE>
_needRestart - Setting will be marked as needing mission restart after being changed. (optional, default false) <BOOL>
Returns:
_return - Error code <NUMBER>
Expand Down Expand Up @@ -56,7 +57,8 @@ params [
["_categoryArg", "", ["", []]],
["_valueInfo", []],
["_isGlobal", false, [false, 0]],
["_script", {}, [{}]]
["_script", {}, [{}]],
["_needRestart", false, [false]]
];

if (_setting isEqualTo "") exitWith {
Expand Down Expand Up @@ -205,4 +207,8 @@ if (isServer) then {
[QGVAR(refreshSetting), _setting] call CBA_fnc_localEvent;
};

if (_needRestart) then {
GVAR(needRestart) pushBackUnique toLower _setting;
};

0
2 changes: 2 additions & 0 deletions addons/settings/fnc_initDisplayGameOptions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ with uiNamespace do {
GVAR(serverTemp) = _display ctrlCreate ["RscText", -1];
};

GVAR(awaitingRestartTemp) = + GVAR(awaitingRestart);

// ----- create addons list (filled later)
private _ctrlAddonList = _display ctrlCreate [QGVAR(AddonsList), -1, _ctrlAddonsGroup];

Expand Down
2 changes: 0 additions & 2 deletions addons/settings/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ class GVAR(Row_Base): RscControlsGroupNoScrollbars {
};
class Locked: RscPicture {
idc = IDC_SETTING_LOCKED;
text = QPATHTOF(locked_ca.paa);
colorText[] = {1,0,0,1};
x = POS_W(28);
y = POS_H(0) + TABLE_LINE_SPACING/2;
w = POS_W(1);
Expand Down
11 changes: 11 additions & 0 deletions addons/settings/gui_createCategory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ private _lastSubCategory = "$START";
private _source = toLower _x;

private _currentValue = GET_TEMP_NAMESPACE_VALUE(_setting,_source);
private _wasEdited = false;

if (isNil "_currentValue") then {
_currentValue = [_setting, _source] call FUNC(get);
} else {
_wasEdited = true;
};

private _currentPriority = GET_TEMP_NAMESPACE_PRIORITY(_setting,_source);
if (isNil "_currentPriority") then {
_currentPriority = [_setting, _source] call FUNC(priority);
} else {
_wasEdited = true;
};

// ----- create or retrieve options "list" controls group
Expand Down Expand Up @@ -143,6 +149,11 @@ private _lastSubCategory = "$START";
_ctrlSettingName ctrlSetText format ["%1:", _displayName];
_ctrlSettingName ctrlSetTooltip _tooltip;

// change color if setting was edited
if (_wasEdited) then {
_ctrlSettingName ctrlSetTextColor COLOR_TEXT_ENABLED_WAS_EDITED;
};

// ----- execute setting script
private _script = getText (configFile >> ctrlClassName _ctrlSettingGroup >> QGVAR(script));
[_ctrlSettingGroup, _setting, _source, _currentValue, _settingData] call (uiNamespace getVariable _script);
Expand Down
3 changes: 3 additions & 0 deletions addons/settings/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ if (isNil QGVAR(default)) then {

GVAR(missionConfig) setVariable [_setting, [_value, _priority]];
} forEach ([_missionConfig, false] call FUNC(parse));

GVAR(needRestart) = [];
GVAR(awaitingRestart) = [];
};
Binary file removed addons/settings/locked_ca.paa
Binary file not shown.
Binary file added addons/settings/need_restart_ca.paa
Binary file not shown.
Binary file added addons/settings/overwritten_ca.paa
Binary file not shown.
13 changes: 11 additions & 2 deletions addons/settings/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,19 @@
#define TABLE_LINE_SPACING POS_H(0.4)

#define COLOR_TEXT_ENABLED [1, 1, 1, 1]
#define COLOR_TEXT_ENABLED_WAS_EDITED [0.95, 0.95, 0.1, 1]
#define COLOR_TEXT_DISABLED [1, 1, 1, 0.4]
#define COLOR_BUTTON_ENABLED [1, 1, 1, 1]
#define COLOR_BUTTON_DISABLED [0, 0, 0, 1]

#define ICON_DEFAULT "\a3\3den\Data\Displays\Display3DEN\ToolBar\undo_ca.paa"
#define ICON_APPLIES QPATHTOF(applies_ca.paa)
#define ICON_OVERWRITTEN QPATHTOF(overwritten_ca.paa)
#define ICON_NEED_RESTART QPATHTOF(need_restart_ca.paa)

#define COLOR_APPLIES [0, 0.95, 0, 1]
#define COLOR_OVERWRITTEN [0.95, 0, 0, 1]
#define COLOR_NEED_RESTART [0.95, 0.95, 0, 1]

#define CAN_SET_SERVER_SETTINGS ((isServer || FUNC(whitelisted)) && {!isNull GVAR(server)}) // in single player, as host (local server) or as logged in (not voted) admin connected to a dedicated server
#define CAN_SET_CLIENT_SETTINGS !isServer // in multiplayer as dedicated client
Expand All @@ -108,8 +116,9 @@
#define GET_TEMP_NAMESPACE_VALUE(setting,source) (GET_TEMP_NAMESPACE(source) getVariable [setting, [nil, nil]] select 0)
#define GET_TEMP_NAMESPACE_PRIORITY(setting,source) (GET_TEMP_NAMESPACE(source) getVariable [setting, [nil, nil]] select 1)

#define SET_TEMP_NAMESPACE_VALUE(setting,value,source) (GET_TEMP_NAMESPACE(source) setVariable [setting, [value, GET_TEMP_NAMESPACE_PRIORITY(setting,source)]])
#define SET_TEMP_NAMESPACE_PRIORITY(setting,priority,source) (GET_TEMP_NAMESPACE(source) setVariable [setting, [GET_TEMP_NAMESPACE_VALUE(setting,source), priority]])
#define SET_TEMP_NAMESPACE_AWAITING_RESTART(setting) if (toLower setting in GVAR(needRestart) && {!is3den}) then {GVAR(awaitingRestartTemp) pushBackUnique toLower setting}
#define SET_TEMP_NAMESPACE_VALUE(setting,value,source) GET_TEMP_NAMESPACE(source) setVariable [setting, [value, GET_TEMP_NAMESPACE_PRIORITY(setting,source)]]; SET_TEMP_NAMESPACE_AWAITING_RESTART(setting)
#define SET_TEMP_NAMESPACE_PRIORITY(setting,priority,source) GET_TEMP_NAMESPACE(source) setVariable [setting, [GET_TEMP_NAMESPACE_VALUE(setting,source), priority]]; SET_TEMP_NAMESPACE_AWAITING_RESTART(setting)

#define TEMP_PRIORITY(setting) (call {private _arr = [\
(uiNamespace getVariable QGVAR(clientTemp)) getVariable [setting, [nil, [setting, "client"] call FUNC(priority)]] select 1,\
Expand Down
8 changes: 8 additions & 0 deletions addons/settings/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@
<French>Overwrite\nServer</French>
<Polish>Nadpisz\nSerwer</Polish>
</Key>
<Key ID="STR_cba_settings_applies">
<English>This setting applies.</English>
<German>Diese Einstellung gilt.</German>
</Key>
<Key ID="STR_cba_settings_need_restart">
<English>This setting applies after the next mission restart.</English>
<German>Diese Einstellung gilt nach dem nächsten Neustart der Mission.</German>
</Key>
<Key ID="STR_cba_settings_overwritten_by_client_tooltip">
<English>This setting is overwritten by the clients.</English>
<German>Diese Einstellung wird von den Clients überschrieben.</German>
Expand Down
Loading

0 comments on commit 0dd4d34

Please sign in to comment.