Created sprite and animation tester menu.

This commit is contained in:
lightheel 2025-08-04 14:26:24 -04:00
parent 615fb85204
commit fb09350825
2 changed files with 111 additions and 57 deletions

View File

@ -51,6 +51,8 @@ import com.github.nacabaro.vbhelper.battle.SpriteFileManager
import com.github.nacabaro.vbhelper.battle.ArenaBattleSystem import com.github.nacabaro.vbhelper.battle.ArenaBattleSystem
import com.github.nacabaro.vbhelper.battle.DigimonAnimationType import com.github.nacabaro.vbhelper.battle.DigimonAnimationType
import com.github.nacabaro.vbhelper.battle.AnimatedSpriteImage import com.github.nacabaro.vbhelper.battle.AnimatedSpriteImage
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
@Composable @Composable
@ -596,6 +598,7 @@ fun BattlesScreen() {
// Sprite animation tester state // Sprite animation tester state
var showSpriteTester by remember { mutableStateOf(false) } var showSpriteTester by remember { mutableStateOf(false) }
var spriteTesterView by remember { mutableStateOf("entry") } // "entry" or "testing"
var dimId by remember { mutableStateOf("") } var dimId by remember { mutableStateOf("") }
var monId by remember { mutableStateOf("") } var monId by remember { mutableStateOf("") }
var currentTestAnimation by remember { mutableStateOf(DigimonAnimationType.IDLE) } var currentTestAnimation by remember { mutableStateOf(DigimonAnimationType.IDLE) }
@ -784,7 +787,7 @@ fun BattlesScreen() {
} }
} }
val spriteTester = @Composable { val spriteTesterEntry = @Composable {
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(16.dp) modifier = Modifier.padding(16.dp)
@ -819,6 +822,7 @@ fun BattlesScreen() {
if (dimId.isNotEmpty() && monId.isNotEmpty()) { if (dimId.isNotEmpty() && monId.isNotEmpty()) {
testCharacterId = "dim${dimId}_mon${monId}" testCharacterId = "dim${dimId}_mon${monId}"
println("Testing sprite for: $testCharacterId") println("Testing sprite for: $testCharacterId")
spriteTesterView = "testing"
} }
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
@ -828,57 +832,76 @@ fun BattlesScreen() {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
// Animation test buttons Button(
if (testCharacterId.isNotEmpty()) { onClick = { showSpriteTester = false },
Text("Animation States:", fontSize = 16.sp, fontWeight = FontWeight.Bold) modifier = Modifier.fillMaxWidth()
Spacer(modifier = Modifier.height(8.dp)) ) {
Text("Back to Main")
// Create a grid of animation buttons }
val animationTypes = listOf( }
DigimonAnimationType.IDLE to "IDLE", }
DigimonAnimationType.IDLE2 to "IDLE2",
DigimonAnimationType.WALK to "WALK", val spriteTesterTesting = @Composable {
DigimonAnimationType.WALK2 to "WALK2", Column(
DigimonAnimationType.RUN to "RUN", horizontalAlignment = Alignment.CenterHorizontally,
DigimonAnimationType.RUN2 to "RUN2", modifier = Modifier.padding(16.dp)
DigimonAnimationType.WORKOUT to "WORKOUT", ) {
DigimonAnimationType.WORKOUT2 to "WORKOUT2", Text("Sprite Animation Testing", fontSize = 20.sp, fontWeight = FontWeight.Bold)
DigimonAnimationType.HAPPY to "HAPPY", Text("Character: $testCharacterId", fontSize = 14.sp, color = Color.Gray)
DigimonAnimationType.SLEEP to "SLEEP",
DigimonAnimationType.ATTACK to "ATTACK", Spacer(modifier = Modifier.height(16.dp))
DigimonAnimationType.FLEE to "FLEE"
) // Display sprite
AnimatedSpriteImage(
// Display sprite characterId = testCharacterId,
AnimatedSpriteImage( animationType = currentTestAnimation,
characterId = testCharacterId, modifier = Modifier.size(120.dp),
animationType = currentTestAnimation, contentScale = ContentScale.Fit
modifier = Modifier.size(120.dp), )
contentScale = ContentScale.Fit
) Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(16.dp)) // Animation buttons in a grid
Text("Animation Buttons:", fontSize = 16.sp, fontWeight = FontWeight.Bold)
// Animation buttons in a grid Spacer(modifier = Modifier.height(8.dp))
Column(
horizontalAlignment = Alignment.CenterHorizontally, val animationTypes = listOf(
verticalArrangement = Arrangement.spacedBy(8.dp) DigimonAnimationType.IDLE to "IDLE",
) { DigimonAnimationType.IDLE2 to "IDLE2",
// Create rows of 3 buttons each DigimonAnimationType.WALK to "WALK",
animationTypes.chunked(3).forEach { row -> DigimonAnimationType.WALK2 to "WALK2",
Row( DigimonAnimationType.RUN to "RUN",
horizontalArrangement = Arrangement.spacedBy(8.dp) DigimonAnimationType.RUN2 to "RUN2",
) { DigimonAnimationType.WORKOUT to "WORKOUT",
row.forEach { (animationType, label) -> DigimonAnimationType.WORKOUT2 to "WORKOUT2",
Button( DigimonAnimationType.HAPPY to "HAPPY",
onClick = { currentTestAnimation = animationType }, DigimonAnimationType.SLEEP to "SLEEP",
colors = ButtonDefaults.buttonColors( DigimonAnimationType.ATTACK to "ATTACK",
containerColor = if (currentTestAnimation == animationType) Color.Blue else Color.Gray DigimonAnimationType.FLEE to "FLEE"
), )
modifier = Modifier.weight(1f)
) { Column(
Text(label, fontSize = 12.sp) horizontalAlignment = Alignment.CenterHorizontally,
} verticalArrangement = Arrangement.spacedBy(4.dp)
) {
// Create rows of 3 buttons each
animationTypes.chunked(3).forEach { row ->
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
row.forEach { (animationType, label) ->
Button(
onClick = {
currentTestAnimation = animationType
println("Switched to animation: $label")
},
colors = ButtonDefaults.buttonColors(
containerColor = if (currentTestAnimation == animationType) Color.Blue else Color.Gray
),
modifier = Modifier.weight(1f),
contentPadding = androidx.compose.foundation.layout.PaddingValues(vertical = 4.dp, horizontal = 2.dp)
) {
Text(label, fontSize = 10.sp)
} }
} }
} }
@ -887,11 +910,30 @@ fun BattlesScreen() {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
Button( // Navigation buttons
onClick = { showSpriteTester = false }, Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("Back to Main") Button(
onClick = { spriteTesterView = "entry" },
modifier = Modifier.weight(1f)
) {
Text("Back to Entry")
}
Button(
onClick = {
showSpriteTester = false
spriteTesterView = "entry"
testCharacterId = ""
dimId = ""
monId = ""
},
modifier = Modifier.weight(1f)
) {
Text("Back to Main")
}
} }
} }
} }
@ -913,7 +955,11 @@ fun BattlesScreen() {
when (currentView) { when (currentView) {
"main" -> { "main" -> {
if (showSpriteTester) { if (showSpriteTester) {
spriteTester() when (spriteTesterView) {
"entry" -> spriteTesterEntry()
"testing" -> spriteTesterTesting()
else -> spriteTesterEntry()
}
} else { } else {
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
@ -923,7 +969,14 @@ fun BattlesScreen() {
ultimateButton() ultimateButton()
megaButton() megaButton()
Button( Button(
onClick = { showSpriteTester = true } onClick = {
showSpriteTester = true
spriteTesterView = "entry"
testCharacterId = ""
dimId = ""
monId = ""
currentTestAnimation = DigimonAnimationType.IDLE
}
) { ) {
Text("Sprite Animation Tester") Text("Sprite Animation Tester")
} }