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,12 +832,39 @@ 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()
) {
Text("Back to Main")
}
}
}
val spriteTesterTesting = @Composable {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(16.dp)
) {
Text("Sprite Animation Testing", fontSize = 20.sp, fontWeight = FontWeight.Bold)
Text("Character: $testCharacterId", fontSize = 14.sp, color = Color.Gray)
Spacer(modifier = Modifier.height(16.dp))
// Display sprite
AnimatedSpriteImage(
characterId = testCharacterId,
animationType = currentTestAnimation,
modifier = Modifier.size(120.dp),
contentScale = ContentScale.Fit
)
Spacer(modifier = Modifier.height(16.dp))
// Animation buttons in a grid
Text("Animation Buttons:", fontSize = 16.sp, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
// Create a grid of animation buttons
val animationTypes = listOf( val animationTypes = listOf(
DigimonAnimationType.IDLE to "IDLE", DigimonAnimationType.IDLE to "IDLE",
DigimonAnimationType.IDLE2 to "IDLE2", DigimonAnimationType.IDLE2 to "IDLE2",
@ -849,36 +880,28 @@ fun BattlesScreen() {
DigimonAnimationType.FLEE to "FLEE" DigimonAnimationType.FLEE to "FLEE"
) )
// Display sprite
AnimatedSpriteImage(
characterId = testCharacterId,
animationType = currentTestAnimation,
modifier = Modifier.size(120.dp),
contentScale = ContentScale.Fit
)
Spacer(modifier = Modifier.height(16.dp))
// Animation buttons in a grid
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp) verticalArrangement = Arrangement.spacedBy(4.dp)
) { ) {
// Create rows of 3 buttons each // Create rows of 3 buttons each
animationTypes.chunked(3).forEach { row -> animationTypes.chunked(3).forEach { row ->
Row( Row(
horizontalArrangement = Arrangement.spacedBy(8.dp) horizontalArrangement = Arrangement.spacedBy(4.dp)
) { ) {
row.forEach { (animationType, label) -> row.forEach { (animationType, label) ->
Button( Button(
onClick = { currentTestAnimation = animationType }, onClick = {
currentTestAnimation = animationType
println("Switched to animation: $label")
},
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = if (currentTestAnimation == animationType) Color.Blue else Color.Gray containerColor = if (currentTestAnimation == animationType) Color.Blue else Color.Gray
), ),
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f),
contentPadding = androidx.compose.foundation.layout.PaddingValues(vertical = 4.dp, horizontal = 2.dp)
) { ) {
Text(label, fontSize = 12.sp) Text(label, fontSize = 10.sp)
}
} }
} }
} }
@ -887,14 +910,33 @@ 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()
) {
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") Text("Back to Main")
} }
} }
} }
}
Scaffold ( Scaffold (
topBar = { topBar = {
@ -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")
} }