Skip to content

Commit

Permalink
fix(map,connections): removing a connection did not remove the signat…
Browse files Browse the repository at this point in the history
…ure, causing rendering issues. also added text labels for connection sizes
  • Loading branch information
updraft0 committed Jun 21, 2024
1 parent b6e1685 commit 5f2fced
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,9 @@ object MapEntity extends ReactiveEntity[MapEnv, MapId, MapState, Identified[MapR
removeConn: MapRequest.RemoveSystemConnection
) =
for
// TODO: remove connection id from signature too!
_ <- query.map.deleteMapWormholeConnection(mapId, removeConn.connectionId, sessionId.characterId)
// delete any signatures that map to those connection ids
_ <- query.map.deleteSignaturesWithConnectionIds(mapId, Chunk(removeConn.connectionId), sessionId.characterId)
whcOpt <- MapQueries
.getWormholeConnectionsWithSigs(mapId, Some(removeConn.connectionId), includeDeleted = true)
.map(_.headOption)
Expand Down
16 changes: 16 additions & 0 deletions ui/src/main/css/views/map-connection.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ svg path.connector-path {
svg g.wormhole-connection {
pointer-events: bounding-box;

& text.connection-size {
fill: $gray-lightest;
stroke: none;
font-size: 0.6em;
}

&:hover {
z-index: 95;
filter: drop-shadow(-3px 3px 4px rgba(0,0,0, 0.3));
Expand Down Expand Up @@ -52,6 +58,12 @@ svg g.wormhole-connection {
}
}

&[data-mass-size="Unknown"] {
& text.connection-size {
display: none;
}
}

&[data-mass-size="S"] {
& path.connector-path-outline {
stroke-dasharray: 10 5;
Expand All @@ -65,6 +77,10 @@ svg g.wormhole-connection {
}

&[data-mass-size="XL"] {
&:hover path.connector-path-outline {
stroke: $gray-lighter;
}

& path.connector-path-outline {
stroke: $teal-dark;
stroke-width: 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ private val K162Types = List(
"k162-u",
"K162 -> C1/2/3",
"K162",
Some(WormholeClass.C3),
None,
WormholeConnectionType.K162(WormholeK162Type.Unknown)
),
WormholeSelectInfo(
"k162-d",
"K162 -> C4/5",
"K162",
Some(WormholeClass.C5),
None,
WormholeConnectionType.K162(WormholeK162Type.Dangerous)
),
WormholeSelectInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ class ConnectionView(
cx := s"${endPos.x}",
cy := s"${endPos.y}",
r := s"${ConnectionView.EndRadius}"
),
text(
cls := "connection-size",
filterAttr := "url(#background-size)",
x := s"${startPos.x + ((endPos.x - startPos.x) / 2)}",
y := s"${startPos.y + ((endPos.y - startPos.y) / 2)}",
textAnchor := "middle",
dominantBaseline := "central",
getWormholeMassSize(conn).toString
)
)
)
Expand Down
20 changes: 18 additions & 2 deletions ui/src/main/scala/controltower/page/map/view/MapController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,26 @@ class MapController(rds: ReferenceDataStore, val clock: Signal[Instant])(using O
whcs.foldLeft(map): (m, whc) =>
m
.updatedWith(whc.fromSystemId)(
_.map(mss => mss.copy(connections = mss.connections.filterNot(_.id == whc.id)))
_.map(mss =>
mss.copy(
signatures = mss.signatures.filterNot:
case w: MapSystemSignature.Wormhole => w.connectionId.contains(whc.id)
case _ => false
,
connections = mss.connections.filterNot(_.id == whc.id)
)
)
)
.updatedWith(whc.toSystemId)(
_.map(mss => mss.copy(connections = mss.connections.filterNot(_.id == whc.id)))
_.map(mss =>
mss.copy(
signatures = mss.signatures.filterNot:
case w: MapSystemSignature.Wormhole => w.connectionId.contains(whc.id)
case _ => false
,
connections = mss.connections.filterNot(_.id == whc.id)
)
)
)
),
allConnections.current -> ((conns: Map[ConnectionId, MapWormholeConnectionWithSigs]) =>
Expand Down
15 changes: 15 additions & 0 deletions ui/src/main/scala/controltower/page/map/view/MapView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,21 @@ private final class MapView(
svg.height := "100%",
svg.width := "100%",
svg.overflow := "visible",
svg.defs(
svg.filter(
// TODO could improve with drop shadows etc.
svg.idAttr := "background-size",
svg.width := "1.2",
svg.height := "1.2",
svg.x := "-0.1",
svg.y := "-0.1",
svg.feFlood(svg.floodColor := "#3c3f41" /* FIXME hardcoding? */ ),
svg.feComposite(
svg.in := "SourceGraphic",
svg.operator := "over"
)
)
),
children.command <-- connectionNodes,
connectionInProgress.view
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum ConnectionTarget derives CanEqual:
toSystemName: Signal[Option[String]],
toSolarSystem: SolarSystem,
isEol: Signal[Boolean],
connection: Signal[MapWormholeConnectionWithSigs],
connection: Signal[Option[MapWormholeConnectionWithSigs]],
sigId: Option[SigId]
) extends ConnectionTarget

Expand Down Expand Up @@ -83,17 +83,16 @@ private inline def sigView(

val connectionTargets = system.map: mss =>
mss.connections.map: whc =>
val targetId = if (whc.fromSystemId == systemId) whc.toSystemId else whc.fromSystemId
val connection =
mapCtx.connection(whc.id).map(_.getOrElse(throw new IllegalStateException("BUG: Connection id not found!")))
val targetId = if (whc.fromSystemId == systemId) whc.toSystemId else whc.fromSystemId
val connection = mapCtx.connection(whc.id)
ConnectionTarget.Wormhole(
id = whc.id,
toSystemId = targetId,
toSystemName = mapCtx.systemName(targetId),
toSolarSystem = static.solarSystemMap(targetId),
connection = connection,
isEol = connection.map(whcs =>
whcs.toSignature.exists(_.eolAt.nonEmpty) || whcs.fromSignature.exists(_.eolAt.nonEmpty)
isEol = connection.map(
_.exists(whcs => whcs.toSignature.exists(_.eolAt.nonEmpty) || whcs.fromSignature.exists(_.eolAt.nonEmpty))
),
sigId = mss.signatures
.find {
Expand Down Expand Up @@ -541,8 +540,12 @@ given DropdownItem[ConnectionTarget] with
span(
cls := "wormhole-connection-option",
dataAttr("connection-id") := id.toString,
dataAttr("mass-status") <-- connection.map(getWormholeMassStatus).map(_.toString),
dataAttr("mass-size") <-- connection.map(getWormholeMassSize).map(_.toString),
dataAttr("mass-status") <-- connection
.mapSome(getWormholeMassStatus)
.map(_.getOrElse(WormholeMassStatus.Unknown).toString),
dataAttr("mass-size") <-- connection
.mapSome(getWormholeMassSize)
.map(_.getOrElse(WormholeMassSize.Unknown).toString),
cls("wormhole-eol") <-- isEol,
span(
cls := "connection-system-name",
Expand Down Expand Up @@ -744,8 +747,15 @@ private[view] def wormholeSelect(
signatureGroups,
static.wormholeTypes
)
val wormholeType = Var(possibleWormholeTypes.find(_.connectionType == connectionType).get)
val dropdown = OptionDropdown(possibleWormholeTypes, wormholeType, isDisabled = canEdit.map(!_))
val wormholeType = Var(
possibleWormholeTypes
.find(_.connectionType == connectionType)
.getOrElse:
org.scalajs.dom.console
.debug(s"Potential bug - have a connection type ${connectionType} but no possible wormhole types found")
possibleWormholeTypes.head
)
val dropdown = OptionDropdown(possibleWormholeTypes, wormholeType, isDisabled = canEdit.map(!_))

if (useTd)
td(
Expand Down

0 comments on commit 5f2fced

Please sign in to comment.