Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zeus utility modules #4661

Merged
merged 24 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
51de0bd
Merge remote-tracking branch 'refs/remotes/acemod/master'
RSpeekenbrink Nov 11, 2016
d2638cf
Added Zeus Module: Simulation
RSpeekenbrink Nov 11, 2016
9332101
Added AddObjects and Remove Objects & ACE Util Category
RSpeekenbrink Nov 12, 2016
d27c68c
Removed Tabs
RSpeekenbrink Nov 12, 2016
1683b5d
Merge remote-tracking branch 'refs/remotes/acemod/master' into ZeusUtil
RSpeekenbrink Nov 12, 2016
f329405
Code Cleanup
RSpeekenbrink Nov 12, 2016
7037676
Fix array in fnc_moduleSimulation.sqf
RSpeekenbrink Nov 12, 2016
2398ac9
Tab and Newline Cleanup
RSpeekenbrink Nov 12, 2016
5a87acf
Filename Upercase on remote fix (fnc_removeObjects)
RSpeekenbrink Nov 12, 2016
aa3289d
Filename Upercase on remote fix (fnc_addObjects)
RSpeekenbrink Nov 12, 2016
221d0ae
Reduce network traffic of toggle simulation module
kymckay Nov 12, 2016
40ba9ef
Edited functions to meet Review
RSpeekenbrink Nov 12, 2016
7868eaf
Merge remote-tracking branch 'origin/ZeusUtil' into ZeusUtil
RSpeekenbrink Nov 12, 2016
be7c4d6
Remove fnc_errorAndClose from fnc_ui_addObjects.sqf
RSpeekenbrink Nov 12, 2016
4b690e8
Remove White Space from fnc_moduleSImulation
RSpeekenbrink Nov 12, 2016
a1ebaed
_fnc_errorAndClose & removed from fnc_ui_removeObjects
RSpeekenbrink Nov 12, 2016
dd85fcb
Space @ EOF removed :)
RSpeekenbrink Nov 12, 2016
59ef96c
simplified code (Tested in MP & SP)
RSpeekenbrink Nov 12, 2016
1c73355
Merge add/remove editable objects zeus modules
kymckay Nov 12, 2016
30c694d
Clean up ace_zeus
kymckay Nov 12, 2016
aab2cb7
Clean up some camel case
kymckay Nov 12, 2016
438255a
Remove disableSerialization from fnc_ui_editableObjects
RSpeekenbrink Nov 12, 2016
008bb40
Fix zeus feedback of toggle simulation module
kymckay Nov 13, 2016
6c6bb58
Remove unnecessary `disableSerialization` usage
kymckay Nov 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions addons/zeus/CfgFactionClasses.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgFactionClasses {
class ACE_UI_Util {
displayName = "ACE Util";
priority = 2;
side = 7;
};
};
17 changes: 17 additions & 0 deletions addons/zeus/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ class CfgVehicles {
function = QFUNC(moduleAddSpareTrack);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);//@todo
};
class GVAR(moduleAddObjects): GVAR(moduleBase) {
curatorCanAttach = 1;
category = "ACE_UI_Util";
displayName = CSTRING(AddObjectsToCurator);
curatorInfoType = QGVAR(RscAddObjects);
};
class GVAR(moduleAddSpareWheel): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleAddSpareWheel_DisplayName);
Expand Down Expand Up @@ -129,6 +135,11 @@ class CfgVehicles {
displayName = CSTRING(ModulePatrolArea_DisplayName);
curatorInfoType = QGVAR(RscPatrolArea);
};
class GVAR(moduleRemoveObjects): GVAR(moduleAddObjects) {
curatorCanAttach = 1;
displayName = CSTRING(RemoveObjectsFromCurator);
curatorInfoType = QGVAR(RscRemoveObjects);
};
class GVAR(moduleSearchArea): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleSearchArea_DisplayName);
Expand Down Expand Up @@ -157,6 +168,12 @@ class CfgVehicles {
function = QFUNC(moduleSetMedicalVehicle);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);
};
class GVAR(moduleSimulation): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleSimulation_DisplayName);
function = QFUNC(moduleSimulation);
isGlobal = 0;
};
class GVAR(moduleSurrender): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleSurrender_DisplayName);
Expand Down
3 changes: 3 additions & 0 deletions addons/zeus/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ PREP(moduleSearchNearby);
PREP(moduleSetMedic);
PREP(moduleSetMedicalVehicle);
PREP(moduleSetMedicalFacility);
PREP(moduleSimulation);
PREP(moduleSurrender);
PREP(moduleTeleportPlayers);
PREP(moduleUnconscious);
PREP(moduleZeusSettings);
PREP(ui_attributeCargo);
//PREP(ui_attributePosition);
PREP(ui_addObjects);
PREP(ui_attributeRadius);
PREP(ui_defendArea);
PREP(ui_globalSetSkill);
PREP(ui_groupSide);
PREP(ui_patrolArea);
PREP(ui_removeObjects);
PREP(ui_searchArea);
PREP(ui_teleportPlayers);
PREP(zeusAttributes);
4 changes: 4 additions & 0 deletions addons/zeus/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {
QGVAR(moduleAddObjects),
QGVAR(moduleDefendArea),
QGVAR(moduleGlobalSetSkill),
QGVAR(moduleGroupSide),
QGVAR(modulePatrolArea),
QGVAR(moduleRemoveObjects),
QGVAR(moduleSearchArea),
QGVAR(moduleSearchNearby),
QGVAR(moduleSimulation),
QGVAR(moduleTeleportPlayers)
};
weapons[] = {};
Expand Down Expand Up @@ -49,6 +52,7 @@ class ACE_Curator {
GVAR(cargoAndRepair)[] = {"ace_cargo", "ace_repair"};
};

#include "CfgFactionClasses.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
Expand Down
30 changes: 30 additions & 0 deletions addons/zeus/functions/fnc_moduleSimulation.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Author: Fisher
* Toggle Simulation on object (runs on server only via module framework).
*
* Arguments:
* 0: The module logic <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/

#include "script_component.hpp"

params ["_logic"];

private _object = attachedTo _logic;
if (isNull _object) then {
[LSTRING(NoObjectSelected)] call EFUNC(common,displayTextStructured);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this script does indeed only run on the server, then why does it show a text there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it so that it runs on both server & local? @SilentSpike

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a good catch, hmm, I suppose it probably should run on the client and then send an event to the server so that this client feedback can be given.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not optimal in terms of minimising network traffic, but much better UX for zeus and also these modules are only running when prompted by zeus anyway so it's not a big deal.

} else {
if (isMultiplayer) then {
_object enableSimulationGlobal !(simulationEnabled _object);
} else {
_object enableSimulation !(simulationEnabled _object);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole then block can be simplified to:
_object enableSimulationGlobal !(simulationEnabled _object);
enableSimulation and enableSimulationGlobal are synonymous in SP as the SP client is always the server.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what I thought too, the biki seems to suggest that enableSimulation should be used instead of the global varient in SP so I wasn't sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Weird comment on the wiki. Should be tested.

Copy link
Contributor Author

@RSpeekenbrink RSpeekenbrink Nov 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableSimulationGlobal seems to work in MP, enableSimulation doesn't so I guess replace it with just _object enableSimulationGlobal !(simulationEnabled _object); ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is about a offhand (?) comment on the wiki:
https://community.bistudio.com/wiki/enableSimulationGlobal

Description:
MP command. Enable or disable simulation for given entity, globally. Call this only from the server. In SP use enableSimulation

Thing is that the SP client is for all intents and purposes the "server". But maybe the command is bugged and doesn't work at all in SP? Someone should test it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested enableSimulationGlobal in singleplayer aswell, it works fine on my end

};

deleteVehicle _logic;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space : (

56 changes: 56 additions & 0 deletions addons/zeus/functions/fnc_ui_addObjects.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Author: Fisher
* Adds all objects in given radius to all curators.
*
* Arguments:
* 0: Dummy controls group <CONTROL>
*
* Return Value:
* None
*
* Public: No
*/

#include "script_component.hpp"

disableSerialization;

params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);

_control ctrlRemoveAllEventHandlers "setFocus";

scopeName "Main";

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 _objectsToAdd = nearestObjects [_position, ["All"], _radius];

{
_x addCuratorEditableObjects [_objectsToAdd, true];
} forEach allCurators;

deleteVehicle _logic;
};

_display displayAddEventHandler ["unload", _fnc_onUnload];
_control ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];
53 changes: 53 additions & 0 deletions addons/zeus/functions/fnc_ui_removeObjects.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Author: Fisher
* Removes all objects in given radius for all curators.
*
* Arguments:
* 0: Dummy controls group <CONTROL>
*
* Return Value:
* None
*
* Public: No
*/

#include "script_component.hpp"

params ["_control"];
private _display = ctrlParent _control;
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);

_control ctrlRemoveAllEventHandlers "setFocus";

scopeName "Main";
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 _objectsToAdd = nearestObjects [_position, ["All"], _radius];

{
_x removeCuratorEditableObjects [_objectsToAdd, true];
} forEach allCurators;

deleteVehicle _logic;
};

_display displayAddEventHandler ["unload", _fnc_onUnload];
_control ctrlAddEventHandler ["buttonClick", _fnc_onConfirm];
11 changes: 10 additions & 1 deletion addons/zeus/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@
<Hungarian>Semmi sincs az egér alatt</Hungarian>
<Italian>Piazza su una unità</Italian>
<Japanese>ユニットの上に設置</Japanese>
</Key>
<Key ID="STR_ACE_Zeus_NoObjectSelected">
<English>Place on an object</English>
</Key>
<Key ID="STR_ACE_Zeus_RequiresAddon">
<English>Requires an addon that is not present</English>
Expand Down Expand Up @@ -643,6 +646,9 @@
<French>Ajoute n'importe quel objet spawné à tous les curateurs de la mission</French>
<German>Fügt jedes gespawnte Objekt allen Kuratoren der Mission hinzu</German>
<Japanese>ミッション内で作成されたオブジェクトに全キュレーターを追加</Japanese>
</Key>
<Key ID="STR_ACE_Zeus_RemoveObjectsFromCurator">
<English>Remove Objects from Curator</English>
</Key>
<Key ID="STR_ACE_Zeus_AttributeCargo">
<English>Cargo:</English>
Expand Down Expand Up @@ -694,6 +700,9 @@
<Japanese>無効な半径が入力されました</Japanese>
<Polish>Wpisano nieprawidłowy promień</Polish>
<German>Ungültiger Radius eingegeben</German>
</Key>
<Key ID="STR_ACE_Zeus_ModuleSimulation_DisplayName">
<English>Toggle Simulation</English>
</Key>
</Package>
</Project>
</Project>
36 changes: 36 additions & 0 deletions addons/zeus/ui/RscAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,42 @@ class GVAR(RscSearchArea): RscDisplayAttributes {
};
};

class GVAR(RscAddObjects): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscAddObjects)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscAddObjects)))] 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_addObjects));
};
class ButtonCancel: ButtonCancel {};
};
};

class GVAR(RscRemoveObjects): RscDisplayAttributes {
onLoad = QUOTE([ARR_3('onLoad', _this, QUOTE(QGVAR(RscRemoveObjects)))] call FUNC(zeusAttributes));
onUnload = QUOTE([ARR_3('onUnload', _this, QUOTE(QGVAR(RscRemoveObjects)))] 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_removeObjects));
};
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));
Expand Down