Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion addons/settings/fnc_check.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ switch (toUpper _settingType) do {
};
case "TIME": {
_settingData params ["_min", "_max"];
_value isEqualType 0 && {_value >= _min} && {_value <= _max} && {round _value == _value}
_value isEqualType 0 && {_value >= _min} && {_value <= _max} && {round _value == _value}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
_value isEqualType 0 && {_value >= _min} && {_value <= _max} && {round _value == _value}
_value isEqualType 0 && {_value >= _min} && {_value <= _max} && {round _value isEqualTo _value}

};
default {false};
};
9 changes: 4 additions & 5 deletions addons/settings/fnc_gui_addonChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ if !(_selectedAddon in _optionsGroups) then {
// toggle lists
{
private _isSelected = _x isEqualTo _selectedAddon;
private _optionsGroup = _optionsGroups get _x;

_optionsGroup ctrlEnable _isSelected;
_optionsGroup ctrlShow _isSelected;
} forEach (keys _optionsGroups);

_y ctrlEnable _isSelected;
_y ctrlShow _isSelected;
} forEach _optionsGroups;

// the category was built for whichever source was shown when it was created
call FUNC(gui_refresh);
Expand Down
13 changes: 13 additions & 0 deletions addons/settings/fnc_gui_configure.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ if !(ctrlShown _ctrlAddonsGroup) then {
//--- change button text
_ctrlToggleButton ctrlSetText LLSTRING(configureBase);

//--- showing the addons group shows every category built inside it, only the
//--- selected one may stay. Its own rows are put back once the source is known.
private _selectedCategory = uiNamespace getVariable [QGVAR(addon), ""];

{
_y ctrlShow (_x isEqualTo _selectedCategory);
} forEach (_display getVariable [QGVAR(optionsGroups), createHashMap]);

//--- emulate scope selection
private _previousSelectedSource = uiNamespace getVariable QGVAR(source);

Expand Down Expand Up @@ -109,8 +117,13 @@ if !(ctrlShown _ctrlAddonsGroup) then {
_ctrlServerButton
];

//--- points the rows at that source again, which is also what hides the
//--- overwrite checkboxes showing the group above brought back
_ctrlPreviousButton call FUNC(gui_sourceChanged);
ctrlSetFocus _ctrlPreviousButton;

//--- and so are the rows a search or a folded sub-category had hidden
[_display, false] call FUNC(gui_filterSettings);
} else {
//--- enable and show default menu
_ctrlGeneralGroup ctrlEnable true;
Expand Down
9 changes: 8 additions & 1 deletion addons/settings/fnc_gui_filterSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ private _shownRows = [];

// a header is kept for as long as the search left it anything, folded or not
_x setVariable [QGVAR(matched), _matched];
_x ctrlShow _show;

// showing a row shows every control inside it, so the overwrite checkboxes
// the source it is pointed at doesn't use have to be hidden again. Rows that
// stay where they are keep theirs, this runs on every keystroke of the search.
if (_show isNotEqualTo (ctrlShown _x)) then {
_x ctrlShow _show;
_x call FUNC(gui_setOverwriteVisible);
};

if (_show) then {
_shownRows pushBack _x;
Expand Down
9 changes: 3 additions & 6 deletions addons/settings/fnc_gui_retargetRow.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ _controlsGroup setVariable [QGVAR(source), _source];
private _enabled = _controlsGroup call FUNC(gui_setRowEnabled);

// ----- which overwrite checkboxes a row has depends on the source it shows
private _isGlobal = _controlsGroup getVariable [QGVAR(isGlobal), 0];
_controlsGroup call FUNC(gui_setOverwriteVisible);

private _isGlobal = _controlsGroup getVariable [QGVAR(isGlobal), SETTING_LOCAL_OVERRIDABLE];
private _ctrlOverwriteClient = _controlsGroup controlsGroupCtrl IDC_SETTING_OVERWRITE_CLIENT;
private _ctrlOverwriteMission = _controlsGroup controlsGroupCtrl IDC_SETTING_OVERWRITE_MISSION;

[_ctrlOverwriteClient, _source isNotEqualTo "client" && {_isGlobal < 2}] call FUNC(gui_setOverwriteVisible);
[_ctrlOverwriteMission, _source isEqualTo "server" && {_isGlobal < 2}] call FUNC(gui_setOverwriteVisible);

// "overwrite clients" is forced for global settings, so it can't be unticked
_ctrlOverwriteClient setVariable [QGVAR(cbEnabled), !(_isGlobal > 0 && _source isNotEqualTo "mission")];
_ctrlOverwriteClient setVariable [QGVAR(cbEnabled), !(_isGlobal isNotEqualTo SETTING_LOCAL_OVERRIDABLE && _source isNotEqualTo "mission")];

// what "overwrite clients" goes back to belongs to the source that was shown
_ctrlOverwriteClient setVariable [QGVAR(state), nil];
Expand Down
36 changes: 27 additions & 9 deletions addons/settings/fnc_gui_setOverwriteVisible.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,46 @@
Internal Function: CBA_settings_fnc_gui_setOverwriteVisible

Description:
Shows or hides one of the "overwrite" checkboxes of a settings menu row.
Shows the "overwrite" checkboxes that the source a settings menu row is
pointed at can use, and hides the rest.

Which of them a row has depends on the source it is showing, so this has to
be reversible.
Which of them a row has depends on that source, so this has to be reversible.
It also has to be repeatable: showing a row shows every control inside it,
the hidden checkboxes included, so whoever shows one puts them back.

Parameters:
_ctrl - Overwrite checkbox <CONTROL>
_show - Show the checkbox <BOOL>
_controlsGroup - Setting controls group <CONTROL>

Returns:
None

Examples:
(begin example)
[_ctrlOverwriteMission, false] call CBA_settings_fnc_gui_setOverwriteVisible;
_ctrlSettingGroup call CBA_settings_fnc_gui_setOverwriteVisible;
(end)

Author:
LinkIsGrim
---------------------------------------------------------------------------- */

params ["_ctrl", "_show"];
params ["_controlsGroup"];

_ctrl ctrlShow _show;
_ctrl ctrlEnable _show;
// a local setting never leaves the client it is set on, so it has nothing to
// point anywhere
private _isLocalOnly = ROW_IS_LOCAL_ONLY(_controlsGroup);
private _source = ROW_SOURCE(_controlsGroup);

private _showClient = _source isNotEqualTo "client" && !_isLocalOnly;
private _showMission = _source isEqualTo "server" && !_isLocalOnly;

private _ctrlOverwriteClient = _controlsGroup controlsGroupCtrl IDC_SETTING_OVERWRITE_CLIENT;
private _ctrlOverwriteMission = _controlsGroup controlsGroupCtrl IDC_SETTING_OVERWRITE_MISSION;

_ctrlOverwriteClient ctrlShow _showClient;
_ctrlOverwriteMission ctrlShow _showMission;

// a checkbox that isn't there can't be ticked either. Whether the ones that are
// can be is not this function's task to answer, so it only ever takes that away -
// FUNC(gui_setRowEnabled) and the row's updateUI_priority own the other half.
_ctrlOverwriteClient ctrlEnable (_showClient && ctrlEnabled _ctrlOverwriteClient);
_ctrlOverwriteMission ctrlEnable (_showMission && ctrlEnabled _ctrlOverwriteMission);
7 changes: 6 additions & 1 deletion addons/settings/fnc_gui_setRowEnabled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ params ["_controlsGroup"];
private _setting = ROW_SETTING(_controlsGroup);
private _source = ROW_SOURCE(_controlsGroup);

// a local setting is never overwritten by the mission, so there is nothing a
// mission maker could set from here. The server keeps it: a server is a client
// too, and FUNC(set) writes both when it is set there.
private _isLocalOnly = ROW_IS_LOCAL_ONLY(_controlsGroup);

private _enabled = switch (_source) do {
case "client": {CAN_SET_CLIENT_SETTINGS && {isNil {GVAR(userconfig) getVariable _setting}}};
case "mission": {CAN_SET_MISSION_SETTINGS && {isNil {GVAR(missionConfig) getVariable _setting}}};
case "mission": {CAN_SET_MISSION_SETTINGS && !_isLocalOnly && {isNil {GVAR(missionConfig) getVariable _setting}}};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
case "mission": {CAN_SET_MISSION_SETTINGS && !_isLocalOnly && {isNil {GVAR(missionConfig) getVariable _setting}}};
case "mission": {CAN_SET_MISSION_SETTINGS && !_isLocalOnly && {GVAR(missionConfig) isNil _setting}};

I do see the others use the older way.

case "server": {CAN_SET_SERVER_SETTINGS && {isNil {GVAR(serverConfig) getVariable _setting}}};
default {false};
};
Expand Down
4 changes: 3 additions & 1 deletion addons/settings/fnc_gui_settingOverwrite.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ _ctrlOverwriteClient setVariable [QFUNC(event), {
_controlsGroup setVariable [QFUNC(auto_check_overwrite), {
params ["_controlsGroup", "_source"];

if (_source isEqualTo "mission") then {
// a local only setting has no "overwrite clients" to tick, and a priority
// ticked in here would be sanitized away again the moment it is saved
if (_source isEqualTo "mission" && !ROW_IS_LOCAL_ONLY(_controlsGroup)) then {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hemtt complains about help[L-S19]: Unneeded Not

Suggested change
if (_source isEqualTo "mission" && !ROW_IS_LOCAL_ONLY(_controlsGroup)) then {
private _isLocalOnly = ROW_IS_LOCAL_ONLY(_controlsGroup);
if (_source isEqualTo "mission" && !_isLocalOnly) then {

private _ctrlOverwriteClient = _controlsGroup controlsGroupCtrl IDC_SETTING_OVERWRITE_CLIENT;

if (!cbChecked _ctrlOverwriteClient) then {
Expand Down
14 changes: 12 additions & 2 deletions addons/settings/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,18 @@
// str and format ["%1", ] on their own can only do either.
#define TO_STRING(var) (call {private _str = var; if (_str isEqualType "") then {_str = str _str}; format ["%1", _str]})

#define IS_GLOBAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == 1)
#define IS_LOCAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == 2)
// A setting's _isGlobal, as it is registered and as a settings menu row stores it.
// Every client has their own value unless something overwrites it, GLOBAL_ONLY is
// always overwritten for everyone, LOCAL_ONLY can't be overwritten at all.
#define SETTING_LOCAL_OVERRIDABLE 0
#define SETTING_GLOBAL_ONLY 1
#define SETTING_LOCAL_ONLY 2

#define IS_GLOBAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == SETTING_GLOBAL_ONLY)
#define IS_LOCAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == SETTING_LOCAL_ONLY)

// the same question asked of a row, which keeps its setting's _isGlobal
#define ROW_IS_LOCAL_ONLY(group) ((group getVariable [ARR_2(QGVAR(isGlobal),SETTING_LOCAL_OVERRIDABLE)]) == SETTING_LOCAL_ONLY)
Comment on lines +247 to +251

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#define IS_GLOBAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == SETTING_GLOBAL_ONLY)
#define IS_LOCAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] == SETTING_LOCAL_ONLY)
// the same question asked of a row, which keeps its setting's _isGlobal
#define ROW_IS_LOCAL_ONLY(group) ((group getVariable [ARR_2(QGVAR(isGlobal),SETTING_LOCAL_OVERRIDABLE)]) == SETTING_LOCAL_ONLY)
#define IS_GLOBAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] isEqualTo SETTING_GLOBAL_ONLY)
#define IS_LOCAL_SETTING(setting) (GVAR(default) getVariable [setting, []] param [7, 0] isEqualTo SETTING_LOCAL_ONLY)
// the same question asked of a row, which keeps its setting's _isGlobal
#define ROW_IS_LOCAL_ONLY(group) ((group getVariable [ARR_2(QGVAR(isGlobal),SETTING_LOCAL_OVERRIDABLE)]) isEqualTo SETTING_LOCAL_ONLY)


#define SANITIZE_PRIORITY(setting,priority,source) (call {\
private _priority = priority;\
Expand Down
2 changes: 1 addition & 1 deletion addons/settings/test.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"

#define TESTS ["parse"]
#define TESTS ["parse", "gui"]

SCRIPT(test-settings);

Expand Down
Loading
Loading