mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-22 09:49:14 +01:00
Enable OSC per-button text and color selection
This commit is contained in:
parent
c7d213c3ea
commit
659e090d38
@ -243,6 +243,8 @@ abstract class OnScreenButton(
|
||||
override fun resetConfig() {
|
||||
config.enabled = defaultEnabled
|
||||
config.alpha = OnScreenConfiguration.DefaultAlpha
|
||||
config.textColor = OnScreenConfiguration.DefaultTextColor
|
||||
config.backgroundColor = OnScreenConfiguration.DefaultBackgroundColor
|
||||
config.scale = OnScreenConfiguration.DefaultScale
|
||||
config.relativeX = defaultRelativeX
|
||||
config.relativeY = defaultRelativeY
|
||||
|
@ -350,25 +350,17 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun getTextColor() : Int {
|
||||
return controls.globalTextColor
|
||||
}
|
||||
// Used to retrieve the current color to use in the color picker dialog
|
||||
fun getButtonTextColor() = editInfo.editButton.config.textColor
|
||||
fun getButtonBackgroundColor() = editInfo.editButton.config.backgroundColor
|
||||
|
||||
fun getBackGroundColor() : Int {
|
||||
return controls.globalBackgroundColor
|
||||
}
|
||||
|
||||
fun setTextColor(color : Int) {
|
||||
for (button in controls.allButtons) {
|
||||
button.config.textColor = color
|
||||
}
|
||||
fun setButtonTextColor(color : Int) {
|
||||
editInfo.editButton.config.textColor = color
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun setBackGroundColor(color : Int) {
|
||||
for (button in controls.allButtons) {
|
||||
button.config.backgroundColor = color
|
||||
}
|
||||
fun setButtonBackgroundColor(color : Int) {
|
||||
editInfo.editButton.config.backgroundColor = color
|
||||
invalidate()
|
||||
}
|
||||
|
||||
@ -411,15 +403,15 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
||||
}
|
||||
|
||||
override var textColor : Int
|
||||
get() = controls.globalTextColor
|
||||
get() = controls.allButtons.first().config.textColor
|
||||
set(value) {
|
||||
setTextColor(value)
|
||||
controls.allButtons.forEach { it.config.textColor = value }
|
||||
}
|
||||
|
||||
override var backgroundColor : Int
|
||||
get() = controls.globalBackgroundColor
|
||||
get() = controls.allButtons.first().config.backgroundColor
|
||||
set(value) {
|
||||
setBackGroundColor(value)
|
||||
controls.allButtons.forEach { it.config.backgroundColor = value }
|
||||
}
|
||||
|
||||
override var scale : Float
|
||||
|
@ -38,15 +38,15 @@ class OnScreenEditActivity : AppCompatActivity() {
|
||||
private fun paletteAction() {
|
||||
DoubleColorPicker(this@OnScreenEditActivity).apply {
|
||||
setTitle(this@OnScreenEditActivity.getString(R.string.osc_background_color))
|
||||
setDefaultColorButton(binding.onScreenControllerView.getBackGroundColor())
|
||||
setDefaultColorButton(binding.onScreenControllerView.getButtonBackgroundColor())
|
||||
setRoundColorButton(true)
|
||||
setColors(*SwitchColors.colors.toIntArray())
|
||||
setDefaultDoubleColorButton(binding.onScreenControllerView.getTextColor())
|
||||
setDefaultDoubleColorButton(binding.onScreenControllerView.getButtonTextColor())
|
||||
setSecondTitle(this@OnScreenEditActivity.getString(R.string.osc_text_color))
|
||||
setOnChooseDoubleColorListener(object : OnChooseDoubleColorListener {
|
||||
override fun onChooseColor(position : Int, color : Int, position2 : Int, color2 : Int) {
|
||||
binding.onScreenControllerView.setBackGroundColor(SwitchColors.colors[position])
|
||||
binding.onScreenControllerView.setTextColor(SwitchColors.colors[position2])
|
||||
binding.onScreenControllerView.setButtonBackgroundColor(SwitchColors.colors[position])
|
||||
binding.onScreenControllerView.setButtonTextColor(SwitchColors.colors[position2])
|
||||
}
|
||||
|
||||
override fun onCancel() {}
|
||||
|
@ -240,16 +240,4 @@ class Controls(onScreenControllerView : OnScreenControllerView) {
|
||||
val triggerButtons = listOf(buttonZL, buttonZR)
|
||||
|
||||
val allButtons = circularButtons + joysticks + rectangularButtons + triggerButtons
|
||||
|
||||
/**
|
||||
* We can take any of the global text color variables from the buttons
|
||||
*/
|
||||
val globalTextColor
|
||||
get() = circularButtons.first().config.textColor
|
||||
|
||||
/**
|
||||
* We can take any of the global background color variables from the buttons
|
||||
*/
|
||||
val globalBackgroundColor
|
||||
get() = circularButtons.first().config.backgroundColor
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user