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

Fix Cancel (RMB) Action #3524

Merged
merged 2 commits into from
Mar 6, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions addons/explosives/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP(addExplosiveActions);
PREP(addToSpeedDial);
PREP(addTransmitterActions);
PREP(addTriggerActions);
PREP(cancelPlacement);
PREP(canDefuse);
PREP(canDetonate);
PREP(connectExplosive);
Expand Down
1 change: 1 addition & 0 deletions addons/explosives/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
params ["_display"];

_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelPlacement)}];
23 changes: 23 additions & 0 deletions addons/explosives/functions/fnc_cancelPlacement.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Author: Garth 'L-H' de Wet
* Cancels explosives placement.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Key <NUMBER>
*
* Return Value:
* None
*
* Example:
* [unit, 1] call ace_explosives_fnc_cancelPlacement
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit", "_key"];

if (_key != 1 || {!GVAR(pfeh_running)}) exitWith {};

GVAR(placeAction) = PLACE_CANCEL;
8 changes: 4 additions & 4 deletions addons/explosives/functions/fnc_setupExplosive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ GVAR(TweakedAngle) = 0;
//Don't allow placing in a bad position:
if (_badPosition && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;};

if (((inputAction "zoomTemp") > 0) || //Cancel on RMB, For some reason this works (when held) but AddActionEventHandler doesn't
{_unit != ACE_player} ||
{!([_unit, objNull, ["isNotSwimming"]] call EFUNC(common,canInteractWith))} ||
{!(_magClassname in (magazines _unit))}) then {
if (_unit != ACE_player ||
{!([_unit, objNull, ["isNotSwimming"]] call EFUNC(common,canInteractWith))} ||
{!(_magClassname in (magazines _unit))}
) then {
GVAR(placeAction) = PLACE_CANCEL;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to remove this entire if statement, just the RMB part.
All of the other checks need to be run each frame in the PFEH so it will cancel if any of them happen.
e.g. if canInteractWith is false, we need to cancel right away instead of waiting for RMB

};

Expand Down
1 change: 1 addition & 0 deletions addons/sandbag/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
params ["_display"];

_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(deployCancel)}];
6 changes: 0 additions & 6 deletions addons/sandbag/functions/fnc_deploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,4 @@ _unit setVariable [QGVAR(Deploy), [
{[_this select 0] call FUNC(deployConfirm)}
] call EFUNC(common,addActionEventHandler)];

_unit setVariable [QGVAR(Cancel), [
_unit, "zoomtemp",
{GVAR(deployPFH) != -1},
{[_this select 0] call FUNC(deployCancel)}
] call EFUNC(common,addActionEventHandler)];

_unit setVariable [QGVAR(isDeploying), true, true];
7 changes: 5 additions & 2 deletions addons/sandbag/functions/fnc_deployCancel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Cancels sandbag deployment
*
* Arguments:
* 0: unit <OBJECT>
* 0: Unit <OBJECT>
* 1: Key <NUMBER>
*
* Return Value:
* None
Expand All @@ -15,7 +16,9 @@
*/
#include "script_component.hpp"

params ["_unit"];
params ["_unit", "_key"];

if (_key != 1 || {GVAR(deployPFH) == -1}) exitWith {};

// enable running again
[_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set);
Expand Down
1 change: 0 additions & 1 deletion addons/sandbag/functions/fnc_deployConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ GVAR(deployPFH) = -1;
call EFUNC(interaction,hideMouseHint);

[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);

// play animation
_unit playActionNow "PutDown";
Expand Down
1 change: 1 addition & 0 deletions addons/tacticalladder/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
params ["_display"];

_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelTLdeploy)}];
15 changes: 8 additions & 7 deletions addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Cancel tactical ladder deployment
*
* Arguments:
* 0: unit <OBJECT>
* 1: ladder <OBJECT>
* 0: Unit <OBJECT>
* 1: Key <NUMBER>
*
* Return Value:
* None
Expand All @@ -18,23 +18,24 @@

#define __ANIMS ["extract_1","extract_2","extract_3","extract_4","extract_5","extract_6","extract_7","extract_8","extract_9","extract_10","extract_11"]

params ["_unit", "_ladder"];
params ["_unit", "_key"];

if (_key != 1 || {isNull GVAR(ladder)}) exitWith {};

// enable running again
[_unit, "forceWalk", "ACE_Ladder", false] call EFUNC(common,statusEffect_set);

detach _ladder;
detach GVAR(ladder);

_ladder animate ["rotate", 0];
GVAR(ladder) animate ["rotate", 0];

{
_ladder animate [_x, 0];
GVAR(ladder) animate [_x, 0];
} count __ANIMS;

// remove mouse buttons and hint
call EFUNC(interaction,hideMouseHint);

[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler);

GVAR(ladder) = objNull;
1 change: 0 additions & 1 deletion addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ detach _ladder;
call EFUNC(interaction,hideMouseHint);

[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);

GVAR(ladder) = objNull;

Expand Down
6 changes: 0 additions & 6 deletions addons/tacticalladder/functions/fnc_positionTL.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,3 @@ _unit setVariable [QGVAR(Deploy), [
{!isNull GVAR(ladder)},
{[_this select 0, GVAR(ladder)] call FUNC(confirmTLdeploy)}
] call EFUNC(common,addActionEventHandler)];

_unit setVariable [QGVAR(Cancel), [
_unit, "zoomtemp",
{!isNull GVAR(ladder)},
{[_this select 0, GVAR(ladder)] call FUNC(cancelTLdeploy)}
] call EFUNC(common,addActionEventHandler)];
1 change: 1 addition & 0 deletions addons/trenches/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
params ["_display"];

_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(placeCancel)}];
8 changes: 5 additions & 3 deletions addons/trenches/functions/fnc_placeCancel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Cancels trench dig
*
* Arguments:
* 0: unit <OBJECT>
* 0: Unit <OBJECT>
* 1: Key <NUMBER>
*
* Return Value:
* None
Expand All @@ -15,7 +16,9 @@
*/
#include "script_component.hpp"

params ["_unit"];
params ["_unit", "_key"];

if (_key != 1 || {GVAR(digPFH) == -1}) exitWith {};

// enable running again
[_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set);
Expand All @@ -31,6 +34,5 @@ GVAR(digPFH) = -1;
call EFUNC(interaction,hideMouseHint);

[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);

_unit setVariable [QGVAR(isPlacing), false, true];
1 change: 0 additions & 1 deletion addons/trenches/functions/fnc_placeConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ GVAR(digPFH) = -1;
call EFUNC(interaction,hideMouseHint);

[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);

_unit setVariable [QGVAR(isPlacing), false, true];

Expand Down
6 changes: 0 additions & 6 deletions addons/trenches/functions/fnc_placeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,4 @@ _unit setVariable [QGVAR(Dig), [
{[_this select 0] call FUNC(placeConfirm)}
] call EFUNC(common,addActionEventHandler)];

_unit setVariable [QGVAR(Cancel), [
_unit, "zoomtemp",
{GVAR(digPFH) != -1},
{[_this select 0] call FUNC(placeCancel)}
] call EFUNC(common,addActionEventHandler)];

_unit setVariable [QGVAR(isPlacing), true, true];