mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fortify - Categories (#9167)
* Fortify - Categories * Update fnc_registerObjects.sqf * Apply suggestions from code review Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Apply suggestions from code review * Update docs/wiki/framework/fortify-framework.md Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/fortify/ACEX_Fortify_Presets.hpp Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * just use flat objects array * Update fnc_getPlaceableSet.sqf --------- Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
This commit is contained in:
parent
50100b8178
commit
bcbd762748
@ -64,4 +64,26 @@ class ACEX_Fortify_Presets {
|
|||||||
{"Land_BagFence_01_long_green_F", 10}
|
{"Land_BagFence_01_long_green_F", 10}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
class bigCombo {
|
||||||
|
displayName = CSTRING(bigCombo);
|
||||||
|
objects[] = {
|
||||||
|
{"Land_BagBunker_Tower_F", 50, "big"},
|
||||||
|
{"Land_BagBunker_Large_F", 100, "big"},
|
||||||
|
{"Land_BagBunker_Small_F", 25, "big"},
|
||||||
|
{"Land_Cargo_Patrol_V1_F", 100, "big"},
|
||||||
|
{"Land_BagFence_Round_F", 5, "big"},
|
||||||
|
{"Land_BagFence_Short_F", 5, "big"},
|
||||||
|
{"Land_BagFence_Long_F", 10, "big"},
|
||||||
|
{"Land_PillboxBunker_01_big_F", 100, "bigGreen"},
|
||||||
|
{"Land_PillboxWall_01_3m_F", 10, "bigGreen"},
|
||||||
|
{"Land_PillboxWall_01_6m_F", 15, "bigGreen"},
|
||||||
|
{"Land_PillboxBunker_01_hex_F", 50, "bigGreen"},
|
||||||
|
{"Land_PillboxBunker_01_rectangle_F", 50, "bigGreen"},
|
||||||
|
{"Land_Plank_01_8m_F", 10, "bigGreen"},
|
||||||
|
{"Land_Plank_01_4m_F", 5, "bigGreen"},
|
||||||
|
{"Land_BagFence_01_round_green_F", 5, "bigGreen"},
|
||||||
|
{"Land_BagFence_01_short_green_F", 5, "bigGreen"},
|
||||||
|
{"Land_BagFence_01_long_green_F", 10, "bigGreen"}
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -21,9 +21,10 @@ private _side = side group _player;
|
|||||||
private _objects = missionNamespace getVariable [format [QGVAR(Objects_%1), _side], []];
|
private _objects = missionNamespace getVariable [format [QGVAR(Objects_%1), _side], []];
|
||||||
private _actions = [];
|
private _actions = [];
|
||||||
private _infiniteBudget = ([side group _player] call FUNC(getBudget)) == -1;
|
private _infiniteBudget = ([side group _player] call FUNC(getBudget)) == -1;
|
||||||
|
private _subActions = createHashmap;
|
||||||
|
|
||||||
{
|
{
|
||||||
_x params ["_classname", "_cost"];
|
_x params ["_classname", "_cost", ["_category", ""]];
|
||||||
|
|
||||||
private _displayName = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
private _displayName = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||||
|
|
||||||
@ -43,7 +44,24 @@ private _infiniteBudget = ([side group _player] call FUNC(getBudget)) == -1;
|
|||||||
[_side, _classname]
|
[_side, _classname]
|
||||||
] call EFUNC(interact_menu,createAction);
|
] call EFUNC(interact_menu,createAction);
|
||||||
|
|
||||||
|
if (_category == "") then {
|
||||||
_actions pushBack [_action, [], _player];
|
_actions pushBack [_action, [], _player];
|
||||||
|
} else {
|
||||||
|
private _categoryActions = _subActions getOrDefault [_category, [], true];
|
||||||
|
_categoryActions pushBack [_action, [], _player];
|
||||||
|
};
|
||||||
} forEach _objects;
|
} forEach _objects;
|
||||||
|
|
||||||
|
{
|
||||||
|
private _displayName = if (isLocalized _x) then {
|
||||||
|
localize _x
|
||||||
|
} else {
|
||||||
|
if (isText (configFile >> "ACEX_Fortify_Presets" >> _x >> "displayName")) exitWith { getText (configFile >> "ACEX_Fortify_Presets" >> _x >> "displayName") };
|
||||||
|
if (isText (missionConfigFile >> "ACEX_Fortify_Presets" >> _x >> "displayName")) exitWith { getText (missionConfigFile >> "ACEX_Fortify_Presets" >> _x >> "displayName") };
|
||||||
|
_x
|
||||||
|
};
|
||||||
|
private _action = [_x, _displayName, "", {}, {true}] call EFUNC(interact_menu,createAction);
|
||||||
|
_actions pushBack [_action, _y, _player];
|
||||||
|
} forEach _subActions;
|
||||||
|
|
||||||
_actions
|
_actions
|
||||||
|
@ -30,14 +30,15 @@ if (!isClass _config) exitWith {
|
|||||||
|
|
||||||
private _objects = getArray (_config >> "objects");
|
private _objects = getArray (_config >> "objects");
|
||||||
|
|
||||||
// Attemp to filter bad input
|
// Attempt to filter bad input
|
||||||
_objects = _objects select {
|
_objects = _objects select {
|
||||||
if ((_x isEqualTypeParams ["", 0])) then {
|
if ((_x isEqualTypeParams ["", 0]) || {_x isEqualTypeParams ["", 0, ""]}) then {
|
||||||
_x params [["_classname", "#", [""]], ["_cost", -1, [0]]];
|
_x params [["_classname", "#", [""]], ["_cost", -1, [0]]];
|
||||||
if (isClass (configFile >> "CfgVehicles" >> _classname)) then {
|
if (isClass (configFile >> "CfgVehicles" >> _classname)) then {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
ERROR_2("Preset [%1] - Classname does not exist",_preset,_classname);
|
ERROR_2("Preset [%1] - Classname does not exist",_preset,_classname);
|
||||||
|
false
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
ERROR_2("Preset [%1] - Bad data in objects array %2",_preset,_x);
|
ERROR_2("Preset [%1] - Bad data in objects array %2",_preset,_x);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Author: Kingsley
|
* Author: Kingsley
|
||||||
* Registers the given objects in the given side's player interaction menu.
|
* Registers the given objects in the given side's player interaction menu.
|
||||||
* Players on that side must have the pickaxe item in their inventory to access the menu.
|
* Players on that side must have the pickaxe item in their inventory to access the menu.
|
||||||
* Classnames must be in the format [<classname>, <cost>]
|
* Classnames must be in the format [<classname>, <cost>, <category(optional)>]
|
||||||
* MUST BE CALLED ON SERVER!
|
* MUST BE CALLED ON SERVER!
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -16,6 +16,7 @@
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [west, 5000, [["Land_BagFence_Long_F", 5], ["Land_BagBunker_Small_F", 50]]] call ace_fortify_fnc_registerObjects
|
* [west, 5000, [["Land_BagFence_Long_F", 5], ["Land_BagBunker_Small_F", 50]]] call ace_fortify_fnc_registerObjects
|
||||||
|
* [west, 5000, [["Land_BagFence_Long_F", 5, "tan"], ["Land_BagFence_01_long_green_F", 5, "green"]]] call ace_fortify_fnc_registerObjects
|
||||||
*
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
@ -29,6 +30,9 @@ if (_side isEqualTo sideUnknown) exitWith {ERROR_1("Bad Side %1",_this);};
|
|||||||
|
|
||||||
_objects select {
|
_objects select {
|
||||||
private _isValid = _x params [["_xClassname", "", [""]], ["_xCost", 0, [0]]];
|
private _isValid = _x params [["_xClassname", "", [""]], ["_xCost", 0, [0]]];
|
||||||
|
private _category = toLower (_x param [2, "", [""]]);
|
||||||
|
if (_category != "") then { _x set [2, _category]; };
|
||||||
|
|
||||||
if (_isValid) then {
|
if (_isValid) then {
|
||||||
_isValid = isClass (configFile >> "CfgVehicles" >> _xClassname);
|
_isValid = isClass (configFile >> "CfgVehicles" >> _xClassname);
|
||||||
if (!_isValid) then {WARNING_1("Classname does not exist in CfgVehicles %1",_x);};
|
if (!_isValid) then {WARNING_1("Classname does not exist in CfgVehicles %1",_x);};
|
||||||
|
@ -330,5 +330,15 @@
|
|||||||
<Chinesesimp>大型(绿色)</Chinesesimp>
|
<Chinesesimp>大型(绿色)</Chinesesimp>
|
||||||
<Korean>대형 (초목)</Korean>
|
<Korean>대형 (초목)</Korean>
|
||||||
</Key>
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Fortify_bigCombo">
|
||||||
|
<English>Big (Both)</English>
|
||||||
|
<Polish>Duże (Oba)</Polish>
|
||||||
|
<Russian>Большой (Оба)</Russian>
|
||||||
|
<Turkish>Büyük (İkisi de)</Turkish>
|
||||||
|
<Japanese>大型 (両方)</Japanese>
|
||||||
|
<German>Groß (Beide)</German>
|
||||||
|
<Chinesesimp>大型(两方)</Chinesesimp>
|
||||||
|
<Korean>대형 (둘 다)</Korean>
|
||||||
|
</Key>
|
||||||
</Package>
|
</Package>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -37,7 +37,7 @@ To add a preset via code you use the function `call ace_fortify_fnc_registerObje
|
|||||||
```sqf
|
```sqf
|
||||||
* Registers the given objects in the given side's player interaction menu.
|
* Registers the given objects in the given side's player interaction menu.
|
||||||
* Players on that side must have the `Fortify Tool` item in their inventory to access the menu.
|
* Players on that side must have the `Fortify Tool` item in their inventory to access the menu.
|
||||||
* Classnames must be in the format [<classname>, <cost>]
|
* Classnames must be in the format [<classname>, <cost>, <category(optional)>]
|
||||||
* MUST BE CALLED ON SERVER!
|
* MUST BE CALLED ON SERVER!
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -50,6 +50,7 @@ To add a preset via code you use the function `call ace_fortify_fnc_registerObje
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [west, 5000, [["Land_BagFence_Long_F", 5], ["Land_BagBunker_Small_F", 50]]] call ace_fortify_fnc_registerObjects
|
* [west, 5000, [["Land_BagFence_Long_F", 5], ["Land_BagBunker_Small_F", 50]]] call ace_fortify_fnc_registerObjects
|
||||||
|
* [west, 5000, [["Land_BagFence_Long_F", 5, "tan"], ["Land_BagFence_01_long_green_F", 5, "green"]]] call ace_fortify_fnc_registerObjects
|
||||||
```
|
```
|
||||||
|
|
||||||
Adding it through `description.ext` or config you use:
|
Adding it through `description.ext` or config you use:
|
||||||
@ -63,6 +64,13 @@ class ACEX_Fortify_Presets {
|
|||||||
{"Bunker", 50}
|
{"Bunker", 50}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
class TAG_categories {
|
||||||
|
displayName = "My Categories";
|
||||||
|
objects[] = {
|
||||||
|
{"Sandbag", 5, "A Category"},
|
||||||
|
{"Bunker", 50, "TAG_MyPreset"} // will use the localized displayName of that preset ("My Preset")
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user