mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-05 11:45:10 +01:00
Simplify OnScreenConfiguration
`ControllerConfigurationDummy` was removed as it isn't needed anymore, and the remaining classes simplified.
This commit is contained in:
parent
17f45c0366
commit
c4d0d02509
@ -35,12 +35,11 @@ abstract class OnScreenButton(
|
||||
const val CONFIGURED_ASPECT_RATIO = 2074f / 874f
|
||||
}
|
||||
|
||||
val config = if (onScreenControllerView.isInEditMode) ControllerConfigurationDummy(defaultRelativeX, defaultRelativeY)
|
||||
else ControllerConfigurationImpl(onScreenControllerView.context, buttonId, defaultRelativeX, defaultRelativeY)
|
||||
val config = OnScreenConfiguration(onScreenControllerView.context, buttonId, defaultRelativeX, defaultRelativeY)
|
||||
|
||||
protected val drawable = ContextCompat.getDrawable(onScreenControllerView.context, drawableId)!!
|
||||
|
||||
internal val buttonSymbolPaint = Paint().apply {
|
||||
private val buttonSymbolPaint = Paint().apply {
|
||||
color = config.textColor
|
||||
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
|
||||
isAntiAlias = true
|
||||
|
@ -10,37 +10,14 @@ import emu.skyline.input.ButtonId
|
||||
import emu.skyline.utils.SwitchColors
|
||||
import emu.skyline.utils.sharedPreferences
|
||||
|
||||
interface ControllerConfiguration {
|
||||
var alpha : Int
|
||||
var textColor : Int
|
||||
var backgroundColor : Int
|
||||
var enabled : Boolean
|
||||
var globalScale : Float
|
||||
var relativeX : Float
|
||||
var relativeY : Float
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy implementation so layout editor is able to render [OnScreenControllerView] when [android.view.View.isInEditMode] is true
|
||||
*/
|
||||
class ControllerConfigurationDummy(defaultRelativeX : Float, defaultRelativeY : Float) : ControllerConfiguration {
|
||||
override var alpha : Int = 155
|
||||
override var textColor = SwitchColors.BLACK.color
|
||||
override var backgroundColor = SwitchColors.WHITE.color
|
||||
override var enabled = true
|
||||
override var globalScale = 1f
|
||||
override var relativeX = defaultRelativeX
|
||||
override var relativeY = defaultRelativeY
|
||||
}
|
||||
|
||||
class ControllerConfigurationImpl(private val context : Context, private val buttonId : ButtonId, defaultRelativeX : Float, defaultRelativeY : Float) : ControllerConfiguration {
|
||||
class OnScreenConfiguration(private val context : Context, private val buttonId : ButtonId, defaultRelativeX : Float, defaultRelativeY : Float) {
|
||||
private inline fun <reified T> config(default : T, prefix : String = "${buttonId.name}_") = sharedPreferences(context, default, prefix, "controller_config")
|
||||
|
||||
override var alpha by config(155, "")
|
||||
override var textColor by config(SwitchColors.BLACK.color)
|
||||
override var backgroundColor by config(SwitchColors.WHITE.color)
|
||||
override var enabled by config(true)
|
||||
override var globalScale by config(1.15f, "")
|
||||
override var relativeX by config(defaultRelativeX)
|
||||
override var relativeY by config(defaultRelativeY)
|
||||
var alpha by config(155, "")
|
||||
var textColor by config(SwitchColors.BLACK.color)
|
||||
var backgroundColor by config(SwitchColors.WHITE.color)
|
||||
var enabled by config(true)
|
||||
var globalScale by config(1.15f, "")
|
||||
var relativeX by config(defaultRelativeX)
|
||||
var relativeY by config(defaultRelativeY)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ package emu.skyline.input.onscreen
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.PointF
|
||||
import android.graphics.Typeface
|
||||
import android.os.SystemClock
|
||||
import androidx.core.graphics.minus
|
||||
import emu.skyline.R
|
||||
|
Loading…
Reference in New Issue
Block a user