diff --git a/index.html b/index.html index cf8ace0..fd1cf52 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,7 @@

+
@@ -27,22 +28,62 @@
Mapped Value
+
-
- {{ currentLocation }} +
+ + {{ currentLocation.name }}
+
+
-
+
+
+ +
+ + {{ body.BodyName.replace(body.StarSystem, '') }} +
+ +
+ + {{ body.PlanetClass || body.StarType || '' }} +
+ +
+ {{ Intl.NumberFormat().format(Math.round(body.DistanceFromArrivalLS)) }} +
+ +
+ +
+
+
@@ -51,6 +92,7 @@

+
@@ -60,6 +102,7 @@
Mapped Value
+

diff --git a/journal examples.txt b/journal examples.txt index 3b42017..7235a9e 100644 --- a/journal examples.txt +++ b/journal examples.txt @@ -7,15 +7,27 @@ COMPLETED SYSTEM FSS SCAN UNCOMPLETE DISCOVERY SCAN { "timestamp":"2023-05-08T19:17:44Z", "event":"FSSDiscoveryScan", "Progress":0.239641, "BodyCount":7, "NonBodyCount":17, "SystemName":"LHS 551", "SystemAddress":22660650050977 } -AUTO SCAN +AUTO SCAN - STAR { "timestamp":"2023-05-08T19:13:58Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"LHS 119 A", "BodyID":1, "Parents":[ {"Null":0} ], "StarSystem":"LHS 119", "SystemAddress":18262603605409, "DistanceFromArrivalLS":0.000000, "StarType":"M", "Subclass":4, "StellarMass":0.214844, "Radius":267243648.000000, "AbsoluteMagnitude":11.148788, "Age_MY":11724, "SurfaceTemperature":2175.000000, "Luminosity":"V", "SemiMajorAxis":3448964357376.098633, "Eccentricity":0.010115, "OrbitalInclination":-105.666674, "Periapsis":272.289207, "OrbitalPeriod":18957803249.359131, "AscendingNode":-65.823206, "MeanAnomaly":326.300292, "RotationPeriod":131207.524554, "AxialTilt":0.000000, "WasDiscovered":true, "WasMapped":false } -DISCOVERY SCAN - DISCOVERED STAR +AUTO SCAN - ASTROID +{ "timestamp":"2023-05-08T20:34:25Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Aten A A Belt Cluster 8", "BodyID":11, "Parents":[ {"Ring":3}, {"Star":1}, {"Null":0} ], "StarSystem":"Aten", "SystemAddress":16063580284321, "DistanceFromArrivalLS":4.171922, "WasDiscovered":true, "WasMapped":false } + +AUTO SCAN - PLANET +{ "timestamp":"2023-05-04T19:15:34Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector SL-B b14-5 A 2", "BodyID":13, "Parents":[ {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector SL-B b14-5", "SystemAddress":11662043981201, "DistanceFromArrivalLS":14.736108, "TidalLock":true, "TerraformState":"", "PlanetClass":"High metal content body", "Atmosphere":"", "AtmosphereType":"None", "Volcanism":"", "MassEM":0.134842, "Radius":3279249.500000, "SurfaceGravity":4.997877, "SurfaceTemperature":478.828308, "SurfacePressure":0.000000, "Landable":true, "Materials":[ { "Name":"iron", "Percent":21.042704 }, { "Name":"nickel", "Percent":15.915817 }, { "Name":"sulphur", "Percent":15.119031 }, { "Name":"carbon", "Percent":12.713538 }, { "Name":"chromium", "Percent":9.463602 }, { "Name":"manganese", "Percent":8.690421 }, { "Name":"phosphorus", "Percent":8.139426 }, { "Name":"vanadium", "Percent":5.167356 }, { "Name":"niobium", "Percent":1.438156 }, { "Name":"tin", "Percent":1.371430 }, { "Name":"antimony", "Percent":0.938514 } ], "Composition":{ "Ice":0.000000, "Rock":0.675801, "Metal":0.324199 }, "SemiMajorAxis":4417732596.397400, "Eccentricity":0.000022, "OrbitalInclination":0.000008, "Periapsis":115.738785, "OrbitalPeriod":272940.599918, "AscendingNode":-62.515181, "MeanAnomaly":244.149914, "RotationPeriod":273121.869415, "AxialTilt":0.183773, "WasDiscovered":true, "WasMapped":false } + +AUTO SCAN - PLANET WITH RINGS +{ "timestamp":"2023-05-08T20:35:59Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"Aten A 1", "BodyID":12, "Parents":[ {"Star":1}, {"Null":0} ], "StarSystem":"Aten", "SystemAddress":16063580284321, "DistanceFromArrivalLS":1167.434670, "TidalLock":false, "TerraformState":"", "PlanetClass":"Gas giant with water based life", "Atmosphere":"", "AtmosphereComposition":[ { "Name":"Hydrogen", "Percent":73.087502 }, { "Name":"Helium", "Percent":26.864477 } ], "Volcanism":"", "MassEM":728.355774, "Radius":77289928.000000, "SurfaceGravity":48.596746, "SurfaceTemperature":176.230774, "SurfacePressure":0.000000, "Landable":false, "SemiMajorAxis":350418865680.694580, "Eccentricity":0.001707, "OrbitalInclination":0.004975, "Periapsis":338.090969, "OrbitalPeriod":195814841.985703, "AscendingNode":110.765871, "MeanAnomaly":43.859451, "RotationPeriod":115219.325821, "AxialTilt":2.695141, "Rings":[ { "Name":"Aten A 1 A Ring", "RingClass":"eRingClass_Rocky", "MassMT":1.4721e+11, "InnerRad":1.4467e+08, "OuterRad":1.6124e+08 }, { "Name":"Aten A 1 B Ring", "RingClass":"eRingClass_Icy", "MassMT":2.0931e+12, "InnerRad":1.6134e+08, "OuterRad":3.1323e+08 } ], "ReserveLevel":"LowResources", "WasDiscovered":true, "WasMapped":true } + +DISCOVERY SCAN - STAR { "timestamp":"2023-05-08T19:16:19Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"V439 Andromedae B", "BodyID":2, "Parents":[ {"Null":0} ], "StarSystem":"V439 Andromedae", "SystemAddress":2282808677074, "DistanceFromArrivalLS":9823.421969, "StarType":"G", "Subclass":4, "StellarMass":0.894531, "Radius":641376256.000000, "AbsoluteMagnitude":5.081848, "Age_MY":8408, "SurfaceTemperature":5678.000000, "Luminosity":"Vab", "SemiMajorAxis":1226380169391.632080, "Eccentricity":0.205087, "OrbitalInclination":42.869302, "Periapsis":318.335747, "OrbitalPeriod":1559399366.378784, "AscendingNode":108.884004, "MeanAnomaly":170.879935, "RotationPeriod":461309.851688, "AxialTilt":0.000000, "WasDiscovered":true, "WasMapped":false } -FSS SCAN - DISCOVERED BODY +FSS SCAN - PLANET { "timestamp":"2023-05-08T19:18:10Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"LHS 551 3", "BodyID":3, "Parents":[ {"Star":0} ], "StarSystem":"LHS 551", "SystemAddress":22660650050977, "DistanceFromArrivalLS":1145.828346, "TidalLock":false, "TerraformState":"", "PlanetClass":"Icy body", "Atmosphere":"neon rich atmosphere", "AtmosphereType":"NeonRich", "AtmosphereComposition":[ { "Name":"Helium", "Percent":97.112808 }, { "Name":"Neon", "Percent":2.887197 } ], "Volcanism":"minor ammonia magma volcanism", "MassEM":0.786165, "Radius":7230740.000000, "SurfaceGravity":5.993182, "SurfaceTemperature":40.704479, "SurfacePressure":15131.975586, "Landable":false, "Composition":{ "Ice":0.682992, "Rock":0.211345, "Metal":0.105663 }, "SemiMajorAxis":343500107526.779175, "Eccentricity":0.004332, "OrbitalInclination":0.041314, "Periapsis":315.505986, "OrbitalPeriod":217869794.368744, "AscendingNode":1.173041, "MeanAnomaly":90.159583, "RotationPeriod":49998.912442, "AxialTilt":-0.036086, "WasDiscovered":true, "WasMapped":true } +FSS SCAN - ASTROID +{ "timestamp":"2023-05-08T20:38:19Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Aten B A Belt Cluster 2", "BodyID":45, "Parents":[ {"Ring":43}, {"Star":2}, {"Null":0} ], "StarSystem":"Aten", "SystemAddress":16063580284321, "DistanceFromArrivalLS":79972.251687, "WasDiscovered":true, "WasMapped":false } + DETAILED SURFACE SCAN - MAPPED BODY { "timestamp":"2023-05-08T19:22:20Z", "event":"SAAScanComplete", "BodyName":"LHS 551 1", "SystemAddress":22660650050977, "BodyID":1, "ProbesUsed":8, "EfficiencyTarget":8 } { "timestamp":"2023-05-08T19:22:21Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"LHS 551 1", "BodyID":1, "Parents":[ {"Star":0} ], "StarSystem":"LHS 551", "SystemAddress":22660650050977, "DistanceFromArrivalLS":578.392122, "TidalLock":false, "TerraformState":"", "PlanetClass":"Rocky ice body", "Atmosphere":"helium atmosphere", "AtmosphereType":"Helium", "AtmosphereComposition":[ { "Name":"Helium", "Percent":89.334976 }, { "Name":"Hydrogen", "Percent":8.427828 }, { "Name":"Neon", "Percent":2.237205 } ], "Volcanism":"major water geysers volcanism", "MassEM":4.158691, "Radius":10698825.000000, "SurfaceGravity":14.480845, "SurfaceTemperature":58.117901, "SurfacePressure":67337.343750, "Landable":false, "Composition":{ "Ice":0.403397, "Rock":0.397748, "Metal":0.198856 }, "SemiMajorAxis":173410028219.223022, "Eccentricity":0.000081, "OrbitalInclination":-0.013599, "Periapsis":290.186625, "OrbitalPeriod":78148038.387299, "AscendingNode":-3.343060, "MeanAnomaly":332.810795, "RotationPeriod":157634.536311, "AxialTilt":0.224570, "WasDiscovered":true, "WasMapped":true } diff --git a/src/icons/Flaticon.eot b/src/icons/Flaticon.eot new file mode 100644 index 0000000..0e3b78d Binary files /dev/null and b/src/icons/Flaticon.eot differ diff --git a/src/icons/Flaticon.svg b/src/icons/Flaticon.svg new file mode 100644 index 0000000..3e79380 --- /dev/null +++ b/src/icons/Flaticon.svg @@ -0,0 +1,670 @@ + + + + + +Created by FontForge 20170731 at Sun Oct 4 20:48:03 2020 + By root + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/icons/Flaticon.ttf b/src/icons/Flaticon.ttf new file mode 100644 index 0000000..9439414 Binary files /dev/null and b/src/icons/Flaticon.ttf differ diff --git a/src/icons/Flaticon.woff b/src/icons/Flaticon.woff new file mode 100644 index 0000000..7016a77 Binary files /dev/null and b/src/icons/Flaticon.woff differ diff --git a/src/icons/Flaticon.woff2 b/src/icons/Flaticon.woff2 new file mode 100644 index 0000000..f1b1107 Binary files /dev/null and b/src/icons/Flaticon.woff2 differ diff --git a/src/icons/_flaticon.scss b/src/icons/_flaticon.scss new file mode 100644 index 0000000..2ba1e6a --- /dev/null +++ b/src/icons/_flaticon.scss @@ -0,0 +1,110 @@ + /* + Flaticon icon font: Flaticon + Creation date: 04/10/2020 20:48 + */ + + @font-face { + font-family: "Flaticon"; + src: url("./Flaticon.eot"); + src: url("./Flaticon.eot?#iefix") format("embedded-opentype"), + url("./Flaticon.woff2") format("woff2"), + url("./Flaticon.woff") format("woff"), + url("./Flaticon.ttf") format("truetype"), + url("./Flaticon.svg#Flaticon") format("svg"); + font-weight: normal; + font-style: normal; +} + +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: "Flaticon"; + src: url("./Flaticon.svg#Flaticon") format("svg"); + } +} + + .fi:before{ + display: inline-block; + font-family: "Flaticon"; + font-style: normal; + font-weight: normal; + font-variant: normal; + line-height: 1; + text-decoration: inherit; + text-rendering: optimizeLegibility; + text-transform: none; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-smoothing: antialiased; + } + + .flaticon-lander:before { content: "\f100"; } +.flaticon-volcano:before { content: "\f101"; } +.flaticon-cooling-tower:before { content: "\f102"; } +.flaticon-cooling-tower-1:before { content: "\f103"; } +.flaticon-volcano-1:before { content: "\f104"; } +.flaticon-flag-outline-on-a-pole-with-stars-around:before { content: "\f105"; } +.flaticon-saturn:before { content: "\f106"; } +.flaticon-earth:before { content: "\f107"; } +.flaticon-planet:before { content: "\f108"; } +.flaticon-planet-1:before { content: "\f109"; } +.flaticon-globe:before { content: "\f10a"; } +.flaticon-jupiter:before { content: "\f10b"; } +.flaticon-venus:before { content: "\f10c"; } +.flaticon-moon:before { content: "\f10d"; } +.flaticon-astronomy:before { content: "\f10e"; } +.flaticon-asteroid:before { content: "\f10f"; } +.flaticon-asteroid-1:before { content: "\f110"; } +.flaticon-ingot:before { content: "\f111"; } +.flaticon-snowflake:before { content: "\f112"; } +.flaticon-star:before { content: "\f113"; } +.flaticon-solar-system:before { content: "\f114"; } +.flaticon-asteroid-2:before { content: "\f115"; } +.flaticon-water:before { content: "\f116"; } +.flaticon-water-drops:before { content: "\f117"; } +.flaticon-asteroid-3:before { content: "\f118"; } +.flaticon-asteroid-4:before { content: "\f119"; } +.flaticon-jupiter-1:before { content: "\f11a"; } +.flaticon-jupiter-2:before { content: "\f11b"; } +.flaticon-jupiter-3:before { content: "\f11c"; } +.flaticon-pickaxe:before { content: "\f11d"; } +.flaticon-curved-line:before { content: "\f11e"; } +.flaticon-bacteria:before { content: "\f11f"; } +.flaticon-dna:before { content: "\f120"; } +.flaticon-ingot-1:before { content: "\f121"; } +.flaticon-gold-bars:before { content: "\f122"; } + + $font-Flaticon-lander: "\f100"; + $font-Flaticon-volcano: "\f101"; + $font-Flaticon-cooling-tower: "\f102"; + $font-Flaticon-cooling-tower-1: "\f103"; + $font-Flaticon-volcano-1: "\f104"; + $font-Flaticon-flag-outline-on-a-pole-with-stars-around: "\f105"; + $font-Flaticon-saturn: "\f106"; + $font-Flaticon-earth: "\f107"; + $font-Flaticon-planet: "\f108"; + $font-Flaticon-planet-1: "\f109"; + $font-Flaticon-globe: "\f10a"; + $font-Flaticon-jupiter: "\f10b"; + $font-Flaticon-venus: "\f10c"; + $font-Flaticon-moon: "\f10d"; + $font-Flaticon-astronomy: "\f10e"; + $font-Flaticon-asteroid: "\f10f"; + $font-Flaticon-asteroid-1: "\f110"; + $font-Flaticon-ingot: "\f111"; + $font-Flaticon-snowflake: "\f112"; + $font-Flaticon-star: "\f113"; + $font-Flaticon-solar-system: "\f114"; + $font-Flaticon-asteroid-2: "\f115"; + $font-Flaticon-water: "\f116"; + $font-Flaticon-water-drops: "\f117"; + $font-Flaticon-asteroid-3: "\f118"; + $font-Flaticon-asteroid-4: "\f119"; + $font-Flaticon-jupiter-1: "\f11a"; + $font-Flaticon-jupiter-2: "\f11b"; + $font-Flaticon-jupiter-3: "\f11c"; + $font-Flaticon-pickaxe: "\f11d"; + $font-Flaticon-curved-line: "\f11e"; + $font-Flaticon-bacteria: "\f11f"; + $font-Flaticon-dna: "\f120"; + $font-Flaticon-ingot-1: "\f121"; + $font-Flaticon-gold-bars: "\f122"; \ No newline at end of file diff --git a/src/icons/flaticon.css b/src/icons/flaticon.css new file mode 100644 index 0000000..95dcd01 --- /dev/null +++ b/src/icons/flaticon.css @@ -0,0 +1,70 @@ + /* + Flaticon icon font: Flaticon + Creation date: 04/10/2020 20:48 + */ + +@font-face { + font-family: "Flaticon"; + src: url("./Flaticon.eot"); + src: url("./Flaticon.eot?#iefix") format("embedded-opentype"), + url("./Flaticon.woff2") format("woff2"), + url("./Flaticon.woff") format("woff"), + url("./Flaticon.ttf") format("truetype"), + url("./Flaticon.svg#Flaticon") format("svg"); + font-weight: normal; + font-style: normal; +} + +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: "Flaticon"; + src: url("./Flaticon.svg#Flaticon") format("svg"); + } +} + +[class^="flaticon-"]:before, [class*=" flaticon-"]:before, +[class^="flaticon-"]:after, [class*=" flaticon-"]:after { + font-family: Flaticon; + /* + font-size: 20px; + margin-left: 20px; + */ + font-style: normal; + text-shadow: 0 0 0; +} + +.flaticon-lander:before { content: "\f100"; margin-left: 2px;} +.flaticon-volcano:before { content: "\f101"; } +.flaticon-cooling-tower:before { content: "\f102"; } +.flaticon-cooling-tower-1:before { content: "\f103"; } +.flaticon-volcano-1:before { content: "\f104"; } +.flaticon-flag-outline-on-a-pole-with-stars-around:before { content: "\f105"; } +.flaticon-saturn:before { content: "\f106"; } +.flaticon-earth:before { content: "\f107"; } +.flaticon-planet:before { content: "\f108"; } +.flaticon-planet-1:before { content: "\f109"; } +.flaticon-globe:before { content: "\f10a"; } +.flaticon-jupiter:before { content: "\f10b"; } +.flaticon-venus:before { content: "\f10c"; } +.flaticon-moon:before { content: "\f10d"; } +.flaticon-astronomy:before { content: "\f10e"; } +.flaticon-asteroid:before { content: "\f10f"; } +.flaticon-asteroid-1:before { content: "\f110"; } +.flaticon-ingot:before { content: "\f111"; } +.flaticon-snowflake:before { content: "\f112"; } +.flaticon-star:before { content: "\f113"; } +.flaticon-solar-system:before { content: "\f114"; } +.flaticon-asteroid-2:before { content: "\f115"; } +.flaticon-water:before { content: "\f116"; } +.flaticon-water-drops:before { content: "\f117"; } +.flaticon-asteroid-3:before { content: "\f118"; } +.flaticon-asteroid-4:before { content: "\f119"; } +.flaticon-jupiter-1:before { content: "\f11a"; } +.flaticon-jupiter-2:before { content: "\f11b"; } +.flaticon-jupiter-3:before { content: "\f11c"; } +.flaticon-pickaxe:before { content: "\f11d"; } +.flaticon-curved-line:before { content: "\f11e"; } +.flaticon-bacteria:before { content: "\f11f"; } +.flaticon-dna:before { content: "\f120"; } +.flaticon-ingot-1:before { content: "\f121"; } +.flaticon-gold-bars:before { content: "\f122"; }.flaticon-ring-metal:before { content: "\f111"; } \ No newline at end of file diff --git a/src/icons/flaticon.html b/src/icons/flaticon.html new file mode 100644 index 0000000..f1e6de7 --- /dev/null +++ b/src/icons/flaticon.html @@ -0,0 +1,630 @@ + + + + + + + + Flaticon WebFont + + + + + + + + +
+ + Font Demo +
+ + +
+ +

Instructions

+ +
    +
  • + 1Copy the "Fonts" files and CSS files to your website CSS folder. +
  • +
  • + 2Add the CSS link to your website source code on header. + + <head> +
    ... +
    <link rel="stylesheet" type="text/css" href="your_website_domain/css_root/flaticon.css"> +
    ... +
    </head> +
    +
  • + +
  • +

    + 3Use the icon class on "display: inline" elements: +
    + Use example: <i class="flaticon-airplane49"></i> or <span class="flaticon-airplane49"></span> +

  • +
+ +
+ + + + +
+ + +
+
.flaticon-lander
+ +
+ +
+
.flaticon-volcano
+
Author: Freepik
+
+ +
+
.flaticon-cooling-tower
+
Author: Freepik
+
+ +
+
.flaticon-cooling-tower-1
+
Author: Freepik
+
+ +
+
.flaticon-volcano-1
+
Author: deemakdaksina
+
+ +
+
.flaticon-flag-outline-on-a-pole-with-stars-around
+
Author: Freepik
+
+ +
+
.flaticon-saturn
+
Author: prettycons
+
+ +
+
.flaticon-earth
+
Author: Freepik
+
+ +
+
.flaticon-planet
+
Author: itim2101
+
+ +
+
.flaticon-planet-1
+
Author: Victoruler
+
+ +
+
.flaticon-globe
+
Author: Smashicons
+
+ +
+
.flaticon-jupiter
+
Author: monkik
+
+ +
+
.flaticon-venus
+
Author: monkik
+
+ +
+
.flaticon-moon
+
Author: Nhor Phai
+
+ +
+
.flaticon-astronomy
+
Author: Eucalyp
+
+ +
+
.flaticon-asteroid
+
Author: Freepik
+
+ +
+
.flaticon-asteroid-1
+
Author: Smashicons
+
+ +
+
.flaticon-ingot
+
Author: Smashicons
+
+ +
+
.flaticon-snowflake
+
Author: kmg design
+
+ +
+
.flaticon-star
+
Author: Freepik
+
+ +
+
.flaticon-solar-system
+
Author: Freepik
+
+ +
+
.flaticon-asteroid-2
+
Author: Abbasi
+
+ +
+
.flaticon-water
+
Author: Freepik
+
+ +
+
.flaticon-water-drops
+
Author: Freepik
+
+ +
+
.flaticon-asteroid-3
+
Author: Smashicons
+
+ +
+
.flaticon-asteroid-4
+
Author: Freepik
+
+ +
+
.flaticon-jupiter-1
+
Author: monkik
+
+ +
+
.flaticon-jupiter-2
+
Author: Icongeek26
+
+ +
+
.flaticon-jupiter-3
+ +
+ +
+
.flaticon-pickaxe
+
Author: Freepik
+
+ +
+
.flaticon-curved-line
+
Author: Freepik
+
+ +
+
.flaticon-bacteria
+
Author: Smashicons
+
+ +
+
.flaticon-dna
+
Author: Freepik
+
+ +
+
.flaticon-ingot-1
+
Author: Smashicons
+
+ +
+
.flaticon-gold-bars
+
Author: prettycons
+
+ + +
+ + + +
+ +
License and attribution:
+
Copy the Attribution License:
+ + + +
+ +
+ +
Examples:
+ +
+

+ + <i class="flaticon-lander"></i> +

+
+ +
+

+ + <i class="flaticon-volcano"></i> +

+
+ +
+

+ + <i class="flaticon-cooling-tower"></i> +

+
+ +
+

+ + <i class="flaticon-cooling-tower-1"></i> +

+
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/src/interfaces/Body.js b/src/interfaces/Body.js new file mode 100644 index 0000000..b7ceb53 --- /dev/null +++ b/src/interfaces/Body.js @@ -0,0 +1,11 @@ +export class Body { + constructor() {} + + isAsteroid() { + return this.BodyName.includes('Belt') + } + + simpleName() { + return this.BodyName.replace(this.StarSystem, '') + } +} \ No newline at end of file diff --git a/src/interfaces/JournalInterface.js b/src/interfaces/JournalInterface.js index efd2006..55008ae 100644 --- a/src/interfaces/JournalInterface.js +++ b/src/interfaces/JournalInterface.js @@ -1,5 +1,7 @@ +import { Body } from './Body' +import { System } from './System' + const EventEmitter = require('events') -const { app } = require('electron') const fs = require('fs') const path = require('path') const max = require('lodash/max') @@ -8,21 +10,22 @@ const os = require('os') const lineReader = require('reverse-line-reader') const chokidar = require('chokidar') const Tail = require('tail').Tail +const find = require('lodash/find') -// set log() to console.log() so whenever I get around to setting up a log file, I don't have to -// search and replace all the console.log()'s +// Set log() to console.log() so whenever I get around to setting up a log file, I don't have to +// search and replace all the console.log()'s. const log = console.log.bind(console) export class JournalInterface extends EventEmitter { - constructor() { + constructor(isPackaged) { super() this.journalDir = null - if (!app.isPackaged) { // account for WSL during development + if (!isPackaged) { // Account for WSL during development this.journalDir = "/mnt/c/Users/marle/Saved\ Games/Frontier\ Developments/Elite\ Dangerous/" - } else if (os.platform() === 'win32') { // windows + } else if (os.platform() === 'win32') { // Windows this.journalDir = os.homedir() + '\\Saved Games\\Frontier Developments\\Elite Dangerous' - } else if (os.platform() === 'linux') { // linux + } else if (os.platform() === 'linux') { // Linux this.journalDir = os.homedir() + '/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/Saved Games/Frontier Developments/Elite Dangerous/' } else { log(`ERROR: Journal files not found. OS: ${os.platform()}.`) @@ -32,15 +35,18 @@ export class JournalInterface extends EventEmitter { this.currentJournal = this.getLatestJournal() - // lineReader seems to be async, so start async processes here + // LineReader seems to be async, so start async processes here. this.currentLocation = null - this.currentSystemBodies = null log('JournalInterface initialized. Attempting to find current location.') this.getCurrentLocation() .then(() => { log('Attempting to find scanned bodies in current system.') this.getScannedBodies() + .then(() => { + log('Scanned bodies found.') + this.emit('SCANNED_BODIES_FOUND') + }) }) } @@ -57,48 +63,93 @@ export class JournalInterface extends EventEmitter { log(`New journal file found, now watching ${path.basename(this.currentJournal)}.`) } - // get current location on setup, so if app is restarted, user can pick up where they left off - // rather than waiting til they jump to the next system to use the program again + // Get current location on setup, so if app is restarted, user can pick up where they left off + // Rather than waiting til they jump to the next system to use the program again. async getCurrentLocation() { - lineReader.eachLine(this.currentJournal, (raw, last) => { + return lineReader.eachLine(this.currentJournal, (raw, last) => { if (raw) { // skip blank line at end of file const line = JSON.parse(raw) if (line.event === 'FSDJump') { - this.currentLocation = line.StarSystem + this.currentLocation = new System(line.StarSystem) + log(`Current location set to ${this.currentLocation.name}.`) + this.emit('FSDJump') return false } else if (last) { log('Warning: unable to find last hyperspace jump. Current location unknown.') return false } } - }).then(() => { - this.emit('FSDJump') - log(`Current location set to ${this.currentLocation}.`) }) } - // look for all scanned bodies before last FSDJump, for same reasons as getCurrentLocation() - // if ScanType = Detailed, look at line immediately above for event = SAAScanComplete? + // Look for all scanned bodies before last FSDJump, for same reasons as getCurrentLocation(). async getScannedBodies() { - const detailedScanLine = null + let detailedScanLine = null - lineReader.eachLine(this.currentJournal, (raw, last) => { - if (raw) { // skip blank line at end of file + return lineReader.eachLine(this.currentJournal, (raw, last) => { + + if (raw) { // Skip blank line at end of file. const line = JSON.parse(raw) - if (line.event === 'Scan') { - if (line.ScanType === 'Detailed') { - detailedScanLine = line + // Check if previous line was ScanType = Detailed, and handle that. + if (detailedScanLine !== null) { + if (line.event === 'SAAScanComplete') { + // This was a DSS, so set the DSS flag to true and add to list. + detailedScanLine.DSSDone = true + this.currentLocation.bodies.push(Object.assign(new Body, detailedScanLine)) + } else { + // Else, check that the body hasn't already been added (by a DSS scan line). + let r = find(this.currentLocation.bodies, ['BodyID', detailedScanLine.BodyID]) + + if (r === undefined) { + // Set DSS flag if body was not already logged, then add to list. + detailedScanLine.DSSDone = false + this.currentLocation.bodies.push(Object.assign(new Body, detailedScanLine)) + } } + + // Finally, clear the variable. + detailedScanLine = null + } + + // Now move on to evaluating the current line. + if (line.event === 'Scan') { + // If ScanType = Detailed and body is not a star, save the line so we can check + // the one immediately above for event = SAAScanComplete, which indicates this + // was a DSS. + if (line.ScanType === 'Detailed' && line.StarType === undefined) { + detailedScanLine = line + + } else if (line.StarType !== undefined) { // Save stars to bodies list. + this.currentLocation.bodies.push(Object.assign(new Body, line)) + + } else if (line.ScanType === 'AutoScan') { // Save auto/discovery scan bodies. + // Check if planet, and then do the duplicate check (otherwise it's an + // astroid, as we've already accounted for stars). + if (line.PlanetClass !== undefined) { + let r = find(this.currentLocation.bodies, ['BodyID', line.BodyID]) + + if (r === undefined) { + line.DSSDone = false + this.currentLocation.bodies.push(Object.assign(new Body, line)) + } + + } else { // Asteroids. + this.currentLocation.bodies.push(Object.assign(new Body, line)) + } + } + } else if (line.event === 'FSDJump') { + // Stop evaluating once we reach the beginning of current system entries. + return false } } }) } - // set up journal directory watcher to catch new journal files as the game seems to sometimes - // make more than one journal per day - // also for instances where UTC day switches over mid-play session + // Set up journal directory watcher to catch new journal files as the game seems to sometimes + // make more than one journal per day. + // Also for instances where UTC day switches over mid-play session. watchDirectory() { const watcher = chokidar.watch(this.journalPattern, {usePolling: true, persistent: true}) @@ -107,17 +158,17 @@ export class JournalInterface extends EventEmitter { log('Watching journal folder for changes...') } - // parse and handle journal lines + // Parse and handle journal lines. parseLine(raw) { const line = JSON.parse(raw) if (line.event === 'FSDJump') { - this.currentLocation = line.StarSystem + this.currentLocation = new System(line.StarSystem) this.emit('FSDJump') } } - // watch the journal for changes + // Watch the journal for changes. watchJournal() { const tail = new Tail(this.currentJournal, {useWatchFile: true}) diff --git a/src/interfaces/System.js b/src/interfaces/System.js new file mode 100644 index 0000000..4e03dad --- /dev/null +++ b/src/interfaces/System.js @@ -0,0 +1,8 @@ +export class System { + constructor(StarSystem) { + // In future, this is where we preform EDSM lookup + + this.name = StarSystem + this.bodies = [] + } +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 811cc8c..62ed0c9 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ const createWindow = () => { preload: path.join(__dirname, 'preload.js'), nodeIntegration: true, contextIsolation: false, + additionalArguments: [`EDS-ENV=${app.isPackaged}`], }, }); diff --git a/src/renderer.js b/src/renderer.js index 88d2c32..31c5f36 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -27,14 +27,23 @@ */ import './index.css' +import './icons/flaticon.css' +const { app } = require('electron') import { createApp, ref } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js' - import { JournalInterface } from './interfaces/JournalInterface' +// Grab app.isPackaged from main process +let isPackaged = false +window.process.argv.forEach((item) => { + if (item.includes('EDS-ENV')) { + isPackaged = (item.split('=').pop() === 'true') + } +}) + createApp({ setup() { - const journal = new JournalInterface + const journal = new JournalInterface(isPackaged) // TODO: show warning to user if (journal.journalDir === null) { @@ -45,11 +54,15 @@ createApp({ journal.watchJournal() const currentLocation = ref('Unknown') + const currentSystemBodies = ref([]) journal.on('FSDJump', () => currentLocation.value = journal.currentLocation) + journal.on('SCANNED_BODIES_FOUND', () => currentSystemBodies.value = journal.currentLocation.bodies) + return { currentLocation, + currentSystemBodies, } } }).mount('#app')