mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 16:25:29 +03:00
Introduce constants for default OSC config values
This commit is contained in:
parent
83bc93601f
commit
acdf4e6823
@ -243,6 +243,6 @@ abstract class OnScreenButton(
|
|||||||
open fun resetConfig() {
|
open fun resetConfig() {
|
||||||
resetRelativeValues()
|
resetRelativeValues()
|
||||||
config.enabled = true
|
config.enabled = true
|
||||||
config.scale = 0f
|
config.scale = OnScreenConfiguration.DefaultScale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,30 @@ import emu.skyline.utils.SwitchColors
|
|||||||
import emu.skyline.utils.sharedPreferences
|
import emu.skyline.utils.sharedPreferences
|
||||||
|
|
||||||
class OnScreenConfiguration(private val context : Context, private val buttonId : ButtonId, defaultRelativeX : Float, defaultRelativeY : Float) {
|
class OnScreenConfiguration(private val context : Context, private val buttonId : ButtonId, defaultRelativeX : Float, defaultRelativeY : Float) {
|
||||||
|
companion object {
|
||||||
|
const val DefaultAlpha = 130
|
||||||
|
const val DefaultGlobalScale = 1.15f
|
||||||
|
const val DefaultScale = 0.0f
|
||||||
|
}
|
||||||
|
|
||||||
private inline fun <reified T> config(default : T, prefix : String = "${buttonId.name}_") = sharedPreferences(context, default, prefix, "controller_config")
|
private inline fun <reified T> config(default : T, prefix : String = "${buttonId.name}_") = sharedPreferences(context, default, prefix, "controller_config")
|
||||||
|
|
||||||
var enabled by config(true)
|
var enabled by config(true)
|
||||||
|
|
||||||
var alpha by config(155, "")
|
var alpha by config(DefaultAlpha, "")
|
||||||
var textColor by config(SwitchColors.BLACK.color)
|
var textColor by config(SwitchColors.BLACK.color)
|
||||||
var backgroundColor by config(SwitchColors.WHITE.color)
|
var backgroundColor by config(SwitchColors.WHITE.color)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global scale applied to all buttons
|
* The global scale applied to all buttons
|
||||||
*/
|
*/
|
||||||
var globalScale by config(1.15f, "")
|
var globalScale by config(DefaultGlobalScale, "")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scale of each button, this is added to the global scale
|
* The scale of each button, this is added to the global scale
|
||||||
* Allows buttons to have their own size, while still be controlled by the global scale
|
* Allows buttons to have their own size, while still be controlled by the global scale
|
||||||
*/
|
*/
|
||||||
var scale by config(0.0f)
|
var scale by config(DefaultScale)
|
||||||
|
|
||||||
var relativeX by config(defaultRelativeX)
|
var relativeX by config(defaultRelativeX)
|
||||||
var relativeY by config(defaultRelativeY)
|
var relativeY by config(defaultRelativeY)
|
||||||
|
@ -271,8 +271,8 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
controls.allButtons.forEach {
|
controls.allButtons.forEach {
|
||||||
it.resetConfig()
|
it.resetConfig()
|
||||||
}
|
}
|
||||||
controls.globalScale = 1.15f
|
controls.globalScale = OnScreenConfiguration.DefaultGlobalScale
|
||||||
controls.alpha = 155
|
controls.alpha = OnScreenConfiguration.DefaultAlpha
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user