From 41e1b25397bd849b4e09be98cc1f69a147c27578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Thu, 21 Sep 2017 17:24:58 +0300 Subject: [PATCH] Refuel: Turn on nozzle after connection (#5426) * Turn on nozzle after connection * Remove some superflous progress bars * Handle tempFuel var * Handle conflicts 2: conflict harder * Remove duplicate code --- .../functions/fnc_connectNozzleAction.sqf | 7 +++ .../refuel/functions/fnc_readFuelCounter.sqf | 28 ++++------- addons/refuel/functions/fnc_turnOff.sqf | 18 ++------ addons/refuel/functions/fnc_turnOn.sqf | 18 ++------ addons/refuel/stringtable.xml | 46 +------------------ 5 files changed, 23 insertions(+), 94 deletions(-) diff --git a/addons/refuel/functions/fnc_connectNozzleAction.sqf b/addons/refuel/functions/fnc_connectNozzleAction.sqf index 1c6c3b7dbf..ac3906499c 100644 --- a/addons/refuel/functions/fnc_connectNozzleAction.sqf +++ b/addons/refuel/functions/fnc_connectNozzleAction.sqf @@ -122,6 +122,13 @@ private _attachPosModel = _sink worldToModel (ASLtoAGL _bestPosASL); }; [_unit, _sink, _nozzle, _endPosTestOffset] call FUNC(refuel); + + if ([_unit, _nozzle] call FUNC(canTurnOn)) then { + _unit setVariable [QGVAR(tempFuel), nil]; + [_unit, _nozzle] call FUNC(turnOn); + } else { + [LSTRING(CouldNotTurnOn)] call EFUNC(common,displayText); + }; }, "", localize LSTRING(ConnectAction), diff --git a/addons/refuel/functions/fnc_readFuelCounter.sqf b/addons/refuel/functions/fnc_readFuelCounter.sqf index 08f4010fde..70c6a2799b 100644 --- a/addons/refuel/functions/fnc_readFuelCounter.sqf +++ b/addons/refuel/functions/fnc_readFuelCounter.sqf @@ -18,24 +18,12 @@ params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]]; -[ - TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), - [_unit, _source], - { - params ["_args"]; - _args params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]]; +private _currentFuel = [_source] call FUNC(getFuel); +private _fuelCounter = if (_currentFuel == REFUEL_INFINITE_FUEL) then { + _source getVariable [QGVAR(fuelCounter), 0] +} else { + (_source getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel +}; - private _currentFuel = [_source] call FUNC(getFuel); - if (_currentFuel == REFUEL_INFINITE_FUEL) then { - private _fuelCounter = 0.01 * round (100 * (_source getVariable [QGVAR(fuelCounter), 0])); - [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); - } else { - private _fuelCounter = 0.01 * round (100 * ((_source getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel)); - [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); - }; - }, - "", - localize LSTRING(CheckFuelCounterAction), - {true}, - [INTERACT_EXCEPTIONS] -] call EFUNC(common,progressBar); +private _fuelCounter = 0.01 * round (100 * _fuelCounter); +[[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); diff --git a/addons/refuel/functions/fnc_turnOff.sqf b/addons/refuel/functions/fnc_turnOff.sqf index d4733a9cd8..067d59c51e 100644 --- a/addons/refuel/functions/fnc_turnOff.sqf +++ b/addons/refuel/functions/fnc_turnOff.sqf @@ -18,18 +18,6 @@ params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]]; -[ - TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), - [_unit, _nozzle], - { - params ["_args"]; - _args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]]; - _nozzle setVariable [QGVAR(lastTickMissionTime), nil]; - _nozzle setVariable [QGVAR(isRefueling), false, true]; - [LSTRING(Hint_Stopped), 1.5, _unit] call EFUNC(common,displayTextStructured); - }, - "", - localize LSTRING(TurnOffAction), - {true}, - [INTERACT_EXCEPTIONS] -] call EFUNC(common,progressBar); +_nozzle setVariable [QGVAR(lastTickMissionTime), nil]; +_nozzle setVariable [QGVAR(isRefueling), false, true]; +[LSTRING(Hint_Stopped), 1.5, _unit] call EFUNC(common,displayTextStructured); diff --git a/addons/refuel/functions/fnc_turnOn.sqf b/addons/refuel/functions/fnc_turnOn.sqf index cf70a28d3b..e57cd3725a 100644 --- a/addons/refuel/functions/fnc_turnOn.sqf +++ b/addons/refuel/functions/fnc_turnOn.sqf @@ -18,18 +18,6 @@ params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]]; -[ - TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), - [_unit, _nozzle], - { - params ["_args"]; - _args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]]; - _nozzle setVariable [QGVAR(lastTickMissionTime), CBA_missionTime]; - _nozzle setVariable [QGVAR(isRefueling), true, true]; - [LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured); - }, - "", - localize LSTRING(TurnOnAction), - {true}, - [INTERACT_EXCEPTIONS] -] call EFUNC(common,progressBar); +_nozzle setVariable [QGVAR(lastTickMissionTime), CBA_missionTime]; +_nozzle setVariable [QGVAR(isRefueling), true, true]; +[LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured); diff --git a/addons/refuel/stringtable.xml b/addons/refuel/stringtable.xml index f8320c1691..bb533aa3fa 100644 --- a/addons/refuel/stringtable.xml +++ b/addons/refuel/stringtable.xml @@ -256,21 +256,6 @@ 停止加油 停止加油 - - Stopping fueling... - Stoppe Betankung... - Zatrzymywanie tankowania... - Останавливаем заправку... - Parando reabastecimento... - Zastavuji tankování... - Fermando il rifornimento... - Deteniendo reabastecimiento... - Arrête le ravitaillement... - 給油をやめている・・・ - 재급유 그만하는중... - 停止加油中... - 停止加油中... - Start fueling Betankung beginnen @@ -286,20 +271,8 @@ 开始加油 開始加油 - - Starting fueling... - Beginne Betankung... - Rozpoczynanie tankowania... - Начинаем заправку... - Começando reabastecimento... - Spouštím tankování... - Iniziando il rifornimento... - Comenzando reabastecimiento... - Début du ravitaillement... - 給油を始めている・・・ - 재급유 시작중... - 开始加油中... - 開始加油中... + + Couldn't turn on fuel nozzle %1 Liters fueled @@ -436,21 +409,6 @@ 检查燃料表 檢查燃料表 - - Checking fuel counter... - Betrachte Tankuhr... - Sprawdzanie wskaźnika paliwa... - Проверяем счетчик топлива... - Verificando contador de combustível... - Konroluji palivoměr... - Controllando l'indicatore del livello benzina... - Verificando el contador de combustible - Vérification du compteur... - 燃料計を見ている・・・ - 연료카운터 확인중... - 检查燃料表中... - 檢查燃料表中... - %1 liters have been fueled. %1 Liter wurden getankt.