diff --git a/gradle.properties b/gradle.properties index 78aa71d..6474675 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss -version=2.0.0-alpha.13 +version=2.0.0-alpha.14 idofrontVersion=0.22.3 diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt b/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt index d742c34..916e9c1 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt @@ -19,6 +19,7 @@ data class Config( val useRecommendedJvmArguments: Boolean = true, val preferHue: Float? = null, val startInFullscreen: Boolean = false, + val lastPlayedMap: Map = mapOf(), ) { fun save() { Dirs.configFile.writeText(Formats.yaml.encodeToString(this)) diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstance.kt b/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstance.kt index 884a11c..063bb69 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstance.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstance.kt @@ -12,7 +12,7 @@ import com.mineinabyss.launchy.logic.UpdateResult import com.mineinabyss.launchy.logic.showDialogOnError import com.mineinabyss.launchy.state.InProgressTask import com.mineinabyss.launchy.state.LaunchyState -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -40,8 +40,8 @@ class GameInstance( var updatesAvailable by mutableStateOf(false) var enabled: Boolean by mutableStateOf(true) - suspend fun createModpackState(state: LaunchyState): ModpackState? { - val userConfig = ModpackUserConfig.load(userConfigFile).getOrNull() ?: ModpackUserConfig() + suspend fun createModpackState(state: LaunchyState): GameInstanceState? { + val userConfig = InstanceUserConfig.load(userConfigFile).getOrNull() ?: InstanceUserConfig() val modpack = state.runTask("loadingModpack ${config.name}", InProgressTask("Loading modpack ${config.name}")) { config.source.loadInstance(this) @@ -59,7 +59,7 @@ class GameInstance( updatesAvailable = true } } - return ModpackState(this, modpack, userConfig) + return GameInstanceState(this, modpack, userConfig) } init { diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/config/ModpackUserConfig.kt b/src/main/kotlin/com/mineinabyss/launchy/data/config/InstanceUserConfig.kt similarity index 88% rename from src/main/kotlin/com/mineinabyss/launchy/data/config/ModpackUserConfig.kt rename to src/main/kotlin/com/mineinabyss/launchy/data/config/InstanceUserConfig.kt index 2fe9939..63bc7f5 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/config/ModpackUserConfig.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/config/InstanceUserConfig.kt @@ -43,7 +43,7 @@ data class DownloadInfo( } @Serializable -data class ModpackUserConfig( +data class InstanceUserConfig( val userAgreedDeps: InstanceModLoaders? = null, val fullEnabledGroups: Set = setOf(), val fullDisabledGroups: Set = setOf(), @@ -56,13 +56,13 @@ data class ModpackUserConfig( ) { fun save(file: Path) { file.createParentDirectories().deleteIfExists() - file.writeText(Formats.yaml.encodeToString(this)) + file.writeText(Formats.yaml.encodeToString(this)) } companion object { - fun load(file: Path): Result = runCatching { - return@runCatching if (file.exists()) Formats.yaml.decodeFromStream(file.inputStream()) - else ModpackUserConfig() + fun load(file: Path): Result = runCatching { + return@runCatching if (file.exists()) Formats.yaml.decodeFromStream(file.inputStream()) + else InstanceUserConfig() }.onFailure { it.printStackTrace() } } } diff --git a/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt b/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt index 9bfe41e..3e3038e 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt @@ -3,7 +3,7 @@ package com.mineinabyss.launchy.logic import com.mineinabyss.launchy.data.modpacks.InstanceModLoaders import com.mineinabyss.launchy.state.LaunchyState import com.mineinabyss.launchy.state.ProfileState -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import com.mineinabyss.launchy.ui.screens.Dialog import com.mineinabyss.launchy.ui.screens.dialog import kotlinx.coroutines.Job @@ -30,7 +30,7 @@ import kotlin.io.path.notExists object Launcher { - suspend fun launch(state: LaunchyState, pack: ModpackState, profile: ProfileState): Unit = coroutineScope { + suspend fun launch(state: LaunchyState, pack: GameInstanceState, profile: ProfileState): Unit = coroutineScope { val dir = MinecraftDirectory(pack.instance.minecraftDir.toFile()) val launcher = LauncherBuilder.buildDefault() val javaPath = state.jvm.javaPath @@ -38,6 +38,7 @@ object Launcher { dialog = Dialog.ChooseJVMPath return@coroutineScope } + state.lastPlayed[pack.instance.config.name] = Date().time // Auth or show dialog when (val session = profile.currentSession) { null -> Auth.authOrShowDialog(state, profile) { diff --git a/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt b/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt index 6275280..65e2b9c 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt @@ -6,7 +6,7 @@ import com.mineinabyss.launchy.data.modpacks.InstanceModLoaders import com.mineinabyss.launchy.data.modpacks.Mod import com.mineinabyss.launchy.state.InProgressTask import com.mineinabyss.launchy.state.LaunchyState -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope @@ -16,7 +16,7 @@ import kotlin.io.path.* object ModDownloader { - suspend fun ModpackState.installMCAndModLoaders(state: LaunchyState, modLoaders: InstanceModLoaders) { + suspend fun GameInstanceState.installMCAndModLoaders(state: LaunchyState, modLoaders: InstanceModLoaders) { state.runTask(Tasks.installModLoadersId, InProgressTask("Installing ${modLoaders.fabricLoader}")) { Launcher.download( modLoaders, @@ -35,7 +35,7 @@ object ModDownloader { data object Failed : DownloadResult } - suspend fun ModpackState.download(mod: Mod, ignoreCachedCheck: Boolean): DownloadResult { + suspend fun GameInstanceState.download(mod: Mod, ignoreCachedCheck: Boolean): DownloadResult { val name = mod.info.name try { println("Starting download of $name") @@ -91,7 +91,7 @@ object ModDownloader { * does not install any mod updates or new dep versions if they changed in the modpack. * Primarily the mod loader/minecraft version. */ - suspend fun ModpackState.ensureDependenciesReady(state: LaunchyState) = coroutineScope { + suspend fun GameInstanceState.ensureDependenciesReady(state: LaunchyState) = coroutineScope { val currentDeps = userAgreedDeps if (currentDeps == null) { userAgreedDeps = modpack.modLoaders @@ -99,7 +99,7 @@ object ModDownloader { installMCAndModLoaders(state, currentDeps ?: modpack.modLoaders) } - fun ModpackState.copyMods() { + fun GameInstanceState.copyMods() { // Clear mods folder val existingEntries = instance.modsDir.useDirectoryEntries { files -> files.filter { !it.isDirectory() }.toList() @@ -122,13 +122,13 @@ object ModDownloader { (existingEntries - linked).forEach { it.deleteIfExists() } } - suspend fun ModpackState.prepareWithoutChangingInstalledMods(state: LaunchyState) { + suspend fun GameInstanceState.prepareWithoutChangingInstalledMods(state: LaunchyState) { ensureDependenciesReady(state) copyMods() } @OptIn(ExperimentalPathApi::class) - fun ModpackState.copyOverrides(state: LaunchyState) { + fun GameInstanceState.copyOverrides(state: LaunchyState) { state.runTask(Tasks.copyOverridesId, InProgressTask("Copying overrides")) { modpack.overridesPaths.forEach { it.copyToRecursively( @@ -143,7 +143,7 @@ object ModDownloader { /** * Updates mod loader versions and mods to latest modpack definition. */ - suspend fun ModpackState.startInstall(state: LaunchyState, ignoreCachedCheck: Boolean = false): Result<*> = + suspend fun GameInstanceState.startInstall(state: LaunchyState, ignoreCachedCheck: Boolean = false): Result<*> = coroutineScope { userAgreedDeps = modpack.modLoaders ensureDependenciesReady(state) diff --git a/src/main/kotlin/com/mineinabyss/launchy/state/LaunchyState.kt b/src/main/kotlin/com/mineinabyss/launchy/state/LaunchyState.kt index 30d42c9..a80249a 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/state/LaunchyState.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/state/LaunchyState.kt @@ -3,7 +3,7 @@ package com.mineinabyss.launchy.state import androidx.compose.runtime.* import com.mineinabyss.launchy.data.config.Config import com.mineinabyss.launchy.data.config.GameInstance -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import java.util.* class LaunchyState( @@ -12,10 +12,13 @@ class LaunchyState( private val instances: List ) { val profile = ProfileState(config) - var modpackState: ModpackState? by mutableStateOf(null) + var instanceState: GameInstanceState? by mutableStateOf(null) private val launchedProcesses = mutableStateMapOf() val jvm = JvmState(config) val ui = UIState(config) + val lastPlayed = mutableStateMapOf().apply { + putAll(config.lastPlayedMap) + } val gameInstances = mutableStateListOf().apply { addAll(instances) @@ -46,7 +49,8 @@ class LaunchyState( memoryAllocation = jvm.userMemoryAllocation, useRecommendedJvmArguments = jvm.useRecommendedJvmArgs, preferHue = ui.preferHue, - startInFullscreen = ui.fullscreen + startInFullscreen = ui.fullscreen, + lastPlayedMap = lastPlayed ).save() } diff --git a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/DownloadQueueState.kt b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/DownloadQueueState.kt index f8c1e00..453d182 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/DownloadQueueState.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/DownloadQueueState.kt @@ -5,11 +5,11 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateMapOf import com.mineinabyss.launchy.data.ModID import com.mineinabyss.launchy.data.config.DownloadInfo -import com.mineinabyss.launchy.data.config.ModpackUserConfig +import com.mineinabyss.launchy.data.config.InstanceUserConfig import com.mineinabyss.launchy.data.modpacks.Modpack class DownloadQueueState( - private val userConfig: ModpackUserConfig, + private val userConfig: InstanceUserConfig, val modpack: Modpack, val toggles: ModTogglesState ) { diff --git a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModpackState.kt b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/GameInstanceState.kt similarity index 91% rename from src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModpackState.kt rename to src/main/kotlin/com/mineinabyss/launchy/state/modpack/GameInstanceState.kt index b3792eb..b4d831d 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModpackState.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/GameInstanceState.kt @@ -4,13 +4,13 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.mineinabyss.launchy.data.config.GameInstance -import com.mineinabyss.launchy.data.config.ModpackUserConfig +import com.mineinabyss.launchy.data.config.InstanceUserConfig import com.mineinabyss.launchy.data.modpacks.Modpack -class ModpackState( +class GameInstanceState( val instance: GameInstance, val modpack: Modpack, - private val userConfig: ModpackUserConfig + private val userConfig: InstanceUserConfig ) { val toggles: ModTogglesState = ModTogglesState(modpack, userConfig) val queued = DownloadQueueState(userConfig, modpack, toggles) diff --git a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModTogglesState.kt b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModTogglesState.kt index df37399..ba8411e 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModTogglesState.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/state/modpack/ModTogglesState.kt @@ -2,7 +2,7 @@ package com.mineinabyss.launchy.state.modpack import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue -import com.mineinabyss.launchy.data.config.ModpackUserConfig +import com.mineinabyss.launchy.data.config.InstanceUserConfig import com.mineinabyss.launchy.data.modpacks.Mod import com.mineinabyss.launchy.data.modpacks.Modpack import com.mineinabyss.launchy.logic.ToggleMods.setModEnabled @@ -10,7 +10,7 @@ import com.mineinabyss.launchy.state.mutableStateSetOf class ModTogglesState( val modpack: Modpack, - val modpackConfig: ModpackUserConfig + val modpackConfig: InstanceUserConfig ) { val enabledMods = mutableStateSetOf().apply { addAll(modpackConfig.toggledMods.mapNotNull { modpack.mods.getMod(it) }) diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/Screens.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/Screens.kt index 4d1b435..794e4d7 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/Screens.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/Screens.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import com.mineinabyss.launchy.LocalLaunchyState import com.mineinabyss.launchy.state.InProgressTask -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import com.mineinabyss.launchy.ui.AppTopBar import com.mineinabyss.launchy.ui.colors.currentHue import com.mineinabyss.launchy.ui.dialogs.AuthDialog @@ -22,7 +22,7 @@ import com.mineinabyss.launchy.ui.elements.LaunchyDialog import com.mineinabyss.launchy.ui.screens.home.HomeScreen import com.mineinabyss.launchy.ui.screens.home.newinstance.NewInstance import com.mineinabyss.launchy.ui.screens.home.settings.SettingsScreen -import com.mineinabyss.launchy.ui.screens.modpack.main.ModpackScreen +import com.mineinabyss.launchy.ui.screens.modpack.main.InstanceScreen import com.mineinabyss.launchy.ui.screens.modpack.main.SlightBackgroundTint import com.mineinabyss.launchy.ui.screens.modpack.settings.InfoBarProperties import com.mineinabyss.launchy.ui.screens.modpack.settings.InstanceSettingsScreen @@ -32,11 +32,11 @@ var screen: Screen by mutableStateOf(Screen.Default) var dialog: Dialog by mutableStateOf(Dialog.None) -private val ModpackStateProvider = compositionLocalOf { error("No local modpack provided") } +private val ModpackStateProvider = compositionLocalOf { error("No local modpack provided") } val snackbarHostState = SnackbarHostState() -val LocalModpackState: ModpackState +val LocalGameInstanceState: GameInstanceState @Composable get() = ModpackStateProvider.current @Composable @@ -44,10 +44,10 @@ fun Screens() = Scaffold( snackbarHost = { SnackbarHost(snackbarHostState) } ) { val state = LocalLaunchyState - val packState = state.modpackState + val packState = state.instanceState if (packState != null) CompositionLocalProvider(ModpackStateProvider provides packState) { - Screen(Screen.Instance) { ModpackScreen() } + Screen(Screen.Instance) { InstanceScreen() } Screen(Screen.InstanceSettings, transition = Transitions.SlideUp) { InstanceSettingsScreen() } } Screen(Screen.Default) { HomeScreen() } diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/HomeScreen.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/HomeScreen.kt index 527bf21..872f1b0 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/HomeScreen.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/HomeScreen.kt @@ -40,7 +40,7 @@ fun HomeScreen() { Spacer(Modifier.height(16.dp)) } item { - ModpackGroup("Instances", state.gameInstances) + InstanceList("Instances", state.gameInstances) } // item { // ModpackGroup("Find more", state.downloadedModpacks) diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackCard.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceCard.kt similarity index 98% rename from src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackCard.kt rename to src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceCard.kt index 05e5cd4..65d0a87 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackCard.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceCard.kt @@ -57,7 +57,7 @@ fun InstanceCard( onClick = { instance ?: return@Card coroutineScope.launch { - state.modpackState = instance.createModpackState(state) + state.instanceState = instance.createModpackState(state) currentHue = instance.config.hue screen = Screen.Instance } diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackGroup.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceList.kt similarity index 88% rename from src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackGroup.kt rename to src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceList.kt index 26f31db..2715c78 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/ModpackGroup.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/InstanceList.kt @@ -10,10 +10,12 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import com.mineinabyss.launchy.LocalLaunchyState import com.mineinabyss.launchy.data.config.GameInstance @Composable -fun ModpackGroup(title: String, packs: List) { +fun InstanceList(title: String, packs: List) { + val state = LocalLaunchyState Column { // var showAll by remember { mutableStateOf(false) } val visiblePacks = packs//.take(6) @@ -38,7 +40,7 @@ fun ModpackGroup(title: String, packs: List) { horizontalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp), ) { - items(visiblePacks) { pack -> + items(visiblePacks.sortedByDescending { state.lastPlayed[it.config.name] }) { pack -> InstanceCard(pack.config, pack) } } diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/ModpackScreen.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/InstanceScreen.kt similarity index 89% rename from src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/ModpackScreen.kt rename to src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/InstanceScreen.kt index 53c319b..9ab98b8 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/ModpackScreen.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/InstanceScreen.kt @@ -8,8 +8,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.mineinabyss.launchy.LocalLaunchyState -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import com.mineinabyss.launchy.ui.screens.modpack.main.buttons.PlayButton import com.mineinabyss.launchy.ui.screens.modpack.main.buttons.SettingsButton import com.mineinabyss.launchy.ui.screens.modpack.main.buttons.UpdateButton @@ -18,9 +17,8 @@ import com.mineinabyss.launchy.ui.state.windowScope @ExperimentalComposeUiApi @Preview @Composable -fun ModpackScreen() { - val state = LocalLaunchyState - val packState = LocalModpackState +fun InstanceScreen() { + val packState = LocalGameInstanceState Box { BackgroundImage(windowScope) diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/MainScreenImages.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/MainScreenImages.kt index b7f3fbb..38476cd 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/MainScreenImages.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/MainScreenImages.kt @@ -19,11 +19,11 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.dp import androidx.compose.ui.window.WindowScope import com.mineinabyss.launchy.LocalLaunchyState -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState @Composable fun BoxScope.BackgroundImage(windowScope: WindowScope) { - val pack = LocalModpackState + val pack = LocalGameInstanceState val background by pack.instance.config.getBackground() AnimatedVisibility(background != null, enter = fadeIn(), exit = fadeOut()) { if (background == null) return@AnimatedVisibility @@ -76,7 +76,7 @@ fun BoxScope.SlightBackgroundTint(modifier: Modifier = Modifier) { @Composable fun LogoLarge(modifier: Modifier) { val state = LocalLaunchyState - val pack = LocalModpackState + val pack = LocalGameInstanceState val painter by pack.instance.config.getLogo() AnimatedVisibility( painter != null, diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/UpdateInfoButton.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/UpdateInfoButton.kt index f2891d9..1de3779 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/UpdateInfoButton.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/UpdateInfoButton.kt @@ -19,12 +19,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp import com.mineinabyss.launchy.LocalLaunchyState -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState @Composable fun UpdateInfoButton() { val state = LocalLaunchyState - val packState = LocalModpackState + val packState = LocalGameInstanceState var toggled by remember { mutableStateOf(false) } Button(onClick = { toggled = !toggled }, shape = RoundedCornerShape(20.dp)) { Column { diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/InstallButton.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/InstallButton.kt index 65d6243..f6f16e9 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/InstallButton.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/InstallButton.kt @@ -16,13 +16,13 @@ import com.mineinabyss.launchy.logic.AppDispatchers import com.mineinabyss.launchy.logic.ModDownloader.startInstall import com.mineinabyss.launchy.ui.elements.OutlinedRedButton import com.mineinabyss.launchy.ui.elements.PrimaryButton -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import kotlinx.coroutines.launch @Composable fun RetryFailedButton(enabled: Boolean) { val state = LocalLaunchyState - val packState = LocalModpackState + val packState = LocalGameInstanceState OutlinedRedButton( enabled = enabled, onClick = { @@ -37,7 +37,7 @@ fun RetryFailedButton(enabled: Boolean) { @Composable fun InstallButton(enabled: Boolean, modifier: Modifier = Modifier) { val state = LocalLaunchyState - val packState = LocalModpackState + val packState = LocalGameInstanceState PrimaryButton( enabled = enabled, onClick = { diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/PlayButton.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/PlayButton.kt index 7617f06..16fcd7f 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/PlayButton.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/PlayButton.kt @@ -22,7 +22,7 @@ import com.mineinabyss.launchy.logic.AppDispatchers.launchOrShowDialog import com.mineinabyss.launchy.logic.Launcher import com.mineinabyss.launchy.logic.ModDownloader.prepareWithoutChangingInstalledMods import com.mineinabyss.launchy.logic.ModDownloader.startInstall -import com.mineinabyss.launchy.state.modpack.ModpackState +import com.mineinabyss.launchy.state.modpack.GameInstanceState import com.mineinabyss.launchy.ui.elements.PrimaryButtonColors import com.mineinabyss.launchy.ui.elements.SecondaryButtonColors import com.mineinabyss.launchy.ui.screens.Dialog @@ -35,7 +35,7 @@ fun PlayButton( hideText: Boolean = false, instance: GameInstance, modifier: Modifier = Modifier, - getModpackState: suspend () -> ModpackState?, + getModpackState: suspend () -> GameInstanceState?, ) { val state = LocalLaunchyState val process = state.processFor(instance) @@ -58,7 +58,7 @@ fun PlayButton( ) Box { - var foundPackState: ModpackState? by remember { mutableStateOf(null) } + var foundPackState: GameInstanceState? by remember { mutableStateOf(null) } val onClick: () -> Unit = { coroutineScope.launch(Dispatchers.IO) { val packState = foundPackState ?: getModpackState() ?: return@launch diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/UpdateButton.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/UpdateButton.kt index fe605bc..58b44fe 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/UpdateButton.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/main/buttons/UpdateButton.kt @@ -9,12 +9,12 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import com.mineinabyss.launchy.LocalLaunchyState import com.mineinabyss.launchy.logic.Instances.updateInstance -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState @Composable fun UpdateButton() { val state = LocalLaunchyState - val pack = LocalModpackState + val pack = LocalGameInstanceState Box { Button(onClick = { pack.instance.updateInstance(state) diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InfoBar.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InfoBar.kt index 69cd102..d5cc6b1 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InfoBar.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InfoBar.kt @@ -22,7 +22,7 @@ import com.mineinabyss.launchy.LocalLaunchyState import com.mineinabyss.launchy.data.Constants import com.mineinabyss.launchy.data.Constants.SETTINGS_HORIZONTAL_PADDING import com.mineinabyss.launchy.ui.elements.Tooltip -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import com.mineinabyss.launchy.ui.screens.modpack.main.buttons.InstallButton import com.mineinabyss.launchy.ui.screens.modpack.main.buttons.RetryFailedButton @@ -32,7 +32,7 @@ object InfoBarProperties { @Composable fun InfoBar(modifier: Modifier = Modifier) { val state = LocalLaunchyState - val packState = LocalModpackState + val packState = LocalGameInstanceState Surface( tonalElevation = 2.dp, shadowElevation = 0.dp, diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InstanceSettingsScreen.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InstanceSettingsScreen.kt index 3e1b55f..6e1d7d9 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InstanceSettingsScreen.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/InstanceSettingsScreen.kt @@ -25,7 +25,7 @@ import com.mineinabyss.launchy.logic.DesktopHelpers import com.mineinabyss.launchy.logic.Instances.delete import com.mineinabyss.launchy.logic.Instances.updateInstance import com.mineinabyss.launchy.ui.elements.* -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import com.mineinabyss.launchy.ui.screens.Screen import com.mineinabyss.launchy.ui.screens.screen import kotlin.io.path.listDirectoryEntries @@ -33,7 +33,7 @@ import kotlin.io.path.listDirectoryEntries @Composable @Preview fun InstanceSettingsScreen() { - val state = LocalModpackState + val state = LocalGameInstanceState var selectedTabIndex by remember { mutableStateOf(0) } ComfyWidth { Column { @@ -98,7 +98,7 @@ fun InstanceProperties( @Composable fun OptionsTab() { val state = LocalLaunchyState - val pack = LocalModpackState + val pack = LocalGameInstanceState ComfyContent(Modifier.padding(16.dp)) { Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { @@ -139,7 +139,7 @@ fun OptionsTab() { @Composable fun ModManagement() { - val state = LocalModpackState + val state = LocalGameInstanceState Scaffold( containerColor = Color.Transparent, bottomBar = { InfoBar() }, diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModGroup.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModGroup.kt index 262d194..62c8e2d 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModGroup.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModGroup.kt @@ -24,14 +24,14 @@ import com.mineinabyss.launchy.data.modpacks.Group import com.mineinabyss.launchy.data.modpacks.Mod import com.mineinabyss.launchy.logic.ToggleMods.setModEnabled import com.mineinabyss.launchy.ui.elements.Tooltip -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import com.mineinabyss.launchy.util.Option @Composable fun ModGroup(group: Group, mods: Collection) { var expanded by remember { mutableStateOf(false) } val arrowRotationState by animateFloatAsState(targetValue = if (expanded) 180f else 0f) - val state = LocalModpackState + val state = LocalGameInstanceState val modsChanged = mods.any { it in state.queued.deletions || it in state.queued.newDownloads || it in state.queued.failures diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt index 631db18..294481d 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt @@ -24,12 +24,12 @@ import com.mineinabyss.launchy.logic.DesktopHelpers import com.mineinabyss.launchy.logic.ToggleMods.setModConfigEnabled import com.mineinabyss.launchy.logic.ToggleMods.setModEnabled import com.mineinabyss.launchy.ui.elements.Tooltip -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState @OptIn(ExperimentalFoundationApi::class) @Composable fun ModInfoDisplay(group: Group, mod: Mod) { - val state = LocalModpackState + val state = LocalGameInstanceState val modEnabled by derivedStateOf { mod in state.toggles.enabledMods } val configEnabled by derivedStateOf { mod in state.toggles.enabledConfigs } var configExpanded by remember { mutableStateOf(false) } diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/TripleSwitch.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/TripleSwitch.kt index 72f8d72..c0d72ed 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/TripleSwitch.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/TripleSwitch.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.unit.dp import com.mineinabyss.launchy.data.Constants import com.mineinabyss.launchy.data.modpacks.Group import com.mineinabyss.launchy.data.modpacks.Mod -import com.mineinabyss.launchy.ui.screens.LocalModpackState +import com.mineinabyss.launchy.ui.screens.LocalGameInstanceState import com.mineinabyss.launchy.util.Option @Composable @@ -28,7 +28,7 @@ fun ToggleButtons( group: Group, mods: Collection, ) { - val state = LocalModpackState + val state = LocalGameInstanceState val offColor = Color.Transparent val offTextColor = MaterialTheme.colorScheme.surface val forced = group.forceEnabled || group.forceDisabled