Added sprite test button to battle.

This commit is contained in:
lightheel 2025-08-04 14:13:26 -04:00
parent 3687ff2c21
commit 615fb85204
2 changed files with 146 additions and 17 deletions

View File

@ -177,9 +177,9 @@ class DigimonAnimationStateMachine(
currentAnimation = DigimonAnimationType.IDLE currentAnimation = DigimonAnimationType.IDLE
isPlaying = true isPlaying = true
// Get both IDLE and IDLE2 frames
val idleFrames = spriteFileMappings[DigimonAnimationType.IDLE] ?: listOf("00") val idleFrames = spriteFileMappings[DigimonAnimationType.IDLE] ?: listOf("00")
val idle2Frames = spriteFileMappings[DigimonAnimationType.IDLE2] ?: listOf("01")
val idle2Frames = spriteFileMappings[DigimonAnimationType.HAPPY] ?: listOf("08")
// Combine frames for cycling idle animation // Combine frames for cycling idle animation
val combinedFrames = (idleFrames + idle2Frames).distinct() val combinedFrames = (idleFrames + idle2Frames).distinct()

View File

@ -52,6 +52,7 @@ 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
@Composable @Composable
fun BattleScreen( fun BattleScreen(
stage: String, stage: String,
@ -593,6 +594,13 @@ fun BattlesScreen() {
var selectedStage by remember { mutableStateOf("") } var selectedStage by remember { mutableStateOf("") }
var currentStage by remember { mutableStateOf("rookie") } var currentStage by remember { mutableStateOf("rookie") }
// Sprite animation tester state
var showSpriteTester by remember { mutableStateOf(false) }
var dimId by remember { mutableStateOf("") }
var monId by remember { mutableStateOf("") }
var currentTestAnimation by remember { mutableStateOf(DigimonAnimationType.IDLE) }
var testCharacterId by remember { mutableStateOf("") }
// Create hardcoded character lists for each stage // Create hardcoded character lists for each stage
val rookieCharacters = listOf( val rookieCharacters = listOf(
APIBattleCharacter("AGUMON", "degimon_name_Dim012_003", "dim012_mon03", 0, 1, 1800, 1800, 2400.0f, 700.0f), APIBattleCharacter("AGUMON", "degimon_name_Dim012_003", "dim012_mon03", 0, 1, 1800, 1800, 2400.0f, 700.0f),
@ -776,6 +784,118 @@ fun BattlesScreen() {
} }
} }
val spriteTester = @Composable {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(16.dp)
) {
Text("Sprite Animation Tester", fontSize = 20.sp, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.height(16.dp))
// DIM ID input
OutlinedTextField(
value = dimId,
onValueChange = { dimId = it },
label = { Text("DIM ID (e.g., 012)") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(8.dp))
// Mon ID input
OutlinedTextField(
value = monId,
onValueChange = { monId = it },
label = { Text("Mon ID (e.g., 03)") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
// Load sprite button
Button(
onClick = {
if (dimId.isNotEmpty() && monId.isNotEmpty()) {
testCharacterId = "dim${dimId}_mon${monId}"
println("Testing sprite for: $testCharacterId")
}
},
modifier = Modifier.fillMaxWidth()
) {
Text("Load Sprite")
}
Spacer(modifier = Modifier.height(16.dp))
// Animation test buttons
if (testCharacterId.isNotEmpty()) {
Text("Animation States:", fontSize = 16.sp, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.height(8.dp))
// Create a grid of animation buttons
val animationTypes = listOf(
DigimonAnimationType.IDLE to "IDLE",
DigimonAnimationType.IDLE2 to "IDLE2",
DigimonAnimationType.WALK to "WALK",
DigimonAnimationType.WALK2 to "WALK2",
DigimonAnimationType.RUN to "RUN",
DigimonAnimationType.RUN2 to "RUN2",
DigimonAnimationType.WORKOUT to "WORKOUT",
DigimonAnimationType.WORKOUT2 to "WORKOUT2",
DigimonAnimationType.HAPPY to "HAPPY",
DigimonAnimationType.SLEEP to "SLEEP",
DigimonAnimationType.ATTACK to "ATTACK",
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(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
// Create rows of 3 buttons each
animationTypes.chunked(3).forEach { row ->
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
row.forEach { (animationType, label) ->
Button(
onClick = { currentTestAnimation = animationType },
colors = ButtonDefaults.buttonColors(
containerColor = if (currentTestAnimation == animationType) Color.Blue else Color.Gray
),
modifier = Modifier.weight(1f)
) {
Text(label, fontSize = 12.sp)
}
}
}
}
}
}
Spacer(modifier = Modifier.height(16.dp))
Button(
onClick = { showSpriteTester = false },
modifier = Modifier.fillMaxWidth()
) {
Text("Back to Main")
}
}
}
Scaffold ( Scaffold (
topBar = { topBar = {
TopBanner( TopBanner(
@ -792,21 +912,30 @@ fun BattlesScreen() {
) { ) {
when (currentView) { when (currentView) {
"main" -> { "main" -> {
Column( if (showSpriteTester) {
horizontalAlignment = Alignment.CenterHorizontally spriteTester()
) { } else {
rookieButton() Column(
championButton() horizontalAlignment = Alignment.CenterHorizontally
ultimateButton()
megaButton()
Button(
onClick = {
val spriteFileManager = SpriteFileManager(context)
spriteFileManager.clearSpriteFiles()
println("Sprite files cleared!")
}
) { ) {
Text("Clear Sprite Files") rookieButton()
championButton()
ultimateButton()
megaButton()
Button(
onClick = { showSpriteTester = true }
) {
Text("Sprite Animation Tester")
}
Button(
onClick = {
val spriteFileManager = SpriteFileManager(context)
spriteFileManager.clearSpriteFiles()
println("Sprite files cleared!")
}
) {
Text("Clear Sprite Files")
}
} }
} }
} }