Skip to content
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

Use hash map for markers tree cache #584

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 2.02
#define REQUIRED_VERSION 2.04
mharis001 marked this conversation as resolved.
Show resolved Hide resolved
#define REQUIRED_CBA_VERSION {3,14,0}

#ifdef COMPONENT_BEAUTIFIED
Expand Down
12 changes: 3 additions & 9 deletions addons/markers_tree/functions/fnc_compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Exit if markers tree has already been compiled
if (!isNil {uiNamespace getVariable QGVAR(cache)}) exitWith {};

private _cache = [];
private _cache = createHashMap;
private _cfgMarkerClasses = configFile >> "CfgMarkerClasses";

{
Expand All @@ -34,14 +34,8 @@ private _cfgMarkerClasses = configFile >> "CfgMarkerClasses";
_color = [1, 1, 1, 1];
};

private _index = _cache findIf {_x select 0 == _category};
private _data = [_class, _name, _icon, _color];

if (_index == -1) then {
_cache pushBack [_category, [_data]];
} else {
(_cache select _index select 1) pushBack _data;
};
private _list = _cache getOrDefault [_category, [], true];
_list pushBack [_class, _name, _icon, _color];
};
} forEach configProperties [configFile >> "CfgMarkers", "isClass _x"];

Expand Down
16 changes: 4 additions & 12 deletions addons/markers_tree/functions/fnc_populate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

params ["_ctrlTree"];

private _markersCache = uiNamespace getVariable QGVAR(cache);

{
_x params ["_category", "_markers"];

private _categoryIndex = _ctrlTree tvAdd [[], _category];
private _categoryIndex = _ctrlTree tvAdd [[], _x];

{
_x params ["_class", "_name", "_icon", "_color"];
Expand All @@ -35,11 +31,7 @@ private _markersCache = uiNamespace getVariable QGVAR(cache);
_ctrlTree tvSetPicture [_path, _icon];
_ctrlTree tvSetPictureColor [_path, _color];
_ctrlTree tvSetPictureColorSelected [_path, _color];
} forEach _markers;
} forEach _markersCache;

_ctrlTree tvSort [[], false];
} forEach _y;
} forEach (uiNamespace getVariable QGVAR(cache));

for "_i" from 0 to ((_ctrlTree tvCount []) - 1) do {
_ctrlTree tvSort [[_i], false];
};
_ctrlTree tvSortAll [[], false];
8 changes: 0 additions & 8 deletions addons/markers_tree/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,3 @@
#include "\x\zen\addons\editor\script_idc.hpp"

#define IDC_MARKERS_TREE 92892

#define IDCS_MODE_BUTTONS [ \
IDC_RSCDISPLAYCURATOR_MODEUNITS, \
IDC_RSCDISPLAYCURATOR_MODEGROUPS, \
IDC_RSCDISPLAYCURATOR_MODEMODULES, \
IDC_RSCDISPLAYCURATOR_MODEMARKERS, \
IDC_RSCDISPLAYCURATOR_MODERECENT \
]