mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
Might be incomplete uhhh
This commit is contained in:
parent
61dfc2ce0d
commit
6be167bbed
@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardColors
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@ -44,6 +45,9 @@ fun CharacterEntry(
|
||||
disabled: Boolean = false,
|
||||
shape: Shape = MaterialTheme.shapes.medium,
|
||||
multiplier: Int = 4,
|
||||
cardColors: CardColors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest
|
||||
),
|
||||
onClick: () -> Unit = { }
|
||||
) {
|
||||
val bitmap = remember (icon.bitmap) {
|
||||
@ -61,7 +65,8 @@ fun CharacterEntry(
|
||||
},
|
||||
modifier = modifier
|
||||
.aspectRatio(1f)
|
||||
.padding(8.dp)
|
||||
.padding(8.dp),
|
||||
colors = cardColors
|
||||
) {
|
||||
Box(
|
||||
contentAlignment = Alignment.BottomCenter,
|
||||
|
||||
@ -3,6 +3,7 @@ package com.github.nacabaro.vbhelper.daos
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
|
||||
@Dao
|
||||
@ -37,7 +38,7 @@ interface AdventureDao {
|
||||
JOIN Adventure a ON uc.id = a.characterId
|
||||
"""
|
||||
)
|
||||
suspend fun getAdventureCharacters(): List<CharacterDtos.AdventureCharacterWithSprites>
|
||||
fun getAdventureCharacters(): Flow<List<CharacterDtos.AdventureCharacterWithSprites>>
|
||||
|
||||
@Query("""
|
||||
DELETE FROM Adventure
|
||||
|
||||
@ -69,7 +69,8 @@ interface UserCharacterDao {
|
||||
c.nameWidth as nameSpriteWidth,
|
||||
c.nameHeight as nameSpriteHeight,
|
||||
d.isBEm as isBemCard,
|
||||
a.characterId = uc.id as isInAdventure
|
||||
a.characterId = uc.id as isInAdventure,
|
||||
uc.isActive as active
|
||||
FROM UserCharacter uc
|
||||
JOIN CardCharacter c ON uc.charId = c.id
|
||||
JOIN Card d ON d.id = c.cardId
|
||||
@ -93,7 +94,8 @@ interface UserCharacterDao {
|
||||
c.nameWidth as nameSpriteWidth,
|
||||
c.nameHeight as nameSpriteHeight,
|
||||
d.isBEm as isBemCard,
|
||||
a.characterId = uc.id as isInAdventure
|
||||
a.characterId = uc.id as isInAdventure,
|
||||
uc.isActive as active
|
||||
FROM UserCharacter uc
|
||||
JOIN CardCharacter c ON uc.charId = c.id
|
||||
JOIN Card d ON c.cardId = d.id
|
||||
@ -130,7 +132,8 @@ interface UserCharacterDao {
|
||||
c.nameWidth as nameSpriteWidth,
|
||||
c.nameHeight as nameSpriteHeight,
|
||||
d.isBEm as isBemCard,
|
||||
a.characterId as isInAdventure
|
||||
a.characterId as isInAdventure,
|
||||
uc.isActive as active
|
||||
FROM UserCharacter uc
|
||||
JOIN CardCharacter c ON uc.charId = c.id
|
||||
JOIN Card d ON c.cardId = d.id
|
||||
@ -194,7 +197,8 @@ interface UserCharacterDao {
|
||||
c.nameWidth as nameSpriteWidth,
|
||||
c.nameHeight as nameSpriteHeight,
|
||||
d.isBEm as isBemCard,
|
||||
a.characterId = uc.id as isInAdventure
|
||||
a.characterId = uc.id as isInAdventure,
|
||||
uc.isActive as active
|
||||
FROM UserCharacter uc
|
||||
JOIN CardCharacter c ON uc.charId = c.id
|
||||
JOIN Card d ON d.id = c.cardId
|
||||
@ -219,7 +223,8 @@ interface UserCharacterDao {
|
||||
c.nameWidth as nameSpriteWidth,
|
||||
c.nameHeight as nameSpriteHeight,
|
||||
d.isBEm as isBemCard,
|
||||
a.characterId = uc.id as isInAdventure
|
||||
a.characterId = uc.id as isInAdventure,
|
||||
uc.isActive as active
|
||||
FROM UserCharacter uc
|
||||
JOIN CardCharacter c ON uc.charId = c.id
|
||||
JOIN Card d ON d.id = c.cardId
|
||||
|
||||
@ -31,7 +31,8 @@ object CharacterDtos {
|
||||
val nameSpriteWidth: Int,
|
||||
val nameSpriteHeight: Int,
|
||||
val isBemCard: Boolean,
|
||||
val isInAdventure: Boolean
|
||||
val isInAdventure: Boolean,
|
||||
val active: Boolean
|
||||
)
|
||||
|
||||
data class CardCharacterInfo(
|
||||
|
||||
@ -10,6 +10,7 @@ import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
@ -37,13 +38,11 @@ fun AdventureScreen(
|
||||
navController: NavController,
|
||||
storageScreenController: AdventureScreenControllerImpl
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val application = LocalContext.current.applicationContext as VBHelper
|
||||
val database = application.container.db
|
||||
val storageRepository = StorageRepository(database)
|
||||
val characterList = remember {
|
||||
mutableStateOf<List<CharacterDtos.AdventureCharacterWithSprites>>(emptyList())
|
||||
}
|
||||
val characterList by storageRepository.getAdventureCharacters().collectAsState(emptyList())
|
||||
|
||||
var obtainedItem by remember {
|
||||
mutableStateOf<ItemDtos.PurchasedItem?>(null)
|
||||
}
|
||||
@ -59,13 +58,6 @@ fun AdventureScreen(
|
||||
mutableStateOf<CharacterDtos.AdventureCharacterWithSprites?>(null)
|
||||
}
|
||||
|
||||
LaunchedEffect(storageRepository) {
|
||||
coroutineScope.launch {
|
||||
characterList.value = storageRepository
|
||||
.getAdventureCharacters()
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopBanner(
|
||||
@ -76,7 +68,7 @@ fun AdventureScreen(
|
||||
)
|
||||
}
|
||||
) { contentPadding ->
|
||||
if (characterList.value.isEmpty()) {
|
||||
if (characterList.isEmpty()) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
@ -91,7 +83,7 @@ fun AdventureScreen(
|
||||
modifier = Modifier
|
||||
.padding(top = contentPadding.calculateTopPadding())
|
||||
) {
|
||||
items(characterList.value) {
|
||||
items(characterList) {
|
||||
AdventureEntry(
|
||||
icon = BitmapData(
|
||||
bitmap = it.spriteIdle,
|
||||
|
||||
@ -23,6 +23,7 @@ class HomeScreenControllerImpl(
|
||||
val adventureCharacters = database
|
||||
.adventureDao()
|
||||
.getAdventureCharacters()
|
||||
.first()
|
||||
|
||||
val finishedAdventureCharacters = adventureCharacters.filter { character ->
|
||||
character.finishesAdventure <= currentTime
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.github.nacabaro.vbhelper.screens.settingsScreen
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -13,6 +15,7 @@ import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@ -25,6 +28,8 @@ fun SettingsScreen(
|
||||
navController: NavController,
|
||||
settingsScreenController: SettingsScreenControllerImpl,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Scaffold (
|
||||
topBar = {
|
||||
TopBanner(
|
||||
@ -44,19 +49,22 @@ fun SettingsScreen(
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
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()
|
||||
}
|
||||
SettingsSection("DiM/BEm management")
|
||||
SettingsEntry(title = "Import card", description = "Import DiM/BEm card file") {
|
||||
settingsScreenController.onClickImportCard()
|
||||
}
|
||||
SettingsEntry(title = "Rename DiM/BEm", description = "Set card name") { }
|
||||
SettingsSection("About and credits")
|
||||
SettingsEntry(title = "Credits", description = "Credits") {
|
||||
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")
|
||||
SettingsEntry(title = "Export data", description = "Export application database") {
|
||||
settingsScreenController.onClickOpenDirectory()
|
||||
|
||||
@ -12,6 +12,7 @@ import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material3.CardColors
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -98,6 +99,8 @@ fun StorageScreen(
|
||||
)
|
||||
}
|
||||
},
|
||||
cardColors = CardColors
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ class StorageRepository (
|
||||
return db.userCharacterDao().deleteCharacterById(id)
|
||||
}
|
||||
|
||||
suspend fun getAdventureCharacters(): List<CharacterDtos.AdventureCharacterWithSprites> {
|
||||
fun getAdventureCharacters(): Flow<List<CharacterDtos.AdventureCharacterWithSprites>> {
|
||||
return db.adventureDao().getAdventureCharacters()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user