Non GSX Fuel setting

This commit is contained in:
2026-02-12 21:27:12 +01:00
parent 310b5f39dc
commit 122a93461d
31 changed files with 2328 additions and 8267 deletions
@@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
import { WASMDataPax } from '../../types/WASMData';
import { LoadingState, SimBrief } from '../../types/general';
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
import { CoherentCallSBEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
import { CoherentCallSBEntryPax, loadAircraft, unloadAircraft } from '../../utils/utils';
import CGSelect from '../CGSelect/CGSelect';
import ActionBar from '../actionbar/ActionBar';
import Input from '../input/Input';
@@ -16,7 +16,7 @@ interface SBEntryProps {
const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
const [fuel, setFuel] = useState(Math.round(WASMData.targetPayload.fuel));
const [fuelEnabled, setFuelEnabled] = useState(true);
const [SBInFlight, setSBInFlight] = useState(false);
@@ -52,6 +52,10 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
}
};
const updateData = (SBPlan?: SimBrief, _fuel?: number) => {
CoherentCallSBEntryPax(CGTarget, _fuel ?? fuel, SBPlan);
};
useEffect(() => {
if (!simBrief || gsxActive) return;
@@ -70,12 +74,17 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
return;
}
updateData(undefined, SBResponse.message as SimBrief);
const _fuel = parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0;
updateData(SBResponse.message as SimBrief, _fuel);
setFuel(_fuel);
setFuel(parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0);
setSBInFlight(false);
}, [simBrief, gsxActive]);
useEffect(() => updateData(), [CGTarget, fuel]);
useEffect(
() =>
setFuel((prev) => {
@@ -84,13 +93,6 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
}),
[WASMData.userData.isER]
);
useEffect(() => {
setFuelEnabled((prev) => (!prev ? inRangeOf(Math.round(WASMData.livePayload.fuel), fuel) : prev));
}, [WASMData.livePayload.fuel]);
const updateData = (_CGTarget?: number, SBPlan?: SimBrief) => {
CoherentCallSBEntryPax(_CGTarget ?? CGTarget, SBPlan);
};
return (
<>
@@ -106,22 +108,6 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
onChange={(value) => handleInput(value, WASMData.limits.maxFuel, setFuel)}
disabled={loadingState !== 'preview' || gsxActive}
/>
<button
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
data-ripple-light="true"
onClick={() => {
SimVar.SetSimVarValue(
'L:MD11_EFB_PAYLOAD_FUEL',
'lbs',
WASMData.userData.isImperial ? fuel : fuel * 2.20462262185
);
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
setFuelEnabled(WASMData.livePayload.fuel === fuel);
}}
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
>
Load Fuel
</button>
</div>
</div>
</div>
@@ -164,14 +150,12 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLo
increase={() =>
setCGTarget((prev) => {
const _new = prev + 0.1;
updateData(_new);
return _new;
})
}
decrease={() =>
setCGTarget((prev) => {
const _new = prev - 0.1;
updateData(_new);
return _new;
})
}