Skip to content

Commit

Permalink
show outpost names in detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
ManApart committed Nov 18, 2023
1 parent 4bd7e0f commit 0343023
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/UserInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable
data class PlanetInfo(
val labels: MutableSet<Label> = mutableSetOf(),
var notes: String = "",
val outPosts: MutableSet<Outpost> = mutableSetOf()
val outPosts: MutableList<Outpost> = mutableListOf()
)

@Serializable
Expand Down
15 changes: 15 additions & 0 deletions src/jsMain/kotlin/views/SystemView.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package views

import Outpost
import Planet
import PlanetInfo
import ResourceType
Expand Down Expand Up @@ -256,6 +257,8 @@ private fun TagConsumer<HTMLElement>.detailView(system: StarSystem, planet: Plan
}
}
resourceRow(resources)
val info = inMemoryStorage.planetUserInfo[planet.uniqueId] ?: PlanetInfo()
outPostsRow(info.outPosts)
}
div { id = "user-info" }
}
Expand All @@ -281,6 +284,18 @@ private fun TagConsumer<HTMLElement>.resourceRow(resources: Set<ResourceType>) {
}
}
}
private fun TagConsumer<HTMLElement>.outPostsRow(outposts: List<Outpost>) {
tr {
td("outpost-td") { +"Outposts" }
td("outpost-value-td") {
if (outposts.isEmpty()) {
+"None"
} else {
+outposts.joinToString(", ") { it.name }
}
}
}
}

private fun navigateOrrery(key: KeyboardEvent) {
if (window.location.hash.contains("system") && currentSystem != null) {
Expand Down

0 comments on commit 0343023

Please sign in to comment.