Skip to content

Commit

Permalink
Update fast forward settings
Browse files Browse the repository at this point in the history
- iPad .actionSheet Fixes
- add 150% speed
  • Loading branch information
LitRitt committed Mar 11, 2023
1 parent 2aada21 commit 98a551e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 41 deletions.
60 changes: 34 additions & 26 deletions Delta/Emulation/GameViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,8 @@ extension GameViewController
let promptSpeedEnabled = Settings.isPromptSpeedEnabled

if promptSpeedEnabled {
if let pauseViewController = self.pauseViewController
{
pauseViewController.dismiss()
self.resumeEmulation() // Emulation pauses until input without this
if let pauseView = self.pauseViewController {
pauseView.dismiss()
}
self.promptFastForwardSpeed()
} else {
Expand All @@ -1145,39 +1143,49 @@ extension GameViewController

func promptFastForwardSpeed()
{
guard let emulatorCore = self.emulatorCore else { return }

let alertController = UIAlertController(title: NSLocalizedString("Change Fast Forward Speed", comment: ""), message: NSLocalizedString("Speeds above 100% will speed up gameplay, and are useful for saving time in cutscenes and dialogue.\n\nSpeeds below 100% will slow down gameplay, and are useful for precisely timing inputs.", comment: ""), preferredStyle: .actionSheet)
let alertController = UIAlertController(title: NSLocalizedString("Change Fast Forward Speed", comment: ""), message: NSLocalizedString("Speeds above 100% will speed up gameplay. Speeds below 100% will slow down gameplay.", comment: ""), preferredStyle: .actionSheet)
alertController.popoverPresentationController?.sourceView = self.view
alertController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
alertController.popoverPresentationController?.permittedArrowDirections = []

alertController.addAction(UIAlertAction(title: "🐢 25%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 0.25
emulatorCore.rate = 0.25
alertController.addAction(UIAlertAction(title: "25%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 0.25)
}))
alertController.addAction(UIAlertAction(title: "🍯 50%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 0.5
emulatorCore.rate = 0.5
alertController.addAction(UIAlertAction(title: "50%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 0.5)
}))
alertController.addAction(UIAlertAction(title: "🏃🏽 200%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 2.0
emulatorCore.rate = 2.0
alertController.addAction(UIAlertAction(title: "150%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 1.5)
}))
alertController.addAction(UIAlertAction(title: "200%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 2.0)
}))
if Settings.isUnsafeFastForwardSpeedsEnabled {
alertController.addAction(UIAlertAction(title: "🐇 400%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 4.0
emulatorCore.rate = 4.0
alertController.addAction(UIAlertAction(title: "400%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 4.0)
}))
alertController.addAction(UIAlertAction(title: "🏎️ 800%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 8.0
emulatorCore.rate = 8.0
alertController.addAction(UIAlertAction(title: "800%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 8.0)
}))
alertController.addAction(UIAlertAction(title: "⚡️ 1600%", style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 16.0
emulatorCore.rate = 16.0
alertController.addAction(UIAlertAction(title: "1600%", style: .default, handler: { (action) in
self.setFastForwardSpeed(speed: 16.0)
}))
}
alertController.addAction(.cancel)
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
self.setFastForwardSpeed()
}))
self.present(alertController, animated: true, completion: nil)
}

func setFastForwardSpeed(speed: Double = 0) {
if speed != 0 {
guard let emulatorCore = self.emulatorCore else { return }

Settings.customFastForwardSpeed = speed
emulatorCore.rate = speed
}
self.resumeEmulation()
}
}

//MARK: - GameViewControllerDelegate -
Expand Down
5 changes: 4 additions & 1 deletion Delta/Settings/Cores/MelonDSCoreSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ private extension MelonDSCoreSettingsViewController

func changeCore()
{
let alertController = UIAlertController(title: NSLocalizedString("Change Emulator Core", comment: ""), message: NSLocalizedString("Save states are not compatible between different emulator cores. Make sure to use in-game saves in order to keep using your save data.\n\nYour existing save states will not be deleted and will be available whenever you switch cores again.", comment: ""), preferredStyle: .alert)
let alertController = UIAlertController(title: NSLocalizedString("Change Emulator Core", comment: ""), message: NSLocalizedString("Save states are not compatible between different emulator cores. Make sure to use in-game saves in order to keep using your save data.\n\nYour existing save states will not be deleted and will be available whenever you switch cores again.", comment: ""), preferredStyle: .actionSheet)
alertController.popoverPresentationController?.sourceView = self.view
alertController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
alertController.popoverPresentationController?.permittedArrowDirections = []

var desmumeActionTitle = DS.core.metadata?.name.value ?? DS.core.name
var melonDSActionTitle = MelonDS.core.metadata?.name.value ?? MelonDS.core.name
Expand Down
36 changes: 22 additions & 14 deletions Delta/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,23 +409,28 @@ private extension SettingsViewController

func changeCustomFastForwardSpeed()
{
let alertController = UIAlertController(title: NSLocalizedString("Change Fast Forward Speed", comment: ""), message: NSLocalizedString("Speeds above 100% will speed up gameplay, and are useful for saving time in cutscenes and dialogue.\n\nSpeeds below 100% will slow down gameplay, and are useful for precisely timing inputs.", comment: ""), preferredStyle: .alert)
let alertController = UIAlertController(title: NSLocalizedString("Change Fast Forward Speed", comment: ""), message: NSLocalizedString("Speeds above 100% will speed up gameplay. Speeds below 100% will slow down gameplay.", comment: ""), preferredStyle: .actionSheet)
alertController.popoverPresentationController?.sourceView = self.view
alertController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
alertController.popoverPresentationController?.permittedArrowDirections = []

var speedOneTitle = "🐢 25%"
var speedTwoTitle = "🍯 50%"
var speedThreeTitle = "🏃🏽 200%"
var speedFourTitle = "🐇 400%"
var speedFiveTitle = "🏎️ 800%"
var speedSixTitle = "⚡️ 1600%"
var speedOneTitle = "25%"
var speedTwoTitle = "50%"
var speedThreeTitle = "150%"
var speedFourTitle = "200%"
var speedFiveTitle = "400%"
var speedSixTitle = "800%"
var speedSevenTitle = "1600%"

switch Settings.customFastForwardSpeed
{
case 0.25: speedOneTitle += ""
case 0.5: speedTwoTitle += ""
case 2.0: speedThreeTitle += ""
case 4.0: speedFourTitle += ""
case 8.0: speedFiveTitle += ""
case 16.0: speedSixTitle += ""
case 1.5: speedThreeTitle += ""
case 2.0: speedFourTitle += ""
case 4.0: speedFiveTitle += ""
case 8.0: speedSixTitle += ""
case 16.0: speedSevenTitle += ""
default: break
}

Expand All @@ -436,16 +441,19 @@ private extension SettingsViewController
Settings.customFastForwardSpeed = 0.5
}))
alertController.addAction(UIAlertAction(title: speedThreeTitle, style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 1.5
}))
alertController.addAction(UIAlertAction(title: speedFourTitle, style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 2.0
}))
if Settings.isUnsafeFastForwardSpeedsEnabled {
alertController.addAction(UIAlertAction(title: speedFourTitle, style: .default, handler: { (action) in
alertController.addAction(UIAlertAction(title: speedFiveTitle, style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 4.0
}))
alertController.addAction(UIAlertAction(title: speedFiveTitle, style: .default, handler: { (action) in
alertController.addAction(UIAlertAction(title: speedSixTitle, style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 8.0
}))
alertController.addAction(UIAlertAction(title: speedSixTitle, style: .default, handler: { (action) in
alertController.addAction(UIAlertAction(title: speedSevenTitle, style: .default, handler: { (action) in
Settings.customFastForwardSpeed = 16.0
}))
}
Expand Down

0 comments on commit 98a551e

Please sign in to comment.