mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 17:15:29 +03:00
Improve separation between OSCEditActivity
and OSCView
The activity shouldn't access the edit button directly, but should only access data available through the public interface.
This commit is contained in:
parent
7e3d3bd281
commit
69fb15ffc9
@ -72,7 +72,6 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal val editInfo = OnScreenEditInfo()
|
internal val editInfo = OnScreenEditInfo()
|
||||||
val editButton get() = editInfo.editButton
|
|
||||||
fun setOnEditButtonChangedListener(listener : OnEditButtonChangedListener?) {
|
fun setOnEditButtonChangedListener(listener : OnEditButtonChangedListener?) {
|
||||||
editInfo.onEditButtonChangedListener = listener
|
editInfo.onEditButtonChangedListener = listener
|
||||||
}
|
}
|
||||||
@ -296,6 +295,10 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
setOnTouchListener(playingTouchHandler)
|
setOnTouchListener(playingTouchHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateEditButtonInfo() {
|
||||||
|
editInfo.onEditButtonChangedListener?.invoke(editInfo.editButton)
|
||||||
|
}
|
||||||
|
|
||||||
fun setEditMode(isEdit : Boolean) {
|
fun setEditMode(isEdit : Boolean) {
|
||||||
// Select all buttons when entering edit if we weren't already editing
|
// Select all buttons when entering edit if we weren't already editing
|
||||||
if (!editInfo.isEditing)
|
if (!editInfo.isEditing)
|
||||||
|
@ -35,6 +35,8 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var appSettings : AppSettings
|
lateinit var appSettings : AppSettings
|
||||||
|
|
||||||
|
private var currentButtonName = ""
|
||||||
|
|
||||||
private fun paletteAction() {
|
private fun paletteAction() {
|
||||||
DoubleColorPicker(this@OnScreenEditActivity).apply {
|
DoubleColorPicker(this@OnScreenEditActivity).apply {
|
||||||
setTitle(this@OnScreenEditActivity.getString(R.string.osc_background_color))
|
setTitle(this@OnScreenEditActivity.getString(R.string.osc_background_color))
|
||||||
@ -66,7 +68,7 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun resetAction() {
|
private fun resetAction() {
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(getString(R.string.osc_reset, binding.onScreenControllerView.editButton.buttonId.short))
|
.setTitle(getString(R.string.osc_reset, currentButtonName))
|
||||||
.setMessage(R.string.osc_reset_confirm)
|
.setMessage(R.string.osc_reset_confirm)
|
||||||
.setPositiveButton(R.string.confirm) { _, _ -> binding.onScreenControllerView.resetButton() }
|
.setPositiveButton(R.string.confirm) { _, _ -> binding.onScreenControllerView.resetButton() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
@ -140,7 +142,7 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
updateActiveButtonDisplayInfo(binding.onScreenControllerView.editButton)
|
binding.onScreenControllerView.updateEditButtonInfo()
|
||||||
fullScreen()
|
fullScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +185,8 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
*/
|
*/
|
||||||
private fun updateActiveButtonDisplayInfo(button : ConfigurableButton) {
|
private fun updateActiveButtonDisplayInfo(button : ConfigurableButton) {
|
||||||
binding.enabledCheckbox.checkedState = button.config.groupEnabled
|
binding.enabledCheckbox.checkedState = button.config.groupEnabled
|
||||||
binding.currentButton.text = getString(R.string.osc_current_button, button.buttonId.short)
|
currentButtonName = button.buttonId.short ?: ""
|
||||||
|
binding.currentButton.text = getString(R.string.osc_current_button, currentButtonName)
|
||||||
binding.scaleSlider.slider.value = (button.config.scale - OnScreenConfiguration.MinScale) / (OnScreenConfiguration.MaxScale - OnScreenConfiguration.MinScale) * 100f
|
binding.scaleSlider.slider.value = (button.config.scale - OnScreenConfiguration.MinScale) / (OnScreenConfiguration.MaxScale - OnScreenConfiguration.MinScale) * 100f
|
||||||
binding.opacitySlider.slider.value = (button.config.alpha - OnScreenConfiguration.MinAlpha) / (OnScreenConfiguration.MaxAlpha - OnScreenConfiguration.MinAlpha).toFloat() * 100f
|
binding.opacitySlider.slider.value = (button.config.alpha - OnScreenConfiguration.MinAlpha) / (OnScreenConfiguration.MaxAlpha - OnScreenConfiguration.MinAlpha).toFloat() * 100f
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user