android: Fixed Turbo toast appearing in situations other than toggling Turbo
+ minor code cleanup
This commit is contained in:
parent
8da60d02af
commit
414d6f5757
4 changed files with 16 additions and 10 deletions
|
|
@ -25,7 +25,7 @@ class HotkeyUtility(
|
||||||
Hotkey.CYCLE_LAYOUT.button -> screenAdjustmentUtil.cycleLayouts()
|
Hotkey.CYCLE_LAYOUT.button -> screenAdjustmentUtil.cycleLayouts()
|
||||||
Hotkey.CLOSE_GAME.button -> EmulationLifecycleUtil.closeGame()
|
Hotkey.CLOSE_GAME.button -> EmulationLifecycleUtil.closeGame()
|
||||||
Hotkey.PAUSE_OR_RESUME.button -> EmulationLifecycleUtil.pauseOrResume()
|
Hotkey.PAUSE_OR_RESUME.button -> EmulationLifecycleUtil.pauseOrResume()
|
||||||
Hotkey.TURBO_LIMIT.button -> TurboHelper.setTurboEnabled(!TurboHelper.isTurboSpeedEnabled())
|
Hotkey.TURBO_LIMIT.button -> TurboHelper.toggleTurbo(true)
|
||||||
Hotkey.QUICKSAVE.button -> {
|
Hotkey.QUICKSAVE.button -> {
|
||||||
NativeLibrary.saveState(NativeLibrary.QUICKSAVE_SLOT)
|
NativeLibrary.saveState(NativeLibrary.QUICKSAVE_SLOT)
|
||||||
Toast.makeText(context,
|
Toast.makeText(context,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class SettingsActivityPresenter(private val activityView: SettingsActivityView)
|
||||||
//added to ensure that layout changes take effect as soon as settings window closes
|
//added to ensure that layout changes take effect as soon as settings window closes
|
||||||
NativeLibrary.reloadSettings()
|
NativeLibrary.reloadSettings()
|
||||||
NativeLibrary.updateFramebuffer(NativeLibrary.isPortraitMode)
|
NativeLibrary.updateFramebuffer(NativeLibrary.isPortraitMode)
|
||||||
TurboHelper.reloadTurbo() // TODO: Can this go someone else? -OS
|
TurboHelper.reloadTurbo(false) // TODO: Can this go somewhere else? -OS
|
||||||
}
|
}
|
||||||
NativeLibrary.reloadSettings()
|
NativeLibrary.reloadSettings()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button.id == NativeLibrary.ButtonType.BUTTON_TURBO && button.status == NativeLibrary.ButtonState.PRESSED) {
|
if (button.id == NativeLibrary.ButtonType.BUTTON_TURBO && button.status == NativeLibrary.ButtonState.PRESSED) {
|
||||||
TurboHelper.setTurboEnabled((!TurboHelper.isTurboSpeedEnabled()))
|
TurboHelper.toggleTurbo(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.id, button.status)
|
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.id, button.status)
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,7 @@ object TurboHelper {
|
||||||
return turboSpeedEnabled
|
return turboSpeedEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTurboEnabled(state: Boolean) {
|
fun reloadTurbo(showToast: Boolean) {
|
||||||
turboSpeedEnabled = state
|
|
||||||
reloadTurbo()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun reloadTurbo() {
|
|
||||||
val context = CitraApplication.appContext
|
val context = CitraApplication.appContext
|
||||||
val toastMessage: String
|
val toastMessage: String
|
||||||
|
|
||||||
|
|
@ -34,6 +29,17 @@ object TurboHelper {
|
||||||
toastMessage = context.getString(R.string.turbo_disabled_toast)
|
toastMessage = context.getString(R.string.turbo_disabled_toast)
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show()
|
if (showToast) {
|
||||||
|
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTurboEnabled(state: Boolean, showToast: Boolean) {
|
||||||
|
turboSpeedEnabled = state
|
||||||
|
reloadTurbo(showToast)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleTurbo(showToast: Boolean) {
|
||||||
|
setTurboEnabled(!TurboHelper.isTurboSpeedEnabled(), showToast)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue