mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-10-01 15:41:36 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b3ce486cb |
@@ -1,24 +0,0 @@
|
|||||||
package com.github.nacabaro.vbhelper.daos
|
|
||||||
|
|
||||||
import androidx.room.Dao
|
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.Query
|
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardBackground
|
|
||||||
|
|
||||||
@Dao
|
|
||||||
interface CardBackgroundDao {
|
|
||||||
@Insert
|
|
||||||
suspend fun insertCardBackground(vararg cardBackground: CardBackground)
|
|
||||||
|
|
||||||
@Query("""
|
|
||||||
SELECT * FROM CardBackground
|
|
||||||
WHERE cardId = :cardId
|
|
||||||
""")
|
|
||||||
suspend fun getCardBackground(cardId: Long): CardBackground
|
|
||||||
|
|
||||||
@Query("""
|
|
||||||
SELECT * FROM CardBackground
|
|
||||||
""")
|
|
||||||
suspend fun getBackgrounds(): List<CardBackground>
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import androidx.room.Insert
|
|||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import com.github.nacabaro.vbhelper.domain.card.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardSprites
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface CardDao {
|
interface CardDao {
|
||||||
@@ -34,11 +33,4 @@ interface CardDao {
|
|||||||
|
|
||||||
@Query("DELETE FROM Card WHERE id = :id")
|
@Query("DELETE FROM Card WHERE id = :id")
|
||||||
suspend fun deleteCard(id: Long)
|
suspend fun deleteCard(id: Long)
|
||||||
|
|
||||||
@Insert
|
|
||||||
suspend fun insertSprites(vararg sprites: CardSprites)
|
|
||||||
|
|
||||||
@Query("SELECT * FROM CardSprites")
|
|
||||||
suspend fun getSprites(): List<CardSprites>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,30 +5,28 @@ import androidx.room.Query
|
|||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface CardFusionsDao {
|
interface CardFusionsDao {
|
||||||
@Query(
|
@Query("""
|
||||||
"""
|
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
CardFusions (
|
CardFusions (
|
||||||
fromCharaId,
|
fromCharaId,
|
||||||
toVirusFusion,
|
attribute1Fusion,
|
||||||
toDataFusion,
|
attribute2Fusion,
|
||||||
toVaccineFusion,
|
attribute3Fusion,
|
||||||
toFreeFusion
|
attribute4Fusion
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :fromCharaId),
|
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :fromCharaId),
|
||||||
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdVirus),
|
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdAttr1),
|
||||||
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdData),
|
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdAttr2),
|
||||||
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdVaccine),
|
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdAttr3),
|
||||||
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdFree)
|
(SELECT id FROM CardCharacter WHERE cardId = :cardId AND charaIndex = :toCharaIdAttr4)
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
suspend fun insertNewFusion(
|
suspend fun insertNewFusion(
|
||||||
cardId: Long,
|
cardId: Long,
|
||||||
fromCharaId: Int,
|
fromCharaId: Int,
|
||||||
toCharaIdVirus: Int,
|
toCharaIdAttr1: Int,
|
||||||
toCharaIdData: Int,
|
toCharaIdAttr2: Int,
|
||||||
toCharaIdVaccine: Int,
|
toCharaIdAttr3: Int,
|
||||||
toCharaIdFree: Int
|
toCharaIdAttr4: Int
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ interface CharacterDao {
|
|||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""
|
"""
|
||||||
INSERT INTO CardTransformations (charaId, requiredVitals, requiredTrophies, requiredBattles, requiredWinRate, changeTimerHours, requiredAdventureLevelCompleted, toCharaId)
|
INSERT INTO PossibleTransformations (charaId, requiredVitals, requiredTrophies, requiredBattles, requiredWinRate, changeTimerHours, requiredAdventureLevelCompleted, toCharaId)
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT id FROM CardCharacter WHERE charaIndex = :fromChraraIndex AND cardId = :cardId),
|
(SELECT id FROM CardCharacter WHERE charaIndex = :fromChraraIndex AND cardId = :cardId),
|
||||||
:requiredVitals,
|
:requiredVitals,
|
||||||
@@ -75,7 +75,7 @@ interface CharacterDao {
|
|||||||
pt.changeTimerHours as changeTimerHours,
|
pt.changeTimerHours as changeTimerHours,
|
||||||
pt.requiredAdventureLevelCompleted as requiredAdventureLevelCompleted
|
pt.requiredAdventureLevelCompleted as requiredAdventureLevelCompleted
|
||||||
FROM
|
FROM
|
||||||
CardTransformations pt
|
PossibleTransformations pt
|
||||||
JOIN CardCharacter c on pt.toCharaId = c.id
|
JOIN CardCharacter c on pt.toCharaId = c.id
|
||||||
JOIN Sprite s ON s.id = c.spriteId
|
JOIN Sprite s ON s.id = c.spriteId
|
||||||
LEFT JOIN Dex d ON d.id = pt.toCharaId
|
LEFT JOIN Dex d ON d.id = pt.toCharaId
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import androidx.room.Database
|
|||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import com.github.nacabaro.vbhelper.daos.AdventureDao
|
import com.github.nacabaro.vbhelper.daos.AdventureDao
|
||||||
import com.github.nacabaro.vbhelper.daos.CardAdventureDao
|
import com.github.nacabaro.vbhelper.daos.CardAdventureDao
|
||||||
import com.github.nacabaro.vbhelper.daos.CardBackgroundDao
|
|
||||||
import com.github.nacabaro.vbhelper.daos.CharacterDao
|
import com.github.nacabaro.vbhelper.daos.CharacterDao
|
||||||
import com.github.nacabaro.vbhelper.daos.DexDao
|
import com.github.nacabaro.vbhelper.daos.DexDao
|
||||||
import com.github.nacabaro.vbhelper.daos.CardDao
|
import com.github.nacabaro.vbhelper.daos.CardDao
|
||||||
@@ -14,14 +13,13 @@ import com.github.nacabaro.vbhelper.daos.ItemDao
|
|||||||
import com.github.nacabaro.vbhelper.daos.SpecialMissionDao
|
import com.github.nacabaro.vbhelper.daos.SpecialMissionDao
|
||||||
import com.github.nacabaro.vbhelper.daos.SpriteDao
|
import com.github.nacabaro.vbhelper.daos.SpriteDao
|
||||||
import com.github.nacabaro.vbhelper.daos.UserCharacterDao
|
import com.github.nacabaro.vbhelper.daos.UserCharacterDao
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardBackground
|
import com.github.nacabaro.vbhelper.domain.card.Background
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardCharacter
|
import com.github.nacabaro.vbhelper.domain.card.CardCharacter
|
||||||
import com.github.nacabaro.vbhelper.domain.card.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardAdventure
|
import com.github.nacabaro.vbhelper.domain.card.CardAdventure
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardFusions
|
import com.github.nacabaro.vbhelper.domain.card.CardFusions
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardSprites
|
import com.github.nacabaro.vbhelper.domain.card.PossibleTransformations
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardTransformations
|
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Adventure
|
import com.github.nacabaro.vbhelper.domain.characters.Adventure
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Dex
|
import com.github.nacabaro.vbhelper.domain.characters.Dex
|
||||||
@@ -41,7 +39,6 @@ import com.github.nacabaro.vbhelper.domain.items.Items
|
|||||||
CardCharacter::class,
|
CardCharacter::class,
|
||||||
CardAdventure::class,
|
CardAdventure::class,
|
||||||
CardFusions::class,
|
CardFusions::class,
|
||||||
CardSprites::class,
|
|
||||||
Sprite::class,
|
Sprite::class,
|
||||||
UserCharacter::class,
|
UserCharacter::class,
|
||||||
BECharacterData::class,
|
BECharacterData::class,
|
||||||
@@ -52,8 +49,8 @@ import com.github.nacabaro.vbhelper.domain.items.Items
|
|||||||
Dex::class,
|
Dex::class,
|
||||||
Items::class,
|
Items::class,
|
||||||
Adventure::class,
|
Adventure::class,
|
||||||
CardBackground::class,
|
Background::class,
|
||||||
CardTransformations::class
|
PossibleTransformations::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
@@ -68,5 +65,4 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
abstract fun specialMissionDao(): SpecialMissionDao
|
abstract fun specialMissionDao(): SpecialMissionDao
|
||||||
abstract fun cardAdventureDao(): CardAdventureDao
|
abstract fun cardAdventureDao(): CardAdventureDao
|
||||||
abstract fun cardFusionsDao(): CardFusionsDao
|
abstract fun cardFusionsDao(): CardFusionsDao
|
||||||
abstract fun cardBackgroundDao(): CardBackgroundDao
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.github.nacabaro.vbhelper.domain
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = Character::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["monId"],
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
),
|
||||||
|
ForeignKey(
|
||||||
|
entity = Character::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["nextMon"],
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
data class Evolutions(
|
||||||
|
@PrimaryKey val monId: Int,
|
||||||
|
@PrimaryKey val nextMon: Int,
|
||||||
|
val trophies: Int,
|
||||||
|
val vitals: Int,
|
||||||
|
val totalBattles: Int,
|
||||||
|
val winRate: Int // Does not need to be a floating point
|
||||||
|
)
|
||||||
+2
-2
@@ -14,8 +14,8 @@ import androidx.room.PrimaryKey
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
data class CardBackground (
|
data class Background (
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
@PrimaryKey(autoGenerate = true) val id: Long,
|
||||||
val cardId: Long,
|
val cardId: Long,
|
||||||
val background: ByteArray,
|
val background: ByteArray,
|
||||||
val backgroundWidth: Int,
|
val backgroundWidth: Int,
|
||||||
@@ -15,25 +15,25 @@ import androidx.room.PrimaryKey
|
|||||||
ForeignKey(
|
ForeignKey(
|
||||||
entity = CardCharacter::class,
|
entity = CardCharacter::class,
|
||||||
parentColumns = ["id"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["toVirusFusion"],
|
childColumns = ["attribute1Fusion"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
),
|
),
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
entity = CardCharacter::class,
|
entity = CardCharacter::class,
|
||||||
parentColumns = ["id"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["toDataFusion"],
|
childColumns = ["attribute2Fusion"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
),
|
),
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
entity = CardCharacter::class,
|
entity = CardCharacter::class,
|
||||||
parentColumns = ["id"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["toVaccineFusion"],
|
childColumns = ["attribute3Fusion"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
),
|
),
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
entity = CardCharacter::class,
|
entity = CardCharacter::class,
|
||||||
parentColumns = ["id"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["toFreeFusion"],
|
childColumns = ["attribute4Fusion"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@@ -41,8 +41,8 @@ import androidx.room.PrimaryKey
|
|||||||
data class CardFusions(
|
data class CardFusions(
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long,
|
@PrimaryKey(autoGenerate = true) val id: Long,
|
||||||
val fromCharaId: Long,
|
val fromCharaId: Long,
|
||||||
val toVirusFusion: Long?,
|
val attribute1Fusion: Long?,
|
||||||
val toDataFusion: Long?,
|
val attribute2Fusion: Long?,
|
||||||
val toVaccineFusion: Long?,
|
val attribute3Fusion: Long?,
|
||||||
val toFreeFusion: Long?
|
val attribute4Fusion: Long?
|
||||||
)
|
)
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.github.nacabaro.vbhelper.domain.card
|
|
||||||
|
|
||||||
import androidx.room.Entity
|
|
||||||
import androidx.room.PrimaryKey
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
data class CardSprites(
|
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
|
||||||
val sprite: ByteArray,
|
|
||||||
val width: Int,
|
|
||||||
val height: Int
|
|
||||||
)
|
|
||||||
+1
-1
@@ -20,7 +20,7 @@ import androidx.room.PrimaryKey
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
data class CardTransformations (
|
data class PossibleTransformations (
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
var charaId: Long,
|
var charaId: Long,
|
||||||
val requiredVitals: Int,
|
val requiredVitals: Int,
|
||||||
@@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.github.nacabaro.vbhelper.components.TopBanner
|
import com.github.nacabaro.vbhelper.components.TopBanner
|
||||||
import com.github.nacabaro.vbhelper.navigation.NavigationItems
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CreditsScreen(
|
fun CreditsScreen(
|
||||||
@@ -20,9 +19,6 @@ fun CreditsScreen(
|
|||||||
text = "Credits",
|
text = "Credits",
|
||||||
onBackClick = {
|
onBackClick = {
|
||||||
navController.popBackStack()
|
navController.popBackStack()
|
||||||
},
|
|
||||||
onGearClick = {
|
|
||||||
navController.navigate(NavigationItems.Viewer.route)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
+5
-55
@@ -17,10 +17,8 @@ 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.characters.Sprite
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
import com.github.nacabaro.vbhelper.domain.card.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardBackground
|
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardCharacter
|
import com.github.nacabaro.vbhelper.domain.card.CardCharacter
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardSprites
|
|
||||||
import com.github.nacabaro.vbhelper.source.ApkSecretsImporter
|
import com.github.nacabaro.vbhelper.source.ApkSecretsImporter
|
||||||
import com.github.nacabaro.vbhelper.source.SecretsImporter
|
import com.github.nacabaro.vbhelper.source.SecretsImporter
|
||||||
import com.github.nacabaro.vbhelper.source.SecretsRepository
|
import com.github.nacabaro.vbhelper.source.SecretsRepository
|
||||||
@@ -217,7 +215,7 @@ class SettingsScreenControllerImpl(
|
|||||||
spriteHappy = card.spriteData.sprites[spriteCounter + 4].pixelData,
|
spriteHappy = card.spriteData.sprites[spriteCounter + 4].pixelData,
|
||||||
spriteSleep = card.spriteData.sprites[spriteCounter + 5].pixelData,
|
spriteSleep = card.spriteData.sprites[spriteCounter + 5].pixelData,
|
||||||
spriteAttack = card.spriteData.sprites[spriteCounter + 2].pixelData,
|
spriteAttack = card.spriteData.sprites[spriteCounter + 2].pixelData,
|
||||||
spriteDodge = card.spriteData.sprites[spriteCounter + 3].pixelData,
|
spriteDodge = card.spriteData.sprites[spriteCounter + 3].pixelData
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
domainSprite = Sprite(
|
domainSprite = Sprite(
|
||||||
@@ -326,10 +324,10 @@ class SettingsScreenControllerImpl(
|
|||||||
.insertNewFusion(
|
.insertNewFusion(
|
||||||
cardId = cardId,
|
cardId = cardId,
|
||||||
fromCharaId = it.characterIndex,
|
fromCharaId = it.characterIndex,
|
||||||
toCharaIdVirus = it.attribute1Fusion,
|
toCharaIdAttr1 = it.attribute1Fusion,
|
||||||
toCharaIdData = it.attribute2Fusion,
|
toCharaIdAttr2 = it.attribute2Fusion,
|
||||||
toCharaIdVaccine = it.attribute3Fusion,
|
toCharaIdAttr3 = it.attribute3Fusion,
|
||||||
toCharaIdFree = it.attribute4Fusion
|
toCharaIdAttr4 = it.attribute4Fusion
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,40 +347,6 @@ class SettingsScreenControllerImpl(
|
|||||||
.updateDimProgress(cardProgress)
|
.updateDimProgress(cardProgress)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun importBackgrounds(
|
|
||||||
cardId: Long,
|
|
||||||
card: com.github.cfogrady.vb.dim.card.Card<*, *, *, *, *, *>
|
|
||||||
) {
|
|
||||||
val backgrounds = mutableListOf<CardBackground>()
|
|
||||||
|
|
||||||
if (card is DimCard) {
|
|
||||||
backgrounds.add(
|
|
||||||
CardBackground(
|
|
||||||
cardId = cardId,
|
|
||||||
background = card.spriteData.sprites[1].pixelData,
|
|
||||||
backgroundWidth = card.spriteData.sprites[1].width,
|
|
||||||
backgroundHeight = card.spriteData.sprites[1].height
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else if (card is BemCard) {
|
|
||||||
val possibleBackgroundsIds = listOf(1, 10, 30, 31, 32, 33)
|
|
||||||
for (id in possibleBackgroundsIds) {
|
|
||||||
backgrounds.add(
|
|
||||||
CardBackground(
|
|
||||||
cardId = cardId,
|
|
||||||
background = card.spriteData.sprites[id].pixelData,
|
|
||||||
backgroundWidth = card.spriteData.sprites[id].width,
|
|
||||||
backgroundHeight = card.spriteData.sprites[id].height
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
database
|
|
||||||
.cardBackgroundDao()
|
|
||||||
.insertCardBackground(*backgrounds.toTypedArray())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun importCard(uri: Uri) {
|
private fun importCard(uri: Uri) {
|
||||||
context.lifecycleScope.launch(Dispatchers.IO) {
|
context.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val contentResolver = context.contentResolver
|
val contentResolver = context.contentResolver
|
||||||
@@ -415,20 +379,6 @@ class SettingsScreenControllerImpl(
|
|||||||
importAdventureMissions(cardId, card)
|
importAdventureMissions(cardId, card)
|
||||||
|
|
||||||
importCardFusions(cardId, card)
|
importCardFusions(cardId, card)
|
||||||
|
|
||||||
importBackgrounds(cardId, card)
|
|
||||||
|
|
||||||
val cardSprites: List<CardSprites> = card.spriteData.sprites.map {
|
|
||||||
CardSprites(
|
|
||||||
sprite = it.pixelData,
|
|
||||||
width = it.width,
|
|
||||||
height = it.height
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
database
|
|
||||||
.cardDao()
|
|
||||||
.insertSprites(*cardSprites.toTypedArray())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inputStream?.close()
|
inputStream?.close()
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
package com.github.nacabaro.vbhelper.screens.spriteViewer
|
package com.github.nacabaro.vbhelper.screens.spriteViewer
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardBackground
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
|
|
||||||
interface SpriteViewerController {
|
interface SpriteViewerController {
|
||||||
suspend fun getAllSprites(): List<CardBackground>
|
suspend fun getAllSprites(): List<Sprite>
|
||||||
fun convertToBitmap(sprites: List<CardBackground>): List<Bitmap>
|
fun convertToBitmap(sprites: List<Sprite>): List<Bitmap>
|
||||||
}
|
}
|
||||||
+43
-7
@@ -1,29 +1,65 @@
|
|||||||
package com.github.nacabaro.vbhelper.screens.spriteViewer
|
package com.github.nacabaro.vbhelper.screens.spriteViewer
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.util.Log
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import androidx.core.graphics.createBitmap
|
|
||||||
import com.github.nacabaro.vbhelper.domain.card.CardBackground
|
|
||||||
|
|
||||||
class SpriteViewerControllerImpl(
|
class SpriteViewerControllerImpl(
|
||||||
private val context: ComponentActivity
|
private val context: ComponentActivity
|
||||||
) : SpriteViewerController {
|
) : SpriteViewerController {
|
||||||
override suspend fun getAllSprites(): List<CardBackground> {
|
override suspend fun getAllSprites(): List<Sprite> {
|
||||||
val applicationContext = context.applicationContext as VBHelper
|
val applicationContext = context.applicationContext as VBHelper
|
||||||
val db = applicationContext.container.db
|
val db = applicationContext.container.db
|
||||||
val sprites = db.cardBackgroundDao().getBackgrounds()
|
val sprites = db.spriteDao().getAllSprites()
|
||||||
return sprites
|
return sprites
|
||||||
}
|
}
|
||||||
|
|
||||||
// I don't like this, chief
|
// I don't like this, chief
|
||||||
override fun convertToBitmap(sprites: List<CardBackground>): List<Bitmap> {
|
override fun convertToBitmap(sprites: List<Sprite>): List<Bitmap> {
|
||||||
val bitmapList = mutableListOf<Bitmap>()
|
val bitmapList = mutableListOf<Bitmap>()
|
||||||
|
|
||||||
for (sprite in sprites) {
|
for (sprite in sprites) {
|
||||||
bitmapList.add(createBitmap(sprite.backgroundWidth, sprite.backgroundHeight, Bitmap.Config.RGB_565).apply {
|
Log.d("SpriteViewer", "sprite: $sprite")
|
||||||
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.background))
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteIdle1))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteIdle2))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteWalk1))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteWalk2))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteRun1))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteRun2))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteTrain1))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteTrain2))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteHappy))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteSleep))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteAttack))
|
||||||
|
})
|
||||||
|
bitmapList.add(Bitmap.createBitmap(sprite.width, sprite.height, Bitmap.Config.RGB_565).apply {
|
||||||
|
copyPixelsFromBuffer(ByteBuffer.wrap(sprite.spriteDodge))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.12.3"
|
agp = "8.12.2"
|
||||||
datastore = "1.1.2"
|
datastore = "1.1.2"
|
||||||
kotlin = "2.0.0"
|
kotlin = "2.0.0"
|
||||||
coreKtx = "1.15.0"
|
coreKtx = "1.15.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user