Skip to content
Open
Show file tree
Hide file tree
Changes from 16 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
17 changes: 17 additions & 0 deletions addons/settings/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ PREP(whitelisted);
if (hasInterface) then {
PREP(openSettingsMenu);
PREP(gui_addonChanged);
PREP(gui_createCategory);
PREP(gui_sourceChanged);
PREP(gui_configure);
PREP(gui_refresh);
PREP(gui_search);
PREP(gui_index);
PREP(gui_searchSelect);
PREP(gui_fillAddonList);
PREP(gui_filterSettings);
PREP(gui_reflow);
PREP(gui_toggleSubCategory);
PREP(gui_setTablePosY);
PREP(gui_rowClassInfo);
PREP(gui_confirmDiscard);
PREP(gui_getLiveEdits);
PREP(gui_setRowEdited);
PREP(gui_setRowEnabled);
PREP(gui_setOverwriteVisible);
PREP(gui_retargetRow);
PREP(gui_onKeyDown);
PREP(gui_preset);
PREP(gui_saveTempData);
PREP(gui_export);
Expand Down
4 changes: 0 additions & 4 deletions addons/settings/fnc_export.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ private _temp = [];

(GVAR(default) getVariable _setting) params ["_defaultValue", "", "", "", "_category"];

if (isLocalized _category) then {
_category = localize _category;
};

if (_exportDefault || {
_value isNotEqualTo _defaultValue ||
SANITIZE_PRIORITY(_setting,_priority,_source) > SANITIZE_PRIORITY(_setting,0,_source)
Expand Down
37 changes: 20 additions & 17 deletions addons/settings/fnc_gui_addonChanged.sqf
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
#include "script_component.hpp"

EXIT_LOCKED;

// get button
params ["_control", "_index"];

// get dialog
private _display = ctrlParent _control;

private _selectedAddon = _display getVariable (_control lbData _index);
private _selectedAddon = _control lbData _index;

// fix error when no addons present
if (isNil "_selectedAddon") exitWith {};
if (_selectedAddon isEqualTo "") exitWith {};

if (_selectedAddon isEqualType "") then {
uiNamespace setVariable [QGVAR(addon), _selectedAddon];
};
// commit anything half typed before the rows are pointed somewhere else
ctrlSetFocus _control;

uiNamespace setVariable [QGVAR(addonIndex), _index];
uiNamespace setVariable [QGVAR(addon), _selectedAddon];

// toggle lists
private _selectedSource = uiNamespace getVariable QGVAR(source);
private _optionsGroups = _display getVariable QGVAR(optionsGroups);

if !(_display getVariable [_selectedAddon, false]) then {
#include "gui_createCategory.inc.sqf"
_display setVariable [_selectedAddon, true];
if !(_selectedAddon in _optionsGroups) then {
[_display, _selectedAddon] call FUNC(gui_createCategory);
};

// toggle lists
{
(_x splitString "$") params ["", "_addon", "_source"];
private _isSelected = _x isEqualTo _selectedAddon;

(_optionsGroups get _x) ctrlEnable _isSelected;
(_optionsGroups get _x) ctrlShow _isSelected;
} forEach (keys _optionsGroups);

private _ctrlOptionsGroup = _display getVariable _x;
private _isSelected = _source == _selectedSource && {_addon == _selectedAddon};
// the category was built for whichever source was shown when it was created
call FUNC(gui_refresh);

_ctrlOptionsGroup ctrlEnable _isSelected;
_ctrlOptionsGroup ctrlShow _isSelected;
} forEach (_display getVariable QGVAR(lists));
// the category may have just been created, or created while a different search was active
[_display] call FUNC(gui_filterSettings);
98 changes: 98 additions & 0 deletions addons/settings/fnc_gui_confirmDiscard.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Internal Function: CBA_settings_fnc_gui_confirmDiscard

Description:
Closes the settings menu, listing first what would be thrown away.

Nothing pending means no prompt, and neither does a setting that was touched
and put back, since that would change nothing if saved.

Uses its own dialog rather than BIS_fnc_guiMessage, which does nothing at all
in 3DEN and offers no way to decline elsewhere.

Parameters:
_display - Settings menu display <DISPLAY>

Returns:
Closing was deferred to the prompt <BOOL>

Examples:
(begin example)
[_display] call CBA_settings_fnc_gui_confirmDiscard;
(end)

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

params ["_display"];

private _names = call FUNC(gui_getLiveEdits);
private _count = count _names;

if (_count == 0) exitWith {
_display closeDisplay IDC_CANCEL;
false
};

private _dialog = _display createDisplay QGVAR(confirmDiscard);

// Stringtables have no plural forms, so the two readings are separate keys
private _text = format [
[LLSTRING(discardChanges_one), LLSTRING(discardChanges)] select (_count > 1),
_count
];

private _shown = _names select [0, CONFIRM_LIST_MAX];

{
_text = _text + format ["<br/> - %1", _x];
} forEach _shown;

private _hidden = _count - (count _shown);

if (_hidden > 0) then {
_text = _text + format ["<br/> " + LLSTRING(discardChanges_more), _hidden];
};

(_dialog displayCtrl IDC_CONFIRM_TEXT) ctrlSetStructuredText parseText _text;

// One line per setting, plus the sentence above them. Nothing in a controls group reflows on
// its own, so the panel and the buttons are moved to match
private _lines = 1 + (count _shown) + ([0, 1] select (_hidden > 0));
Comment thread
LinkIsGrim marked this conversation as resolved.
Outdated
private _height = POS_H(CONFIRM_BASE_HEIGHT) + (_lines * POS_H(CONFIRM_LINE_HEIGHT));

private _ctrlGroup = _dialog displayCtrl IDC_CONFIRM_GROUP;
(ctrlPosition _ctrlGroup) params ["_groupX", "_groupY", "_groupW"];
_ctrlGroup ctrlSetPosition [_groupX, _groupY, _groupW, _height];
_ctrlGroup ctrlCommit 0;

private _ctrlText = _dialog displayCtrl IDC_CONFIRM_TEXT;
(ctrlPosition _ctrlText) params ["_textX", "_textY", "_textW"];
_ctrlText ctrlSetPosition [_textX, _textY, _textW, _lines * POS_H(CONFIRM_LINE_HEIGHT)];
_ctrlText ctrlCommit 0;

private _ctrlBackground = _dialog displayCtrl IDC_CONFIRM_BACKGROUND;
(ctrlPosition _ctrlBackground) params ["_bgX", "_bgY", "_bgW"];
_ctrlBackground ctrlSetPosition [_bgX, _bgY, _bgW, _height - _bgY];
_ctrlBackground ctrlCommit 0;

{
(ctrlPosition _x) params ["_btnX", "", "_btnW", "_btnH"];
_x ctrlSetPosition [_btnX, _height - _btnH - POS_H(0.3), _btnW, _btnH];
_x ctrlCommit 0;
} forEach [_dialog displayCtrl IDC_CONFIRM_OK, _dialog displayCtrl IDC_CANCEL];

// The menu has to outlive the prompt, so the prompt is what closes it
_dialog setVariable [QGVAR(parentDisplay), _display];

(_dialog displayCtrl IDC_CONFIRM_OK) ctrlAddEventHandler ["ButtonClick", {
private _dialog = ctrlParent (_this select 0);
private _parent = _dialog getVariable [QGVAR(parentDisplay), displayNull];

_dialog closeDisplay IDC_OK;
_parent closeDisplay IDC_CANCEL;
}];

true
Loading
Loading