Skip to content

Commit

Permalink
use Native Hashmaps where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jokoho48 committed Apr 19, 2024
1 parent 62110ed commit 0617c14
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
*/
params ["_name", "_path", ["_dik", DIK_F1], ["_onUse", {LOG("Nothing here.")}, [{}, ""]], ["_onRender", {true}, [{}]], ["_hasSubMenus", false], ["_args", []]];
if (isNil QGVAR(menuEntries)) then {
GVAR(menuEntries) = false call CFUNC(createNamespace);
GVAR(menuEntries) setVariable ["MAIN", []];
GVAR(menuEntries) = createHashMap;
GVAR(menuEntries) set ["MAIN", []];
};

private _entry = GVAR(menuEntries) getVariable [_path, []];
private _entry = GVAR(menuEntries) get [_path, []];

if ((_entry findIf {(_x select 0) == _dik}) != -1) exitWith {
["Menu Item %1/%2 reused Keybinding %3", _path, _name, call compile (keyName _dik)] call BIS_fnc_error;
[_name, _path, _dik + 1, _onUse, _onRender, _hasSubMenus, _args] call FUNC(addMenuItem);
};
_entry pushBack [_dik, _name, _onUse, _onRender, _hasSubMenus, _args];
_entry sort true;
GVAR(menuEntries) setVariable [_path, _entry];
GVAR(menuEntries) set [_path, _entry];
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/Menu/fn_executeEntry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
params ["_path", "_keyCode"];
private _entries = GVAR(menuEntries) getVariable [_path, []];
private _entries = GVAR(menuEntries) get [_path, []];
{
_x params ["_dik", "", "_onUse", "_onRender", "", "_args"];
if (_dik == _keyCode) then {
Expand Down
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/Menu/fn_renderMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ params [["_path", "", [""]], ["_mainPrefixText", ""]];
if (_path isEqualTo "") then {
"MAIN" call FUNC(renderMenu);
};
private _entry = GVAR(menuEntries) getVariable [_path, []];
private _entry = GVAR(menuEntries) get [_path, []];
if (_entry isEqualTo []) exitWith {
"MAIN" call FUNC(renderMenu);
};
Expand Down
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/fn_openSpectator.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (isNil QGVAR(SideColorsString)) then {
};

if (isNil QGVAR(PositionMemory)) then {
GVAR(PositionMemory) = false call CFUNC(createNamespace);
GVAR(PositionMemory) = createHashMap;
};

if (GVAR(aceMapGesturesLoaded)) then {
Expand Down
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/fn_restorePosition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
params ["_slot", "_smoothTranslation"];

private _element = GVAR(PositionMemory) getVariable (str _slot);
private _element = GVAR(PositionMemory) get (str _slot);
if (isNil "_element") exitWith {};

if (count _element != 12) exitWith {};
Expand Down
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/fn_savePosition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ private _element = [
GVAR(ShoulderOffset),
GVAR(TopDownOffset)
];
GVAR(PositionMemory) setVariable [str _slot, _element];
GVAR(PositionMemory) set [str _slot, _element];

0 comments on commit 0617c14

Please sign in to comment.