Set charted/uncharted styles accordingly.
This commit is contained in:
parent
b22c26cae6
commit
9d5042cc05
4 changed files with 38 additions and 22 deletions
12
index.html
12
index.html
|
@ -20,7 +20,7 @@
|
|||
|
||||
<!-- table header -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 separator">
|
||||
<div class="row ms-1 me-1 separator">
|
||||
<div class="col-3 text-center">Name</div>
|
||||
<div class="col">Type</div>
|
||||
<div class="col-auto text-center">Distance</div>
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
<!-- system name -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1">
|
||||
<div class="row ms-1 me-1">
|
||||
<div id="currentSystem" class="col highlighted text-center">
|
||||
<i id="currentSystemIcon" class="flaticon-solar-system hidden"></i>
|
||||
<span id="currentSystemName">Unknown</span>
|
||||
|
@ -40,11 +40,7 @@
|
|||
</div>
|
||||
|
||||
<!-- high-value scans -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 align-items-center">
|
||||
<div class="col system charted">
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid" id="highValueScans">
|
||||
</div>
|
||||
|
||||
<!-- low-value scans -->
|
||||
|
@ -62,7 +58,7 @@
|
|||
|
||||
<!-- table header -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 separator">
|
||||
<div class="row ms-1 me-1 separator">
|
||||
<div class="col-1 text-right">LY</div>
|
||||
<div class="col-3 text-center">Name</div>
|
||||
<div class="col">Type</div>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
}
|
||||
})
|
14
src/ui.js
14
src/ui.js
|
@ -44,20 +44,21 @@ const buildRings = (body) => {
|
|||
/* --------------------------------------------------------------------------- createBodyRow ---- */
|
||||
|
||||
export const createBodyRow = (body) => {
|
||||
const row = $('<div>').addClass('row ml-1 mr-1')
|
||||
const chartedStyle = body.WasDiscovered ? 'charted' : 'uncharted'
|
||||
const row = $('<div>').addClass('row ms-1 me-1')
|
||||
row.attr('id', body.bodyID)
|
||||
|
||||
// spacer
|
||||
row.appendChild($('<div>').addClass('col-1 system'))
|
||||
|
||||
// name
|
||||
const name = $('<div>').addClass('col-2 system charted text-left')
|
||||
const name = $('<div>').addClass(`col-2 text-left system ${chartedStyle}`)
|
||||
name.appendChild($('<i>')).addClass(`flaticon-${body.nameIcon()}`)
|
||||
name.appendChild($('<span>')).text(body.simpleName())
|
||||
row.appendChild(name)
|
||||
|
||||
// type icon
|
||||
const type = $('<div>').addClass('col pr-0 mr-0 system charted')
|
||||
const type = $('<div>').addClass(`col pe-0 me-0 system ${chartedStyle}`)
|
||||
type.appendChild($('<i>').addClass(`flaticon-${body.typeIcon()}`))
|
||||
// rings
|
||||
if (body.Rings !== undefined) {
|
||||
|
@ -69,11 +70,12 @@ export const createBodyRow = (body) => {
|
|||
row.appendChild(type)
|
||||
|
||||
// distance
|
||||
const distance = $('<div>').addClass('col-auto pl-2 ml-0 system charted').text(body.distance())
|
||||
const distance = $('<div>').addClass(`col-auto ps-2 ms-0 system ${chartedStyle}`)
|
||||
distance.text(body.distance())
|
||||
row.appendChild(distance)
|
||||
|
||||
// info
|
||||
const info = $('<div>').addClass('col-1 system charted')
|
||||
const info = $('<div>').addClass(`col-1 system ${chartedStyle}`)
|
||||
// terraformable
|
||||
const terraform = $('<i>').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 = $('<div>').addClass('col-2 system charted text-right')
|
||||
const value = $('<div>').addClass(`col-2 text-right system ${chartedStyle}`)
|
||||
row.appendChild(value)
|
||||
|
||||
return row
|
||||
|
|
Loading…
Reference in a new issue