Skip to content

Add Unload Vehicle Cargo keybind and context menu action #528

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

Merged
merged 18 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
6 changes: 6 additions & 0 deletions addons/context_actions/CfgContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ class EGVAR(context_menu,actions) {
statement = QUOTE(_objects call FUNC(refuelVehicles));
icon = "\a3\ui_f\data\igui\cfg\simpleTasks\types\refuel_ca.paa";
};
class UnloadViV {
displayName = "$STR_A3_ModuleDepot_Unload";
condition = QUOTE(_objects call FUNC(canUnloadViV));
statement = QUOTE(_objects call FUNC(unloadViV));
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\unloadVehicle_ca.paa";
};
};
class EditableObjects {
displayName = CSTRING(EditableObjects);
Expand Down
2 changes: 2 additions & 0 deletions addons/context_actions/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PREP(canRearmVehicles);
PREP(canRefuelVehicles);
PREP(canRepairVehicles);
PREP(canToggleSurrender);
PREP(canUnloadViV);
PREP(copyVehicleAppearance);
PREP(getArtilleryActions);
PREP(healUnits);
Expand All @@ -25,4 +26,5 @@ PREP(teleportPlayers);
PREP(teleportZeus);
PREP(toggleCaptive);
PREP(toggleSurrender);
PREP(unloadViV);
PREP(updateEditableObjects);
20 changes: 20 additions & 0 deletions addons/context_actions/functions/fnc_canUnloadViV.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Checks if the given objects list contains ViV cargo or carriers that can be unloaded.
*
* Arguments:
* N: Objects <OBJECT>
*
* Return Value:
* Can Unload Vehicles <BOOL>
*
* Example:
* [_object] call zen_context_actions_fnc_canUnloadViV
*
* Public: No
*/

_this findIf {
!(getVehicleCargo _x isEqualTo []) || {!isNull isVehicleCargo _x}
} != -1
20 changes: 20 additions & 0 deletions addons/context_actions/functions/fnc_unloadViV.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Unloads vehicles from the objects list.
*
* Arguments:
* N: Objects <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_object] call zen_context_actions_fnc_unloadViV
*
* Public: No
*/

{
if (isNull isVehicleCargo _x) then {_x setVehicleCargo objNull} else {objNull setVehicleCargo _x};
} forEach _this;
18 changes: 18 additions & 0 deletions addons/editor/initKeybinds.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@
};
}, {}, [DIK_G, [false, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + G

[ELSTRING(main,DisplayName), QGVAR(unloadViV), [localize "STR_A3_ModuleDepot_Unload", LSTRING(UnloadViV_Description)], {
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
{
if (isNull isVehicleCargo _x) then {
// Not being carried
if !(getVehicleCargo _x isEqualTo []) then {
_x setVehicleCargo objNull;
};
} else {
// Being carried
objNull setVehicleCargo _x;
};
} forEach SELECTED_OBJECTS;

true // handled, prevents vanilla eject
};
}, {}, [DIK_G, [false, false, true]]] call CBA_fnc_addKeybind; // Default: ALT + G

[ELSTRING(main,DisplayName), QGVAR(deepCopy), [LSTRING(DeepCopy), LSTRING(DeepCopy_Description)], {
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
private _position = [nil, false] call EFUNC(common,getPosFromScreen);
Expand Down
3 changes: 3 additions & 0 deletions addons/editor/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@
<Polish>Wysadza pasażerów ze wszystkich wybranych pojazdów. Jeżeli pojazd jest w powietrzu, pasażerowie dostaną spadochron.\nJednostki zostaną wysadzone jedna po drugiej (nie wszystkie na raz).</Polish>
<Japanese>選択された全車両から後部座席のユニットを脱出させます。もし車両が飛行中の場合はパラシュートが与えられます。\nなお脱出は一人づつ降りるようになっています (即時ではなく数秒づつ)。</Japanese>
</Key>
<Key ID="STR_ZEN_Editor_UnloadViV_Description">
<English>Unloads all selected Vehicle-in-Vehicle cargo and carriers. A vehicle that is simultaneously both is unloaded from its carrier.</English>
</Key>
<Key ID="STR_ZEN_Editor_DeployCountermeasures">
<English>Deploy Countermeasures</English>
<French>Déployer des contre-mesures</French>
Expand Down