ACE3/addons/zeus/functions/fnc_ui_garrison.sqf
Josuan Albin bb03f55c5c Add garrison zeus modules (#4555)
* Add garrison and un-garrison modules

* Remove unnecessary text from garrison header

* Add french translations to new strings

* Add changes requested by review

* Change pushback to pushBack

* Move garrison funcs to ai, finish headers

* Remove diag log debug

* Fix typos and header issues

* Add missing newlines

* Fix strings, Fix typos and headers

* Enable debug and disable compile cache, Add trace and comments

* Rebase before review

* Fix default case running instead of case 3

* Fix edge case related to players being in garrison group

The player would make the enableAttack checks in ungarrison and garrisonMove fail, this is now fixed.

* Fix some arrays in garrsionMove and garrison

* Relax distance checks in garrisonMove, change AI behaviour while pathing to aware

* Add debug view

* Remove unused var, fix unit pos using the wrong format

* Make debug more visually pleasing

* Change garrison debug target to a waypoint icon

* Change disableAI event to AISection, comment out doFollow in doMove EH

* Fix locality issue
2017-10-10 11:06:37 -05:00

105 lines
2.8 KiB
Plaintext

/*
* Author: alganthe
* Initalises the "Garrison" zeus module display.
*
* Arguments:
* 0: Garrison controls group <CONTROL>
*
* Return Value:
* None
*
* Example:
* onSetFocus = "_this call ace_zeus_fnc_ui_garrison"
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
params ["_control"];
//Generic Init:
private _display = ctrlparent _control;
private _ctrlButtonOK = _display displayctrl 1; //IDC_OK
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
TRACE_1("logicObject",_logic);
_control ctrlRemoveAllEventHandlers "setFocus";
// Handles errors
private _unit = effectiveCommander (attachedTo _logic);
scopeName "Main";
private _fnc_errorAndClose = {
params ["_msg"];
_display closeDisplay 0;
deleteVehicle _logic;
[_msg] call FUNC(showMessage);
breakOut "Main";
};
switch (false) do {
case !(isNull _unit): {
[LSTRING(NothingSelected)] call _fnc_errorAndClose;
};
case (_unit isKindOf "CAManBase"): {
[LSTRING(OnlyInfantry)] call _fnc_errorAndClose;
};
case (alive _unit): {
[LSTRING(OnlyAlive)] call _fnc_errorAndClose;
};
case !(isPlayer _unit): {
[LSTRING(OnlyNonPlayer)] call _fnc_errorAndClose;
};
};
//Specific on-load stuff:
private _listbox = _display displayCtrl 73063;
{
_listbox lbSetValue [_listbox lbAdd (_x select 0), _x select 1];
} forEach [
[localize LSTRING(ModuleGarrison_FillingModeEven), 0],
[localize LSTRING(ModuleGarrison_FillingModeBuilding), 1],
[localize LSTRING(ModuleGarrison_FillingModeRandom), 2]
];
_listbox lbSetCurSel 0;
//Specific on-load stuff:
(_display displayCtrl 73061) cbSetChecked (_logic getVariable ["TopDownFilling",false]);
(_display displayCtrl 73062) cbSetChecked (_logic getVariable ["Teleport",false]);
private _fnc_onUnload = {
params ["_display"];
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
if (isNull _logic) exitWith {};
deleteVehicle _logic;
};
private _fnc_onConfirm = {
params [["_ctrlButtonOK", controlNull, [controlNull]]];
private _display = ctrlparent _ctrlButtonOK;
if (isNull _display) exitWith {};
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
if (isNull _logic) exitWith {};
private _lb = _display displayCtrl 73063;
private _radius = GETVAR(_display,GVAR(radius),50);
private _position = GETVAR(_display,GVAR(position),getPos _logic);
private _mode = _lb lbValue (lbCurSel _lb);
private _TopDownFilling = cbChecked (_display displayCtrl 73061);
private _teleport = cbChecked (_display displayCtrl 73062);
[_logic, _position ,_radius, _mode, _TopDownFilling, _teleport] call FUNC(moduleGarrison);
};
_display displayAddEventHandler ["unload", _fnc_onUnload];
_ctrlButtonOK ctrlAddEventHandler ["buttonclick", _fnc_onConfirm];