Skip to content

Commit

Permalink
JP 15 Party Update (#1868)
Browse files Browse the repository at this point in the history
Co-authored-by: reconman <[email protected]>
  • Loading branch information
ArthurKun21 and reconman authored Aug 11, 2024
1 parent a1736b7 commit deab95e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand All @@ -39,6 +59,7 @@ fun PartySelection(config: BattleConfigCore) {
title(stringResource(R.string.p_battle_config_party))

PartySelectionDialogContent(
isSelectionExtended = isSelectionExtended,
selected = party,
onSelectedChange = {
party = it
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit deab95e

Please sign in to comment.