Add Zeus utility modules

- Add categories to zeus modules to group them based on their functionality
- Add new utility modules:
  1. Toggle simulation
  2. Update editable objects
- Clean up some of the zeus module code (standardise function headers, camel case, etc.)
This commit is contained in:
Remco Speekenbrink 2016-11-15 13:07:48 +01:00 committed by SilentSpike
parent 608f8bbfdc
commit 324bf68614
35 changed files with 288 additions and 74 deletions

View File

@ -0,0 +1,27 @@
class CfgFactionClasses {
class GVAR(AI) {
displayName = "ACE AI";
priority = 2;
side = 7;
};
class GVAR(Captive) {
displayName = "ACE Captive";
priority = 2;
side = 7;
};
class GVAR(Medical) {
displayName = "ACE Medical";
priority = 2;
side = 7;
};
class GVAR(Repair) {
displayName = "ACE Repair";
priority = 2;
side = 7;
};
class GVAR(Utility) {
displayName = "ACE Utility";
priority = 2;
side = 7;
};
};

View File

@ -94,82 +94,109 @@ class CfgVehicles {
};
class GVAR(moduleAddSpareTrack): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Repair);
displayName = CSTRING(ModuleAddSpareTrack_DisplayName);
function = QFUNC(moduleAddSpareTrack);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);//@todo
};
class GVAR(moduleAddSpareWheel): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Repair);
displayName = CSTRING(ModuleAddSpareWheel_DisplayName);
function = QFUNC(moduleAddSpareWheel);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);//@todo
};
class GVAR(moduleCaptive): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Captive);
displayName = CSTRING(ModuleCaptive_DisplayName);
function = QFUNC(moduleCaptive);
icon = QPATHTOF(UI\Icon_Module_Zeus_Captive_ca.paa);
};
class GVAR(moduleDefendArea): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(AI);
displayName = CSTRING(ModuleDefendArea_DisplayName);
curatorInfoType = QGVAR(RscDefendArea);
};
class GVAR(moduleEditableObjects): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Utility);
displayName = CSTRING(ModuleEditableObjects_DisplayName);
curatorInfoType = QGVAR(RscEditableObjects);
};
class GVAR(moduleGlobalSetSkill): GVAR(moduleBase) {
category = QGVAR(AI);
displayName = CSTRING(ModuleGlobalSetSkill_DisplayName);
curatorInfoType = QGVAR(RscGlobalSetSkill);
};
class GVAR(moduleGroupSide): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Utility);
displayName = CSTRING(ModuleGroupSide_DisplayName);
curatorInfoType = QGVAR(RscGroupSide);
};
class GVAR(modulePatrolArea): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(AI);
displayName = CSTRING(ModulePatrolArea_DisplayName);
curatorInfoType = QGVAR(RscPatrolArea);
};
class GVAR(moduleSearchArea): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(AI);
displayName = CSTRING(ModuleSearchArea_DisplayName);
curatorInfoType = QGVAR(RscSearchArea);
};
class GVAR(moduleSearchNearby): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(AI);
displayName = CSTRING(ModuleSearchNearby_DisplayName);
function = QFUNC(moduleSearchNearby);
};
class GVAR(moduleSetMedic): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Medical);
displayName = CSTRING(ModuleSetMedic_DisplayName);
function = QFUNC(moduleSetMedic);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);
};
class GVAR(moduleSetMedicalFacility): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Medical);
displayName = CSTRING(ModuleSetMedicalFacility_DisplayName);
function = QFUNC(moduleSetMedicalFacility);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);
};
class GVAR(moduleSetMedicalVehicle): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Medical);
displayName = CSTRING(ModuleSetMedicalVehicle_DisplayName);
function = QFUNC(moduleSetMedicalVehicle);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);
};
class GVAR(moduleSimulation): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Utility);
displayName = CSTRING(ModuleSimulation_DisplayName);
function = QFUNC(moduleSimulation);
};
class GVAR(moduleSurrender): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Captive);
displayName = CSTRING(ModuleSurrender_DisplayName);
function = QFUNC(moduleSurrender);
icon = QPATHTOF(UI\Icon_Module_Zeus_Surrender_ca.paa);
};
class GVAR(moduleTeleportPlayers): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Utility);
displayName = CSTRING(ModuleTeleportPlayers_DisplayName);
curatorInfoType = QGVAR(RscTeleportPlayers);
};
class GVAR(moduleUnconscious): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Medical);
displayName = CSTRING(ModuleUnconscious_DisplayName);
function = QFUNC(moduleUnconscious);
icon = QPATHTOF(UI\Icon_Module_Zeus_Unconscious_ca.paa);

View File

@ -14,6 +14,7 @@ PREP(moduleSearchNearby);
PREP(moduleSetMedic);
PREP(moduleSetMedicalVehicle);
PREP(moduleSetMedicalFacility);
PREP(moduleSimulation);
PREP(moduleSurrender);
PREP(moduleTeleportPlayers);
PREP(moduleUnconscious);
@ -22,6 +23,7 @@ PREP(ui_attributeCargo);
//PREP(ui_attributePosition);
PREP(ui_attributeRadius);
PREP(ui_defendArea);
PREP(ui_editableObjects);
PREP(ui_globalSetSkill);
PREP(ui_groupSide);
PREP(ui_patrolArea);

View File

@ -14,3 +14,26 @@ QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill);
[QGVAR(modulePatrolArea), CBA_fnc_taskPatrol] call CBA_fnc_addEventHandler;
[QGVAR(moduleSearchNearby), CBA_fnc_searchNearby] call CBA_fnc_addEventHandler;
[QGVAR(moduleSearchArea), CBA_fnc_taskSearchArea] call CBA_fnc_addEventHandler;
// Editable object commands must be ran on server, this events are used in the respective module
if (isServer) then {
[QGVAR(addObjects), {
params ["_objects", ["_curator",objNull]];
if !(isNull _curator) exitWith { _curator addCuratorEditableObjects [_objects, true]; };
{
_x addCuratorEditableObjects [_objects, true];
} forEach allCurators;
}] call CBA_fnc_addEventHandler;
[QGVAR(removeObjects), {
params ["_objects", ["_curator",objNull]];
if !(isNull _curator) exitWith { _curator removeCuratorEditableObjects [_objects, true]; };
{
_x removeCuratorEditableObjects [_objects, true];
} forEach allCurators;
}] call CBA_fnc_addEventHandler;
};

View File

@ -5,11 +5,13 @@ class CfgPatches {
name = COMPONENT_NAME;
units[] = {
QGVAR(moduleDefendArea),
QGVAR(moduleEditableObjects),
QGVAR(moduleGlobalSetSkill),
QGVAR(moduleGroupSide),
QGVAR(modulePatrolArea),
QGVAR(moduleSearchArea),
QGVAR(moduleSearchNearby),
QGVAR(moduleSimulation),
QGVAR(moduleTeleportPlayers)
};
weapons[] = {};
@ -49,6 +51,7 @@ class ACE_Curator {
GVAR(cargoAndRepair)[] = {"ace_cargo", "ace_repair"};
};
#include "CfgFactionClasses.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"

View File

@ -10,7 +10,7 @@
* 2: activated <BOOL>
*
* Return Value:
* nil
* None
*
* Public: No
*/

View File

@ -9,7 +9,7 @@
* 2: activated <BOOL>
*
* Return Value:
* nil
* None
*
* Public: No
*/

View File

@ -10,7 +10,7 @@
* 2: activated <BOOL>
*
* Return Value:
* nil
* None
*
* Public: No
*/

View File

@ -9,7 +9,7 @@
* 2: activated <BOOL>
*
* Return Value:
* nil
* None
*
* Public: No
*/

View File

@ -12,7 +12,7 @@
* 1: The zeus player <UNIT>
*
* Return Value:
* nil
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -7,10 +7,7 @@
* 1: Variable new value <ANY>
*
* Return Value:
* None <NIL>
*
* Example:
* "ace_zeus_GlobalSkillAI" addPublicVariableEventHandler ace_zeus_fnc_moduleGlobalSetSkill
* None
*
* Public: No
*/

View File

@ -7,7 +7,7 @@
* 1: Chosen side <SIDE>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* [this, west] call ace_zeus_fnc_moduleGroupSide

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -0,0 +1,27 @@
/*
* Author: Fisher, SilentSpike
* Toggle Simulation on object.
*
* Arguments:
* 0: The module logic <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic"];
if !(local _logic) exitWith {};
private _object = attachedTo _logic;
if (isNull _object) then {
[LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured);
} else {
[QEGVAR(common,enableSimulationGlobal), [_object, !(simulationEnabled _object)]] call CBA_fnc_serverEvent;
};
deleteVehicle _logic;

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: Teleport group <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* [player, "5854854754", false] call ace_zeus_fnc_moduleTeleportPlayers

View File

@ -8,7 +8,7 @@
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -8,7 +8,7 @@
* 2: activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/

View File

@ -7,10 +7,7 @@
* 0: ace_cargo controls group <CONTROL>
*
* Return Value:
* None <NIL>
*
* Example:
* onSetFocus = "_this call ace_zeus_fnc_ui_vehCargo"
* None
*
* Public: No
*/
@ -20,7 +17,7 @@
params ["_control"];
TRACE_1("params",_control);
private _veh = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
private _veh = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
TRACE_1("",_veh);
private _loaded = _veh getVariable [QEGVAR(cargo,loaded), []];

View File

@ -6,19 +6,17 @@
* 0: position controls group <CONTROL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
_control ctrlRemoveAllEventHandlers "setFocus";

View File

@ -6,15 +6,13 @@
* 0: radius controls group <CONTROL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;

View File

@ -6,19 +6,17 @@
* 0: dummy controls group <CONTROL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
_control ctrlRemoveAllEventHandlers "setFocus";

View File

@ -0,0 +1,65 @@
/*
* Author: Fisher, SilentSpike
* Updated all/local curator with objects in the module radius.
*
* Arguments:
* 0: editableObjects controls group <CONTROL>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
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";
//Specific on-load stuff:
(_display displayCtrl 16188) cbSetChecked true;
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 _radius = GETVAR(_display,GVAR(radius),50);
private _position = GETVAR(_display,GVAR(position),getPos _logic);
private _allCurators = cbChecked (_display displayCtrl 16188);
private _removeObjects = cbChecked (_display displayCtrl 16189);
private _objects = nearestObjects [_position, ["All"], _radius];
private _localCurator = [getAssignedCuratorLogic player, objNull] select _allCurators;
if (_removeObjects) then {
[QGVAR(removeObjects), [_objects, _localCurator]] call CBA_fnc_serverEvent;
} else {
[QGVAR(addObjects), [_objects, _localCurator]] call CBA_fnc_serverEvent;
};
deleteVehicle _logic;
};
_display displayAddEventHandler ["unload", _fnc_onUnload];
_ctrlButtonOK ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];

View File

@ -6,25 +6,20 @@
* 0: globalSetSkill controls group <CONTROL>
*
* Return Value:
* None <NIL>
*
* Example:
* onSetFocus = "_this call ace_zeus_fnc_ui_globalSetSkill"
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
params ["_control"];
TRACE_1("params",_control);
//Generic Init:
private _display = ctrlparent _control;
private _ctrlButtonOK = _display displayctrl 1; //IDC_OK
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
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";

View File

@ -6,10 +6,7 @@
* 0: groupSide controls group <CONTROL>
*
* Return Value:
* NONE <NIL>
*
* Example:
* onSetFocus = "_this call ace_zeus_fnc_ui_groupSide"
* None
*
* Public: No
*/
@ -17,14 +14,12 @@
#include "script_component.hpp"
#define IDCs [31201,31200,31202,31203]
disableSerialization;
params ["_control"];
//Generic Init:
private _display = ctrlparent _control;
private _ctrlButtonOK = _display displayctrl 1; //IDC_OK
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
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";

View File

@ -6,19 +6,17 @@
* 0: dummy controls group <CONTROL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
_control ctrlRemoveAllEventHandlers "setFocus";

View File

@ -6,19 +6,17 @@
* 0: dummy controls group <CONTROL>
*
* Return Value:
* None <NIL>
* None
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
//Generic Init:
params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull);
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
_control ctrlRemoveAllEventHandlers "setFocus";

View File

@ -6,24 +6,19 @@
* 0: teleportPlayers controls group <CONTROL>
*
* Return Value:
* NONE <NIL>
*
* Example:
* onSetFocus = "_this call ace_zeus_fnc_ui_teleportPlayers"
* None
*
* 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);
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";

View File

@ -9,7 +9,7 @@
* 2: Display class name <STRING>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* onLoad = "['onLoad',_this,'RscDisplayExample'] call ace_zeus_fnc_zeusAttributes"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Zeus">
<Key ID="STR_ACE_Zeus_Settings_DisplayName">
@ -205,6 +205,21 @@
<Polish>Osłaniaj obszar</Polish>
<German>Verteidige Gebiet</German>
</Key>
<Key ID="STR_ACE_Zeus_ModuleEditableObjects_DisplayName">
<English>Update Editable Objects</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleEditableObjects_curators">
<English>All Curators</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleEditableObjects_curators_desc">
<English>Apply changes to all curators</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleEditableObjects_removal">
<English>Remove Objects</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleEditableObjects_removal_desc">
<English>Remove existing instead of adding new</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleGlobalSetSkill_DisplayName">
<English>Global AI Skill</English>
<French>Compétence global de l'IA</French>
@ -465,6 +480,9 @@
<French>Assigner installation médicale</French>
<Japanese>医療施設として割り当て</Japanese>
</Key>
<Key ID="STR_ACE_Zeus_ModuleSimulation_DisplayName">
<English>Toggle Simulation</English>
</Key>
<Key ID="STR_ACE_Zeus_ModuleAddSpareWheel_DisplayName">
<English>Add Spare Wheel</English>
<Portuguese>Adicionar roda sobressalente</Portuguese>

View File

@ -97,6 +97,59 @@ class GVAR(RscDefendArea): RscDisplayAttributes {
};
};
class GVAR(RscEditableObjects): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QQGVAR(RscEditableObjects))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QQGVAR(RscEditableObjects))] call FUNC(zeusAttributes));
class Controls: Controls {
class Background: Background {};
class Title: Title {};
class Content: Content {
class Controls {
class radius: GVAR(AttributeRadius) {};
//class position: GVAR(AttributePosition) {};
class editableObjects: RscControlsGroupNoScrollbars {
onSetFocus = QUOTE(_this call FUNC(ui_editableObjects));
idc = 26422;
x = 0;
y = 0;
w = W_PART(11.1);
h = H_PART(2.5);
class controls {
class Label: RscText {
idc = -1;
text = CSTRING(ModuleEditableObjects_curators);
toolTip = CSTRING(ModuleEditableObjects_curators_desc);
x = 0;
y = 0;
w = W_PART(10);
h = H_PART(1);
colorBackground[] = {0,0,0,0.5};
};
class AllCurators: RscCheckBox {
idc = 16188;
x = W_PART(10.1);
y = 0;
w = W_PART(1);
h = H_PART(1);
};
class Label2: Label {
text = CSTRING(ModuleEditableObjects_removal);
toolTip = CSTRING(ModuleEditableObjects_removal_desc);
y = H_PART(1.1);
};
class EditingMode: AllCurators {
idc = 16189;
y = H_PART(1.1);
};
};
};
};
};
class ButtonOK: ButtonOK {};
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));