Common - Add setter for hideActions - #1832
Conversation
| _index - The action index. <NUMBER> | ||
| _key - The key (case-sensitive). <STRING> | ||
| _hide - Whether to hide the action. <BOOL> |
There was a problem hiding this comment.
| _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 ...
There was a problem hiding this comment.
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
| false | ||
| }; | ||
|
|
||
| if (_hide || _forceAdd || {_index in GVAR(hideActionHash)}) then { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
| if (count _y == 0) then { | |
| if (count _y isEqualTo 0) then { |
hideActions [2.22]hideActions
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
There was a problem hiding this comment.
Two things:
- I don't quite understand what the purpose of
_forceAddis. 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
hideActionscommand. 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
[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
There was a problem hiding this comment.
https://github.com/johnb432/No-Actions/blob/master/addons/main/functions/fnc_hideAction.sqf
Here's something I cooked up that should address the scenario you described.
There was a problem hiding this comment.
that would only work if you ran on every single action enum for every player switch
with this PRs current setup we only touch enums we have previously touched, so it should be the most compatible with any other systems
from acemod/ACE3#11459
req 2.22 to function but mergeable now