-
Notifications
You must be signed in to change notification settings - Fork 738
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
Add Zeus utility modules #4661
Conversation
ModuleSimulation toggles simulation for objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things required, no actual code checks performed.
@@ -644,6 +647,9 @@ | |||
<German>Fügt jedes gespawnte Objekt allen Kuratoren der Mission hinzu</German> | |||
<Japanese>ミッション内で作成されたオブジェクトに全キュレーターを追加</Japanese> | |||
</Key> | |||
<Key ID="STR_ACE_Zeus_RemoveObjectsToCurator"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STR_ACE_Zeus_RemoveObjectsFromCurator
@@ -607,6 +607,9 @@ | |||
<Italian>Piazza su una unità</Italian> | |||
<Japanese>ユニットの上に設置</Japanese> | |||
</Key> | |||
<Key ID="STR_ACE_Zeus_NoObjectSelected"> | |||
<English>Place on a object</English> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on an object
@@ -0,0 +1,64 @@ | |||
/* | |||
* Author: Fisher | |||
* Removes all objects in given radius for all curators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing final point.
* Removes all objects in given radius for all curators | ||
* | ||
* Arguments: | ||
* 0: dummy controls group <CONTROL> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dummy
(capitalization)
* 0: dummy controls group <CONTROL> | ||
* | ||
* Return Value: | ||
* none <NIL> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just None
.
* | ||
* Return Value: | ||
* None <NIL> | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An empty line too many.
@@ -49,6 +52,14 @@ class ACE_Curator { | |||
GVAR(cargoAndRepair)[] = {"ace_cargo", "ace_repair"}; | |||
}; | |||
|
|||
class CfgFactionClasses { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be in separate file ˙CfgFactionClasses.hpp
and included below.
@@ -49,6 +52,14 @@ class ACE_Curator { | |||
GVAR(cargoAndRepair)[] = {"ace_cargo", "ace_repair"}; | |||
}; | |||
|
|||
class CfgFactionClasses { | |||
class ACE_Util { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACE_UI_Util
maybe?
PREP(moduleSurrender); | ||
PREP(moduleTeleportPlayers); | ||
PREP(moduleUnconscious); | ||
PREP(moduleZeusSettings); | ||
PREP(ui_attributeCargo); | ||
//PREP(ui_attributePosition); | ||
PREP(ui_AddObjects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui_addObjects
- same for file.
PREP(ui_attributeRadius); | ||
PREP(ui_defendArea); | ||
PREP(ui_globalSetSkill); | ||
PREP(ui_groupSide); | ||
PREP(ui_patrolArea); | ||
PREP(ui_RemoveObjects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui_removeObjects
- same for file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newlines @ EOF.
Someone should test this in MP. With Zeus being a client. This heavily relies on global server only commands, but I'm pretty sure the way these modules are set up, they are executed on the zeus machine.
[LSTRING(NoObjectSelected)] call EFUNC(common,displayTextStructured); | ||
} else { | ||
_simulationEnabled = simulationEnabled _object; | ||
_object enableSimulationGlobal (!_simulationEnabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't work in MP like this.
https://community.bistudio.com/wiki/enableSimulationGlobal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an event in common
component for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it with BIS_fnc_MP
now, I couldn't find the event you where talking about
Maybe its on me, been a while since I worked on ArmA files :P
#include "script_component.hpp" | ||
|
||
params ["_logic"]; | ||
private ["_object","_simulationEnabled"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use private
keyword instead.
|
||
params ["_control"]; | ||
private _display = ctrlParent _control; | ||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objNull
}; | ||
|
||
private _fnc_onUnload = { | ||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
{ | ||
_y = _x; | ||
{ _x addCuratorEditableObjects [[_y], true]; } foreach allCurators; | ||
} foreach _objectsToAdd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forEach
.
New scope in new line.
Has to be executed on server and probably doesn't work like this in MP.
missing private
for _y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this simply:
{
_x addCuratorEditableObjects [_objectsToAdd, true];
} forEach allCurators;
addCuratorEditableObjects
is already meant to be able to add arrays of objects. No point in walking over the array just to pass each element in a size one array.
}; | ||
|
||
private _fnc_onUnload = { | ||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
private _display = ctrlparent _ctrlButtonOK; | ||
if (isNull _display) exitWith {}; | ||
|
||
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objnull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
{ | ||
_y = _x; | ||
{ _x removeCuratorEditableObjects [[_y], true]; } foreach allCurators; | ||
} foreach _objectsToAdd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Like the addition of module categories, have been meaning to get around to that myself 👍 UI stuff all looks to be handled correctly in line with the existing modules 👍 (I should probably post some explicit guidelines on standard procedure for the addition of new UI modules - I ought to fix that position attribute at some point too). I'd like to see a setting on the add/remove modules to toggle whether it's all curators or just the current one (all by default), however I can easily add that after merge if you're not confident with the UI stuff. Regarding the locality stuff: Module functions will run globally by default (if inheriting from the base module), so they will run everywhere. The simulation module can thus just use the command without having to worry about locality (since it will be ran on all machines by the module framework). The UI modules have their functions stem from the UI itself, so those are only run on the zeus client by default. You'll have to handle locality within those function (i.e running the add/remove object commands on the server). |
@@ -695,5 +701,8 @@ | |||
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
[[_object, (!_simulationEnabled)],"enableSimulationGlobal",false] call BIS_fnc_MP; | ||
}; | ||
|
||
deleteVehicle _logic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
|
||
params ["_logic"]; | ||
|
||
if !(local _logic) exitWith {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SilentSpike
So this function runs everywhere... Which machine is the module local to? Server or Zeus client? Shouldn't this be a isServer
check for simplicity regardless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module will be local to zeus client. However in the case of this module, we may want to actually exploit the module framework and make it only run on the server (then use the simulationGlobal command).
To do so, in the module's cfgVehicles entry you simple set isGlobal = 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and remove this locality check yes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then make the command instead of enableSimulationGlobal
just enableSimulation
?
Thanks SilentSpike for the comment, in a way I was confused about the Simulation command since I also thought if you call enableSimulationGlobal it will automatically be executed from the server to all clients. I just tested the simulation script on a server without the About the UI stuff, i'm currently learning how UI stuff works in ArmA so im not that confident yet. |
[LSTRING(NoObjectSelected)] call EFUNC(common,displayTextStructured); | ||
} else { | ||
private _simulationEnabled = simulationEnabled _object; | ||
[[_object, (!_simulationEnabled)],"enableSimulationGlobal",false] call BIS_fnc_MP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is not what @jonpas and I meant. Should probably be restored to what it was if the other comment regarding the modules locality is solved.
{ | ||
_x addCuratorEditableObjects [_objectsToAdd, true]; | ||
} foreach allCurators; | ||
} foreach _objectsToAdd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks wrong
|
||
#include "script_component.hpp" | ||
|
||
disableSerialization; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SilentSpike
module scripts are run in scheduled environment, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These UI initialisation functions will stem from an onSetFocus
event handler, which I don't believe is scheduled, not sure though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they don't run in scheduled environment, then disableSerialization
should be removed as unscheduled environment does not support serialization to begin with.
{ | ||
_x removeCuratorEditableObjects [_objectsToAdd, true]; | ||
} foreach allCurators; | ||
} foreach _objectsToAdd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above. no need to iterate through _objectsToAdd
at all. also, forEach
camel case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im a derp, I forgot to remove the other foreach loop
Module will run on the server only via the module framework (removing the need for any back and fourth).
# Conflicts: # addons/zeus/functions/fnc_moduleSimulation.sqf
@@ -22,7 +22,8 @@ | |||
[LSTRING(NoObjectSelected)] call EFUNC(common,displayTextStructured); | |||
} else { | |||
private _simulationEnabled = simulationEnabled _object; | |||
[[_object, (!_simulationEnabled)],"enableSimulationGlobal",false] call BIS_fnc_MP; | |||
_object enableSimulationGlobal (!_simulationEnabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab. should be four spaces to let travis pass
deleteVehicle _logic; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space here
@SilentSpike the same problem exists for |
}; | ||
|
||
deleteVehicle _logic; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space : (
- Merges the add/remove curator editable objects modules into one with a checkbox to specific behaviour. - Adds a checkbox to specify whether to effect all curators or only the local curator - Fixes locality handling of the module code
I've merged the add/remove modules together, fixed their locality, added checkbox to toggle all/local curator. All that's left now is some cleanup and this is good to go 👍 |
- Standardise function headers (remove examples where not applicable) - Add module categories (and make display names beautiful) - Alphabetise some classes
Alright, I'm happy to merge this, but if someone else wants to give the code a quick re-review beforehand that'd be great 👍 |
Will modify my PRs when this is merged. |
|
}] call CBA_fnc_addEventHandler; | ||
|
||
[QGVAR(removeObjects), { | ||
params ["_objects", "_curator"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SilentSpike
Do you mean:
params ["_objects", ["_curator", objNull]];
so that the exitWith
thing works as alternative syntax?
Alternativeley change !isNull _curator
to !isNil "_curator"
same above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this works anyway (at least in unscheduled env.) due to isNull
silently failing when _curator
is undefined, but I still think relying on this SQF ... "feature" is bad design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch commy, I don't know why I totally forgot params can supply a default value when writing this 👍
|
||
private _object = attachedTo _logic; | ||
if (isNull _object) then { | ||
[LSTRING(NoObjectSelected)] call EFUNC(common,displayTextStructured); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
||
params ["_control"]; | ||
|
||
disableSerialization; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does nothing in unscheduled env.
should be removed if these module scripts do indeed run unscheduled. otherwise ignore this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably my bad if unnecessary as it's in all of my existing ui functions, not sure if I had reasoning for that when I first wrote them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
@654wak654 @alganthe Modules don't necessarily need categories defined, if they inherit from the base module then it'll still default to |
- Module must run on zeus client so that feedback can be shown if validation fails - Use event in common to run the `enableSimulationGlobal` command - Can use existing localised string - Also adds default value to the editable objects events
@@ -15,11 +15,13 @@ | |||
|
|||
params ["_logic"]; | |||
|
|||
if !(local _logic) exitWith {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the module is local to the zeus? good to know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this line is standard in all zeus modules (BI included) with a few exceptions.
Just tested and confirmed that |
if (isNull _object) then { | ||
[LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); | ||
} else { | ||
[QEGVAR(common,enableSimulationGlobal), [_object, !(simulationEnabled _object)]] call CBA_fnc_serverEvent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for learning purposes, what does QEGVAR
exactly in this state?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QuotedExternalGlobalVARiable
=> "ace_common_enableSimulationGlobal"
http://ace3mod.com/wiki/development/coding-guidelines.html#macro-usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line makes use of this event defined in the common
component:
https://github.com/acemod/ACE3/blob/master/addons/common/XEH_postInit.sqf#L135
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah I get it, makes a lot of sense now, thanks 👍
When merged this pull request will:
This module needs to be placed on an object. This will toggle the simulation of the object. Handy for base builds etc.
This module will ask for a radius once placed (radius in meters) and will add all objects to zeus within that radius.
This module will do the same as Add but then inverted (Remove all objects in the radius from zeus, it will not remove the objects it will just make them uneditable and no icon will show up etc)