Skip to content

Common - Add setter for hideActions - #1832

Open
PabstMirror wants to merge 4 commits into
masterfrom
hideAction
Open

Common - Add setter for hideActions#1832
PabstMirror wants to merge 4 commits into
masterfrom
hideAction

Conversation

@PabstMirror

Copy link
Copy Markdown
Contributor

from acemod/ACE3#11459

req 2.22 to function but mergeable now

Comment on lines +10 to +12
_index - The action index. <NUMBER>
_key - The key (case-sensitive). <STRING>
_hide - Whether to hide the action. <BOOL>

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
_index - The action index. <NUMBER>
_key - The key (case-sensitive). <STRING>
_hide - Whether to hide the action. <BOOL>
_index - The action index. (Default: 0) <NUMBER>
_key - The key (case-sensitive). <STRING>
_hide - Whether to hide the action. (Default: false) <BOOL>

At 1st was gonna add the default for _key too, but realized it's completely pointless to not specify that param, so it's better as a mandatory one; damned SQF requiring a default value to allow type-checking ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, it may technically have a default from params
but I don't think it makes sense to list them, at least for _index where the default of 0 won't do anything useful

Comment thread addons/common/fnc_hideAction.sqf Outdated
false
};

if (_hide || _forceAdd || {_index in GVAR(hideActionHash)}) 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.

I can't test in any way, but hashmaps are fast and in as well, so an in check might be faster than a lazy eval.

private _hideSelected= [];
private _unhideSelected = [];
{
if (count _y == 0) 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.

Suggested change
if (count _y == 0) then {
if (count _y isEqualTo 0) then {

Comment thread addons/common/fnc_hideAction.sqf Outdated
@PabstMirror PabstMirror changed the title Common - Add setter for hideActions [2.22] Common - Add setter for hideActions Aug 11, 2026
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
@PabstMirror PabstMirror added this to the 3.19.1 milestone Aug 13, 2026

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.

Two things:

  • I don't quite understand what the purpose of _forceAdd is. In what scenarios would you use this?
  • Part of current behaviour: Hide an action (action A), then unhide using the function. Hide action A, but using the hideActions command. Now, hide/unhide any other action using the function and action A will be visible again. I don't like that behaviour, it feels very imposing and invasive.
    Proposed behavior: when you add a key to the index hashmap, it will hide the action (or keep it hidden if there was another key present with same action index). If all keys of a specific index are removed (i.e. index hashmap is empty), the index hashmap will be removed from the action hashmap and the action will be shown again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm going to rework _forceAdd because I also can't think of a good use
but for 2nd point, we have to think about undoing everything that was done

e.g.
Start as playerA
["autoHover", "mySetting", true] call cba // update setting
cba does hideActions true
switch to UAV
["autoHover", "mySetting", false] call cba // update setting
switch back to playerA

  • here we need to undo the hideActions that was originally applied to the player

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[15, "noEngineAction", true] call CBA_fnc_hideAction;  // hides
[15, "noEngineAction", false] call CBA_fnc_hideAction; // shows
[15, "noEngineAction", false, true] call CBA_fnc_hideAction; // shows and then removes from hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants