ACE3/addons/zeus/functions/fnc_ui_attributeRadius.sqf
SilentSpike b3192adbb7 Add support for a zeus module position attribute
Allows zeus to select a position for the module task to be carried out at - as a bonus it works alongside the radius attribute and will draw a circle preview if a radius is present.

Unfortunately control types 100 & 101 don't play nicely with controls groups and so I've commented out the position attribute from the displays that would currently use it. Otherwise it is all seemingly working fine, just that the position of the control is all wrong and it doesn't stay within the bounds of the controls group.

I opened an issue tracker ticket for the problem here: https://feedback.bistudio.com/T116708
2016-05-21 17:29:53 +01:00

48 lines
1.0 KiB
Plaintext

/*
* Author: SilentSpike
* Initalises the `radius` zeus module attribute
*
* Arguments:
* 0: radius controls group <CONTROL>
*
* Return Value:
* None <NIL>
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
_control ctrlRemoveAllEventHandlers "setFocus";
//Specific on-load stuff:
private _edit = _control controlsGroupCtrl 26467;
_edit ctrlSetText "100";
private _fnc_onKeyUp = {
params ["_display"];
private _edit = _display displayCtrl 26467;
private _radius = parseNumber (ctrlText _edit);
// Handle invalid radius (non-numerical input)
if (_radius == 0) then {
_edit ctrlSetTooltip (localize LSTRING(AttributeRadiusInvalid));
_edit ctrlSetTextColor [1,0,0,1];
} else {
_edit ctrlSetTooltip "";
_edit ctrlSetTextColor [1,1,1,1];
SETVAR(_display,GVAR(radius),_radius);
};
};
[_display] call _fnc_onKeyUp;
_display displayAddEventHandler ["keyUp", _fnc_onKeyUp];