Skip to content

Commit

Permalink
Add support for toolbox tooltips (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
mharis001 authored Oct 13, 2021
1 parent 61d9261 commit 9ef351e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion addons/attributes/functions/fnc_compileWaypoints.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
*/

uiNamespace setVariable [QGVAR(waypointTypes), configProperties [configFile >> "ZEN_WaypointTypes", "isClass _x"] apply {
[toUpper getText (_x >> "displayName"), getText (_x >> "type"), getText (_x >> "script")]
[toUpper getText (_x >> "displayName"), getText (_x >> "tooltip"), getText (_x >> "type"), getText (_x >> "script")]
}];
20 changes: 13 additions & 7 deletions addons/attributes/functions/fnc_gui_toolbox.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@ if (_returnBool) then {
};

private _display = ctrlParent _controlsGroup;
parsingNamespace setVariable [QEGVAR(common,rows), _rows max 1];
parsingNamespace setVariable [QEGVAR(common,columns), _columns max 1];

parsingNamespace setVariable [QGVAR(rows), _rows max 1];
parsingNamespace setVariable [QGVAR(columns), _columns max 1];

private _ctrlToolbox = _display ctrlCreate [QGVAR(RscToolbox), -1, _controlsGroup];
private _ctrlToolbox = _display ctrlCreate [QEGVAR(common,RscToolbox), -1, _controlsGroup];
_ctrlToolbox setVariable [QGVAR(params), [_returnBool]];

{
if (isLocalized _x) then {
_x = localize _x;
_x params [["_text", "", [""]], ["_tooltip", "", [""]]];

if (isLocalized _text) then {
_text = localize _text;
};

if (isLocalized _tooltip) then {
_tooltip = localize _tooltip;
};

_ctrlToolbox lbAdd _x;
private _index = _ctrlToolbox lbAdd _text;
_ctrlToolbox lbSetTooltip [_index, _tooltip];
} forEach _strings;

_ctrlToolbox lbSetCurSel _defaultValue;
Expand Down
3 changes: 2 additions & 1 deletion addons/attributes/functions/fnc_gui_waypoint.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ private _waypointScript = waypointScript _entity;
private _waypointTypes = uiNamespace getVariable QGVAR(waypointTypes);

{
_x params ["_name", "_type", "_script"];
_x params ["_name", "_tooltip", "_type", "_script"];

private _index = _ctrlToolbox lbAdd _name;
_ctrlToolbox lbSetTooltip [_index, _tooltip];
_ctrlToolbox setVariable [str _index, [_type, _script]];

if (_type == _waypointType && {_type != "SCRIPTED" || {_script == _waypointScript}}) then {
Expand Down
16 changes: 0 additions & 16 deletions addons/attributes/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ class EGVAR(common,RscBackground);
class EGVAR(common,RscEdit);
class EGVAR(common,RscCombo);

class GVAR(RscToolbox): ctrlToolbox {
idc = -1;
x = POS_W(10.1);
y = 0;
w = POS_W(15.9);
h = POS_H(1);
tooltipColorBox[] = {0, 0, 0, 0};
tooltipColorText[] = {0, 0, 0, 0};
tooltipColorShade[] = {0, 0, 0, 0};
rows = QGVAR(rows);
columns = QGVAR(columns);
};

class GVAR(base): RscControlsGroupNoScrollbars {
idc = IDC_ATTRIBUTE_GROUP;
function = "";
Expand Down Expand Up @@ -168,9 +155,6 @@ class GVAR(waypoint): GVAR(base) {
w = POS_W(26);
h = POS_H(WAYPOINT_ROWS);
colorBackground[] = {0, 0, 0, 0};
tooltipColorBox[] = {0, 0, 0, 0};
tooltipColorText[] = {0, 0, 0, 0};
tooltipColorShade[] = {0, 0, 0, 0};
rows = WAYPOINT_ROWS;
columns = 3;
};
Expand Down
3 changes: 0 additions & 3 deletions addons/common/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ class GVAR(RscToolbox): ctrlToolbox {
y = 0;
w = POS_W(15.9);
h = POS_H(1);
tooltipColorBox[] = {0, 0, 0, 0};
tooltipColorText[] = {0, 0, 0, 0};
tooltipColorShade[] = {0, 0, 0, 0};
// Allows number of rows and columns to be set dynamically using parsingNamespace
rows = QGVAR(rows);
columns = QGVAR(columns);
Expand Down
14 changes: 13 additions & 1 deletion addons/dialog/functions/fnc_create.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,19 @@ private _fnc_verifyListEntries = {
};
};

_strings = _strings select [0, _rows * _columns] apply {if (isLocalized _x) then {localize _x} else {_x}};
_strings = _strings select [0, _rows * _columns] apply {
_x params [["_text", "", [""]], ["_tooltip", "", [""]]];

if (isLocalized _text) then {
_text = localize _text;
};

if (isLocalized _tooltip) then {
_tooltip = localize _tooltip;
};

[_text, _tooltip]
};

// Return bool if there are only two options and default is a bool
private _returnBool = count _strings == 2 && {_default isEqualType false};
Expand Down
5 changes: 4 additions & 1 deletion addons/dialog/functions/fnc_gui_toolbox.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ parsingNamespace setVariable [QEGVAR(common,columns), _columns max 1];
private _ctrlToolbox = _display ctrlCreate [QEGVAR(common,RscToolbox), IDC_ROW_TOOLBOX, _controlsGroup];

{
_ctrlToolbox lbAdd _x;
_x params ["_text", "_tooltip"];

private _index = _ctrlToolbox lbAdd _text;
_ctrlToolbox lbSetTooltip [_index, _tooltip];
} forEach _strings;

// Convert boolean default values to a toolbox index
Expand Down
2 changes: 2 additions & 0 deletions docs/frameworks/custom_waypoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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"

Expand All @@ -20,6 +21,7 @@ Name | Type | Description
class ZEN_WaypointTypes {
class Paradrop {
displayName = "Paradrop";
tooltip = "Paradrops units at the position.";
type = "SCRIPTED";
script = "\x\zen\addons\ai\functions\fnc_waypointParadrop.sqf";
};
Expand Down

0 comments on commit 9ef351e

Please sign in to comment.