2023-05-08 12:25:13 -07:00
|
|
|
/**
|
|
|
|
* This file will automatically be loaded by vite and run in the "renderer" context.
|
|
|
|
* To learn more about the differences between the "main" and the "renderer" context in
|
|
|
|
* Electron, visit:
|
|
|
|
*
|
|
|
|
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
|
|
|
|
*
|
|
|
|
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
|
|
|
|
* in a renderer process, please be aware of potential security implications. You can read
|
|
|
|
* more about security risks here:
|
|
|
|
*
|
|
|
|
* https://electronjs.org/docs/tutorial/security
|
|
|
|
*
|
|
|
|
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
|
|
|
|
* flag:
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* // Create the browser window.
|
|
|
|
* mainWindow = new BrowserWindow({
|
|
|
|
* width: 800,
|
|
|
|
* height: 600,
|
|
|
|
* webPreferences: {
|
|
|
|
* nodeIntegration: true
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
|
2023-05-09 16:05:58 -07:00
|
|
|
import 'bootstrap/dist/css/bootstrap.css'
|
2023-05-09 12:55:15 -07:00
|
|
|
import './assets/index.css'
|
2023-05-08 17:42:09 -07:00
|
|
|
import './icons/flaticon.css'
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-08 17:42:09 -07:00
|
|
|
const { app } = require('electron')
|
2023-05-08 12:25:13 -07:00
|
|
|
import { JournalInterface } from './interfaces/JournalInterface'
|
2023-05-10 21:54:32 -07:00
|
|
|
import { UI } from './models/UI'
|
2023-05-09 20:13:25 -07:00
|
|
|
import { Body } from './models/Body'
|
2023-05-11 01:54:03 -07:00
|
|
|
import { sep } from 'path'
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-08 17:42:09 -07:00
|
|
|
// Grab app.isPackaged from main process
|
|
|
|
let isPackaged = false
|
|
|
|
window.process.argv.forEach((item) => {
|
|
|
|
if (item.includes('EDS-ENV')) {
|
|
|
|
isPackaged = (item.split('=').pop() === 'true')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
/* ------------------------------------------------------------------------------- app setup ---- */
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
const journal = new JournalInterface(isPackaged)
|
2023-05-08 13:10:38 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
if (journal.journalDir === null) {
|
|
|
|
// handle error
|
|
|
|
}
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 12:55:15 -07:00
|
|
|
journal.watchDirectory()
|
|
|
|
journal.watchJournal()
|
2023-05-08 12:25:13 -07:00
|
|
|
|
2023-05-09 20:13:25 -07:00
|
|
|
const test = {name: 'Test', ID: 'TestID'}
|
|
|
|
|
2023-05-11 21:02:23 -07:00
|
|
|
/* ------------------------------------------------------------------------- build body list ---- */
|
2023-05-09 12:55:15 -07:00
|
|
|
|
2023-05-11 21:02:23 -07:00
|
|
|
journal.once('BUILD_BODY_LIST', () => {
|
2023-05-09 20:13:25 -07:00
|
|
|
if (journal.location?.bodies?.length > 0) {
|
2023-05-09 12:55:15 -07:00
|
|
|
journal.location.bodies.forEach((body) => {
|
2023-05-10 21:54:32 -07:00
|
|
|
const row = UI.createBodyRow(body)
|
2023-05-09 16:13:27 -07:00
|
|
|
// TODO APPRAISAL DATA
|
2023-05-09 12:55:15 -07:00
|
|
|
$('#lowValueScans').appendChild(row)
|
|
|
|
})
|
|
|
|
}
|
2023-05-09 13:40:32 -07:00
|
|
|
})
|
|
|
|
|
2023-05-11 21:02:23 -07:00
|
|
|
/* ----------------------------------------------------------------- started hyperspace jump ---- */
|
|
|
|
|
|
|
|
journal.on('ENTERING_WITCH_SPACE', () => UI.enterWitchSpace())
|
|
|
|
|
2023-05-09 13:40:32 -07:00
|
|
|
/* ---------------------------------------------------------------------- entered new system ---- */
|
|
|
|
|
|
|
|
journal.on('ENTERED_NEW_SYSTEM', () => {
|
2023-05-11 21:02:23 -07:00
|
|
|
UI.setCurrentSystem(journal.location)
|
|
|
|
|
|
|
|
$(`#${CSS.escape(journal.location.SystemAddress)}`).remove()
|
2023-05-09 13:40:32 -07:00
|
|
|
|
2023-05-11 21:02:23 -07:00
|
|
|
// verify that the internal navRoute matches the UI navRoute, and rebuild it if not
|
|
|
|
if ($('#navRoute').children().length !== journal.navRoute.length) {
|
|
|
|
journal.emit('SET_NAV_ROUTE')
|
|
|
|
}
|
2023-05-09 16:05:58 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- body scan detected ---- */
|
|
|
|
|
|
|
|
journal.on('BODY_SCANNED', (body, DSS) => {
|
|
|
|
// If this is a DSS scan, it's very likely that the body already exists in our list so we just
|
|
|
|
// need to remove the highlighting if applicable
|
|
|
|
if (DSS) {
|
|
|
|
const bodyRow = $(`#${body.BodyID}`)
|
|
|
|
|
2023-05-09 16:13:27 -07:00
|
|
|
if (bodyRow.length > 0) { // check just in case body was missed in earlier scans
|
2023-05-09 16:05:58 -07:00
|
|
|
bodyRow.removeClass('highlighted uncharted').addClass('charted')
|
2023-05-09 16:13:27 -07:00
|
|
|
} else {
|
2023-05-10 21:54:32 -07:00
|
|
|
const row = UI.createBodyRow(body)
|
2023-05-09 16:13:27 -07:00
|
|
|
// TODO APPRAISAL DATA
|
|
|
|
$('#lowValueScans').appendChild(row)
|
2023-05-09 16:05:58 -07:00
|
|
|
}
|
2023-05-09 16:13:27 -07:00
|
|
|
|
|
|
|
} else { // else it's an FSS/auto scan and won't be in the list yet
|
2023-05-10 21:54:32 -07:00
|
|
|
const row = UI.createBodyRow(body)
|
2023-05-09 16:13:27 -07:00
|
|
|
// TODO APPRAISAL DATA
|
|
|
|
$('#lowValueScans').appendChild(row)
|
2023-05-09 16:05:58 -07:00
|
|
|
}
|
2023-05-11 01:54:03 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------- nav route set ---- */
|
|
|
|
|
|
|
|
journal.on('SET_NAV_ROUTE', () => {
|
|
|
|
// clear previous nav route, if any
|
2023-05-11 02:45:02 -07:00
|
|
|
$('#navRoute').children().remove()
|
|
|
|
|
2023-05-11 21:02:23 -07:00
|
|
|
if (journal.navRoute.length > 0) {
|
2023-05-11 02:45:02 -07:00
|
|
|
journal.navRoute.forEach((system) => {
|
|
|
|
// duplicate check
|
|
|
|
// CSS.escape is needed since CSS technically doesn't allow numeric IDs
|
|
|
|
const systemRow = $(`#${CSS.escape(system.SystemAddress)}`)
|
|
|
|
|
|
|
|
if (systemRow.length === 0) {
|
|
|
|
const row = UI.createSystemRow(system)
|
|
|
|
$('#navRoute').appendChild(row)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2023-05-09 12:55:15 -07:00
|
|
|
})
|