mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
d72555ab0c
* support per tab sorting, and external algorithms * improved sub sorting * improve alphabetical search * update mod sorting * sort by accuracy * sort right panel * more sorts * sort right tab * fix empty * stringtables * Apply suggestions from code review Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> * more suggestions * suggestions * remember last sort * Fix missing throw and put names * bad copy paste in stringtable * Update addons/arsenal/functions/fnc_sortPanel.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
71 lines
1.7 KiB
Plaintext
71 lines
1.7 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: SynixeBrett
|
|
* Add a custom sorting method.
|
|
*
|
|
* Arguments:
|
|
* 0: Tabs to add stat to <ARRAY>
|
|
* 0: Left Tab Indexes <ARRAY>
|
|
* 1: Right Tab Indexes <ARRAY>
|
|
* 1: Sort Class (a unique string for each algorithm) <STRING>
|
|
* 2: Display Name <STRING>
|
|
* 3: Algorithm <CODE>
|
|
*
|
|
* Return Value:
|
|
* 0: Array of IDs (ARRAY of STRINGS)
|
|
*
|
|
* Example:
|
|
* [[[0, 1]], "fireRateSort", "Sort by fire rate", {
|
|
* params ["_itemCfg"];
|
|
* private _fireModes = getArray (_itemCfg >> "modes");
|
|
* private _fireRate = [];
|
|
*
|
|
* {
|
|
* _fireRate pushBackUnique (getNumber (_itemCfg >> _x >> "reloadTime"));
|
|
* } foreach _fireModes;
|
|
*
|
|
* _fireRate sort true;
|
|
* _fireRate param [0, 0]
|
|
* }] call ACE_arsenal_fnc_addSort;
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params [
|
|
["_tabs", [[], []], [[]], 2],
|
|
["_class", "", [""]],
|
|
["_displayName", "", [""]],
|
|
["_statement", {}, [{}]]
|
|
];
|
|
|
|
_tabs params [
|
|
["_leftTabs", [], [[]]],
|
|
["_rightTabs", [], [[]]]
|
|
];
|
|
|
|
call FUNC(compileSorts);
|
|
|
|
private _returnArray = [];
|
|
|
|
private _fnc_addToTabs = {
|
|
params ["_tabsList", "_tabsToAddTo", "_sideString"];
|
|
{
|
|
private _arrayToSave = +_finalArray;
|
|
_arrayToSave set [0, [_class, _sideString, [str _x, format ["0%1", _x]] select (_x < 10)] joinString ""];
|
|
_returnArray pushBack (_arrayToSave select 0);
|
|
(_tabsList select _x) pushBack _arrayToSave;
|
|
} forEach _tabsToAddTo;
|
|
};
|
|
|
|
_finalArray = ["", _displayName, _statement];
|
|
|
|
if !(_leftTabs isEqualTo []) then {
|
|
[GVAR(sortListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs;
|
|
};
|
|
|
|
if !(_rightTabs isEqualTo []) then {
|
|
[GVAR(sortListRightPanel), _rightTabs, "R", 1] call _fnc_addToTabs;
|
|
};
|
|
|
|
_returnArray
|