manueldidonna / pokemon-save-editor-android

A work-in-progress pokémon save editor for Android
GNU General Public License v3.0
0 stars 0 forks source link

Support caught data #17

Closed manueldidonna closed 4 years ago

manueldidonna commented 4 years ago

Needed information

data class CaughtInfo(
    val level: Int,
    val locationId: Int,
    val time: Time,
    val ballId: Int
)

sealed class Time {
    data class Date(val time: OffsetDateTime): Time()
    /**
     * Accepted values for [time] are [Morning], [Day] and [Night]
     */
    data class DayTime(val time: Int) : Time() {
        companion object {
            const val Morning = 0
            const val Day = 1
            const val Night = 2
        }
    }
}

interface SaveData {
    val supportedLocationIds: List<Int>
}
manueldidonna commented 4 years ago
// UI
@Composable
fun ModifyTime(val time: Time, onTimeChange: (Time) -> Unit) {
    when(time) {
        is Time.Date -> { /**TODO */ }
        is Time.DayTime -> {
            ShowSpinner(
                options = listOf(Morning, Day, Night), 
                onSelection = { onTimeChange(time.copy(it)) }
            )
        }
    }
}

@Composable
fun ModifyLocation(val saveData: SaveData, val locationId: Int, onLocationChange: (Int) -> Unit) {
    val resources = PokemonResourcesAmbient.current.locations
    val locations = remember { saveData.supportedLocationIds }
    val list = remember { locations.map { Pair(it, resources.getLocationById(it, saveData.version) } 
    ShowSpinner(options = list, onSelection = onLocationChange)
}
manueldidonna commented 4 years ago

Expose locations by wrapping them in a data class

data class Locations(val ids: List<Int>)

interface SaveData {
    val locations: Locations
}