diff --git a/package.json b/package.json index b3685991..14fbfa9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "icarus", - "version": "0.10.0", + "version": "0.11.0", "description": "ICARUS Terminal for Elite Dangerous", "scripts": { "build": "npm run build:web && npm run build:app && npm run build:service && npm run build:package", diff --git a/src/service/lib/event-handlers/inventory.js b/src/service/lib/event-handlers/inventory.js index 9d1ae08b..5f0007a0 100644 --- a/src/service/lib/event-handlers/inventory.js +++ b/src/service/lib/event-handlers/inventory.js @@ -10,10 +10,10 @@ class Inventory { const shipLocker = (await this.eliteJson.json()).ShipLocker if (!shipLocker) return [] - const inventory = [] + const inventoryItems = [] shipLocker.Consumables.forEach(item => { - let itemInInventory = inventory.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] + let itemInInventory = inventoryItems.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] if (!itemInInventory) { itemInInventory = { name: item?.Name_Localised ?? item.Name, @@ -22,7 +22,7 @@ class Inventory { stolen: 0, count: 0 } - inventory.push(itemInInventory) + inventoryItems.push(itemInInventory) } itemInInventory.count += item.Count @@ -31,7 +31,7 @@ class Inventory { }) shipLocker.Items.forEach(item => { - let itemInInventory = inventory.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] + let itemInInventory = inventoryItems.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] if (!itemInInventory) { itemInInventory = { name: item?.Name_Localised ?? item.Name, @@ -40,7 +40,7 @@ class Inventory { stolen: 0, count: 0 } - inventory.push(itemInInventory) + inventoryItems.push(itemInInventory) } itemInInventory.count += item.Count @@ -49,7 +49,7 @@ class Inventory { }) shipLocker.Components.forEach(item => { - let itemInInventory = inventory.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] + let itemInInventory = inventoryItems.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] if (!itemInInventory) { itemInInventory = { name: item?.Name_Localised ?? item.Name, @@ -58,7 +58,7 @@ class Inventory { stolen: 0, count: 0 } - inventory.push(itemInInventory) + inventoryItems.push(itemInInventory) } itemInInventory.count += item.Count @@ -67,7 +67,7 @@ class Inventory { }) shipLocker.Data.forEach(item => { - let itemInInventory = inventory.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] + let itemInInventory = inventoryItems.filter(i => i.name === (item?.Name_Localised ?? item.Name))[0] if (!itemInInventory) { itemInInventory = { name: item?.Name_Localised ?? item.Name, @@ -76,7 +76,7 @@ class Inventory { stolen: 0, count: 0 } - inventory.push(itemInInventory) + inventoryItems.push(itemInInventory) } itemInInventory.count += item.Count @@ -84,9 +84,22 @@ class Inventory { if (item.OwnerID > 0) itemInInventory.stolen += item.Count }) - inventory.sort((a, b) => a.name.localeCompare(b.name)) + inventoryItems.sort((a, b) => a.name.localeCompare(b.name)) - return inventory + const counts = { + goods: 0, + components: 0, + data: 0, + } + + inventoryItems.filter(i => i.type === 'Goods').forEach(item => counts.goods += item.count) + inventoryItems.filter(i => i.type === 'Component').forEach(item => counts.components += item.count) + inventoryItems.filter(i => i.type === 'Data').forEach(item => counts.data += item.count) + + return { + counts, + items: inventoryItems + } } } diff --git a/src/service/lib/event-handlers/nav-route.js b/src/service/lib/event-handlers/nav-route.js index fd391db8..c6a3ea69 100644 --- a/src/service/lib/event-handlers/nav-route.js +++ b/src/service/lib/event-handlers/nav-route.js @@ -11,6 +11,8 @@ class NavRoute { async getNavRoute () { const currentSystem = await this.system.getSystem() + + let inSystemOnRoute = false let jumpsToDestination = null const route = ((await this.eliteJson.json())?.NavRoute?.Route ?? []).map(system => { @@ -22,6 +24,9 @@ class NavRoute { //const isCurrentSystem = (distanceToHop === 0) const isCurrentSystem = (system?.StarSystem?.toLowerCase() === currentSystem?.name?.toLowerCase()) + if (isCurrentSystem) + inSystemOnRoute = true + if (isCurrentSystem) { jumpsToDestination = 0 } else { @@ -42,7 +47,8 @@ class NavRoute { currentSystem, destination: route?.[route.length - 1] ?? [], jumpsToDestination, - route + route, + inSystemOnRoute } return navRoute diff --git a/src/web/components/panels/nav/system-map.js b/src/web/components/panels/nav/system-map.js index 5d402be6..3d3e1dbd 100644 --- a/src/web/components/panels/nav/system-map.js +++ b/src/web/components/panels/nav/system-map.js @@ -3,7 +3,7 @@ import CopyOnClick from 'components/copy-on-click' const factionStates = { expansion: { - description: 'Controlling faction expanding influence' + description: 'Faction expanding influence' }, investment: { description: 'Ongoing investment, expansion anticipated' @@ -24,7 +24,7 @@ const factionStates = { description: 'Economy bust' }, civilUnrest: { - description: 'Civil Unrest ,support & bounty missions' + description: 'Civil Unrest, support & bounty missions' }, famine: { description: 'Famine, demand for food, support missions' @@ -36,7 +36,7 @@ const factionStates = { description: 'Lockdown, services restricted, support missions' }, retreat: { - description: 'Controlling faction retreating from system' + description: 'Faction retreating from system' }, naturalDisaster: { description: 'Natural disaster, support missions available' @@ -65,9 +65,9 @@ export default function SystemMap ({ system, setSystemObject }) {

- + - {system.name}  + {system.name}

{system.detail && system.detail.bodies && system.detail.bodies.length > 0 && diff --git a/src/web/components/panels/ship/ship-modules-panel.js b/src/web/components/panels/ship/ship-modules-panel.js index d7bc200b..00a9d342 100644 --- a/src/web/components/panels/ship/ship-modules-panel.js +++ b/src/web/components/panels/ship/ship-modules-panel.js @@ -1,7 +1,7 @@ import { UNKNOWN_VALUE } from '../../../../shared/consts' import ShipModules from './ship-modules' -export default function ShipModulesPanel ({ ship, selectedModule, setSelectedModule }) { +export default function ShipModulesPanel ({ ship, selectedModule, setSelectedModule, cmdrStatus }) { if (!ship) return null if (ship.type === UNKNOWN_VALUE && ship.name === UNKNOWN_VALUE && ship.ident === UNKNOWN_VALUE) { @@ -39,38 +39,147 @@ export default function ShipModulesPanel ({ ship, selectedModule, setSelectedMod
- - - - - - - - - - - - - -
- Max jump range - {ship.maxJumpRange || '-'} Ly - - Fuel (curr/max) - {typeof ship?.fuelLevel === 'number' ? ship.fuelLevel : '-'}/{ship.fuelCapacity} T - - Cargo (curr/max) - {typeof ship?.cargo?.count === 'number' ? ship.cargo.count : '-'}/{ship.cargo.capacity} T -
- Insurance Rebuy - {ship.rebuy ? ship.rebuy.toLocaleString() : '-'} CR - - Fuel Reservoir - {typeof ship?.fuelReservoir === 'number' ? ship.fuelReservoir : '-'} - - Total mass - {ship.mass} T -
+ +
+ + + + + + + + + + + + + +
+ Max jump range + {ship.maxJumpRange || '-'} Ly + + Fuel (curr/max) + {typeof ship?.fuelLevel === 'number' ? ship.fuelLevel : '-'}/{ship.fuelCapacity} T + + Cargo (curr/max) + {typeof ship?.cargo?.count === 'number' ? ship.cargo.count : '-'}/{ship.cargo.capacity} T +
+ Insurance Rebuy + {ship.rebuy ? ship.rebuy.toLocaleString() : '-'} CR + + Fuel Reservoir + {typeof ship?.fuelReservoir === 'number' ? ship.fuelReservoir : '-'} + + Total mass + {ship.mass} T +
+ + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + Overheating + + + + Interdiction Detected + + + + Fuel Low + + + + Danger + +
+ + Mass Locked + + + + Frame Shift Cooldown + + + + Frame Shift Charging + + + + Frame Shift Jumping + +
+ + Docked + + + + Supercruise + + + + Fuel Scooping + + + + Flight Assist Off + +
+
+ b.appliedToModules.length === 0)) } const newSystem = await sendEvent('getSystem') - if (newSystem) setCurrentSystem(newSystem) + if (newSystem?.address) setCurrentSystem(newSystem) setComponentReady(true) }, [connected, router.isReady, query]) @@ -38,11 +38,8 @@ export default function EngineeringMaterialsPage () { ? blueprints?.filter(blueprint => query?.symbol.toLowerCase() === blueprint.symbol.toLowerCase())?.[0] ?? null : null setSelectedBlueprint(newSelectedBlueprint) - if (!currentSystem) { - const newSystem = await sendEvent('getSystem') - if (newSystem) setCurrentSystem(newSystem) - } - setComponentReady(true) + const newSystem = await sendEvent('getSystem') + if (newSystem?.address) setCurrentSystem(newSystem) }, [blueprints, query]) useEffect(() => eventListener('newLogEntry', async (log) => { @@ -54,7 +51,7 @@ export default function EngineeringMaterialsPage () { } if (['Location', 'FSDJump'].includes(log.event)) { const newSystem = await sendEvent('getSystem') - if (newSystem) setCurrentSystem(newSystem) + if (newSystem?.address) setCurrentSystem(newSystem) } }), []) @@ -148,12 +145,12 @@ export default function EngineeringMaterialsPage () { key={`engineering_${module.engineering.symbol}_applied-to_${module.name}_slot_${module.slot}`} className='table__row--highlighted' > - - {module.class}{module.rating} {module.name} -
{module.slotName}
+ + {module.slotName} - - {module.slotName} + + {module.slotName}
+ {module.class}{module.rating} {module.name} @@ -187,15 +184,27 @@ export default function EngineeringMaterialsPage () {

Engineers

- +
{Object.keys(selectedBlueprint?.engineers ?? []).map(engineer => ( + ))} diff --git a/src/web/pages/nav/route.js b/src/web/pages/nav/route.js index 512dca60..4c58b86c 100644 --- a/src/web/pages/nav/route.js +++ b/src/web/pages/nav/route.js @@ -77,17 +77,25 @@ export default function NavListPage () {

Destination

-

{navRoute?.destination?.system}

+

{navRoute?.destination?.system}

}
{engineer} + +
+ { + Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades) !== Math.max(...selectedBlueprint?.engineers?.[engineer]?.grades) && + `Grade ${Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades)} — ${Math.max(...selectedBlueprint?.engineers?.[engineer]?.grades)}` + } + { + Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades) === Math.max(...selectedBlueprint?.engineers?.[engineer]?.grades) && + `Grade ${Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades)}` + } +
-
+
{ Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades) !== Math.max(...selectedBlueprint?.engineers?.[engineer]?.grades) && `Grade ${Math.min(...selectedBlueprint?.engineers?.[engineer]?.grades)} — ${Math.max(...selectedBlueprint?.engineers?.[engineer]?.grades)}` @@ -206,12 +215,15 @@ export default function EngineeringMaterialsPage () { } - - {selectedBlueprint?.engineers[engineer]?.system} - {(currentSystem?.position && selectedBlueprint?.engineers[engineer]?.location) && <> -
- {distance(currentSystem.position, selectedBlueprint?.engineers[engineer]?.location).toLocaleString(undefined, { maximumFractionDigits: 0 })} LY - } + + {selectedBlueprint?.engineers[engineer]?.system} + + {(currentSystem?.position && selectedBlueprint?.engineers[engineer]?.location) && + +
+ {' '} + {distance(currentSystem.position, selectedBlueprint?.engineers[engineer]?.location).toLocaleString(undefined, { maximumFractionDigits: 0 })} Ly +
}
- {navRoute && navRoute.route.length > 0 && navRoute?.jumpsToDestination > 0 && + {navRoute?.route?.length > 0 && navRoute?.jumpsToDestination > 0 &&

- {navRoute.jumpsToDestination === 1 ? `${navRoute.jumpsToDestination} jump` : `${navRoute.jumpsToDestination} jumps`} / {navRoute.destination.distance.toLocaleString(undefined, { maximumFractionDigits: 2 })} Ly to {navRoute.destination.system} + {navRoute.destination.distance.toLocaleString(undefined, { maximumFractionDigits: 2 })} Ly + {' '} + {navRoute.inSystemOnRoute && + <>({navRoute.jumpsToDestination === 1 ? `${navRoute.jumpsToDestination} jump` : `${navRoute.jumpsToDestination} jumps`})} + {' '}to destination

} - {navRoute && navRoute.route.length > 0 && + {navRoute?.inSystemOnRoute === false && +

+ Use the galaxy map to plot a new route. +

} + {navRoute?.route?.length > 0 && <>
@@ -113,13 +121,13 @@ export default function NavListPage () { {route.starClass.match(/([OBAFGKM])/) ? 'Fuel Star' : Not Fuel Star} {route?.isCurrentSystem === false &&
{route.distance.toLocaleString(undefined, { maximumFractionDigits: 2 })} Ly
} - {route?.isCurrentSystem === true &&
Current Location
} + {route?.isCurrentSystem === true && <>
Current Location}
) diff --git a/src/web/pages/ship/inventory.js b/src/web/pages/ship/inventory.js index 53c08825..096735b3 100644 --- a/src/web/pages/ship/inventory.js +++ b/src/web/pages/ship/inventory.js @@ -28,17 +28,17 @@ export default function ShipInventoryPage () { <> -

Inventory

+

Item Storage

Ship Locker


{inventory && <> - item.type === 'Consumable')} /> - item.type === 'Goods')} /> - item.type === 'Component')} /> - item.type === 'Data')} /> + item.type === 'Consumable')} /> + item.type === 'Goods')} /> + item.type === 'Component')} /> + item.type === 'Data')} /> }
@@ -46,14 +46,28 @@ export default function ShipInventoryPage () { ) } -function LockerItems ({ heading, items }) { +function LockerItems ({ heading, items, count = false, max = false }) { return ( <>

{heading}

+ {count !== false && +

+ + 0 ? '' : 'text-muted'}`}>{count} + /1000 + + +

}
+
- {route?.isCurrentSystem === false && {route.distance.toLocaleString(undefined, { maximumFractionDigits: 2 })} Ly} - {route?.isCurrentSystem === true && Current Location} + {route?.isCurrentSystem === false && {route.distance.toLocaleString(undefined, { maximumFractionDigits: 2 })} Ly} + {route?.isCurrentSystem === true && <>Current Location}
{items.length === 0 && } @@ -69,7 +83,10 @@ function LockerItems ({ heading, items }) { {items.map(item => ( - + @@ -82,6 +99,7 @@ function LockerItems ({ heading, items }) { }
No {heading}
{item.count} + 0 ? '' : 'text-muted'}`}>{item.count} + {max !== false && /{max}} + {item.name}
+
) } diff --git a/src/web/pages/ship/modules.js b/src/web/pages/ship/modules.js index 5b74a28a..12aa95fb 100644 --- a/src/web/pages/ship/modules.js +++ b/src/web/pages/ship/modules.js @@ -10,24 +10,30 @@ export default function ShipModulesPage () { const { connected, active, ready } = useSocket() const [ship, setShip] = useState() const [selectedModule, setSelectedModule] = useState() + const [cmdrStatus, setCmdrStatus] = useState() useEffect(async () => { if (!connected) return setShip(await sendEvent('getShipStatus')) + setCmdrStatus(await sendEvent('getCmdrStatus')) }, [connected, ready]) useEffect(() => eventListener('gameStateChange', async () => { setShip(await sendEvent('getShipStatus')) + setCmdrStatus(await sendEvent('getCmdrStatus')) }), []) - useEffect(() => eventListener('newLogEntry', async () => { + useEffect(() => eventListener('newLogEntry', async (log) => { setShip(await sendEvent('getShipStatus')) + if (['Location', 'FSDJump'].includes(log.event)) { + setCmdrStatus(await sendEvent('getCmdrStatus')) + } }), []) return ( - +