diff --git a/index.html b/index.html index 5bdea99..30953b9 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,7 @@
-
+
Name
Type
Distance
@@ -31,7 +31,7 @@
-
+
Unknown @@ -40,11 +40,7 @@
-
-
-
-
-
+
@@ -62,7 +58,7 @@
-
+
LY
Name
Type
diff --git a/src/interfaces/JournalInterface.js b/src/interfaces/JournalInterface.js index 3343bd9..8066eae 100644 --- a/src/interfaces/JournalInterface.js +++ b/src/interfaces/JournalInterface.js @@ -167,18 +167,21 @@ export class JournalInterface extends EventEmitter { // Parse and handle scan lines. parseScanLine(line, DSS = false) { const dupChecker = {'BodyName': line.BodyName, 'BodyID': line.bodyID} + let body = null // If it's a DSS scan, then we should have already added the body to the list. But we'll // check to make sure. if (DSS) { // Using findIndex() rather than find() so we can edit the body if found - let body = findIndex(this.location.bodies, dupChecker) + let bodyIndex = findIndex(this.location.bodies, dupChecker) - if (body > -1) { // Body was found in list, so simply toggle the DSS flag. - this.location.bodies[body].DSSDone = true + if (bodyIndex > -1) { // Body was found in list, so simply toggle the DSS flag. + body = this.location.bodies[bodyIndex] + body.DSSDone = true } else { // Body was missed on initial journal scan, so add it to the list. line.DSSDone = true - this.location.bodies.push(Object.assign(new Body, line)) + body = Object.assign(new Body, line) + this.location.bodies.push(body) } } else { // Otherwise it's an FSS or auto scan, and needs to be added to the list. @@ -186,14 +189,16 @@ export class JournalInterface extends EventEmitter { let r = find(this.location.bodies, dupChecker) if (r === undefined) { - this.location.bodies.push(Object.assign(new Body, line)) + body = Object.assign(new Body, line) + this.location.bodies.push(body) } } log(`Scan detected. Body: ${line.BodyName}.`) + this.emit('BODY_SCANNED', body, DSS) } - /* -----------------------------------------------------------------------0000 parseLine ---- */ + /* --------------------------------------------------------------------------- parseLine ---- */ // Parse and handle journal lines. parseLine(raw) { @@ -220,7 +225,6 @@ export class JournalInterface extends EventEmitter { // reset the DSS flag. case 'Scan': { this.parseScanLine(line, DSSFlag) - this.emit('BODY_SCANNED') DSSFlag = false break } diff --git a/src/renderer.js b/src/renderer.js index 901ce9b..3894723 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -26,7 +26,7 @@ * ``` */ -import 'bootstrap/dist/css/bootstrap.min.css' +import 'bootstrap/dist/css/bootstrap.css' import './assets/index.css' import './icons/flaticon.css' @@ -81,4 +81,18 @@ journal.on('ENTERED_NEW_SYSTEM', () => { $('#lowValueScans').children().remove() $('#currentSystemName').text(journal.location.name) +}) + +/* ---------------------------------------------------------------------- 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}`) + + if (bodyRow.length > 0) { + bodyRow.removeClass('highlighted uncharted').addClass('charted') + } + } }) \ No newline at end of file diff --git a/src/ui.js b/src/ui.js index 9be5e9a..a0cae13 100644 --- a/src/ui.js +++ b/src/ui.js @@ -44,20 +44,21 @@ const buildRings = (body) => { /* --------------------------------------------------------------------------- createBodyRow ---- */ export const createBodyRow = (body) => { - const row = $('
').addClass('row ml-1 mr-1') + const chartedStyle = body.WasDiscovered ? 'charted' : 'uncharted' + const row = $('
').addClass('row ms-1 me-1') row.attr('id', body.bodyID) // spacer row.appendChild($('
').addClass('col-1 system')) // name - const name = $('
').addClass('col-2 system charted text-left') + const name = $('
').addClass(`col-2 text-left system ${chartedStyle}`) name.appendChild($('')).addClass(`flaticon-${body.nameIcon()}`) name.appendChild($('')).text(body.simpleName()) row.appendChild(name) // type icon - const type = $('
').addClass('col pr-0 mr-0 system charted') + const type = $('
').addClass(`col pe-0 me-0 system ${chartedStyle}`) type.appendChild($('').addClass(`flaticon-${body.typeIcon()}`)) // rings if (body.Rings !== undefined) { @@ -69,11 +70,12 @@ export const createBodyRow = (body) => { row.appendChild(type) // distance - const distance = $('
').addClass('col-auto pl-2 ml-0 system charted').text(body.distance()) + const distance = $('
').addClass(`col-auto ps-2 ms-0 system ${chartedStyle}`) + distance.text(body.distance()) row.appendChild(distance) // info - const info = $('
').addClass('col-1 system charted') + const info = $('
').addClass(`col-1 system ${chartedStyle}`) // terraformable const terraform = $('').addClass('flaticon-cooling-tower opacity-0') if (body.isPlanet && body.TerraformState) { @@ -89,7 +91,7 @@ export const createBodyRow = (body) => { row.appendChild(info) // mapped value - const value = $('
').addClass('col-2 system charted text-right') + const value = $('
').addClass(`col-2 text-right system ${chartedStyle}`) row.appendChild(value) return row