mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-28 00:15:32 +00:00
Slowdowns and UI
- Current item can be seen from a character when clicked on it, you can also see how much time left does that item have on that character. - Fixed slowdown issue in the items screen. Also fixed this issue in the storage screen as it'd also affect it if there are a lot of characters in the storage.
This commit is contained in:
parent
b4a73031e7
commit
35a7c9d959
@ -1,6 +1,5 @@
|
|||||||
package com.github.nacabaro.vbhelper.components
|
package com.github.nacabaro.vbhelper.components
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@ -23,22 +22,18 @@ import androidx.compose.ui.graphics.asImageBitmap
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import com.github.nacabaro.vbhelper.utils.BitmapData
|
import com.github.nacabaro.vbhelper.utils.BitmapData
|
||||||
import com.github.nacabaro.vbhelper.utils.getBitmap
|
import com.github.nacabaro.vbhelper.utils.getBitmap
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.platform.LocalContext
|
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.TextUnit
|
|
||||||
import com.github.nacabaro.vbhelper.utils.getObscuredBitmap
|
import com.github.nacabaro.vbhelper.utils.getObscuredBitmap
|
||||||
import java.nio.ByteBuffer
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CharacterEntry(
|
fun CharacterEntry(
|
||||||
icon: BitmapData,
|
icon: BitmapData,
|
||||||
obscure: Boolean = false,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
obscure: Boolean = false,
|
||||||
shape: Shape = MaterialTheme.shapes.medium,
|
shape: Shape = MaterialTheme.shapes.medium,
|
||||||
multiplier: Int = 3,
|
multiplier: Int = 3,
|
||||||
onClick: () -> Unit = { }
|
onClick: () -> Unit = { }
|
||||||
@ -79,8 +74,6 @@ fun ItemDisplay(
|
|||||||
icon: Int,
|
icon: Int,
|
||||||
textValue: String,
|
textValue: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
iconSize: Dp = 48.dp,
|
|
||||||
textSize: TextUnit = 24.sp,
|
|
||||||
definition: String = "",
|
definition: String = "",
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@ -101,15 +94,14 @@ fun ItemDisplay(
|
|||||||
painter = painterResource(icon),
|
painter = painterResource(icon),
|
||||||
contentDescription = "Vitals",
|
contentDescription = "Vitals",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.fillMaxSize(0.5f)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.size(iconSize)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = textValue,
|
text = textValue,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
fontSize = textSize,
|
|
||||||
fontFamily = MaterialTheme.typography.titleLarge.fontFamily,
|
fontFamily = MaterialTheme.typography.titleLarge.fontFamily,
|
||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import com.github.nacabaro.vbhelper.R
|
import com.github.nacabaro.vbhelper.R
|
||||||
|
import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
|
||||||
import com.github.nacabaro.vbhelper.ui.theme.VBHelperTheme
|
import com.github.nacabaro.vbhelper.ui.theme.VBHelperTheme
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
@ -159,11 +160,11 @@ fun ItemDialog(
|
|||||||
|
|
||||||
fun getIconResource(index: Int): Int {
|
fun getIconResource(index: Int): Int {
|
||||||
return when (index) {
|
return when (index) {
|
||||||
1 -> R.drawable.baseline_agility_24
|
ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> R.drawable.baseline_agility_24
|
||||||
2 -> R.drawable.baseline_attack_24
|
ItemsScreenControllerImpl.ItemTypes.APTraining.id -> R.drawable.baseline_attack_24
|
||||||
3 -> R.drawable.baseline_shield_24
|
ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> R.drawable.baseline_shield_24
|
||||||
4 -> R.drawable.baseline_trophy_24
|
ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> R.drawable.baseline_trophy_24
|
||||||
5 -> R.drawable.baseline_arrow_up_24
|
ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> R.drawable.baseline_arrow_up_24
|
||||||
6 -> R.drawable.baseline_timer_24
|
6 -> R.drawable.baseline_timer_24
|
||||||
7 -> R.drawable.baseline_rank_24
|
7 -> R.drawable.baseline_rank_24
|
||||||
8 -> R.drawable.baseline_vitals_24
|
8 -> R.drawable.baseline_vitals_24
|
||||||
|
|||||||
@ -99,6 +99,8 @@ fun StorageScreen(
|
|||||||
selectedCharacter = index.id
|
selectedCharacter = index.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedCharacter != null) {
|
if (selectedCharacter != null) {
|
||||||
StorageDialog(
|
StorageDialog(
|
||||||
@ -125,8 +127,6 @@ fun StorageScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StorageDialog(
|
fun StorageDialog(
|
||||||
|
|||||||
@ -15,8 +15,10 @@ import com.github.nacabaro.vbhelper.R
|
|||||||
import com.github.nacabaro.vbhelper.components.CharacterEntry
|
import com.github.nacabaro.vbhelper.components.CharacterEntry
|
||||||
import com.github.nacabaro.vbhelper.components.ItemDisplay
|
import com.github.nacabaro.vbhelper.components.ItemDisplay
|
||||||
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
|
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
|
||||||
|
import com.github.nacabaro.vbhelper.components.getIconResource
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
||||||
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
||||||
|
import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
|
||||||
import com.github.nacabaro.vbhelper.utils.BitmapData
|
import com.github.nacabaro.vbhelper.utils.BitmapData
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@ -153,6 +155,24 @@ fun BEBEmHomeScreen(
|
|||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
)
|
)
|
||||||
|
if (beData.itemRemainingTime != 0) {
|
||||||
|
ItemDisplay(
|
||||||
|
icon = getIconResource(beData.itemType),
|
||||||
|
textValue = "${beData.itemRemainingTime} m",
|
||||||
|
definition = when (beData.itemType) {
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> "PP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> "HP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.APTraining.id -> "AP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> "BP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> "All Training"
|
||||||
|
else -> ""
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.aspectRatio(1f)
|
||||||
|
.padding(8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Row (
|
Row (
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@ -16,8 +16,10 @@ import com.github.nacabaro.vbhelper.R
|
|||||||
import com.github.nacabaro.vbhelper.components.CharacterEntry
|
import com.github.nacabaro.vbhelper.components.CharacterEntry
|
||||||
import com.github.nacabaro.vbhelper.components.ItemDisplay
|
import com.github.nacabaro.vbhelper.components.ItemDisplay
|
||||||
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
|
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
|
||||||
|
import com.github.nacabaro.vbhelper.components.getIconResource
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
||||||
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
||||||
|
import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
|
||||||
import com.github.nacabaro.vbhelper.utils.BitmapData
|
import com.github.nacabaro.vbhelper.utils.BitmapData
|
||||||
import kotlin.text.format
|
import kotlin.text.format
|
||||||
|
|
||||||
@ -130,8 +132,13 @@ fun BEDiMHomeScreen(
|
|||||||
textValue = when {
|
textValue = when {
|
||||||
activeMon.totalBattlesLost == 0 -> "0.00 %"
|
activeMon.totalBattlesLost == 0 -> "0.00 %"
|
||||||
else -> {
|
else -> {
|
||||||
val battleWinPercentage = activeMon.totalBattlesWon.toFloat() / (activeMon.totalBattlesWon + activeMon.totalBattlesLost).toFloat()
|
val battleWinPercentage =
|
||||||
String.format(Locale.getDefault(), "%.2f", battleWinPercentage * 100) + " %" // Specify locale
|
activeMon.totalBattlesWon.toFloat() / (activeMon.totalBattlesWon + activeMon.totalBattlesLost).toFloat()
|
||||||
|
String.format(
|
||||||
|
Locale.getDefault(),
|
||||||
|
"%.2f",
|
||||||
|
battleWinPercentage * 100
|
||||||
|
) + " %" // Specify locale
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
definition = "Total battle win %",
|
definition = "Total battle win %",
|
||||||
@ -145,8 +152,13 @@ fun BEDiMHomeScreen(
|
|||||||
textValue = when {
|
textValue = when {
|
||||||
activeMon.totalBattlesLost == 0 -> "0.00 %"
|
activeMon.totalBattlesLost == 0 -> "0.00 %"
|
||||||
else -> {
|
else -> {
|
||||||
val battleWinPercentage = activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
|
val battleWinPercentage =
|
||||||
String.format(Locale.getDefault(), "%.2f", battleWinPercentage * 100) + " %" // Specify locale
|
activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
|
||||||
|
String.format(
|
||||||
|
Locale.getDefault(),
|
||||||
|
"%.2f",
|
||||||
|
battleWinPercentage * 100
|
||||||
|
) + " %" // Specify locale
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
definition = "Current phase win %",
|
definition = "Current phase win %",
|
||||||
@ -155,6 +167,24 @@ fun BEDiMHomeScreen(
|
|||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
)
|
)
|
||||||
|
if (beData.itemRemainingTime != 0) {
|
||||||
|
ItemDisplay(
|
||||||
|
icon = getIconResource(beData.itemType),
|
||||||
|
textValue = "${beData.itemRemainingTime} m",
|
||||||
|
definition = when (beData.itemType) {
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> "PP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> "HP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.APTraining.id -> "AP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> "BP Training"
|
||||||
|
ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> "All Training"
|
||||||
|
else -> ""
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.aspectRatio(1f)
|
||||||
|
.padding(8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import com.github.nacabaro.vbhelper.database.AppDatabase
|
import com.github.nacabaro.vbhelper.database.AppDatabase
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
|
|
||||||
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
||||||
import com.github.nacabaro.vbhelper.utils.DeviceType
|
import com.github.nacabaro.vbhelper.utils.DeviceType
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -17,7 +16,7 @@ class ItemsScreenControllerImpl (
|
|||||||
): ItemsScreenController {
|
): ItemsScreenController {
|
||||||
private var database: AppDatabase
|
private var database: AppDatabase
|
||||||
|
|
||||||
private enum class ItemTypes(val id: Int) {
|
enum class ItemTypes(val id: Int) {
|
||||||
PPTraining(1),
|
PPTraining(1),
|
||||||
HPTraining(2),
|
HPTraining(2),
|
||||||
APTraining(3),
|
APTraining(3),
|
||||||
@ -39,7 +38,7 @@ class ItemsScreenControllerImpl (
|
|||||||
val item = getItem(itemId)
|
val item = getItem(itemId)
|
||||||
val characterData = database.userCharacterDao().getCharacter(characterId)
|
val characterData = database.userCharacterDao().getCharacter(characterId)
|
||||||
val beCharacterData: BECharacterData
|
val beCharacterData: BECharacterData
|
||||||
var vbCharacterData: VBCharacterData
|
//var vbCharacterData: VBCharacterData
|
||||||
|
|
||||||
if (characterData.characterType == DeviceType.BEDevice) {
|
if (characterData.characterType == DeviceType.BEDevice) {
|
||||||
beCharacterData = database.userCharacterDao().getBeData(characterId)
|
beCharacterData = database.userCharacterDao().getBeData(characterId)
|
||||||
|
|||||||
@ -32,7 +32,6 @@ fun ItemsStore(
|
|||||||
val application = LocalContext.current.applicationContext as VBHelper
|
val application = LocalContext.current.applicationContext as VBHelper
|
||||||
val itemsRepository = ItemsRepository(application.container.db)
|
val itemsRepository = ItemsRepository(application.container.db)
|
||||||
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
|
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
|
||||||
var showDialog by remember { mutableStateOf(false) }
|
|
||||||
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
|
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
|
||||||
|
|
||||||
LaunchedEffect(itemsRepository) {
|
LaunchedEffect(itemsRepository) {
|
||||||
@ -55,12 +54,13 @@ fun ItemsStore(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
onClick = {
|
onClick = {
|
||||||
showDialog = true
|
|
||||||
selectedElementIndex = myItems.value.indexOf(index)
|
selectedElementIndex = myItems.value.indexOf(index)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showDialog && selectedElementIndex != null) {
|
if (selectedElementIndex != null) {
|
||||||
ItemDialog(
|
ItemDialog(
|
||||||
name = myItems.value[selectedElementIndex!!].name,
|
name = myItems.value[selectedElementIndex!!].name,
|
||||||
description = myItems.value[selectedElementIndex!!].description,
|
description = myItems.value[selectedElementIndex!!].description,
|
||||||
@ -68,10 +68,8 @@ fun ItemsStore(
|
|||||||
lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
|
lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
|
||||||
amount = myItems.value[selectedElementIndex!!].quantity,
|
amount = myItems.value[selectedElementIndex!!].quantity,
|
||||||
onClickUse = { },
|
onClickUse = { },
|
||||||
onClickCancel = { showDialog = false }
|
onClickCancel = { selectedElementIndex = null }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -37,7 +37,6 @@ fun MyItems(
|
|||||||
val application = LocalContext.current.applicationContext as VBHelper
|
val application = LocalContext.current.applicationContext as VBHelper
|
||||||
val itemsRepository = ItemsRepository(application.container.db)
|
val itemsRepository = ItemsRepository(application.container.db)
|
||||||
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
|
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
|
||||||
var showDialog by remember { mutableStateOf(false) }
|
|
||||||
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
|
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
|
||||||
|
|
||||||
LaunchedEffect(itemsRepository) {
|
LaunchedEffect(itemsRepository) {
|
||||||
@ -66,12 +65,13 @@ fun MyItems(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
onClick = {
|
onClick = {
|
||||||
showDialog = true
|
|
||||||
selectedElementIndex = myItems.value.indexOf(index)
|
selectedElementIndex = myItems.value.indexOf(index)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showDialog && selectedElementIndex != null) {
|
if (selectedElementIndex != null) {
|
||||||
ItemDialog(
|
ItemDialog(
|
||||||
name = myItems.value[selectedElementIndex!!].name,
|
name = myItems.value[selectedElementIndex!!].name,
|
||||||
description = myItems.value[selectedElementIndex!!].description,
|
description = myItems.value[selectedElementIndex!!].description,
|
||||||
@ -79,7 +79,6 @@ fun MyItems(
|
|||||||
lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
|
lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
|
||||||
amount = myItems.value[selectedElementIndex!!].quantity,
|
amount = myItems.value[selectedElementIndex!!].quantity,
|
||||||
onClickUse = {
|
onClickUse = {
|
||||||
showDialog = false
|
|
||||||
navController
|
navController
|
||||||
.navigate(
|
.navigate(
|
||||||
NavigationItems
|
NavigationItems
|
||||||
@ -89,11 +88,10 @@ fun MyItems(
|
|||||||
myItems.value[selectedElementIndex!!].id.toString()
|
myItems.value[selectedElementIndex!!].id.toString()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
selectedElementIndex = null
|
||||||
},
|
},
|
||||||
onClickCancel = { showDialog = false }
|
onClickCancel = { selectedElementIndex = null }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user