ACE3/addons/zeus/functions/fnc_ui_attributePosition.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

61 lines
1.5 KiB
Plaintext

/*
* Author: SilentSpike
* Initalises the `position` zeus module attribute
*
* Arguments:
* 0: position controls group <CONTROL>
*
* Return Value:
* None <NIL>
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
_control ctrlRemoveAllEventHandlers "setFocus";
//Specific on-load stuff:
private _map = _control controlsGroupCtrl 26469;
// Centre map on the logic initially
_map ctrlMapAnimAdd [0, ctrlMapScale _map, _logic];
ctrlMapAnimCommit _map;
private _fnc_onDraw = {
params ["_map"];
private _display = ctrlParent _map;
private _pos = GETVAR(_display,GVAR(position),[]);
private _radius = GETVAR(_display,GVAR(radius),0);
if !(_pos isEqualTo []) then {
// Works alongside radius attribute
if (_radius == 0) then {
_map drawIcon ["\A3\ui_f\data\map\markers\military\dot_CA.paa", [0,0,0,1], _pos, 19, 19, 0, "", 0, 0];
} else {
_map drawEllipse [_pos, _radius, _radius, 0, [0,0,0,1], ""];
};
};
};
private _fnc_onMapClick = {
params ["_map","_button","_x","_y","_shift","_ctrl","_alt"];
if (_button == 0) then {
private _display = ctrlParent _map;
SETVAR(_display,GVAR(position),_pos);
};
};
SETVAR(_display,GVAR(position),getPos _logic);
_map ctrlAddEventHandler ["draw",_fnc_onDraw];
_map ctrlAddEventHandler ["mouseButtonDown",_fnc_onMapClick];