Might be incomplete uhhh

This commit is contained in:
Nacho 2025-11-16 21:13:28 +01:00
parent 61dfc2ce0d
commit 6be167bbed
9 changed files with 41 additions and 25 deletions

View File

@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.CardColors
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
@ -44,6 +45,9 @@ fun CharacterEntry(
disabled: Boolean = false, disabled: Boolean = false,
shape: Shape = MaterialTheme.shapes.medium, shape: Shape = MaterialTheme.shapes.medium,
multiplier: Int = 4, multiplier: Int = 4,
cardColors: CardColors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest
),
onClick: () -> Unit = { } onClick: () -> Unit = { }
) { ) {
val bitmap = remember (icon.bitmap) { val bitmap = remember (icon.bitmap) {
@ -61,7 +65,8 @@ fun CharacterEntry(
}, },
modifier = modifier modifier = modifier
.aspectRatio(1f) .aspectRatio(1f)
.padding(8.dp) .padding(8.dp),
colors = cardColors
) { ) {
Box( Box(
contentAlignment = Alignment.BottomCenter, contentAlignment = Alignment.BottomCenter,

View File

@ -3,6 +3,7 @@ package com.github.nacabaro.vbhelper.daos
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Query import androidx.room.Query
import com.github.nacabaro.vbhelper.dtos.CharacterDtos import com.github.nacabaro.vbhelper.dtos.CharacterDtos
import kotlinx.coroutines.flow.Flow
@Dao @Dao
@ -37,7 +38,7 @@ interface AdventureDao {
JOIN Adventure a ON uc.id = a.characterId JOIN Adventure a ON uc.id = a.characterId
""" """
) )
suspend fun getAdventureCharacters(): List<CharacterDtos.AdventureCharacterWithSprites> fun getAdventureCharacters(): Flow<List<CharacterDtos.AdventureCharacterWithSprites>>
@Query(""" @Query("""
DELETE FROM Adventure DELETE FROM Adventure

View File

@ -69,7 +69,8 @@ interface UserCharacterDao {
c.nameWidth as nameSpriteWidth, c.nameWidth as nameSpriteWidth,
c.nameHeight as nameSpriteHeight, c.nameHeight as nameSpriteHeight,
d.isBEm as isBemCard, d.isBEm as isBemCard,
a.characterId = uc.id as isInAdventure a.characterId = uc.id as isInAdventure,
uc.isActive as active
FROM UserCharacter uc FROM UserCharacter uc
JOIN CardCharacter c ON uc.charId = c.id JOIN CardCharacter c ON uc.charId = c.id
JOIN Card d ON d.id = c.cardId JOIN Card d ON d.id = c.cardId
@ -93,7 +94,8 @@ interface UserCharacterDao {
c.nameWidth as nameSpriteWidth, c.nameWidth as nameSpriteWidth,
c.nameHeight as nameSpriteHeight, c.nameHeight as nameSpriteHeight,
d.isBEm as isBemCard, d.isBEm as isBemCard,
a.characterId = uc.id as isInAdventure a.characterId = uc.id as isInAdventure,
uc.isActive as active
FROM UserCharacter uc FROM UserCharacter uc
JOIN CardCharacter c ON uc.charId = c.id JOIN CardCharacter c ON uc.charId = c.id
JOIN Card d ON c.cardId = d.id JOIN Card d ON c.cardId = d.id
@ -130,7 +132,8 @@ interface UserCharacterDao {
c.nameWidth as nameSpriteWidth, c.nameWidth as nameSpriteWidth,
c.nameHeight as nameSpriteHeight, c.nameHeight as nameSpriteHeight,
d.isBEm as isBemCard, d.isBEm as isBemCard,
a.characterId as isInAdventure a.characterId as isInAdventure,
uc.isActive as active
FROM UserCharacter uc FROM UserCharacter uc
JOIN CardCharacter c ON uc.charId = c.id JOIN CardCharacter c ON uc.charId = c.id
JOIN Card d ON c.cardId = d.id JOIN Card d ON c.cardId = d.id
@ -194,7 +197,8 @@ interface UserCharacterDao {
c.nameWidth as nameSpriteWidth, c.nameWidth as nameSpriteWidth,
c.nameHeight as nameSpriteHeight, c.nameHeight as nameSpriteHeight,
d.isBEm as isBemCard, d.isBEm as isBemCard,
a.characterId = uc.id as isInAdventure a.characterId = uc.id as isInAdventure,
uc.isActive as active
FROM UserCharacter uc FROM UserCharacter uc
JOIN CardCharacter c ON uc.charId = c.id JOIN CardCharacter c ON uc.charId = c.id
JOIN Card d ON d.id = c.cardId JOIN Card d ON d.id = c.cardId
@ -219,7 +223,8 @@ interface UserCharacterDao {
c.nameWidth as nameSpriteWidth, c.nameWidth as nameSpriteWidth,
c.nameHeight as nameSpriteHeight, c.nameHeight as nameSpriteHeight,
d.isBEm as isBemCard, d.isBEm as isBemCard,
a.characterId = uc.id as isInAdventure a.characterId = uc.id as isInAdventure,
uc.isActive as active
FROM UserCharacter uc FROM UserCharacter uc
JOIN CardCharacter c ON uc.charId = c.id JOIN CardCharacter c ON uc.charId = c.id
JOIN Card d ON d.id = c.cardId JOIN Card d ON d.id = c.cardId

View File

@ -31,7 +31,8 @@ object CharacterDtos {
val nameSpriteWidth: Int, val nameSpriteWidth: Int,
val nameSpriteHeight: Int, val nameSpriteHeight: Int,
val isBemCard: Boolean, val isBemCard: Boolean,
val isInAdventure: Boolean val isInAdventure: Boolean,
val active: Boolean
) )
data class CardCharacterInfo( data class CardCharacterInfo(

View File

@ -10,6 +10,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState import androidx.compose.runtime.produceState
@ -37,13 +38,11 @@ fun AdventureScreen(
navController: NavController, navController: NavController,
storageScreenController: AdventureScreenControllerImpl storageScreenController: AdventureScreenControllerImpl
) { ) {
val coroutineScope = rememberCoroutineScope()
val application = LocalContext.current.applicationContext as VBHelper val application = LocalContext.current.applicationContext as VBHelper
val database = application.container.db val database = application.container.db
val storageRepository = StorageRepository(database) val storageRepository = StorageRepository(database)
val characterList = remember { val characterList by storageRepository.getAdventureCharacters().collectAsState(emptyList())
mutableStateOf<List<CharacterDtos.AdventureCharacterWithSprites>>(emptyList())
}
var obtainedItem by remember { var obtainedItem by remember {
mutableStateOf<ItemDtos.PurchasedItem?>(null) mutableStateOf<ItemDtos.PurchasedItem?>(null)
} }
@ -59,13 +58,6 @@ fun AdventureScreen(
mutableStateOf<CharacterDtos.AdventureCharacterWithSprites?>(null) mutableStateOf<CharacterDtos.AdventureCharacterWithSprites?>(null)
} }
LaunchedEffect(storageRepository) {
coroutineScope.launch {
characterList.value = storageRepository
.getAdventureCharacters()
}
}
Scaffold( Scaffold(
topBar = { topBar = {
TopBanner( TopBanner(
@ -76,7 +68,7 @@ fun AdventureScreen(
) )
} }
) { contentPadding -> ) { contentPadding ->
if (characterList.value.isEmpty()) { if (characterList.isEmpty()) {
Column( Column(
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
@ -91,7 +83,7 @@ fun AdventureScreen(
modifier = Modifier modifier = Modifier
.padding(top = contentPadding.calculateTopPadding()) .padding(top = contentPadding.calculateTopPadding())
) { ) {
items(characterList.value) { items(characterList) {
AdventureEntry( AdventureEntry(
icon = BitmapData( icon = BitmapData(
bitmap = it.spriteIdle, bitmap = it.spriteIdle,

View File

@ -23,6 +23,7 @@ class HomeScreenControllerImpl(
val adventureCharacters = database val adventureCharacters = database
.adventureDao() .adventureDao()
.getAdventureCharacters() .getAdventureCharacters()
.first()
val finishedAdventureCharacters = adventureCharacters.filter { character -> val finishedAdventureCharacters = adventureCharacters.filter { character ->
character.finishesAdventure <= currentTime character.finishesAdventure <= currentTime

View File

@ -1,5 +1,7 @@
package com.github.nacabaro.vbhelper.screens.settingsScreen package com.github.nacabaro.vbhelper.screens.settingsScreen
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -13,6 +15,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
@ -25,6 +28,8 @@ fun SettingsScreen(
navController: NavController, navController: NavController,
settingsScreenController: SettingsScreenControllerImpl, settingsScreenController: SettingsScreenControllerImpl,
) { ) {
val context = LocalContext.current
Scaffold ( Scaffold (
topBar = { topBar = {
TopBanner( TopBanner(
@ -44,19 +49,22 @@ fun SettingsScreen(
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
) { ) {
SettingsSection("NFC Communication") SettingsSection("NFC Communication")
SettingsEntry(title = "Import APK", description = "Import Secrets From Vital Arean 2.1.0 APK") { SettingsEntry(title = "Import APK", description = "Import Secrets From Vital Arena 2.1.0 APK") {
settingsScreenController.onClickImportApk() settingsScreenController.onClickImportApk()
} }
SettingsSection("DiM/BEm management") SettingsSection("DiM/BEm management")
SettingsEntry(title = "Import card", description = "Import DiM/BEm card file") { SettingsEntry(title = "Import card", description = "Import DiM/BEm card file") {
settingsScreenController.onClickImportCard() settingsScreenController.onClickImportCard()
} }
SettingsEntry(title = "Rename DiM/BEm", description = "Set card name") { }
SettingsSection("About and credits") SettingsSection("About and credits")
SettingsEntry(title = "Credits", description = "Credits") { SettingsEntry(title = "Credits", description = "Credits") {
navController.navigate(NavigationItems.Credits.route) navController.navigate(NavigationItems.Credits.route)
} }
SettingsEntry(title = "About", description = "About") { } SettingsEntry(title = "About", description = "About") {
val browserIntent = Intent(
Intent.ACTION_VIEW, Uri.parse("https://github.com/nacabaro/vbhelper/"))
context.startActivity(browserIntent)
}
SettingsSection("Data management") SettingsSection("Data management")
SettingsEntry(title = "Export data", description = "Export application database") { SettingsEntry(title = "Export data", description = "Export application database") {
settingsScreenController.onClickOpenDirectory() settingsScreenController.onClickOpenDirectory()

View File

@ -12,6 +12,7 @@ import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.CardColors
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -98,6 +99,8 @@ fun StorageScreen(
) )
} }
}, },
cardColors = CardColors
) )
} }
} }

View File

@ -47,7 +47,7 @@ class StorageRepository (
return db.userCharacterDao().deleteCharacterById(id) return db.userCharacterDao().deleteCharacterById(id)
} }
suspend fun getAdventureCharacters(): List<CharacterDtos.AdventureCharacterWithSprites> { fun getAdventureCharacters(): Flow<List<CharacterDtos.AdventureCharacterWithSprites>> {
return db.adventureDao().getAdventureCharacters() return db.adventureDao().getAdventureCharacters()
} }