-
Notifications
You must be signed in to change notification settings - Fork 739
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
Arsenal - Add Sorting Algorithms #7719
Changes from 3 commits
54bc9c7
9bccf92
9861c5c
68affa6
c73382c
6ac8ee5
dfc7596
23b929d
3c4413b
a6c3320
d274709
a1a0bb0
9089d1a
9b1956f
e70be8e
4818a38
951c5ff
9c37886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class GVAR(sorts) { | ||
class sortBase { | ||
scope = 1; | ||
displayName = ""; | ||
tabs[] = {{}, {}}; | ||
statement = ""; | ||
}; | ||
|
||
class ACE_alphabetically: sortBase { | ||
scope = 2; | ||
displayName = "$STR_a3_rscdisplayarsenal_sort_alphabet"; | ||
tabs[] = {{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}, {0,1,2,3,4,5,6,7}}; | ||
statement = QUOTE({}); | ||
}; | ||
|
||
class ACE_mod: sortBase { | ||
scope = 2; | ||
displayName = "$STR_a3_rscdisplayarsenal_sort_mod"; | ||
tabs[] = {{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}, {0,1,2,3,4,5,6,7}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_mod)); | ||
}; | ||
|
||
class ACE_mass: sortBase { | ||
scope = 2; | ||
displayName = "Sort by weight"; | ||
tabs[] = {{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}, {}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_mass)); | ||
}; | ||
|
||
class ACE_load: sortBase { | ||
scope = 2; | ||
displayName = "Sort by load"; | ||
tabs[] = {{3,4,5}, {}}; | ||
statement = QUOTE(getContainerMaxLoad configName _this); | ||
}; | ||
|
||
class ACE_rateOfFire: sortBase { | ||
scope = 2; | ||
displayName = "Sort by rate of fire"; | ||
tabs[] = {{0,1,2}, {}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_rateOfFire)); | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: SynixeBrett | ||
* Add a custom sorting method. | ||
* | ||
* Arguments: | ||
* 1: Tabs to add the stat to (ARRAY of ARRAYS) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 1.1 Left tab indexes (ARRAY of NUMBERS) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 1.2 Right tab indexes (ARRAY of NUMBERS) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 2: Sort class (STRING) (A unique string for each algorithm) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 3: Display name (STRING) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 4: Algorithm (CODE) | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* Return Value: | ||
* 0: Array of IDs (ARRAY of STRINGS) | ||
* | ||
* Example: | ||
* [[[0, 1]], "fireRateSort", "Sort by fire rate", { | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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; | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* Public: Yes | ||
*/ | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 "")]; | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_returnArray pushBack (_arrayToSave select 0); | ||
(_tabsList select _x) pushBack _arrayToSave; | ||
} foreach _tabsToAddTo; | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
_finalArray = ["", _displayName, _statement]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as the existing arsenal code, it should be fixed in both places in a follow up PR |
||
|
||
if (count _leftTabs > 0) then { | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[GVAR(sortListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs; | ||
}; | ||
|
||
if (count _rightTabs > 0) then { | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[GVAR(sortListRightPanel), _rightTabs, "R", 1] call _fnc_addToTabs; | ||
}; | ||
|
||
_returnArray |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: SynixeBrett | ||
* Create the internal stats arrays when needed for the first time | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
if (!isNil QGVAR(sortListLeftPanel)) exitWith {}; | ||
|
||
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 "")]; | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(_tabsList select _x) pushBack _arrayToSave; | ||
} foreach _tabsToAddTo; | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
private _sortListLeftPanel = [ | ||
[], // Primary 0 | ||
[], // Handgun 1 | ||
[], // Launcher 2 | ||
[], // Uniform 3 | ||
[], // Vests 4 | ||
[], // Backpacks 5 | ||
[], // Headgear 6 | ||
[], // Goggles 7 | ||
[], // NVGs 8 | ||
[], // Binoculars 9 | ||
[], // Map 10 | ||
[], // GPS 11 | ||
[], // Radio 12 | ||
[], // Compass 13 | ||
[] // Watch 14 | ||
]; | ||
|
||
private _sortListRightPanel = [ | ||
[], // Optics 0 | ||
[], // Side accs 1 | ||
[], // Muzzle 2 | ||
[], // Bipod 3 | ||
[], // Mag 4 | ||
[], // Throw 5 | ||
[], // Put 6 | ||
[] // Misc 7 | ||
]; | ||
|
||
//------------------------- Config handling | ||
private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> QGVAR(sorts)); | ||
|
||
{ | ||
private _finalArray = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary, can just add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how stats did it, if we change it here it should be changed in stats too |
||
|
||
private _class = configName _x; | ||
private _displayName = getText (_x >> "displayName"); | ||
private _statement = getText (_x >> "statement"); | ||
(getArray (_x >> "tabs")) params ["_leftTabsList", "_rightTabsList"]; | ||
|
||
if (_statement != "") then { | ||
_statement = compile _statement; | ||
}; | ||
|
||
_finalArray = ["", _displayName, _statement]; | ||
|
||
if (count _leftTabsList > 0) then { | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[_sortListLeftPanel, _leftTabsList, "L"] call _fnc_addToTabs; | ||
}; | ||
|
||
if (count _rightTabsList > 0) then { | ||
BrettMayson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[_sortListRightPanel, _rightTabsList, "R"] call _fnc_addToTabs; | ||
}; | ||
} foreach _configEntries; | ||
|
||
missionNamespace setVariable [QGVAR(sortListLeftPanel), _sortListLeftPanel]; | ||
missionNamespace setVariable [QGVAR(sortListRightPanel), _sortListRightPanel]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
scope
entry and as a result thesortBase
class necessary? I think its reasonable to have all sorting algorithms defined here be public.Also, fix spaces after commas in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to add properties in the future this class would be useful, it also keeps it inline with the rest of
arsenal