Sorting and highlighting valuable bodies.
This commit is contained in:
parent
5bdeec7857
commit
7dd350d1ff
3 changed files with 23 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
||||||
import type { completeFsdJump, location, navRouteSystem } from "../@types/journalLines"
|
import type { completeFsdJump, location, navRouteSystem } from "../@types/journalLines"
|
||||||
|
|
||||||
|
import * as _ from 'lodash-es'
|
||||||
|
|
||||||
import { Body } from "./Body"
|
import { Body } from "./Body"
|
||||||
import { EDSM } from "./EDSM"
|
import { EDSM } from "./EDSM"
|
||||||
|
|
||||||
|
@ -65,4 +68,10 @@ export class System {
|
||||||
EDSM.connect().emit('SYSTEM_APPRAISED', this)
|
EDSM.connect().emit('SYSTEM_APPRAISED', this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- sortBodies ---- */
|
||||||
|
|
||||||
|
sortBodies() {
|
||||||
|
this.bodies = _.orderBy(this.bodies, ['mappedValue'], ['desc'])
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -87,6 +87,8 @@ export class UI {
|
||||||
|
|
||||||
static createBodyRow(body) {
|
static createBodyRow(body) {
|
||||||
const chartedStyle = body.WasDiscovered && !body.DSSDone ? 'charted' : 'uncharted'
|
const chartedStyle = body.WasDiscovered && !body.DSSDone ? 'charted' : 'uncharted'
|
||||||
|
const valuableStyle = body.mappedValue > 2000 ? 'highlighted' : ''
|
||||||
|
|
||||||
const row = $('<div>').addClass('row ms-1 me-1')
|
const row = $('<div>').addClass('row ms-1 me-1')
|
||||||
row.attr('id', body.bodyID)
|
row.attr('id', body.bodyID)
|
||||||
|
|
||||||
|
@ -94,13 +96,13 @@ export class UI {
|
||||||
row.appendChild($('<div>').addClass('col-1 system'))
|
row.appendChild($('<div>').addClass('col-1 system'))
|
||||||
|
|
||||||
// name
|
// name
|
||||||
const name = $('<div>').addClass(`col-2 text-start system ${chartedStyle}`)
|
const name = $('<div>').addClass(`col-2 text-start system ${chartedStyle} ${valuableStyle}`)
|
||||||
name.appendChild($('<i>')).addClass(`flaticon-${body.nameIcon()}`)
|
name.appendChild($('<i>')).addClass(`flaticon-${body.nameIcon()}`)
|
||||||
name.appendChild($('<span>')).text(body.simpleName())
|
name.appendChild($('<span>')).text(body.simpleName())
|
||||||
row.appendChild(name)
|
row.appendChild(name)
|
||||||
|
|
||||||
// type icon
|
// type icon
|
||||||
const type = $('<div>').addClass(`col pe-0 me-0 system ${chartedStyle}`)
|
const type = $('<div>').addClass(`col pe-0 me-0 system ${chartedStyle} ${valuableStyle}`)
|
||||||
type.appendChild($('<i>').addClass(`flaticon-${body.typeIcon()}`))
|
type.appendChild($('<i>').addClass(`flaticon-${body.typeIcon()}`))
|
||||||
// rings
|
// rings
|
||||||
if (body.Rings !== undefined) {
|
if (body.Rings !== undefined) {
|
||||||
|
@ -112,12 +114,13 @@ export class UI {
|
||||||
row.appendChild(type)
|
row.appendChild(type)
|
||||||
|
|
||||||
// distance
|
// distance
|
||||||
const distance = $('<div>').addClass(`col-auto ps-2 ms-0 system ${chartedStyle}`)
|
const distance = $('<div>')
|
||||||
|
distance.addClass(`col-auto ps-2 ms-0 system ${chartedStyle} ${valuableStyle}`)
|
||||||
distance.text(UI.#formatNumber(body.DistanceFromArrivalLS))
|
distance.text(UI.#formatNumber(body.DistanceFromArrivalLS))
|
||||||
row.appendChild(distance)
|
row.appendChild(distance)
|
||||||
|
|
||||||
// info
|
// info
|
||||||
const info = $('<div>').addClass(`col-1 system ${chartedStyle}`)
|
const info = $('<div>').addClass(`col-1 system ${chartedStyle} ${valuableStyle}`)
|
||||||
// terraformable
|
// terraformable
|
||||||
const terraform = $('<i>').addClass('flaticon-cooling-tower opacity-0')
|
const terraform = $('<i>').addClass('flaticon-cooling-tower opacity-0')
|
||||||
if (body.isPlanet && body.TerraformState) {
|
if (body.isPlanet && body.TerraformState) {
|
||||||
|
@ -125,7 +128,8 @@ export class UI {
|
||||||
}
|
}
|
||||||
info.appendChild(terraform)
|
info.appendChild(terraform)
|
||||||
// was mapped
|
// was mapped
|
||||||
const mapped = $('<i>').addClass('flaticon-flag-outline-on-a-pole-with-stars-around opacity-0')
|
const mapped = $('<i>')
|
||||||
|
mapped.addClass('flaticon-flag-outline-on-a-pole-with-stars-around opacity-0')
|
||||||
if (body.isPlanet() && !body.WasMapped) {
|
if (body.isPlanet() && !body.WasMapped) {
|
||||||
mapped.removeClass('opacity-0')
|
mapped.removeClass('opacity-0')
|
||||||
}
|
}
|
||||||
|
@ -133,7 +137,7 @@ export class UI {
|
||||||
row.appendChild(info)
|
row.appendChild(info)
|
||||||
|
|
||||||
// mapped value
|
// mapped value
|
||||||
const value = $('<div>').addClass(`col-2 text-end system ${chartedStyle}`)
|
const value = $('<div>').addClass(`col-2 text-end system ${chartedStyle} ${valuableStyle}`)
|
||||||
value.text(UI.#formatNumber(body.mappedValue))
|
value.text(UI.#formatNumber(body.mappedValue))
|
||||||
row.appendChild(value)
|
row.appendChild(value)
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ journal.watch()
|
||||||
|
|
||||||
journal.once('BUILD_BODY_LIST', () => {
|
journal.once('BUILD_BODY_LIST', () => {
|
||||||
if (journal.location?.bodies?.length > 0) {
|
if (journal.location?.bodies?.length > 0) {
|
||||||
|
journal.location.sortBodies()
|
||||||
|
|
||||||
journal.location.bodies.forEach((body) => {
|
journal.location.bodies.forEach((body) => {
|
||||||
const row = UI.createBodyRow(body)
|
const row = UI.createBodyRow(body)
|
||||||
// TODO APPRAISAL DATA
|
// TODO APPRAISAL DATA
|
||||||
|
@ -90,6 +92,8 @@ journal.on('ENTERED_NEW_SYSTEM', () => {
|
||||||
/* ---------------------------------------------------------------------- body scan detected ---- */
|
/* ---------------------------------------------------------------------- body scan detected ---- */
|
||||||
|
|
||||||
journal.on('BODY_SCANNED', (body, DSS) => {
|
journal.on('BODY_SCANNED', (body, DSS) => {
|
||||||
|
journal.location.sortBodies()
|
||||||
|
|
||||||
// If this is a DSS scan, it's very likely that the body already exists in our list so we just
|
// 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
|
// need to remove the highlighting if applicable
|
||||||
if (DSS) {
|
if (DSS) {
|
||||||
|
|
Loading…
Reference in a new issue