From 3a1dba448608ab3bcedc8c8b67161658c7f43c48 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Thu, 19 May 2016 00:16:50 +0100 Subject: [PATCH] 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. --- addons/zeus/CfgVehicles.hpp | 15 +++ addons/zeus/XEH_PREP.hpp | 6 +- addons/zeus/XEH_postInit.sqf | 3 + addons/zeus/config.cpp | 3 + ...vehCargo.sqf => fnc_ui_attributeCargo.sqf} | 2 +- .../zeus/functions/fnc_ui_attributeRadius.sqf | 48 ++++++++++ addons/zeus/functions/fnc_ui_defendArea.sqf | 75 +++++++++++++++ addons/zeus/functions/fnc_ui_patrolArea.sqf | 75 +++++++++++++++ addons/zeus/functions/fnc_ui_searchArea.sqf | 81 ++++++++++++++++ addons/zeus/stringtable.xml | 21 ++++ addons/zeus/ui/RscAttributes.hpp | 95 +++++++++++++++++-- 11 files changed, 416 insertions(+), 8 deletions(-) rename addons/zeus/functions/{fnc_ui_vehCargo.sqf => fnc_ui_attributeCargo.sqf} (91%) create mode 100644 addons/zeus/functions/fnc_ui_attributeRadius.sqf create mode 100644 addons/zeus/functions/fnc_ui_defendArea.sqf create mode 100644 addons/zeus/functions/fnc_ui_patrolArea.sqf create mode 100644 addons/zeus/functions/fnc_ui_searchArea.sqf diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index ddf1af6c37..2247c6e969 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -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); diff --git a/addons/zeus/XEH_PREP.hpp b/addons/zeus/XEH_PREP.hpp index cbc04f1c3a..0de614f190 100644 --- a/addons/zeus/XEH_PREP.hpp +++ b/addons/zeus/XEH_PREP.hpp @@ -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); diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index b7d09aa3c0..b2587aa659 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -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); diff --git a/addons/zeus/config.cpp b/addons/zeus/config.cpp index cbcdef373c..0abfea0dd6 100644 --- a/addons/zeus/config.cpp +++ b/addons/zeus/config.cpp @@ -3,8 +3,11 @@ class CfgPatches { class ADDON { units[] = { + QGVAR(moduleDefendArea), QGVAR(moduleGlobalSetSkill), QGVAR(moduleGroupSide), + QGVAR(modulePatrolArea), + QGVAR(moduleSearchArea), QGVAR(moduleSearchNearby), QGVAR(moduleTeleportPlayers) }; diff --git a/addons/zeus/functions/fnc_ui_vehCargo.sqf b/addons/zeus/functions/fnc_ui_attributeCargo.sqf similarity index 91% rename from addons/zeus/functions/fnc_ui_vehCargo.sqf rename to addons/zeus/functions/fnc_ui_attributeCargo.sqf index 2a743c8259..444fa5e7e2 100644 --- a/addons/zeus/functions/fnc_ui_vehCargo.sqf +++ b/addons/zeus/functions/fnc_ui_attributeCargo.sqf @@ -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; diff --git a/addons/zeus/functions/fnc_ui_attributeRadius.sqf b/addons/zeus/functions/fnc_ui_attributeRadius.sqf new file mode 100644 index 0000000000..67ab0801fc --- /dev/null +++ b/addons/zeus/functions/fnc_ui_attributeRadius.sqf @@ -0,0 +1,48 @@ +/* + * Author: SilentSpike + * Initalises the `radius` zeus module attribute + * + * Arguments: + * 0: radius controls group + * + * Return Value: + * None + * + * 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]; diff --git a/addons/zeus/functions/fnc_ui_defendArea.sqf b/addons/zeus/functions/fnc_ui_defendArea.sqf new file mode 100644 index 0000000000..bce2a9c2a2 --- /dev/null +++ b/addons/zeus/functions/fnc_ui_defendArea.sqf @@ -0,0 +1,75 @@ +/* + * Author: SilentSpike + * Initalises the `defend area` zeus module display + * + * Arguments: + * 0: dummy controls group + * + * Return Value: + * None + * + * 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]; diff --git a/addons/zeus/functions/fnc_ui_patrolArea.sqf b/addons/zeus/functions/fnc_ui_patrolArea.sqf new file mode 100644 index 0000000000..3afbf74e8c --- /dev/null +++ b/addons/zeus/functions/fnc_ui_patrolArea.sqf @@ -0,0 +1,75 @@ +/* + * Author: SilentSpike + * Initalises the `patrol area` zeus module display + * + * Arguments: + * 0: dummy controls group + * + * Return Value: + * None + * + * 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]; diff --git a/addons/zeus/functions/fnc_ui_searchArea.sqf b/addons/zeus/functions/fnc_ui_searchArea.sqf new file mode 100644 index 0000000000..3fb393ea37 --- /dev/null +++ b/addons/zeus/functions/fnc_ui_searchArea.sqf @@ -0,0 +1,81 @@ +/* + * Author: SilentSpike + * Initalises the `search area` zeus module display + * + * Arguments: + * 0: dummy controls group + * + * Return Value: + * None + * + * 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]; diff --git a/addons/zeus/stringtable.xml b/addons/zeus/stringtable.xml index a972cd6e06..30bd14bf10 100644 --- a/addons/zeus/stringtable.xml +++ b/addons/zeus/stringtable.xml @@ -181,6 +181,9 @@ Пленный (вкл./выкл.) Apri Catturato + + Defend Area + Global AI Skill @@ -223,6 +226,9 @@ Group Side + + Patrol Area + Toggle Surrender Przełącz kapitulację @@ -262,6 +268,9 @@ Без сознания (вкл./выкл.) Apri Incosciente + + Search Area + Search Nearby Building @@ -435,5 +444,17 @@ Přidá jakékoliv spawnuté objekty všem kurátorům v misi Aggiungi ogni oggetto creato a tutti i Curatori in missione + + Cargo: + + + Task Radius + + + Radius to perform the task within + + + Invalid radius entered + diff --git a/addons/zeus/ui/RscAttributes.hpp b/addons/zeus/ui/RscAttributes.hpp index 7b561d7c23..c5022b6974 100644 --- a/addons/zeus/ui/RscAttributes.hpp +++ b/addons/zeus/ui/RscAttributes.hpp @@ -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) { }; }; }; };