Skip to content

net.kernelpanicsoft.archie.gui.theme

Types

ComposableTheme

@Serializable



data class ComposableTheme(
    val isNineslice: Boolean = false, 
    val states: Map<String, ThemeState>, 
    val variants: Map<String, StatefulTheme> = emptyMap(), 
    val minSize: Size? = null, 
    val contentPadding: ThemePadding? = null
)

The full theme definition for a single composable type (e.g. button, slot).

RawComposableTheme

@Serializable



data class RawComposableTheme(
    val states: Map<String, RawThemeState> = emptyMap(), 
    val variants: Map<String, Map<String, RawThemeState>> = emptyMap(), 
    val minSize: Size? = null, 
    val contentPadding: ThemePadding? = null
)

Raw JSON shape of a theme file, deserialized as-is and resolved by ThemeResourceListener into a ComposableTheme.

RawThemeState

@Serializable



data class RawThemeState(
    val texture: String? = null, 
    val textureSize: Size? = null, 
    val u: Int? = null, 
    val v: Int? = null, 
    val width: Int? = null, 
    val height: Int? = null, 
    val uWidthSnake: Int? = null, 
    val vHeightSnake: Int? = null, 
    val uWidth: Int? = null, 
    val vHeight: Int? = null
)

Raw JSON shape of a single theme state; fields left null inherit from the state's "default" entry.

SimpleThemeState

@Serializable



data class SimpleThemeState(
    val texture: SResourceLocation, 
    val textureSize: Size, 
    val u: Int = 0, 
    val v: Int = 0, 
    val width: Int, 
    val height: Int, 
    val uWidth: Int, 
    val vHeight: Int
) : ThemeState

A fixed-size sprite slice within a sprite atlas or source image.

StatefulTheme

@Serializable



data class StatefulTheme(val states: Map<String, ThemeState>)

A map of state-name → ThemeState for a single variant of a composable.

ThemeData

@Immutable



data class ThemeData(
    val mode: String, 
    val type: String, 
    val darkTextColor: KColor, 
    val lightTextColor: KColor, 
    val namespace: String = Archie.MOD_ID
)

Immutable data holder describing the active theme context for composables.

ThemeManifest

@Serializable



data class ThemeManifest(
    val variants: Set<String> = setOf(ThemeVariants.DEFAULT), 
    val defaultVariant: String = ThemeVariants.DEFAULT, 
    val aliases: Map<String, String> = emptyMap()
)

Resource-pack-defined metadata for a theme (namespace + type), declaring which variant names are valid and how requested modes should resolve to them.

ThemeManifestResourceListener

Loads *.theme.json ThemeManifest resources from the archie_themes directory on resource pack reload, keyed by their resource location.

ThemePadding

@Serializable



data class ThemePadding(
    val all: Int = 0, 
    val horizontal: Int = 0, 
    val vertical: Int = 0, 
    val left: Int = 0, 
    val right: Int = 0, 
    val top: Int = 0, 
    val bottom: Int = 0
)

Inner spacing a composable using a theme should reserve around its own content, so e.g. a button's label never renders flush against the button's edges once it grows past ComposableTheme.minSize to fit a longer label.

ThemeResourceListener

A client resource-reload listener that loads ComposableTheme definitions from assets/<namespace>/archie_themes/ directories in resource packs.

ThemeState

@Serializable



sealed interface ThemeState

Sealed base for composable theme states rendered as sprites.

ThemeVariants

object ThemeVariants

Constants for the built-in theme variant names.

Properties

LocalTheme

val LocalTheme: ProvidableCompositionLocal<ThemeData>

Provides the current ThemeData to composables in the tree.

Functions

composableThemeLocation

inline fun composableThemeLocation(
    namespace: String, 
    type: String, 
    composable: String
): ResourceLocation

Builds the ResourceLocation used to look up a composable's default-variant theme definition.

inline fun composableThemeLocation(
    namespace: String, 
    type: String, 
    mode: String, 
    composable: String
): ResourceLocation

Builds the ResourceLocation used to look up a composable's theme definition for a specific non-default mode (variant).

Theme

@Composable



fun Theme(data: ThemeData, content: @Composable



 () -> Unit)

Sets the active theme using a pre-built ThemeData.

@Composable



fun Theme(
    mode: String = ThemeVariants.DEFAULT, 
    type: String = "java", 
    darkTextColor: KColor = KColor.DARK_GRAY, 
    lightTextColor: KColor = KColor.WHITE, 
    namespace: String = Archie.MOD_ID, 
    content: @Composable



 () -> Unit
)

Sets the active ThemeData for all composables in content.