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 2 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
28 changes: 22 additions & 6 deletions PlayCover/Model/Keymapping.swift
Expand Up @@ -117,8 +117,17 @@ class Keymapping {
self.keymap = importedKeymap
success(true)
} else {
Log.shared.error("Keymapping created for different app!")
success(false)
NSAlert.differentBundleIdKeymap { result in
switch result {
case .alertFirstButtonReturn:
self.keymap = importedKeymap
success(true)
case .alertSecondButtonReturn:
success(false)
default:
success(false)
}
}
}
}
} catch {
Expand All @@ -128,10 +137,17 @@ class Keymapping {
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)
NSAlert.differentBundleIdKeymap { result in
switch result {
case .alertFirstButtonReturn:
self.keymap = keymap
success(true)
case .alertSecondButtonReturn:
success(false)
default:
success(false)
}
}
}
} else {
success(false)
Expand Down
22 changes: 22 additions & 0 deletions PlayCover/Utils/AlertExtensions.swift
@@ -0,0 +1,22 @@
//
// AlertExtensions.swift
// PlayCover
//
// Created by Nick on 2022-11-16.
//

import AppKit

extension NSAlert {
static func differentBundleIdKeymap(response: (NSApplication.ModalResponse) -> Void) {
ZhichGaming marked this conversation as resolved.
Show resolved Hide resolved
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()
response(result)
}
}
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 name of the keymap is different from the bundle ID of the app!";
ZhichGaming marked this conversation as resolved.
Show resolved Hide resolved
"alert.differentBundleIdKeymap.text" = "The keymap may have been created for another application.";

"button.OK" = "OK";
"button.Proceed" = "Proceed";
Expand Down