Add zeus defend, patrol and search modules

Using a shared `radius` attribute for all of these displays so a generalized method of initializing and retrieving the value associated that was implemented.
This commit is contained in:
SilentSpike 2016-05-19 00:16:50 +01:00
parent e05f2ca637
commit 3a1dba4486
11 changed files with 416 additions and 8 deletions

View File

@ -104,6 +104,11 @@ class CfgVehicles {
function = QFUNC(moduleCaptive);
icon = QUOTE(PATHTOF(UI\Icon_Module_Zeus_Captive_ca.paa));
};
class GVAR(moduleDefendArea): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleDefendArea_DisplayName);
curatorInfoType = QGVAR(RscDefendArea);
};
class GVAR(moduleGlobalSetSkill): GVAR(moduleBase) {
displayName = CSTRING(ModuleGlobalSetSkill_DisplayName);
curatorInfoType = QGVAR(RscGlobalSetSkill);
@ -113,6 +118,16 @@ class CfgVehicles {
displayName = CSTRING(ModuleGroupSide_DisplayName);
curatorInfoType = QGVAR(RscGroupSide);
};
class GVAR(modulePatrolArea): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModulePatrolArea_DisplayName);
curatorInfoType = QGVAR(RscPatrolArea);
};
class GVAR(moduleSearchArea): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleSearchArea_DisplayName);
curatorInfoType = QGVAR(RscSearchArea);
};
class GVAR(moduleSearchNearby): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleSearchNearby_DisplayName);

View File

@ -18,8 +18,12 @@ PREP(moduleSurrender);
PREP(moduleTeleportPlayers);
PREP(moduleUnconscious);
PREP(moduleZeusSettings);
PREP(ui_attributeCargo);
PREP(ui_attributeRadius);
PREP(ui_defendArea);
PREP(ui_globalSetSkill);
PREP(ui_groupSide);
PREP(ui_patrolArea);
PREP(ui_searchArea);
PREP(ui_teleportPlayers);
PREP(ui_vehCargo);
PREP(zeusAttributes);

View File

@ -3,4 +3,7 @@
// Global skill module PVs values for persistence, just listen for the PV
QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill);
[QGVAR(moduleDefendArea), CBA_fnc_taskDefend] call EFUNC(common,addEventHandler);
[QGVAR(modulePatrolArea), CBA_fnc_taskPatrol] call EFUNC(common,addEventHandler);
[QGVAR(moduleSearchNearby), CBA_fnc_searchNearby] call EFUNC(common,addEventHandler);
[QGVAR(moduleSearchArea), CBA_fnc_taskSearchArea] call EFUNC(common,addEventHandler);

View File

@ -3,8 +3,11 @@
class CfgPatches {
class ADDON {
units[] = {
QGVAR(moduleDefendArea),
QGVAR(moduleGlobalSetSkill),
QGVAR(moduleGroupSide),
QGVAR(modulePatrolArea),
QGVAR(moduleSearchArea),
QGVAR(moduleSearchNearby),
QGVAR(moduleTeleportPlayers)
};

View File

@ -29,5 +29,5 @@ TRACE_1("",_loaded);
_control ctrlRemoveAllEventHandlers "setFocus";
{
((ctrlParent _control) displayCtrl 80086) lbAdd (str _x);
(_control controlsGroupCtrl 80086) lbAdd (str _x);
} forEach _loaded;

View File

@ -0,0 +1,48 @@
/*
* 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 "50";
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];
SETVAR(_display,GVAR(radius),50);
} else {
_edit ctrlSetTooltip "";
_edit ctrlSetTextColor [1,1,1,1];
SETVAR(_display,GVAR(radius),_radius);
};
};
[_display] call _fnc_onKeyUp;
_display displayAddEventHandler ["keyUp", _fnc_onKeyUp];

View File

@ -0,0 +1,75 @@
/*
* Author: SilentSpike
* Initalises the `defend area` zeus module display
*
* Arguments:
* 0: dummy 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";
//Validate the module target:
private _unit = effectiveCommander (attachedTo _logic);
scopeName "Main";
private _fnc_errorAndClose = {
params ["_msg"];
_display closeDisplay 0;
deleteVehicle _logic;
[_msg] call EFUNC(common,displayTextStructured);
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;
};
};
private _fnc_onUnload = {
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
if (isNull _logic) exitWith {};
if (_this select 1 == 2) then {
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 _unit = effectiveCommander (attachedTo _logic);
private _radius = GETVAR(_display,GVAR(radius),50);
[QGVAR(moduleDefendArea), _unit, [_unit,nil,_radius]] call EFUNC(common,targetEvent);
deleteVehicle _logic;
};
_display displayAddEventHandler ["unload", _fnc_onUnload];
_control ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];

View File

@ -0,0 +1,75 @@
/*
* Author: SilentSpike
* Initalises the `patrol area` zeus module display
*
* Arguments:
* 0: dummy 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";
//Validate the module target:
private _unit = effectiveCommander (attachedTo _logic);
scopeName "Main";
private _fnc_errorAndClose = {
params ["_msg"];
_display closeDisplay 0;
deleteVehicle _logic;
[_msg] call EFUNC(common,displayTextStructured);
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;
};
};
private _fnc_onUnload = {
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
if (isNull _logic) exitWith {};
if (_this select 1 == 2) then {
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 _unit = effectiveCommander (attachedTo _logic);
private _radius = GETVAR(_display,GVAR(radius),50);
[QGVAR(modulePatrolArea), _unit, [_unit,nil,_radius,5]] call EFUNC(common,targetEvent);
deleteVehicle _logic;
};
_display displayAddEventHandler ["unload", _fnc_onUnload];
_control ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];

View File

@ -0,0 +1,81 @@
/*
* Author: SilentSpike
* Initalises the `search area` zeus module display
*
* Arguments:
* 0: dummy 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";
//Validate the module target:
private _unit = effectiveCommander (attachedTo _logic);
scopeName "Main";
private _fnc_errorAndClose = {
params ["_msg"];
_display closeDisplay 0;
deleteVehicle _logic;
[_msg] call EFUNC(common,displayTextStructured);
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;
};
};
private _fnc_onUnload = {
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
if (isNull _logic) exitWith {};
if (_this select 1 == 2) then {
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 _unit = effectiveCommander (attachedTo _logic);
private _radius = GETVAR(_display,GVAR(radius),50);
private _marker = QGVAR(ModuleSearchArea) + str(_unit);
createMarker [_marker, getPosASL _unit];
_marker setMarkerAlpha 0;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerSize [_radius,_radius];
[QGVAR(moduleSearchArea), _unit, [_unit,_marker]] call EFUNC(common,targetEvent);
deleteVehicle _logic;
};
_display displayAddEventHandler ["unload", _fnc_onUnload];
_control ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];

View File

@ -181,6 +181,9 @@
<Russian>Пленный (вкл./выкл.)</Russian>
<Italian>Apri Catturato</Italian>
</Key>
<Key ID="STR_ACE_Zeus_ModuleDefendArea_DisplayName">
<English>Defend Area</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleGlobalSetSkill_DisplayName">
<English>Global AI Skill</English>
</Key>
@ -223,6 +226,9 @@
<Key ID="STR_ACE_Zeus_ModuleGroupSide_DisplayName">
<English>Group Side</English>
</Key>
<Key ID="STR_ACE_Zeus_ModulePatrolArea_DisplayName">
<English>Patrol Area</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleSurrender_DisplayName">
<English>Toggle Surrender</English>
<Polish>Przełącz kapitulację</Polish>
@ -262,6 +268,9 @@
<Russian>Без сознания (вкл./выкл.)</Russian>
<Italian>Apri Incosciente</Italian>
</Key>
<Key ID="STR_ACE_Zeus_ModuleSearchArea_DisplayName">
<English>Search Area</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleSearchNearby_DisplayName">
<English>Search Nearby Building</English>
</Key>
@ -435,5 +444,17 @@
<Czech>Přidá jakékoliv spawnuté objekty všem kurátorům v misi</Czech>
<Italian>Aggiungi ogni oggetto creato a tutti i Curatori in missione</Italian>
</Key>
<Key ID="STR_ACE_Zeus_AttributeCargo">
<English>Cargo:</English>
</Key>
<Key ID="STR_ACE_Zeus_AttributeRadius">
<English>Task Radius</English>
</Key>
<Key ID="STR_ACE_Zeus_AttributeRadius_desc">
<English>Radius to perform the task within</English>
</Key>
<Key ID="STR_ACE_Zeus_AttributeRadiusInvalid">
<English>Invalid radius entered</English>
</Key>
</Package>
</Project>

View File

@ -20,6 +20,53 @@ class RscDisplayAttributes {
};
};
class GVAR(AttributeRadius): RscControlsGroupNoScrollbars {
onSetFocus = QUOTE(_this call FUNC(ui_attributeRadius));
idc = 26466;
x = 0;
y = 0;
w = W_PART(26);
h = H_PART(1.2);
class controls {
class Title1: RscText {
idc = -1;
text = CSTRING(AttributeRadius);
toolTip = CSTRING(AttributeRadius_desc);
x = 0;
y = H_PART(0.1);
w = W_PART(10);
h = H_PART(1);
colorBackground[] = {0,0,0,0.5};
};
class Radius: RscEdit {
idc = 26467;
x = W_PART(10.1);
y = H_PART(0.1);
w = W_PART(15.8);
h = H_PART(1);
autocomplete = "";
};
};
};
class GVAR(RscDefendArea): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscDefendArea)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscDefendArea)))] call FUNC(zeusAttributes));
class Controls: Controls {
class Background: Background {};
class Title: Title {};
class Content: Content {
class Controls {
class radius: GVAR(AttributeRadius) {};
};
};
class ButtonOK: ButtonOK {
onSetFocus = QUOTE(_this call FUNC(ui_defendArea));
};
class ButtonCancel: ButtonCancel {};
};
};
class GVAR(RscGlobalSetSkill): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscGlobalSetSkill)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscGlobalSetSkill)))] call FUNC(zeusAttributes));
@ -193,6 +240,42 @@ class GVAR(RscGroupSide): RscDisplayAttributes {
};
};
class GVAR(RscPatrolArea): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscPatrolArea)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscPatrolArea)))] call FUNC(zeusAttributes));
class Controls: Controls {
class Background: Background {};
class Title: Title {};
class Content: Content {
class Controls {
class radius: GVAR(AttributeRadius) {};
};
};
class ButtonOK: ButtonOK {
onSetFocus = QUOTE(_this call FUNC(ui_patrolArea));
};
class ButtonCancel: ButtonCancel {};
};
};
class GVAR(RscSearchArea): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscSearchArea)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscSearchArea)))] call FUNC(zeusAttributes));
class Controls: Controls {
class Background: Background {};
class Title: Title {};
class Content: Content {
class Controls {
class radius: GVAR(AttributeRadius) {};
};
};
class ButtonOK: ButtonOK {
onSetFocus = QUOTE(_this call FUNC(ui_searchArea));
};
class ButtonCancel: ButtonCancel {};
};
};
class GVAR(RscTeleportPlayers): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscTeleportPlayers)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscTeleportPlayers)))] call FUNC(zeusAttributes));
@ -250,9 +333,9 @@ class GVAR(RscTeleportPlayers): RscDisplayAttributes {
};
class GVAR(cargoAttribute): RscControlsGroupNoScrollbars {
onSetFocus = QUOTE(_this call FUNC(ui_vehCargo));
idc = 80085;
class GVAR(AttributeCargo): RscControlsGroupNoScrollbars {
onSetFocus = QUOTE(_this call FUNC(ui_attributeCargo));
idc = -1;
x = X_PART(7);
y = Y_PART(10);
w = W_PART(26);
@ -260,7 +343,7 @@ class GVAR(cargoAttribute): RscControlsGroupNoScrollbars {
class controls {
class Title: RscText {
idc = -1;
text = "Cargo:";
text = CSTRING(AttributeCargo);
x = 0;
y = 0;
w = W_PART(10);
@ -290,7 +373,7 @@ class RscDisplayAttributesVehicle: RscDisplayAttributes {
class Controls: Controls {
class Content: Content {
class Controls: controls {
class ace_cargo: GVAR(cargoAttribute) { };
class ace_cargo: GVAR(AttributeCargo) { };
};
};
};
@ -300,7 +383,7 @@ class RscDisplayAttributesVehicleEmpty: RscDisplayAttributes {
class Controls: Controls {
class Content: Content {
class Controls: controls {
class ace_cargo: GVAR(cargoAttribute) { };
class ace_cargo: GVAR(AttributeCargo) { };
};
};
};