-
Notifications
You must be signed in to change notification settings - Fork 735
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 all 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,64 @@ | ||
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 = CSTRING(sortByWeightText); | ||
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_mass)); | ||
}; | ||
|
||
class ACE_load: sortBase { | ||
scope = 2; | ||
displayName = CSTRING(sortByLoadText); | ||
tabs[] = {{3,4,5}, {}}; | ||
statement = QUOTE(getContainerMaxLoad configName _this); | ||
}; | ||
|
||
class ACE_accuracy: sortBase { | ||
scope = 2; | ||
displayName = CSTRING(sortByAccuracyText); | ||
tabs[] = {{0,1,2}, {}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_accuracy)); | ||
}; | ||
|
||
class ACE_rateOfFire: sortBase { | ||
scope = 2; | ||
displayName = CSTRING(sortByRateOfFireText); | ||
tabs[] = {{0,1,2}, {}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_rateOfFire)); | ||
}; | ||
|
||
class ACE_scopeMag: sortBase { | ||
scope = 2; | ||
displayName = CSTRING(sortByMagnificationText); | ||
tabs[] = {{}, {0}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_scopeMag)); | ||
}; | ||
|
||
class ACE_magCount: sortBase { | ||
scope = 2; | ||
displayName = CSTRING(sortByMagCountText); | ||
tabs[] = {{}, {4}}; | ||
statement = QUOTE(_this call FUNC(sortStatement_magCount)); | ||
}; | ||
}; |
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: | ||
* 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", { | ||
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; | ||
* | ||
* 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]; | ||
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 !(_leftTabs isEqualTo []) then { | ||
[GVAR(sortListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs; | ||
}; | ||
|
||
if !(_rightTabs isEqualTo []) then { | ||
[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 ""]; | ||
(_tabsList select _x) pushBack _arrayToSave; | ||
} forEach _tabsToAddTo; | ||
}; | ||
|
||
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 !(_leftTabsList isEqualTo []) then { | ||
[_sortListLeftPanel, _leftTabsList, "L"] call _fnc_addToTabs; | ||
}; | ||
|
||
if !(_rightTabsList isEqualTo []) then { | ||
[_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