diff --git a/addons/attributes/CfgWaypointTypes.hpp b/addons/attributes/CfgWaypointTypes.hpp index 997dc9145..b2bbd667b 100644 --- a/addons/attributes/CfgWaypointTypes.hpp +++ b/addons/attributes/CfgWaypointTypes.hpp @@ -62,6 +62,7 @@ class ZEN_WaypointTypes { displayName = ECSTRING(ai,Fastrope); type = "SCRIPTED"; script = QPATHTOEF(ai,functions\fnc_waypointFastrope.sqf); + condition = QUOTE(isClass (configFile >> 'CfgPatches' >> 'ace_fastroping')); }; class SearchBuilding { displayName = ECSTRING(ai,SearchBuilding); diff --git a/addons/attributes/functions/fnc_compileWaypoints.sqf b/addons/attributes/functions/fnc_compileWaypoints.sqf index 9668ebaac..82705f880 100644 --- a/addons/attributes/functions/fnc_compileWaypoints.sqf +++ b/addons/attributes/functions/fnc_compileWaypoints.sqf @@ -15,6 +15,23 @@ * Public: No */ -uiNamespace setVariable [QGVAR(waypointTypes), configProperties [configFile >> "ZEN_WaypointTypes", "isClass _x"] apply { - [toUpper getText (_x >> "displayName"), getText (_x >> "tooltip"), getText (_x >> "type"), getText (_x >> "script")] -}]; +private _waypointTypes = configProperties [configFile >> "ZEN_WaypointTypes", "isClass _x"] apply { + private _condition = compile getText (_x >> "condition"); + + if (_condition isEqualTo {}) then { + _condition = {true}; + }; + + [ + getText (_x >> "displayName"), + getText (_x >> "tooltip"), + getText (_x >> "type"), + getText (_x >> "script"), + _condition, + getNumber (_x >> "priority") + ] +}; + +[_waypointTypes, 5, false] call CBA_fnc_sortNestedArray; + +uiNamespace setVariable [QGVAR(waypointTypes), _waypointTypes]; diff --git a/addons/attributes/functions/fnc_gui_waypoint.sqf b/addons/attributes/functions/fnc_gui_waypoint.sqf index b46a9ca01..b4eb19955 100644 --- a/addons/attributes/functions/fnc_gui_waypoint.sqf +++ b/addons/attributes/functions/fnc_gui_waypoint.sqf @@ -26,17 +26,35 @@ if (!isNull waypointAttachedVehicle _entity) exitWith { _ctrlBackground ctrlSetText localize "str_a3_rscattributewaypointtype_type"; }; -private _ctrlToolbox = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_TOOLBOX; +// Get active waypoint types and create toolbox with appropriate number of rows +private _waypointTypes = uiNamespace getVariable QGVAR(waypointTypes) select { + _entity call (_x select 4) +}; + +private _rows = ceil (count _waypointTypes / 3); +parsingNamespace setVariable [QEGVAR(common,rows), _rows]; +parsingNamespace setVariable [QEGVAR(common,columns), 3]; + +private _ctrlToolbox = _display ctrlCreate [QEGVAR(common,RscToolbox), IDC_ATTRIBUTE_TOOLBOX, _controlsGroup]; +_ctrlToolbox ctrlSetBackgroundColor [0, 0, 0, 0]; +_ctrlToolbox ctrlSetPosition [0, POS_H(1), POS_W(26), POS_H(_rows)]; +_ctrlToolbox ctrlCommit 0; + +private _ctrlBackground = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_BACKGROUND; +_ctrlBackground ctrlSetPositionH POS_H(_rows); +_ctrlBackground ctrlCommit 0; + +_controlsGroup ctrlSetPositionH POS_H(_rows + 1); +_controlsGroup ctrlCommit 0; // Determine the waypoint type from the given entity -private _waypointType = waypointType _entity; +private _waypointType = waypointType _entity; private _waypointScript = waypointScript _entity; -private _waypointTypes = uiNamespace getVariable QGVAR(waypointTypes); { _x params ["_name", "_tooltip", "_type", "_script"]; - private _index = _ctrlToolbox lbAdd _name; + private _index = _ctrlToolbox lbAdd toUpper _name; _ctrlToolbox lbSetTooltip [_index, _tooltip]; _ctrlToolbox setVariable [str _index, [_type, _script]]; @@ -49,7 +67,6 @@ _ctrlToolbox ctrlAddEventHandler ["ToolBoxSelChanged", { params ["_ctrlToolbox", "_index"]; private _value = _ctrlToolbox getVariable str _index; - private _controlsGroup = ctrlParentControlsGroup _ctrlToolbox; _controlsGroup setVariable [QGVAR(value), _value]; }]; diff --git a/addons/attributes/gui.hpp b/addons/attributes/gui.hpp index 0e3c23f73..602ba23a9 100644 --- a/addons/attributes/gui.hpp +++ b/addons/attributes/gui.hpp @@ -132,11 +132,8 @@ class GVAR(toolbox): GVAR(base) { }; }; -#define WAYPOINT_ROWS (ceil (count (uiNamespace getVariable QGVAR(waypointTypes)) / 3)) - class GVAR(waypoint): GVAR(base) { function = QFUNC(gui_waypoint); - h = POS_H(WAYPOINT_ROWS + 1); class controls: controls { class Label: Label { w = POS_W(26); @@ -146,18 +143,8 @@ class GVAR(waypoint): GVAR(base) { x = 0; y = POS_H(1); w = POS_W(26); - h = POS_H(WAYPOINT_ROWS); - }; - class Toolbox: ctrlToolbox { - idc = IDC_ATTRIBUTE_TOOLBOX; - x = 0; - y = POS_H(1); - w = POS_W(26); - h = POS_H(WAYPOINT_ROWS); - colorBackground[] = {0, 0, 0, 0}; - rows = WAYPOINT_ROWS; - columns = 3; }; + // Toolbox created through script based on available waypoints }; }; diff --git a/docs/frameworks/custom_waypoints.md b/docs/frameworks/custom_waypoints.md index a380b6cf3..b2bde66d3 100644 --- a/docs/frameworks/custom_waypoints.md +++ b/docs/frameworks/custom_waypoints.md @@ -10,10 +10,12 @@ Waypoints are added as subclasses to the `ZEN_WaypointTypes` root config class. Name | Type | Description ---- | ---- | ----------- -`displayName` | STRING | Displayed name of the waypoint -`tooltip` | STRING | Tooltip displayed when hovered -`type` | STRING | Waypoint type, [reference](https://community.bistudio.com/wiki/Waypoint_types) -`script` | STRING | Path to waypoint script file, used when type is "SCRIPTED" +`displayName` | STRING | Displayed name of the waypoint. +`tooltip` | STRING | Tooltip displayed when hovered. +`type` | STRING | Waypoint type, [reference](https://community.bistudio.com/wiki/Waypoint_types). +`script` | STRING | Path to waypoint script file, used when type is "SCRIPTED". +`condition` | STRING | Condition to show the waypoint type. +`priority` | NUMBER | Waypoint sorting priority. ### Example