From 2f99985e61d3b0afebfb57da3e37a2894282436e Mon Sep 17 00:00:00 2001 From: Stefan Oltmann Date: Sat, 19 Oct 2024 18:15:45 +0200 Subject: [PATCH] Renamed "World" to "Cluster" and "Cluster" to "ClusterType" to be more in line with the actual game namings --- app/src/commonMain/kotlin/model/Cluster.kt | 489 +---------------- .../commonMain/kotlin/model/ClusterType.kt | 507 ++++++++++++++++++ app/src/commonMain/kotlin/model/World.kt | 62 --- .../kotlin/model/filter/FilterQuery.kt | 8 +- ...Serializer.kt => ClusterTypeSerializer.kt} | 10 +- .../kotlin/service/DefaultWebClient.kt | 14 +- .../commonMain/kotlin/service/WebClient.kt | 8 +- app/src/commonMain/kotlin/ui/App.kt | 28 +- .../kotlin/ui/{WoldView.kt => ClusterView.kt} | 24 +- .../{WorldViewList.kt => ClusterViewList.kt} | 16 +- app/src/commonMain/kotlin/ui/DrawableUtil.kt | 68 +-- app/src/commonMain/kotlin/ui/StarMapView.kt | 10 +- .../kotlin/ui/filter/ClusterSelection.kt | 14 +- .../kotlin/ui/filter/FilterHeader.kt | 6 +- .../desktopMain/kotlin/BiomePathOptimizer.kt | 10 +- .../desktopMain/kotlin/GenerateSampleQuery.kt | 4 +- .../desktopMain/kotlin/OptimizeSampleData.kt | 6 +- 17 files changed, 642 insertions(+), 642 deletions(-) create mode 100644 app/src/commonMain/kotlin/model/ClusterType.kt delete mode 100644 app/src/commonMain/kotlin/model/World.kt rename app/src/commonMain/kotlin/serializer/{ClusterSerializer.kt => ClusterTypeSerializer.kt} (83%) rename app/src/commonMain/kotlin/ui/{WoldView.kt => ClusterView.kt} (94%) rename app/src/commonMain/kotlin/ui/{WorldViewList.kt => ClusterViewList.kt} (91%) diff --git a/app/src/commonMain/kotlin/model/Cluster.kt b/app/src/commonMain/kotlin/model/Cluster.kt index 81fe2a3..4ad3cf9 100644 --- a/app/src/commonMain/kotlin/model/Cluster.kt +++ b/app/src/commonMain/kotlin/model/Cluster.kt @@ -20,488 +20,43 @@ package model import kotlinx.serialization.Serializable +import serializer.ClusterTypeSerializer @Suppress("UNUSED") @Serializable -enum class Cluster( - val prefix: String, - val displayName: String, - val asteroidTypes: List -) { - - /** Terra */ - BASE_TERRA( - prefix = "SNDST-A", - displayName = "Terra", - asteroidTypes = listOf( - AsteroidType.SandstoneDefault - ) - ), - - /** Ceres */ - BASE_CERES( - prefix = "CER-A", - displayName = "Ceres", - asteroidTypes = listOf( - AsteroidType.CeresBaseGameAsteroid - ) - ), - - /** Ceres */ - BASE_BLASTED_CERES( - prefix = "CERS-A", - displayName = "Blasted Ceres", - asteroidTypes = listOf( - AsteroidType.CeresBaseGameShatteredAsteroid - ) - ), - - /** Oceania */ - BASE_OCEANIA( - prefix = "OCAN-A", - displayName = "Oceania", - asteroidTypes = listOf( - AsteroidType.Oceania - ) - ), - - /** Rime */ - BASE_RIME( - prefix = "S-FRZ", - displayName = "Rime", - asteroidTypes = listOf( - AsteroidType.SandstoneFrozen - ) - ), - - /** Verdante */ - BASE_VERDANTE( - prefix = "LUSH-A", - displayName = "Verdante", - asteroidTypes = listOf( - AsteroidType.ForestLush - ) - ), - - /** Arboria */ - BASE_ARBORIA( - prefix = "FRST-A", - displayName = "Arboria", - asteroidTypes = listOf( - AsteroidType.ForestDefault - ) - ), - - /** Volcanea */ - BASE_VOLCANEA( - prefix = "VOLCA", - displayName = "Volcanea", - asteroidTypes = listOf( - AsteroidType.Volcanic - ) - ), - - /** The Badlands */ - BASE_THE_BADLANDS( - prefix = "BAD-A", - displayName = "The Badlands", - asteroidTypes = listOf( - AsteroidType.Badlands - ) - ), - - /** Aridio */ - BASE_ARIDIO( - prefix = "HTFST-A", - displayName = "Aridio", - asteroidTypes = listOf( - AsteroidType.ForestHot - ) - ), - - /** Oasisse */ - BASE_OASISSE( - prefix = "OASIS-A", - displayName = "Oasisse", - asteroidTypes = listOf( - AsteroidType.Oasis - ) - ), - - /** Terra */ - DLC_TERRA( - prefix = "V-SNDST-C", - displayName = "Terra", - asteroidTypes = listOf( - AsteroidType.VanillaSandstoneDefault, - AsteroidType.MediumRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), +data class Cluster( - /** Ceres */ - DLC_CERES( - prefix = "V-CER-C", - displayName = "Ceres", - asteroidTypes = listOf( - AsteroidType.CeresClassicAsteroid, - AsteroidType.MediumSwampy, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + val coordinate: String, - /** Ceres (lab) */ - DLC_BLASTED_CERES( - prefix = "V-CERS-C", - displayName = "Blasted Ceres", - asteroidTypes = listOf( - AsteroidType.CeresClassicShatteredAsteroid, - AsteroidType.MediumSwampy, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + @Serializable(with = ClusterTypeSerializer::class) + val cluster: ClusterType, - /** Oceania */ - DLC_OCEANIA( - prefix = "V-OCAN-C", - displayName = "Oceania", - asteroidTypes = listOf( - AsteroidType.VanillaOceania, - AsteroidType.MediumForestyWasteland, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + val dlcs: List, - /** Squelchy */ - DLC_SQUELCHY( - prefix = "V-SWMP-C", - displayName = "Squelchy", - asteroidTypes = listOf( - AsteroidType.VanillaSwampDefault, - AsteroidType.MediumForestyRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + val asteroids: List, - /** Rime */ - DLC_RIME( - prefix = "V-SFRZ-C", - displayName = "Rime", - asteroidTypes = listOf( - AsteroidType.VanillaSandstoneFrozen, - AsteroidType.MediumSwampy, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + val starMapEntriesVanilla: List?, - /** Verdante */ - DLC_VERDANTE( - prefix = "V-LUSH-C", - displayName = "Verdante", - asteroidTypes = listOf( - AsteroidType.VanillaForestDefault, - AsteroidType.MediumSandyRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), + val starMapEntriesSpacedOut: List? - /** Arboria */ - DLC_ARBORIA( - prefix = "V-FRST-C", - displayName = "Arboria", - asteroidTypes = listOf( - AsteroidType.VanillaArboria, - AsteroidType.MediumSandyRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), - - /** Volcanea */ - DLC_VOLCANEA( - prefix = "V-VOLCA-C", - displayName = "Volcanea", - asteroidTypes = listOf( - AsteroidType.VanillaVolcanic, - AsteroidType.MediumRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), - - /** The Badlands */ - DLC_THE_BADLANDS( - prefix = "V-BAD-C", - displayName = "The Badlands", - asteroidTypes = listOf( - AsteroidType.VanillaBadlands, - AsteroidType.MediumRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), - - /** Aridio */ - DLC_ARIDIO( - prefix = "V-HTFST-C", - displayName = "Aridio", - asteroidTypes = listOf( - AsteroidType.VanillaAridio, - AsteroidType.MediumSandySwamp, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), - - /** Oasisse */ - DLC_OASISSE( - prefix = "V-OASIS-C", - displayName = "Oasisse", - asteroidTypes = listOf( - AsteroidType.VanillaOasis, - AsteroidType.MediumRadioactiveVanillaWarpPlanet, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.MiniRegolithMoonlet - ) - ), - - /** Terrania */ - DLC_TERRANIA( - prefix = "SNDST-C", - displayName = "Terrania", - asteroidTypes = listOf( - AsteroidType.TerraMoonlet, - AsteroidType.IdealLandingSite, - AsteroidType.WarpOilySwamp, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Ceres Minor */ - DLC_CERES_MINOR( - prefix = "CER-C", - displayName = "Ceres Minor", - asteroidTypes = listOf( - AsteroidType.CeresSpacedOutAsteroid, - AsteroidType.SwampyLandingSite, - AsteroidType.OilRichWarpTarget, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Folia */ - DLC_FOLIA( - prefix = "FRST-C", - displayName = "Folia", - asteroidTypes = listOf( - AsteroidType.ForestMoonlet, - AsteroidType.SwampyLandingSite, - AsteroidType.OilRichWarpTarget, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Quagmiris */ - DLC_QUAGMIRIS( - prefix = "SWMP-C", - displayName = "Quagmiris", - asteroidTypes = listOf( - AsteroidType.SwampMoonlet, - AsteroidType.MetalHeavyLandingSite, - AsteroidType.OilRichWarpTarget, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Metallic Swampy Moonlet */ - DLC_METALLIC_SWAMPY_MOONLET( - prefix = "M-SWMP-C", - displayName = "Metallic Swampy Moonlet", - asteroidTypes = listOf( - AsteroidType.MiniMetallicSwampyStart, - AsteroidType.MiniBadlands, - AsteroidType.MiniForestFrozenWarp, - AsteroidType.MiniFlipped, - AsteroidType.MiniRadioactiveOcean, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** The Desolands Moonlet */ - DLC_THE_DESOLANDS_MOONLET( - prefix = "M-BAD-C", - displayName = "The Desolands Moonlet", - asteroidTypes = listOf( - AsteroidType.MiniBadlandsStart, - AsteroidType.MiniRadioactiveOceanWarp, - AsteroidType.MiniMetallicSwampy, - AsteroidType.MiniForestFrozen, - AsteroidType.MiniFlipped, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Frozen Forest Moonlet */ - DLC_FROZEN_FOREST_MOONLET( - prefix = "M-FRZ-C", - displayName = "Frozen Forest Moonlet", - asteroidTypes = listOf( - AsteroidType.MiniForestFrozenStart, - AsteroidType.MiniBadlandsWarp, - AsteroidType.MiniMetallicSwampy, - AsteroidType.MiniFlipped, - AsteroidType.MiniRadioactiveOcean, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), - - /** Flipped Moonlet */ - DLC_FLIPPED_MOONLET( - prefix = "M-FLIP-C", - displayName = "Flipped Moonlet", - asteroidTypes = listOf( - AsteroidType.MiniFlippedStart, - AsteroidType.MiniBadlandsWarp, - AsteroidType.MiniMetallicSwampy, - AsteroidType.MiniForestFrozen, - AsteroidType.MiniRadioactiveOcean, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ), +) { - /** Radioactive Ocean Moonlet */ - DLC_RADIOACTIVE_OCEAN_MOONLET( - prefix = "M-RAD-C", - displayName = "Radioactive Ocean Moonlet", - asteroidTypes = listOf( - AsteroidType.MiniRadioactiveOceanStart, - AsteroidType.MiniBadlands, - AsteroidType.MiniFlippedWarp, - AsteroidType.MiniMetallicSwampy, - AsteroidType.MiniForestFrozen, - AsteroidType.TundraMoonlet, - AsteroidType.MarshyMoonlet, - AsteroidType.MooMoonlet, - AsteroidType.WaterMoonlet, - AsteroidType.NiobiumMoonlet, - AsteroidType.RegolithMoonlet - ) - ); + /** + * Rating value for sorting, based on the starter asteroid. + */ + fun getRating(): Int { - fun isFrostyPlanet(): Boolean = - this == BASE_CERES || this == DLC_CERES || this == DLC_CERES_MINOR + val startingAsteroid = asteroids.first() - fun isBaseGame(): Boolean = - this.name.startsWith("BASE_") + var rating = 0 - companion object { + /* Rate traits higher than geysers; for that multiply. */ + for (worldTrait in startingAsteroid.worldTraits) + rating += worldTrait.rating.value * 3 - val baseGameCluster = listOf( - BASE_TERRA, BASE_CERES, BASE_OCEANIA, BASE_RIME, BASE_VERDANTE, BASE_ARBORIA, - BASE_VOLCANEA, BASE_THE_BADLANDS, BASE_ARIDIO, BASE_OASISSE - ) + for (geyser in startingAsteroid.geysers) + rating += geyser.id.rating.value - val spacedOutCluster = listOf( - DLC_TERRA, DLC_CERES, DLC_OCEANIA, DLC_SQUELCHY, DLC_RIME, DLC_VERDANTE, - DLC_ARBORIA, DLC_VOLCANEA, DLC_THE_BADLANDS, DLC_ARIDIO, DLC_OASISSE, - DLC_TERRANIA, DLC_CERES_MINOR, DLC_FOLIA, DLC_QUAGMIRIS, - DLC_METALLIC_SWAMPY_MOONLET, DLC_THE_DESOLANDS_MOONLET, - DLC_FROZEN_FOREST_MOONLET, DLC_FLIPPED_MOONLET, DLC_RADIOACTIVE_OCEAN_MOONLET - ) + return rating } } diff --git a/app/src/commonMain/kotlin/model/ClusterType.kt b/app/src/commonMain/kotlin/model/ClusterType.kt new file mode 100644 index 0000000..cff8241 --- /dev/null +++ b/app/src/commonMain/kotlin/model/ClusterType.kt @@ -0,0 +1,507 @@ +/* + * ONI Seed Browser + * Copyright (C) 2024 Stefan Oltmann + * https://stefan-oltmann.de/oni-seed-browser + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package model + +import kotlinx.serialization.Serializable + +@Suppress("UNUSED") +@Serializable +enum class ClusterType( + val prefix: String, + val displayName: String, + val asteroidTypes: List +) { + + /** Terra */ + BASE_TERRA( + prefix = "SNDST-A", + displayName = "Terra", + asteroidTypes = listOf( + AsteroidType.SandstoneDefault + ) + ), + + /** Ceres */ + BASE_CERES( + prefix = "CER-A", + displayName = "Ceres", + asteroidTypes = listOf( + AsteroidType.CeresBaseGameAsteroid + ) + ), + + /** Ceres */ + BASE_BLASTED_CERES( + prefix = "CERS-A", + displayName = "Blasted Ceres", + asteroidTypes = listOf( + AsteroidType.CeresBaseGameShatteredAsteroid + ) + ), + + /** Oceania */ + BASE_OCEANIA( + prefix = "OCAN-A", + displayName = "Oceania", + asteroidTypes = listOf( + AsteroidType.Oceania + ) + ), + + /** Rime */ + BASE_RIME( + prefix = "S-FRZ", + displayName = "Rime", + asteroidTypes = listOf( + AsteroidType.SandstoneFrozen + ) + ), + + /** Verdante */ + BASE_VERDANTE( + prefix = "LUSH-A", + displayName = "Verdante", + asteroidTypes = listOf( + AsteroidType.ForestLush + ) + ), + + /** Arboria */ + BASE_ARBORIA( + prefix = "FRST-A", + displayName = "Arboria", + asteroidTypes = listOf( + AsteroidType.ForestDefault + ) + ), + + /** Volcanea */ + BASE_VOLCANEA( + prefix = "VOLCA", + displayName = "Volcanea", + asteroidTypes = listOf( + AsteroidType.Volcanic + ) + ), + + /** The Badlands */ + BASE_THE_BADLANDS( + prefix = "BAD-A", + displayName = "The Badlands", + asteroidTypes = listOf( + AsteroidType.Badlands + ) + ), + + /** Aridio */ + BASE_ARIDIO( + prefix = "HTFST-A", + displayName = "Aridio", + asteroidTypes = listOf( + AsteroidType.ForestHot + ) + ), + + /** Oasisse */ + BASE_OASISSE( + prefix = "OASIS-A", + displayName = "Oasisse", + asteroidTypes = listOf( + AsteroidType.Oasis + ) + ), + + /** Terra */ + DLC_TERRA( + prefix = "V-SNDST-C", + displayName = "Terra", + asteroidTypes = listOf( + AsteroidType.VanillaSandstoneDefault, + AsteroidType.MediumRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Ceres */ + DLC_CERES( + prefix = "V-CER-C", + displayName = "Ceres", + asteroidTypes = listOf( + AsteroidType.CeresClassicAsteroid, + AsteroidType.MediumSwampy, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Ceres (lab) */ + DLC_BLASTED_CERES( + prefix = "V-CERS-C", + displayName = "Blasted Ceres", + asteroidTypes = listOf( + AsteroidType.CeresClassicShatteredAsteroid, + AsteroidType.MediumSwampy, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Oceania */ + DLC_OCEANIA( + prefix = "V-OCAN-C", + displayName = "Oceania", + asteroidTypes = listOf( + AsteroidType.VanillaOceania, + AsteroidType.MediumForestyWasteland, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Squelchy */ + DLC_SQUELCHY( + prefix = "V-SWMP-C", + displayName = "Squelchy", + asteroidTypes = listOf( + AsteroidType.VanillaSwampDefault, + AsteroidType.MediumForestyRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Rime */ + DLC_RIME( + prefix = "V-SFRZ-C", + displayName = "Rime", + asteroidTypes = listOf( + AsteroidType.VanillaSandstoneFrozen, + AsteroidType.MediumSwampy, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Verdante */ + DLC_VERDANTE( + prefix = "V-LUSH-C", + displayName = "Verdante", + asteroidTypes = listOf( + AsteroidType.VanillaForestDefault, + AsteroidType.MediumSandyRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Arboria */ + DLC_ARBORIA( + prefix = "V-FRST-C", + displayName = "Arboria", + asteroidTypes = listOf( + AsteroidType.VanillaArboria, + AsteroidType.MediumSandyRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Volcanea */ + DLC_VOLCANEA( + prefix = "V-VOLCA-C", + displayName = "Volcanea", + asteroidTypes = listOf( + AsteroidType.VanillaVolcanic, + AsteroidType.MediumRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** The Badlands */ + DLC_THE_BADLANDS( + prefix = "V-BAD-C", + displayName = "The Badlands", + asteroidTypes = listOf( + AsteroidType.VanillaBadlands, + AsteroidType.MediumRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Aridio */ + DLC_ARIDIO( + prefix = "V-HTFST-C", + displayName = "Aridio", + asteroidTypes = listOf( + AsteroidType.VanillaAridio, + AsteroidType.MediumSandySwamp, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Oasisse */ + DLC_OASISSE( + prefix = "V-OASIS-C", + displayName = "Oasisse", + asteroidTypes = listOf( + AsteroidType.VanillaOasis, + AsteroidType.MediumRadioactiveVanillaWarpPlanet, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.MiniRegolithMoonlet + ) + ), + + /** Terrania */ + DLC_TERRANIA( + prefix = "SNDST-C", + displayName = "Terrania", + asteroidTypes = listOf( + AsteroidType.TerraMoonlet, + AsteroidType.IdealLandingSite, + AsteroidType.WarpOilySwamp, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Ceres Minor */ + DLC_CERES_MINOR( + prefix = "CER-C", + displayName = "Ceres Minor", + asteroidTypes = listOf( + AsteroidType.CeresSpacedOutAsteroid, + AsteroidType.SwampyLandingSite, + AsteroidType.OilRichWarpTarget, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Folia */ + DLC_FOLIA( + prefix = "FRST-C", + displayName = "Folia", + asteroidTypes = listOf( + AsteroidType.ForestMoonlet, + AsteroidType.SwampyLandingSite, + AsteroidType.OilRichWarpTarget, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Quagmiris */ + DLC_QUAGMIRIS( + prefix = "SWMP-C", + displayName = "Quagmiris", + asteroidTypes = listOf( + AsteroidType.SwampMoonlet, + AsteroidType.MetalHeavyLandingSite, + AsteroidType.OilRichWarpTarget, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Metallic Swampy Moonlet */ + DLC_METALLIC_SWAMPY_MOONLET( + prefix = "M-SWMP-C", + displayName = "Metallic Swampy Moonlet", + asteroidTypes = listOf( + AsteroidType.MiniMetallicSwampyStart, + AsteroidType.MiniBadlands, + AsteroidType.MiniForestFrozenWarp, + AsteroidType.MiniFlipped, + AsteroidType.MiniRadioactiveOcean, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** The Desolands Moonlet */ + DLC_THE_DESOLANDS_MOONLET( + prefix = "M-BAD-C", + displayName = "The Desolands Moonlet", + asteroidTypes = listOf( + AsteroidType.MiniBadlandsStart, + AsteroidType.MiniRadioactiveOceanWarp, + AsteroidType.MiniMetallicSwampy, + AsteroidType.MiniForestFrozen, + AsteroidType.MiniFlipped, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Frozen Forest Moonlet */ + DLC_FROZEN_FOREST_MOONLET( + prefix = "M-FRZ-C", + displayName = "Frozen Forest Moonlet", + asteroidTypes = listOf( + AsteroidType.MiniForestFrozenStart, + AsteroidType.MiniBadlandsWarp, + AsteroidType.MiniMetallicSwampy, + AsteroidType.MiniFlipped, + AsteroidType.MiniRadioactiveOcean, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Flipped Moonlet */ + DLC_FLIPPED_MOONLET( + prefix = "M-FLIP-C", + displayName = "Flipped Moonlet", + asteroidTypes = listOf( + AsteroidType.MiniFlippedStart, + AsteroidType.MiniBadlandsWarp, + AsteroidType.MiniMetallicSwampy, + AsteroidType.MiniForestFrozen, + AsteroidType.MiniRadioactiveOcean, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ), + + /** Radioactive Ocean Moonlet */ + DLC_RADIOACTIVE_OCEAN_MOONLET( + prefix = "M-RAD-C", + displayName = "Radioactive Ocean Moonlet", + asteroidTypes = listOf( + AsteroidType.MiniRadioactiveOceanStart, + AsteroidType.MiniBadlands, + AsteroidType.MiniFlippedWarp, + AsteroidType.MiniMetallicSwampy, + AsteroidType.MiniForestFrozen, + AsteroidType.TundraMoonlet, + AsteroidType.MarshyMoonlet, + AsteroidType.MooMoonlet, + AsteroidType.WaterMoonlet, + AsteroidType.NiobiumMoonlet, + AsteroidType.RegolithMoonlet + ) + ); + + fun isFrostyPlanet(): Boolean = + this == BASE_CERES || this == DLC_CERES || this == DLC_CERES_MINOR + + fun isBaseGame(): Boolean = + this.name.startsWith("BASE_") + + companion object { + + val baseGameCluster = listOf( + BASE_TERRA, BASE_CERES, BASE_OCEANIA, BASE_RIME, BASE_VERDANTE, BASE_ARBORIA, + BASE_VOLCANEA, BASE_THE_BADLANDS, BASE_ARIDIO, BASE_OASISSE + ) + + val spacedOutCluster = listOf( + DLC_TERRA, DLC_CERES, DLC_OCEANIA, DLC_SQUELCHY, DLC_RIME, DLC_VERDANTE, + DLC_ARBORIA, DLC_VOLCANEA, DLC_THE_BADLANDS, DLC_ARIDIO, DLC_OASISSE, + DLC_TERRANIA, DLC_CERES_MINOR, DLC_FOLIA, DLC_QUAGMIRIS, + DLC_METALLIC_SWAMPY_MOONLET, DLC_THE_DESOLANDS_MOONLET, + DLC_FROZEN_FOREST_MOONLET, DLC_FLIPPED_MOONLET, DLC_RADIOACTIVE_OCEAN_MOONLET + ) + } +} diff --git a/app/src/commonMain/kotlin/model/World.kt b/app/src/commonMain/kotlin/model/World.kt deleted file mode 100644 index 56d9e79..0000000 --- a/app/src/commonMain/kotlin/model/World.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ONI Seed Browser - * Copyright (C) 2024 Stefan Oltmann - * https://stefan-oltmann.de/oni-seed-browser - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package model - -import kotlinx.serialization.Serializable -import serializer.ClusterSerializer - -@Suppress("UNUSED") -@Serializable -data class World( - - val coordinate: String, - - @Serializable(with = ClusterSerializer::class) - val cluster: Cluster, - - val dlcs: List, - - val asteroids: List, - - val starMapEntriesVanilla: List?, - - val starMapEntriesSpacedOut: List? - -) { - - /** - * Rating value for sorting, based on the starter asteroid. - */ - fun getRating(): Int { - - val startingAsteroid = asteroids.first() - - var rating = 0 - - /* Rate traits higher than geysers; for that multiply. */ - for (worldTrait in startingAsteroid.worldTraits) - rating += worldTrait.rating.value * 3 - - for (geyser in startingAsteroid.geysers) - rating += geyser.id.rating.value - - return rating - } -} diff --git a/app/src/commonMain/kotlin/model/filter/FilterQuery.kt b/app/src/commonMain/kotlin/model/filter/FilterQuery.kt index 04cbcdd..6c17b1b 100644 --- a/app/src/commonMain/kotlin/model/filter/FilterQuery.kt +++ b/app/src/commonMain/kotlin/model/filter/FilterQuery.kt @@ -21,16 +21,16 @@ package model.filter import kotlinx.serialization.Serializable import model.AsteroidType -import model.Cluster +import model.ClusterType import model.Dlc import model.filter.FilterRule.Companion.EMPTY -import serializer.ClusterSerializer +import serializer.ClusterTypeSerializer @Serializable data class FilterQuery( - @Serializable(with = ClusterSerializer::class) - val cluster: Cluster?, + @Serializable(with = ClusterTypeSerializer::class) + val cluster: ClusterType?, val dlcs: List, diff --git a/app/src/commonMain/kotlin/serializer/ClusterSerializer.kt b/app/src/commonMain/kotlin/serializer/ClusterTypeSerializer.kt similarity index 83% rename from app/src/commonMain/kotlin/serializer/ClusterSerializer.kt rename to app/src/commonMain/kotlin/serializer/ClusterTypeSerializer.kt index 17020d2..e837f9d 100644 --- a/app/src/commonMain/kotlin/serializer/ClusterSerializer.kt +++ b/app/src/commonMain/kotlin/serializer/ClusterTypeSerializer.kt @@ -25,21 +25,21 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import model.Cluster +import model.ClusterType -object ClusterSerializer : KSerializer { +object ClusterTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Cluster", PrimitiveKind.STRING) - override fun serialize(encoder: Encoder, value: Cluster) = + override fun serialize(encoder: Encoder, value: ClusterType) = encoder.encodeString(value.prefix) - override fun deserialize(decoder: Decoder): Cluster { + override fun deserialize(decoder: Decoder): ClusterType { val prefix = decoder.decodeString() - return Cluster.entries.find { it.prefix == prefix } + return ClusterType.entries.find { it.prefix == prefix } ?: throw IllegalArgumentException("Unknown prefix: $prefix") } } diff --git a/app/src/commonMain/kotlin/service/DefaultWebClient.kt b/app/src/commonMain/kotlin/service/DefaultWebClient.kt index e6ee591..760cb5f 100644 --- a/app/src/commonMain/kotlin/service/DefaultWebClient.kt +++ b/app/src/commonMain/kotlin/service/DefaultWebClient.kt @@ -28,7 +28,7 @@ import io.ktor.http.* import io.ktor.serialization.kotlinx.json.* import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import model.World +import model.Cluster import model.filter.FilterQuery const val BASE_API_URL = "https://apibeta.mapsnotincluded.org" @@ -56,9 +56,9 @@ object DefaultWebClient : WebClient { } } - override suspend fun countWorlds(): Long? { + override suspend fun countSeeds(): Long? { - println("Count worlds") + println("Count seeds") val response = httpClient.get(COUNT_URL) @@ -68,7 +68,7 @@ object DefaultWebClient : WebClient { return response.body() } - override suspend fun find(coordinate: String): World? { + override suspend fun find(coordinate: String): Cluster? { println("Find: $coordinate") @@ -82,15 +82,15 @@ object DefaultWebClient : WebClient { return response.body() } - override suspend fun search(filterQuery: FilterQuery): List { + override suspend fun search(filterQuery: FilterQuery): List { println("Search: " + jsonPretty.encodeToString(filterQuery)) - val worlds: List = httpClient.post(SEARCH_URL) { + val clusters: List = httpClient.post(SEARCH_URL) { contentType(ContentType.Application.Json) setBody(filterQuery) }.body() - return worlds + return clusters } } diff --git a/app/src/commonMain/kotlin/service/WebClient.kt b/app/src/commonMain/kotlin/service/WebClient.kt index 901b4b3..7f74001 100644 --- a/app/src/commonMain/kotlin/service/WebClient.kt +++ b/app/src/commonMain/kotlin/service/WebClient.kt @@ -19,15 +19,15 @@ package service -import model.World +import model.Cluster import model.filter.FilterQuery interface WebClient { - suspend fun countWorlds(): Long? + suspend fun countSeeds(): Long? - suspend fun find(coordinate: String): World? + suspend fun find(coordinate: String): Cluster? - suspend fun search(filterQuery: FilterQuery): List + suspend fun search(filterQuery: FilterQuery): List } diff --git a/app/src/commonMain/kotlin/ui/App.kt b/app/src/commonMain/kotlin/ui/App.kt index dab8f22..82b0534 100644 --- a/app/src/commonMain/kotlin/ui/App.kt +++ b/app/src/commonMain/kotlin/ui/App.kt @@ -39,7 +39,7 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch import kotlinx.serialization.json.Json import model.Asteroid -import model.World +import model.Cluster import model.filter.FilterQuery import oni_seed_browser.app.generated.resources.Res import oni_seed_browser.app.generated.resources.background_space @@ -67,7 +67,7 @@ fun App( ) { val worldCount = produceState(null) { - value = DefaultWebClient.countWorlds() + value = DefaultWebClient.countSeeds() } val coroutineScope = rememberCoroutineScope() @@ -76,7 +76,7 @@ fun App( val lazyListState = rememberLazyListState() - val showStarMap = remember { mutableStateOf(null) } + val showStarMap = remember { mutableStateOf(null) } val showAsteroidMap = remember { mutableStateOf(null) } @@ -93,7 +93,7 @@ fun App( showAsteroidDetails.value = null } - val worlds = remember { mutableStateOf(emptyList()) } + val clusters = remember { mutableStateOf(emptyList()) } LaunchedEffect(urlHash.value) { @@ -110,9 +110,9 @@ fun App( val world = DefaultWebClient.find(urlHashValue) if (world != null) - worlds.value = listOf(world) + clusters.value = listOf(world) else - worlds.value = emptyList() + clusters.value = emptyList() } catch (ex: Exception) { @@ -128,10 +128,10 @@ fun App( println("Load demo data...") - val parsedWorlds = Json.decodeFromString>(sampleWorldsJson) + val parsedClusters = Json.decodeFromString>(sampleWorldsJson) /* DLCs first */ - worlds.value = parsedWorlds.sortedWith(compareBy({ it.cluster.isBaseGame() }, { it.cluster })) + clusters.value = parsedClusters.sortedWith(compareBy({ it.cluster.isBaseGame() }, { it.cluster })) } } @@ -140,7 +140,7 @@ fun App( if (worldForStarMapView != null) { StarMapView( - world = worldForStarMapView, + cluster = worldForStarMapView, onCloseClicked = { showStarMap.value = null } ) @@ -217,7 +217,7 @@ fun App( errorMessage.value = null /* Reset the data */ - worlds.value = emptyList() + clusters.value = emptyList() val searchResultWorlds = DefaultWebClient.search( filterQueryState.value @@ -225,7 +225,7 @@ fun App( val sortedWorlds = searchResultWorlds.sortedByDescending { it.getRating() } - worlds.value = sortedWorlds + clusters.value = sortedWorlds } catch (ex: Exception) { @@ -262,7 +262,7 @@ fun App( ) } - } else if (worlds.value.isEmpty()) { + } else if (clusters.value.isEmpty()) { Box( contentAlignment = Alignment.Center, @@ -302,9 +302,9 @@ fun App( modifier = Modifier.weight(1F) ) { - WorldViewList( + ClusterViewList( lazyListState, - worlds.value, + clusters.value, showStarMap, showAsteroidMap, showAsteroidDetails, diff --git a/app/src/commonMain/kotlin/ui/WoldView.kt b/app/src/commonMain/kotlin/ui/ClusterView.kt similarity index 94% rename from app/src/commonMain/kotlin/ui/WoldView.kt rename to app/src/commonMain/kotlin/ui/ClusterView.kt index f811c28..0d78de6 100644 --- a/app/src/commonMain/kotlin/ui/WoldView.kt +++ b/app/src/commonMain/kotlin/ui/ClusterView.kt @@ -38,18 +38,18 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import kotlinx.coroutines.delay import model.Asteroid -import model.World +import model.Cluster import ui.theme.* import kotlin.math.max val widthPerWorld: Dp = 380.dp @Composable -fun WorldView( - world: World, +fun ClusterView( + cluster: Cluster, index: Int, totalCount: Int, - showStarMap: MutableState, + showStarMap: MutableState, showAsteroidMap: MutableState, showAsteroidDetails: MutableState, showTooltip: MutableState @@ -61,13 +61,13 @@ fun WorldView( .border(0.dp, lightGrayTransparentBorderColor, defaultRoundedCornerShape) ) { - val showMapClicked: (() -> Unit) = { showStarMap.value = world } + val showMapClicked: (() -> Unit) = { showStarMap.value = cluster } CoordinateBox( index = index, totalCount = totalCount, - coordinate = world.coordinate, - showMapClicked = if (world.starMapEntriesSpacedOut != null) + coordinate = cluster.coordinate, + showMapClicked = if (cluster.starMapEntriesSpacedOut != null) showMapClicked else null @@ -80,7 +80,7 @@ fun WorldView( if (asteroid == null) { AsteroidsGrid( - world, + cluster, showAsteroidMap, showAsteroidDetails, showTooltip @@ -109,7 +109,7 @@ fun WorldView( val clipboardManager = LocalClipboardManager.current - val url = "https://stefan-oltmann.de/oni-seed-browser/#" + world.coordinate; + val url = "https://stefan-oltmann.de/oni-seed-browser/#" + cluster.coordinate; Spacer(modifier = Modifier.width(defaultSpacing + halfSpacing)) @@ -164,7 +164,7 @@ fun WorldView( @Composable private fun AsteroidsGrid( - world: World, + cluster: Cluster, showAsteroidMap: MutableState, showAsteroidDetails: MutableState, showTooltip: MutableState @@ -187,7 +187,7 @@ private fun AsteroidsGrid( verticalArrangement = Arrangement.spacedBy(defaultSpacing) ) { - val firstAsteroid = world.asteroids.first() + val firstAsteroid = cluster.asteroids.first() /* First Asteroid should span the whole column. */ AsteroidView( @@ -207,7 +207,7 @@ private fun AsteroidsGrid( } ) - val remainingAsteroids = world.asteroids.drop(1) + val remainingAsteroids = cluster.asteroids.drop(1) val asteroidsPerColumn = remainingAsteroids.chunked(gridLayoutColumnCount) diff --git a/app/src/commonMain/kotlin/ui/WorldViewList.kt b/app/src/commonMain/kotlin/ui/ClusterViewList.kt similarity index 91% rename from app/src/commonMain/kotlin/ui/WorldViewList.kt rename to app/src/commonMain/kotlin/ui/ClusterViewList.kt index 32562c6..afe6fd2 100644 --- a/app/src/commonMain/kotlin/ui/WorldViewList.kt +++ b/app/src/commonMain/kotlin/ui/ClusterViewList.kt @@ -34,15 +34,15 @@ import androidx.compose.runtime.MutableState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import model.Asteroid -import model.World +import model.Cluster import ui.theme.doubleSpacing import ui.theme.lightGray @Composable -fun WorldViewList( +fun ClusterViewList( lazyListState: LazyListState, - worlds: List, - showStarMap: MutableState, + clusters: List, + showStarMap: MutableState, showAsteroidMap: MutableState, showAsteroidDetails: MutableState, showTooltip: MutableState, @@ -57,12 +57,12 @@ fun WorldViewList( modifier = Modifier.padding(doubleSpacing) ) { - itemsIndexed(worlds) { index, world -> + itemsIndexed(clusters) { index, cluster -> - WorldView( - world, + ClusterView( + cluster, index + 1, - worlds.size, + clusters.size, showStarMap, showAsteroidMap, showAsteroidDetails, diff --git a/app/src/commonMain/kotlin/ui/DrawableUtil.kt b/app/src/commonMain/kotlin/ui/DrawableUtil.kt index 76d522b..ef74266 100644 --- a/app/src/commonMain/kotlin/ui/DrawableUtil.kt +++ b/app/src/commonMain/kotlin/ui/DrawableUtil.kt @@ -100,40 +100,40 @@ fun getPointOfInterestDrawable(pointOfInterestType: PointOfInterestType): Drawab } @Composable -fun getClusterDrawable(cluster: Cluster): DrawableResource = - when (cluster) { - Cluster.BASE_TERRA -> Res.drawable.cluster_base_terra - Cluster.BASE_CERES -> Res.drawable.cluster_base_ceres - Cluster.BASE_BLASTED_CERES -> Res.drawable.asteroid_blasted_ceres - Cluster.BASE_OCEANIA -> Res.drawable.cluster_base_oceania - Cluster.BASE_RIME -> Res.drawable.cluster_base_rime - Cluster.BASE_VERDANTE -> Res.drawable.cluster_base_verdante - Cluster.BASE_ARBORIA -> Res.drawable.cluster_base_arboria - Cluster.BASE_VOLCANEA -> Res.drawable.cluster_base_volcanea - Cluster.BASE_THE_BADLANDS -> Res.drawable.cluster_base_the_badlands - Cluster.BASE_ARIDIO -> Res.drawable.cluster_base_aridio - Cluster.BASE_OASISSE -> Res.drawable.cluster_base_oasisse - Cluster.DLC_TERRA -> Res.drawable.cluster_spacedout_terra - Cluster.DLC_CERES -> Res.drawable.asteroid_spacedout_ceres - Cluster.DLC_BLASTED_CERES -> Res.drawable.asteroid_blasted_ceres_spaced_out - Cluster.DLC_CERES_MINOR -> Res.drawable.asteroid_spacedout_ceres_minor - Cluster.DLC_OCEANIA -> Res.drawable.cluster_spacedout_oceania - Cluster.DLC_SQUELCHY -> Res.drawable.cluster_spacedout_squelchy - Cluster.DLC_RIME -> Res.drawable.cluster_spacedout_rime - Cluster.DLC_VERDANTE -> Res.drawable.cluster_spacedout_verdante - Cluster.DLC_ARBORIA -> Res.drawable.cluster_spacedout_arboria - Cluster.DLC_VOLCANEA -> Res.drawable.cluster_spacedout_volcanea - Cluster.DLC_THE_BADLANDS -> Res.drawable.cluster_spacedout_the_badlands - Cluster.DLC_ARIDIO -> Res.drawable.cluster_spacedout_aridio - Cluster.DLC_OASISSE -> Res.drawable.cluster_spacedout_oasisse - Cluster.DLC_TERRANIA -> Res.drawable.cluster_spacedout_terrania - Cluster.DLC_FOLIA -> Res.drawable.cluster_spacedout_folia - Cluster.DLC_QUAGMIRIS -> Res.drawable.cluster_spacedout_quagmiris - Cluster.DLC_METALLIC_SWAMPY_MOONLET -> Res.drawable.cluster_spacedout_metallic_swampy_moonlet - Cluster.DLC_THE_DESOLANDS_MOONLET -> Res.drawable.cluster_spacedout_the_desolands_moonlet - Cluster.DLC_FROZEN_FOREST_MOONLET -> Res.drawable.cluster_spacedout_frozen_forest_moonlet - Cluster.DLC_FLIPPED_MOONLET -> Res.drawable.cluster_spacedout_flipped_moonlet - Cluster.DLC_RADIOACTIVE_OCEAN_MOONLET -> Res.drawable.cluster_spacedout_radioactive_ocean_moonlet +fun getClusterDrawable(clusterType: ClusterType): DrawableResource = + when (clusterType) { + ClusterType.BASE_TERRA -> Res.drawable.cluster_base_terra + ClusterType.BASE_CERES -> Res.drawable.cluster_base_ceres + ClusterType.BASE_BLASTED_CERES -> Res.drawable.asteroid_blasted_ceres + ClusterType.BASE_OCEANIA -> Res.drawable.cluster_base_oceania + ClusterType.BASE_RIME -> Res.drawable.cluster_base_rime + ClusterType.BASE_VERDANTE -> Res.drawable.cluster_base_verdante + ClusterType.BASE_ARBORIA -> Res.drawable.cluster_base_arboria + ClusterType.BASE_VOLCANEA -> Res.drawable.cluster_base_volcanea + ClusterType.BASE_THE_BADLANDS -> Res.drawable.cluster_base_the_badlands + ClusterType.BASE_ARIDIO -> Res.drawable.cluster_base_aridio + ClusterType.BASE_OASISSE -> Res.drawable.cluster_base_oasisse + ClusterType.DLC_TERRA -> Res.drawable.cluster_spacedout_terra + ClusterType.DLC_CERES -> Res.drawable.asteroid_spacedout_ceres + ClusterType.DLC_BLASTED_CERES -> Res.drawable.asteroid_blasted_ceres_spaced_out + ClusterType.DLC_CERES_MINOR -> Res.drawable.asteroid_spacedout_ceres_minor + ClusterType.DLC_OCEANIA -> Res.drawable.cluster_spacedout_oceania + ClusterType.DLC_SQUELCHY -> Res.drawable.cluster_spacedout_squelchy + ClusterType.DLC_RIME -> Res.drawable.cluster_spacedout_rime + ClusterType.DLC_VERDANTE -> Res.drawable.cluster_spacedout_verdante + ClusterType.DLC_ARBORIA -> Res.drawable.cluster_spacedout_arboria + ClusterType.DLC_VOLCANEA -> Res.drawable.cluster_spacedout_volcanea + ClusterType.DLC_THE_BADLANDS -> Res.drawable.cluster_spacedout_the_badlands + ClusterType.DLC_ARIDIO -> Res.drawable.cluster_spacedout_aridio + ClusterType.DLC_OASISSE -> Res.drawable.cluster_spacedout_oasisse + ClusterType.DLC_TERRANIA -> Res.drawable.cluster_spacedout_terrania + ClusterType.DLC_FOLIA -> Res.drawable.cluster_spacedout_folia + ClusterType.DLC_QUAGMIRIS -> Res.drawable.cluster_spacedout_quagmiris + ClusterType.DLC_METALLIC_SWAMPY_MOONLET -> Res.drawable.cluster_spacedout_metallic_swampy_moonlet + ClusterType.DLC_THE_DESOLANDS_MOONLET -> Res.drawable.cluster_spacedout_the_desolands_moonlet + ClusterType.DLC_FROZEN_FOREST_MOONLET -> Res.drawable.cluster_spacedout_frozen_forest_moonlet + ClusterType.DLC_FLIPPED_MOONLET -> Res.drawable.cluster_spacedout_flipped_moonlet + ClusterType.DLC_RADIOACTIVE_OCEAN_MOONLET -> Res.drawable.cluster_spacedout_radioactive_ocean_moonlet } @Composable diff --git a/app/src/commonMain/kotlin/ui/StarMapView.kt b/app/src/commonMain/kotlin/ui/StarMapView.kt index 12781e9..5798c10 100644 --- a/app/src/commonMain/kotlin/ui/StarMapView.kt +++ b/app/src/commonMain/kotlin/ui/StarMapView.kt @@ -40,7 +40,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp import model.AsteroidType import model.SpacedOutSpacePOI -import model.World +import model.Cluster import oni_seed_browser.app.generated.resources.Res import oni_seed_browser.app.generated.resources.background_space import org.jetbrains.compose.resources.painterResource @@ -57,11 +57,11 @@ private val gridColor = lightGray.copy(alpha = 0.2f) @Composable fun StarMapView( - world: World, + cluster: Cluster, onCloseClicked: () -> Unit ) { - if (world.starMapEntriesSpacedOut == null) + if (cluster.starMapEntriesSpacedOut == null) return Box( @@ -89,7 +89,7 @@ fun StarMapView( CoordinateBox( index = 0, totalCount = 0, - coordinate = world.coordinate, + coordinate = cluster.coordinate, showMapClicked = null ) @@ -105,7 +105,7 @@ fun StarMapView( val hexHeight = (hexSize * 2 * (cos(PI / 6))).toFloat() - for (entry in world.starMapEntriesSpacedOut) { + for (entry in cluster.starMapEntriesSpacedOut) { val xOffset = hexSize * 3 / 2 * entry.q * cos(ROTATION_RADIANS) - hexHeight * (entry.r + entry.q / 2f) * sin(ROTATION_RADIANS) diff --git a/app/src/commonMain/kotlin/ui/filter/ClusterSelection.kt b/app/src/commonMain/kotlin/ui/filter/ClusterSelection.kt index 903bb2a..62a73a6 100644 --- a/app/src/commonMain/kotlin/ui/filter/ClusterSelection.kt +++ b/app/src/commonMain/kotlin/ui/filter/ClusterSelection.kt @@ -38,7 +38,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import model.Cluster +import model.ClusterType import model.Dlc import model.filter.FilterQuery import org.jetbrains.compose.resources.painterResource @@ -61,14 +61,14 @@ fun ClusterSelection( val enableFrostyPlanet = query.dlcs.contains(Dlc.FrostyPlanet) - val currentSelectedCluster: Cluster? = filterQueryState.value.cluster + val currentSelectedClusterType: ClusterType? = filterQueryState.value.cluster - val clusters = if (spacedOutDlcSelected.value) - Cluster.spacedOutCluster + val clusterTypes = if (spacedOutDlcSelected.value) + ClusterType.spacedOutCluster else - Cluster.baseGameCluster + ClusterType.baseGameCluster - val filteredClusters = clusters.filterNot { + val filteredClusters = clusterTypes.filterNot { !enableFrostyPlanet && it.isFrostyPlanet() } @@ -81,7 +81,7 @@ fun ClusterSelection( for (cluster in filteredClusters) { - val isSelected = currentSelectedCluster == cluster + val isSelected = currentSelectedClusterType == cluster val clusterHovered = remember { mutableStateOf(false) } diff --git a/app/src/commonMain/kotlin/ui/filter/FilterHeader.kt b/app/src/commonMain/kotlin/ui/filter/FilterHeader.kt index e7170ec..1ee2732 100644 --- a/app/src/commonMain/kotlin/ui/filter/FilterHeader.kt +++ b/app/src/commonMain/kotlin/ui/filter/FilterHeader.kt @@ -46,7 +46,7 @@ import ui.theme.defaultRoundedCornerShape @Composable fun FilterHeader( - worldCount: Long?, + seedCount: Long?, filterPanelOpen: MutableState ) { @@ -73,10 +73,10 @@ fun FilterHeader( DoubleSpacer() Text( - text = if (worldCount == null) + text = if (seedCount == null) "Filter" else - "Filter ($worldCount seeds in database)", + "Filter ($seedCount seeds in database)", style = MaterialTheme.typography.headlineMedium, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onBackground diff --git a/app/src/desktopMain/kotlin/BiomePathOptimizer.kt b/app/src/desktopMain/kotlin/BiomePathOptimizer.kt index 5135f30..8eb77b6 100644 --- a/app/src/desktopMain/kotlin/BiomePathOptimizer.kt +++ b/app/src/desktopMain/kotlin/BiomePathOptimizer.kt @@ -25,7 +25,7 @@ import com.menecats.polybool.models.Polygon import model.Asteroid import model.BiomePaths import model.Point -import model.World +import model.Cluster import model.ZoneType import kotlin.math.roundToInt @@ -82,9 +82,9 @@ fun BiomePaths.optimize(): BiomePaths { return BiomePaths(mergedPolygonMap) } -fun List.optimizeBiomePaths(): List { +fun List.optimizeBiomePaths(): List { - val optimizedWorlds = mutableListOf() + val optimizedClusters = mutableListOf() for (world in this) { @@ -104,12 +104,12 @@ fun List.optimizeBiomePaths(): List { ) } - optimizedWorlds.add( + optimizedClusters.add( world.copy( asteroids = optimizedAsteroids ) ) } - return optimizedWorlds + return optimizedClusters } diff --git a/app/src/desktopMain/kotlin/GenerateSampleQuery.kt b/app/src/desktopMain/kotlin/GenerateSampleQuery.kt index 33d7fcc..b75a355 100644 --- a/app/src/desktopMain/kotlin/GenerateSampleQuery.kt +++ b/app/src/desktopMain/kotlin/GenerateSampleQuery.kt @@ -20,7 +20,7 @@ import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import model.AsteroidType -import model.Cluster +import model.ClusterType import model.Dlc import model.GeyserType import model.WorldTrait @@ -103,7 +103,7 @@ fun main() { val query = FilterQuery( - cluster = Cluster.BASE_TERRA, + cluster = ClusterType.BASE_TERRA, dlcs = listOf(Dlc.FrostyPlanet), rules = listOf(firstRuleGroup, listOf(secondRule), thirdRuleGroup) ) diff --git a/app/src/desktopMain/kotlin/OptimizeSampleData.kt b/app/src/desktopMain/kotlin/OptimizeSampleData.kt index 227ba27..1ef28b9 100644 --- a/app/src/desktopMain/kotlin/OptimizeSampleData.kt +++ b/app/src/desktopMain/kotlin/OptimizeSampleData.kt @@ -19,16 +19,16 @@ import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import model.World +import model.Cluster import service.sampleWorldsJson import java.io.File fun main() { - val parsedWorlds = Json.decodeFromString>(sampleWorldsJson) + val parsedClusters = Json.decodeFromString>(sampleWorldsJson) /* DLCs first */ - val sortedWorlds = parsedWorlds.sortedWith(compareBy({ it.cluster.isBaseGame() }, { it.cluster })) + val sortedWorlds = parsedClusters.sortedWith(compareBy({ it.cluster.isBaseGame() }, { it.cluster })) val optimizedWorlds = sortedWorlds.optimizeBiomePaths()