diff --git a/app/src/main/java/emu/skyline/input/onscreen/OnScreenButton.kt b/app/src/main/java/emu/skyline/input/onscreen/OnScreenButton.kt index a00b1d08..763e7b40 100644 --- a/app/src/main/java/emu/skyline/input/onscreen/OnScreenButton.kt +++ b/app/src/main/java/emu/skyline/input/onscreen/OnScreenButton.kt @@ -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 diff --git a/app/src/main/java/emu/skyline/input/onscreen/OnScreenControllerView.kt b/app/src/main/java/emu/skyline/input/onscreen/OnScreenControllerView.kt index 59214c6f..6c4eb9bb 100644 --- a/app/src/main/java/emu/skyline/input/onscreen/OnScreenControllerView.kt +++ b/app/src/main/java/emu/skyline/input/onscreen/OnScreenControllerView.kt @@ -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 diff --git a/app/src/main/java/emu/skyline/input/onscreen/OnScreenEditActivity.kt b/app/src/main/java/emu/skyline/input/onscreen/OnScreenEditActivity.kt index ab3fd863..79043a05 100644 --- a/app/src/main/java/emu/skyline/input/onscreen/OnScreenEditActivity.kt +++ b/app/src/main/java/emu/skyline/input/onscreen/OnScreenEditActivity.kt @@ -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() {} diff --git a/app/src/main/java/emu/skyline/input/onscreen/OnScreenItemDefinitions.kt b/app/src/main/java/emu/skyline/input/onscreen/OnScreenItemDefinitions.kt index 7514abd3..175e73ce 100644 --- a/app/src/main/java/emu/skyline/input/onscreen/OnScreenItemDefinitions.kt +++ b/app/src/main/java/emu/skyline/input/onscreen/OnScreenItemDefinitions.kt @@ -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 }