+ 1Copy the "Fonts" files and CSS files to your website CSS folder.
+
+
+ 2Add the CSS link to your website source code on header.
+
+ <head>
+ ...
+ <linkrel="stylesheet"type="text/css"href="your_website_domain/css_root/flaticon.css">
+ ...
+ </head>
+
+
+
+
+
+ 3Use the icon class on "display: inline" elements:
+
+ Use example: <iclass="flaticon-airplane49"></i> or <spanclass="flaticon-airplane49"></span>
+
+
+
+
+
+
+
+
+
+
\ 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')