From: Lanius Trolling Date: Sat, 24 Aug 2024 13:35:53 +0000 (-0400) Subject: Remove context receivers entirely X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=8ffa2ed0d4f60979ee480804f90b18eb46748ed8;p=factbooks Remove context receivers entirely --- diff --git a/build.gradle.kts b/build.gradle.kts index c75a739..61f7367 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -103,7 +103,6 @@ kotlin { all { languageSettings { optIn("kotlin.RequiresOptIn") - enableLanguageFeature("ContextReceivers") } } diff --git a/src/mapMain/kotlin/info/mechyrdia/mapviewer/render.kt b/src/mapMain/kotlin/info/mechyrdia/mapviewer/render.kt index 50be730..dfcf4b1 100644 --- a/src/mapMain/kotlin/info/mechyrdia/mapviewer/render.kt +++ b/src/mapMain/kotlin/info/mechyrdia/mapviewer/render.kt @@ -335,7 +335,7 @@ private fun setTitle(ptr: MapObjectPtr) { private fun CoroutineScope.setCurrentLocation(ptr: MapObjectPtr) { pushHistoryEntry(ptr) - renderLore(ptr) + renderLore(ptr, this) setTitle(ptr) } @@ -936,20 +936,19 @@ private fun CoroutineScope.renderSector(sectorId: String, initialSelection: Sect } } -context(CoroutineScope) @HtmlTagMarker -private inline fun FlowOrInteractiveOrPhrasingContent.a(ptr: MapObjectPtr, currentSectorId: String?, crossinline block: A.() -> Unit = {}) { +private inline fun FlowOrInteractiveOrPhrasingContent.a(ptr: MapObjectPtr, currentSectorId: String?, coroutineScope: CoroutineScope, crossinline block: A.() -> Unit) { a(href = ptr.toUrl().href) { onClickFunction = { ev -> ev.preventDefault() - openPtr(ptr, currentSectorId, true) + coroutineScope.openPtr(ptr, currentSectorId, true) } block() } } -private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { +private fun renderLore(ptr: MapObjectPtr, coroutineScope: CoroutineScope) { val loreBar = document.getElementById("lore-bar")!!.unsafeCast() loreBar.clear() @@ -963,7 +962,7 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { is SectorPtr -> { val sector = galaxyMap.sectors.getValue(ptr.sector) p { - a(GalaxyPtr, ptr.sector) { + a(GalaxyPtr, ptr.sector, coroutineScope) { +galaxyMap.universeTitle } } @@ -976,12 +975,12 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { val sector = galaxyMap.sectors.getValue(ptr.sector) val system = sector.starSystems.getValue(ptr.system) p { - a(GalaxyPtr, ptr.sector) { + a(GalaxyPtr, ptr.sector, coroutineScope) { +galaxyMap.universeTitle } +" > " val sectorPtr = SectorPtr(ptr.sector) - a(sectorPtr, ptr.sector) { + a(sectorPtr, ptr.sector, coroutineScope) { +sector.name } } @@ -1000,17 +999,17 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { val system = sector.starSystems.getValue(ptr.system) val body = system.celestialBodies.getValue(ptr.body) p { - a(GalaxyPtr, ptr.sector) { + a(GalaxyPtr, ptr.sector, coroutineScope) { +galaxyMap.universeTitle } +" > " val sectorPtr = SectorPtr(ptr.sector) - a(sectorPtr, ptr.sector) { + a(sectorPtr, ptr.sector, coroutineScope) { +sector.name } +" > " val starSystemPtr = StarSystemPtr(ptr.sector, ptr.system) - a(starSystemPtr, ptr.sector) { + a(starSystemPtr, ptr.sector, coroutineScope) { +system.name } } @@ -1049,7 +1048,7 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { for ((sectorId, sector) in sectorsList) li { val sectorPtr = SectorPtr(sectorId) - a(sectorPtr, null) { + a(sectorPtr, null, coroutineScope) { +sector.name } } @@ -1069,7 +1068,7 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { for ((systemId, system) in systemsList) li { val systemPtr = StarSystemPtr(ptr.sector, systemId) - a(systemPtr, ptr.sector) { + a(systemPtr, ptr.sector, coroutineScope) { +system.name } } @@ -1091,7 +1090,7 @@ private fun CoroutineScope.renderLore(ptr: MapObjectPtr) { for ((bodyId, body) in bodiesList) li { val bodyPtr = CelestialBodyPtr(ptr.sector, ptr.system, bodyId) - a(bodyPtr, ptr.sector) { + a(bodyPtr, ptr.sector, coroutineScope) { +body.name } }