Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove keymap checks #517

Merged
merged 7 commits into from Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 32 additions & 7 deletions PlayCover/Model/Keymapping.swift
Expand Up @@ -157,21 +157,27 @@ class Keymapping {
self.keymap = importedKeymap
success(true)
} else {
Log.shared.error("Keymapping created for different app!")
success(false)
if self.differentBundleIdKeymapAlert() {
self.keymap = importedKeymap
success(true)
} else {
success(false)
}
}
}
} catch {
if let selectedPath = openPanel.url {
if let keymap = LegacySettings.convertLegacyKeymapFile(selectedPath) {
if keymap.bundleIdentifier == self.keymap.bundleIdentifier {
self.keymap = keymap
success(true)
} else {
Log.shared.error("Keymapping created for different app! " +
"Legacy keymap files must be named after " +
"the Bundle ID of the intended application!")
success(false)
} else {
if self.differentBundleIdKeymapAlert() {
self.keymap = keymap
success(true)
} else {
success(false)
}
}
} else {
success(false)
Expand Down Expand Up @@ -210,4 +216,23 @@ class Keymapping {
}
}
}

private func differentBundleIdKeymapAlert() -> Bool {
let alert = NSAlert()
alert.messageText = NSLocalizedString("alert.differentBundleIdKeymap.message", comment: "")
alert.informativeText = NSLocalizedString("alert.differentBundleIdKeymap.text", comment: "")
alert.alertStyle = .warning
alert.addButton(withTitle: NSLocalizedString("button.Proceed", comment: ""))
alert.addButton(withTitle: NSLocalizedString("button.Cancel", comment: ""))

let result = alert.runModal()
switch result {
case .alertFirstButtonReturn:
return true
case .alertSecondButtonReturn:
return false
default:
return false
}
}
}
2 changes: 2 additions & 0 deletions PlayCover/en.lproj/Localizable.strings
Expand Up @@ -97,6 +97,8 @@
"alert.install.injectPlayToolsQuestion" = "Do you want to inject PlayTools into this application?";
"alert.install.playToolsInformative" = "PlayTools is a tool that allows you to bind keys to screen touches, custom display resolutions, and more, but it may break certain apps";
"alert.supression" = "You can change this in the PlayCover preferences";
"alert.differentBundleIdKeymap.message" = "The keymap may have been created for another application.";
"alert.differentBundleIdKeymap.text" = "Are you sure you want to import this keymap?";
"alert.power.title" = "Low Power Mode Enabled!";
"alert.power.subtitle" = "Some apps will not work with Low Power Mode enabled. It is recommended to disable it.";

Expand Down