Skip to content

Commit

Permalink
i18n for WorldTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanOltmann committed Oct 20, 2024
1 parent 9816d0d commit 6ce5b71
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 56 deletions.
50 changes: 26 additions & 24 deletions app/src/commonMain/kotlin/model/WorldTrait.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package model

import androidx.compose.ui.graphics.Color
import kotlinx.serialization.Serializable
import oni_seed_browser.app.generated.resources.*
import org.jetbrains.compose.resources.StringResource

/*
* See https://oxygennotincluded.fandom.com/wiki/World_Trait
Expand All @@ -29,127 +31,127 @@ import kotlinx.serialization.Serializable
@Suppress("UNUSED")
@Serializable
enum class WorldTrait(
val displayName: String,
val stringResource: StringResource,
val color: Color,
val rating: Rating = Rating.NEUTRAL
) {

BouldersLarge(
displayName = "Large Boulders",
stringResource = Res.string.worldTraitBouldersLarge,
color = Color(0xFFBDBDBD)
),
BouldersMedium(
displayName = "Medium Boulders",
stringResource = Res.string.worldTraitBouldersMedium,
color = Color(0xFFBDBDBD)
),
BouldersMixed(
displayName = "Mixed Boulders",
stringResource = Res.string.worldTraitBouldersMixed,
color = Color(0xFFBDBDBD)
),
BouldersSmall(
displayName = "Small Boulders",
stringResource = Res.string.worldTraitBouldersSmall,
color = Color(0xFFBDBDBD)
),
DeepOil(
displayName = "Trapped Oil",
stringResource = Res.string.worldTraitDeepOil,
color = Color(0xFF6E6E6E),
/* More oil reservoirs */
rating = Rating.VERY_GOOD
),
FrozenCore(
displayName = "Frozen Core",
stringResource = Res.string.worldTraitFrozenCore,
color = Color(0xFFA1D6ED),
/* Frozen core helps early with CO2 and to cool down the planet */
rating = Rating.GOOD
),
GeoActive(
displayName = "Geoactive",
stringResource = Res.string.worldTraitGeoActive,
color = Color(0xFFECA649),
/* More geyser output */
rating = Rating.VERY_GOOD
),
Geodes(
displayName = "Geodes",
stringResource = Res.string.worldTraitGeodes,
color = Color(0xFFC47BF4),
/* Helpful materials. */
rating = Rating.GOOD
),
GeoDormant(
displayName = "Geodormant",
stringResource = Res.string.worldTraitGeoDormant,
color = Color(0xFF8895A1),
/* Less geyser output */
rating = Rating.VERY_BAD
),
GlaciersLarge(
displayName = "Large Glaciers",
stringResource = Res.string.worldTraitGlaciersLarge,
color = Color(0xFFA1D6ED)
),
IrregularOil(
displayName = "Irregular Oil",
stringResource = Res.string.worldTraitIrregularOil,
color = Color(0xFF6C6C6C),
/* More oil patches, easier to access. */
rating = Rating.VERY_GOOD
),
MagmaVents(
displayName = "Magma Channels",
stringResource = Res.string.worldTraitMagmaVents,
color = Color(0xFFE7544D),
/* Makes the game harder */
rating = Rating.BAD
),
MetalPoor(
displayName = "Metal Poor",
stringResource = Res.string.worldTraitMetalPoor,
color = Color(0xFF8794A0),
/* Less metal */
rating = Rating.VERY_BAD
),
MetalRich(
displayName = "Metal Rich",
stringResource = Res.string.worldTraitMetalRich,
color = Color(0xFFD2AB4B),
/* More metal */
rating = Rating.VERY_GOOD
),
MisalignedStart(
displayName = "Alternate Pod Location",
stringResource = Res.string.worldTraitMisalignedStart,
color = Color(0xFFE7DC93)
),
SlimeSplats(
displayName = "Slime Molds",
stringResource = Res.string.worldTraitSlimeSplats,
color = Color(0xFF8EB542)
),
SubsurfaceOcean(
displayName = "Subsurface Ocean",
stringResource = Res.string.worldTraitSubsurfaceOcean,
color = Color(0xFF61CEF0)
),
Volcanoes(
displayName = "Volcanic Activity",
stringResource = Res.string.worldTraitVolcanoes,
color = Color(0xFFE7544D),
/* Makes the game harder, but more heat energy. */
rating = Rating.BAD
),
CrashedSatellites(
displayName = "Crashed Satellites",
stringResource = Res.string.worldTraitCrashedSatellites,
color = Color(0xFF7ED360),
/* Lots of free radiation */
rating = Rating.VERY_GOOD
),
DistressSignal(
displayName = "Frozen Friend",
stringResource = Res.string.worldTraitDistressSignal,
color = Color(0xFF8794A0)
),
LushCore(
displayName = "Lush Core",
stringResource = Res.string.worldTraitLushCore,
color = Color(0xFF66A052),
/* Access to pips */
rating = Rating.GOOD
),
MetalCaves(
displayName = "Metallic Caves",
stringResource = Res.string.worldTraitMetalCaves,
color = Color(0xFFD2AB4B),
/* More free metal */
rating = Rating.GOOD
),
RadioactiveCrust(
displayName = "Radioactive Crust",
stringResource = Res.string.worldTraitRadioactiveCrust,
color = Color(0xFF7ED360),
/* More free radiation */
rating = Rating.GOOD
Expand Down
9 changes: 0 additions & 9 deletions app/src/commonMain/kotlin/model/filter/FilterRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ data class FilterRule(
worldTrait != null || // always has a value
spaceDestinationCount?.count != null

fun getItemDescription(): String =
when {
geyserCount != null -> "Count: ${geyserCount.geyser.displayName}"
geyserOutput != null -> "Output (g/s): ${geyserOutput.geyser.displayName}"
worldTrait != null -> worldTrait.worldTrait.displayName
spaceDestinationCount != null -> "Space destination: ${spaceDestinationCount.poi}"
else -> "-/-"
}

fun getConditionDescription(): String =
when {
geyserCount != null -> geyserCount.condition.displayString
Expand Down
3 changes: 2 additions & 1 deletion app/src/commonMain/kotlin/ui/WolrdTraitDetail.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import model.WorldTrait
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import ui.theme.cardColorBackground
import ui.theme.defaultRoundedCornerShape
import ui.theme.doubleSpacing
Expand Down Expand Up @@ -68,7 +69,7 @@ fun WorlTraitDetail(
)

Text(
text = worldTrait.displayName,
text = stringResource(worldTrait.stringResource),
style = MaterialTheme.typography.headlineSmall,
color = worldTrait.color,
modifier = Modifier.offset(y = -2.dp)
Expand Down
21 changes: 13 additions & 8 deletions app/src/commonMain/kotlin/ui/filter/FilterPanelEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ package ui.filter
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
Expand All @@ -47,6 +41,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import model.filter.FilterRule
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import ui.getAsteroidTypeDrawable
import ui.noRippleClickable
import ui.onHover
Expand Down Expand Up @@ -131,7 +126,7 @@ fun FilterPanelEntry(
) {

Text(
text = rule.getItemDescription(),
text = getItemDescription(rule),
style = MaterialTheme.typography.bodyLarge,
fontWeight = FontWeight.Bold,
color = if (hoveredItem.value)
Expand Down Expand Up @@ -232,6 +227,16 @@ fun FilterPanelEntry(
}
}

@Composable
private fun getItemDescription(rule: FilterRule): String =
when {
rule.geyserCount != null -> "Count: ${rule.geyserCount.geyser.displayName}"
rule.geyserOutput != null -> "Output (g/s): ${rule.geyserOutput.geyser.displayName}"
rule.worldTrait != null -> stringResource(rule.worldTrait.worldTrait.stringResource)
rule.spaceDestinationCount != null -> "Space destination: ${rule.spaceDestinationCount.poi}"
else -> "-/-"
}

@Composable
private fun VerticalSeparator() {

Expand Down
18 changes: 4 additions & 14 deletions app/src/commonMain/kotlin/ui/filter/OverlayContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
package ui.filter

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
Expand All @@ -38,12 +32,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import model.GeyserType
import model.WorldTrait
import model.filter.FilterCondition
import model.filter.FilterItemGeyserCount
import model.filter.FilterItemGeyserOutput
import model.filter.FilterItemType
import model.filter.FilterItemWorldTrait
import model.filter.FilterQuery
import model.filter.*
import org.jetbrains.compose.resources.stringResource
import ui.getAsteroidTypeDrawable
import ui.getGeyserDrawable
import ui.getWorldTraitDrawable
Expand Down Expand Up @@ -159,7 +149,7 @@ fun OverlayContent(

FilterSelectionEntryItem(
image = getWorldTraitDrawable(worldTrait),
text = worldTrait.displayName,
text = stringResource(worldTrait.stringResource),
onClick = {

/* Update the query */
Expand Down

0 comments on commit 6ce5b71

Please sign in to comment.