From deab95ebc99f90409e387218a81ddcb02e8003a4 Mon Sep 17 00:00:00 2001 From: ArthurKun <16458204+ArthurKun21@users.noreply.github.com> Date: Mon, 12 Aug 2024 06:11:40 +0800 Subject: [PATCH] JP 15 Party Update (#1868) Co-authored-by: reconman --- .../ui/battle_config_item/PartySelection.kt | 26 ++++++++++++++++- .../scripts/locations/Locations.kt | 29 +++++++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/PartySelection.kt b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/PartySelection.kt index b544c3ade..b8be56773 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/PartySelection.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/PartySelection.kt @@ -16,8 +16,12 @@ import androidx.compose.material3.CardDefaults.cardElevation import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -26,10 +30,26 @@ import io.github.fate_grand_automata.R import io.github.fate_grand_automata.prefs.core.BattleConfigCore import io.github.fate_grand_automata.ui.dialog.FgaDialog import io.github.fate_grand_automata.ui.prefs.remember +import io.github.fate_grand_automata.scripts.enums.GameServer @Composable fun PartySelection(config: BattleConfigCore) { var party by config.party.remember() + val server by config.server.remember() + + val isSelectionExtended by remember { + derivedStateOf { + when (server.asGameServer()) { + null, is GameServer.Jp -> true + else -> false + } + } + } + LaunchedEffect(key1 = server) { + if (!isSelectionExtended && party > 9) { + party = 9 + } + } val dialog = FgaDialog() @@ -39,6 +59,7 @@ fun PartySelection(config: BattleConfigCore) { title(stringResource(R.string.p_battle_config_party)) PartySelectionDialogContent( + isSelectionExtended = isSelectionExtended, selected = party, onSelectedChange = { party = it @@ -106,11 +127,14 @@ private fun PartySelectionItem( @Composable fun PartySelectionDialogContent( + isSelectionExtended: Boolean = false, selected: Int, onSelectedChange: (Int) -> Unit ) { Column { - (0..9) + val partyRange = if (isSelectionExtended) 0..14 else 0..9 + + partyRange .chunked(5) .forEach { chunk -> Row( diff --git a/scripts/src/main/java/io/github/fate_grand_automata/scripts/locations/Locations.kt b/scripts/src/main/java/io/github/fate_grand_automata/scripts/locations/Locations.kt index 25a650434..6b3646efe 100644 --- a/scripts/src/main/java/io/github/fate_grand_automata/scripts/locations/Locations.kt +++ b/scripts/src/main/java/io/github/fate_grand_automata/scripts/locations/Locations.kt @@ -1,11 +1,13 @@ package io.github.fate_grand_automata.scripts.locations +import io.github.fate_grand_automata.scripts.enums.GameServer import io.github.fate_grand_automata.scripts.enums.RefillResourceEnum import io.github.fate_grand_automata.scripts.models.BoostItem import io.github.lib_automata.Location import io.github.lib_automata.Region import io.github.lib_automata.dagger.ScriptScope import javax.inject.Inject +import kotlin.math.min import kotlin.math.roundToInt @ScriptScope @@ -86,12 +88,27 @@ class Locations @Inject constructor( BoostItem.Enabled.BoostItem3 -> Location(1280, 1000) }.xFromCenter() - val selectedPartyRegion = Region(-270, 62, 550, 72).xFromCenter() - val partySelectionArray = (0..9).map { - // Party indicators are center-aligned - val x = ((it - 4.5) * 50).roundToInt() - - Location(x, 100).xFromCenter() + val selectedPartyRegion = when (gameServer) { + // JP have 15 max party slots + is GameServer.Jp -> Region(-370, 62, 740, 72).xFromCenter() + else -> Region(-270, 62, 550, 72).xFromCenter() + } + + val partySelectionArray = when (gameServer) { + is GameServer.Jp -> (0..14).map { + // Party 8 is on the center + val x = ((it - 7) * 50) + + Location(x, 100).xFromCenter() + } + + else -> (0..14).map { + // Party indicators are center-aligned + // Party 11-15 are going to be on party 10 just in case + val x = ((min(it, 9) - 4.5) * 50).roundToInt() + + Location(x, 100).xFromCenter() + } } val menuStorySkipRegion = Region(960, 20, 300, 120).xFromCenter()