-
Notifications
You must be signed in to change notification settings - Fork 157
Settings - UI Layout Redesign #1828
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
Open
LinkIsGrim
wants to merge
17
commits into
CBATeam:master
Choose a base branch
from
LinkIsGrim:settings-layout
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
09abd81
Settings - Add Searchbar
LinkIsGrim c6a088d
refactor: precompute settings menu category indices
LinkIsGrim 61855ae
perf: build settings categories from the precomputed indices
LinkIsGrim e43e3cf
perf: cache the config info of settings menu row classes
LinkIsGrim 4e7cafc
refactor: lay the settings table out in one place
LinkIsGrim bbecae1
refactor: read the setting and source off the settings menu row
LinkIsGrim 7231532
refactor: keep whether a settings menu row can be edited on the row
LinkIsGrim e1fcc81
fix: settings menu showed the wrong source as the winning one
LinkIsGrim f68fdd3
perf: give a setting one settings menu row instead of three
LinkIsGrim b09c82b
feat: rework the settings menu layout
LinkIsGrim 8cad7e1
fix: tweak the zebra a bit
LinkIsGrim 767e89d
fix: don't ctrlEnable backgrounds
LinkIsGrim 1756a66
fix: ctrlShow instead of moving off-screen
LinkIsGrim 8103b6e
fix: settings would show yellow (edited) even if the end value isn't …
LinkIsGrim fd9064b
feat: ask for confirmation on discarding settings changes
LinkIsGrim 87e69a7
fix: don't clip the unsaved changes setting list
LinkIsGrim 1eb24ae
Update addons/settings/fnc_gui_confirmDiscard.sqf
LinkIsGrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)); | ||
| 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.