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

Refuel - Fix editor fuel sources #10536

Merged
merged 1 commit into from
Dec 8, 2024
Merged
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
114 changes: 60 additions & 54 deletions addons/refuel/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
#include "script_component.hpp"

// Menus and initSource EH need to be defined before the server raises the EH on the client, otherwise it won't add the actions
if (hasInterface) then {
GVAR(mainAction) = [
QGVAR(Refuel),
localize LSTRING(Refuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{},
{
alive _target
&& {[_player, _target, [INTERACT_EXCEPTIONS]] call EFUNC(common,canInteractWith)}
&& {REFUEL_DISABLED_FUEL != ([_target] call FUNC(getCapacity))}
},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);

GVAR(actions) = [
[QGVAR(TakeNozzle),
localize LSTRING(TakeNozzle),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(TakeNozzle)},
{[_player, _target] call FUNC(canTakeNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuelCounter),
localize LSTRING(CheckFuelCounter),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(readFuelCounter)},
{true},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuel),
localize LSTRING(CheckFuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(checkFuel)},
{[_player, _target] call FUNC(canCheckFuel)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(Return),
localize LSTRING(Return),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(returnNozzle)},
{[_player, _target] call FUNC(canReturnNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction)
];

[QGVAR(initSource), LINKFUNC(initSource)] call CBA_fnc_addEventHandler;
};

["CBA_settingsInitialized", {
if (!GVAR(enabled)) exitWith {};
if (!GVAR(enabled)) exitWith {
GVAR(mainAction) = nil;
GVAR(actions) = nil;
};

["All", "InitPost", {
params ["_vehicle"];
Expand Down Expand Up @@ -58,63 +115,12 @@
} forEach _baseStaticClasses;
};

[QGVAR(initSource), LINKFUNC(initSource)] call CBA_fnc_addEventHandler;

if (!hasInterface) exitWith {};

["isNotRefueling", {!((_this select 0) getVariable [QGVAR(isRefueling), false])}] call EFUNC(common,addCanInteractWithCondition);

["MouseButtonDown", LINKFUNC(onMouseButtonDown)] call CBA_fnc_addDisplayHandler;

GVAR(mainAction) = [
QGVAR(Refuel),
localize LSTRING(Refuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{},
{
alive _target
&& {[_player, _target, [INTERACT_EXCEPTIONS]] call EFUNC(common,canInteractWith)}
&& {REFUEL_DISABLED_FUEL != ([_target] call FUNC(getCapacity))}
},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);

GVAR(actions) = [
[QGVAR(TakeNozzle),
localize LSTRING(TakeNozzle),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(TakeNozzle)},
{[_player, _target] call FUNC(canTakeNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuelCounter),
localize LSTRING(CheckFuelCounter),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(readFuelCounter)},
{true},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuel),
localize LSTRING(CheckFuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(checkFuel)},
{[_player, _target] call FUNC(canCheckFuel)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(Return),
localize LSTRING(Return),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(returnNozzle)},
{[_player, _target] call FUNC(canReturnNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction)
];

private _staticClasses = keys (uiNamespace getVariable QGVAR(cacheRefuelClassesStatic));
private _baseDynamicClasses = keys (uiNamespace getVariable QGVAR(cacheRefuelClassesBaseDynamic));

Expand All @@ -125,7 +131,7 @@
{
[_className, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToClass);
} forEach GVAR(actions);
TRACE_1("add menu to static",_x);
TRACE_1("add menu to static",_className);
} forEach _staticClasses;

{
Expand All @@ -134,7 +140,7 @@
{
[_className, 0, ["ACE_MainActions", QGVAR(Refuel)], _x, true] call EFUNC(interact_menu,addActionToClass);
} forEach GVAR(actions);
TRACE_1("add menu to dynamic",_x);
TRACE_1("add menu to dynamic",_className);
} forEach _baseDynamicClasses;

#ifdef DRAW_HOOKS_POS
Expand Down
Loading