Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate settings that need a mission restart #894

Merged
merged 6 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added addons/settings/applies_ca.paa
Binary file not shown.
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
34 changes: 26 additions & 8 deletions addons/settings/fnc_gui_settingOverwrite.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,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
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.
12 changes: 10 additions & 2 deletions addons/settings/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
#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 +115,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)) then {GVAR(awaitingRestartTemp) pushBackUnique toLower setting}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could skip showing in 3den

#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