Skip to content

Commit

Permalink
XCode15: Adjust SourceView Location on UIAlertController
Browse files Browse the repository at this point in the history
  • Loading branch information
SeiRyu committed Jul 1, 2023
1 parent c6f49d7 commit 2c13463
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Cores/Mini_vMac/PVMiniVMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Update Repository\nif [ \"${TARGET_DEVICE_PLATFORM_NAME}\" = \"iphonesimulator\" ] ; then\n exit 0\nfi\nif [[ \"${CODE_SIGNING_ALLOWED}\" = \"NO\" && ! -f \"${SRCROOT}/../../CodeSigning.xcconfig\" ]]; then\n exit 0\nfi\n\n# Create buildTV Environment\nif [ ! -d \"${SRCROOT}/cmake/buildTV\" ]; then\n mkdir \"${SRCROOT}/cmake/buildTV\"\nfi\n\ncd \"${SRCROOT}\"\nexport LATEST=`git submodule status libretro-minivmac | head -n1 | awk '{print $1;}'`TVBuild2\nif [ ! -f \"${SRCROOT}/cmake/${LATEST}\" ]; then\n rm -fr \"${SRCROOT}/cmake/buildTV/\"*\n touch \"${SRCROOT}/cmake/${LATEST}\"\n cp -pR \"${SRCROOT}/libretro-minivmac/\"* \"${SRCROOT}/cmake/buildTV/\"\n cp \"${SRCROOT}/cmake/Makefile.TV\" \"${SRCROOT}/cmake/buildTV/Makefile\"\nfi\n\n# buildTV\ncd \"${SRCROOT}/cmake/buildTV/\"\n#make clean\nmake -j5\ncp minivmac_libretro_tvos.dylib \"${SRCROOT}/../../CoresRetro/RetroArch/modules/minivmac_libretro_tvos.dylib\"\n";
shellScript = "# Update Repository\nif [ \"${TARGET_DEVICE_PLATFORM_NAME}\" = \"appletvsimulator\" ] ; then\n exit 0\nfi\nif [[ \"${CODE_SIGNING_ALLOWED}\" = \"NO\" && ! -f \"${SRCROOT}/../../CodeSigning.xcconfig\" ]]; then\n exit 0\nfi\n\n# Create buildTV Environment\nif [ ! -d \"${SRCROOT}/cmake/buildTV\" ]; then\n mkdir \"${SRCROOT}/cmake/buildTV\"\nfi\n\ncd \"${SRCROOT}\"\nexport LATEST=`git submodule status libretro-minivmac | head -n1 | awk '{print $1;}'`TVBuild2\nif [ ! -f \"${SRCROOT}/cmake/${LATEST}\" ]; then\n rm -fr \"${SRCROOT}/cmake/buildTV/\"*\n touch \"${SRCROOT}/cmake/${LATEST}\"\n cp -pR \"${SRCROOT}/libretro-minivmac/\"* \"${SRCROOT}/cmake/buildTV/\"\n cp \"${SRCROOT}/cmake/Makefile.TV\" \"${SRCROOT}/cmake/buildTV/Makefile\"\nfi\n\n# buildTV\ncd \"${SRCROOT}/cmake/buildTV/\"\n#make clean\nmake -j5\ncp minivmac_libretro_tvos.dylib \"${SRCROOT}/../../CoresRetro/RetroArch/modules/minivmac_libretro_tvos.dylib\"\n";
};
9396AEF62973074100B1EA1C /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
20 changes: 2 additions & 18 deletions Provenance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,6 @@
B3F7E5A7297736C200362B92 /* PVYabause.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B3FF641C2873EAEB00829C14 /* PVYabause.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
B3F7E5A9297736C200362B92 /* Spotlight.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = B3E21D6B203211BE009939D3 /* Spotlight.appex */; platformFilters = (ios, tvos, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
B3F94A4C27093794002A71EF /* PVAppDelegate+AppCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B357A43B2709228E002C7C0F /* PVAppDelegate+AppCenter.swift */; };
B3F94A4E27093ABC002A71EF /* AppCenterAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = B3F94A4D27093ABC002A71EF /* AppCenterAnalytics */; };
B3F94A5027093ABC002A71EF /* AppCenterCrashes in Frameworks */ = {isa = PBXBuildFile; productRef = B3F94A4F27093ABC002A71EF /* AppCenterCrashes */; };
B3FAC921292B44F3005E8B11 /* PVAtari800.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B354693B1DECDA710018B6F3 /* PVAtari800.framework */; };
B3FAC922292B44F4005E8B11 /* PVAtari800.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B354693B1DECDA710018B6F3 /* PVAtari800.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
B3FAC929292B4505005E8B11 /* PVFCEU.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3270F8B27DCB2B200E83180 /* PVFCEU.framework */; };
Expand Down Expand Up @@ -2806,8 +2804,6 @@
B324C30A219195AE009F4EDC /* AudioToolbox.framework in Frameworks */,
B324C64F219216DD009F4EDC /* PVLibrary.framework in Frameworks */,
B3AF701C21916E38000FA7F9 /* PVSupport.framework in Frameworks */,
B3F94A5027093ABC002A71EF /* AppCenterCrashes in Frameworks */,
B3F94A4E27093ABC002A71EF /* AppCenterAnalytics in Frameworks */,
B324C308219195A8009F4EDC /* GLKit.framework in Frameworks */,
B3FAC992292B4767005E8B11 /* PVGBA.framework in Frameworks */,
B3AEDE2B293F34CA0050BDB6 /* PVPicoDrive.framework in Frameworks */,
Expand Down Expand Up @@ -4620,11 +4616,11 @@
buildConfigurationList = 1AD481C81BA350A500FDA50A /* Build configuration list for PBXNativeTarget "ProvenanceTV" */;
buildPhases = (
1AD481B01BA350A400FDA50A /* Sources */,
1AACCAE61BB60DB500DC21AE /* Embed Frameworks */,
B39DC780279E79D40017E28D /* Embed App Extensions */,
1AD481B11BA350A400FDA50A /* Frameworks */,
1AD481B21BA350A400FDA50A /* Resources */,
1A44C0AE1D0A1E730018751A /* Script: Set Build Number */,
1AACCAE61BB60DB500DC21AE /* Embed Frameworks */,
B39DC780279E79D40017E28D /* Embed App Extensions */,
);
buildRules = (
);
Expand All @@ -4637,8 +4633,6 @@
name = ProvenanceTV;
packageProductDependencies = (
B3D30FC026F0BCE60064603F /* SteamController */,
B3F94A4D27093ABC002A71EF /* AppCenterAnalytics */,
B3F94A4F27093ABC002A71EF /* AppCenterCrashes */,
B3CE94B6293446AC0053B891 /* Introspect */,
B3AFCF992977A81F00A01010 /* PVLogging */,
B3E88CBD2977AB7C00C90E86 /* Reachability */,
Expand Down Expand Up @@ -10994,16 +10988,6 @@
package = B3F7E431297736C200362B92 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
productName = Introspect;
};
B3F94A4D27093ABC002A71EF /* AppCenterAnalytics */ = {
isa = XCSwiftPackageProductDependency;
package = B357A43627092253002C7C0F /* XCRemoteSwiftPackageReference "appcenter-sdk-apple" */;
productName = AppCenterAnalytics;
};
B3F94A4F27093ABC002A71EF /* AppCenterCrashes */ = {
isa = XCSwiftPackageProductDependency;
package = B357A43627092253002C7C0F /* XCRemoteSwiftPackageReference "appcenter-sdk-apple" */;
productName = AppCenterCrashes;
};
B3FB9678276DD7F600F7EDEE /* SteamController */ = {
isa = XCSwiftPackageProductDependency;
package = B3D30FBD26F0B4CD0064603F /* XCRemoteSwiftPackageReference "SteamController" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"repositoryURL": "https://github.com/siteline/SwiftUI-Introspect",
"state": {
"branch": "master",
"revision": "d3cbf32788250741d397cfb5bcd532c37aa1096d",
"revision": "8bf15ad33a529359200bd419a72ca2dda841089b",
"version": null
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ extension PVEmulatorViewController {
if let menuButton = menuButton {
actionSheet.popoverPresentationController?.sourceView = menuButton
actionSheet.popoverPresentationController?.sourceRect = menuButton.bounds
} else {
return
}
}
#if targetEnvironment(macCatalyst) || os(macOS)
if let menuButton = menuButton, sender === menuButton {
actionSheet.popoverPresentationController?.sourceView = menuButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ final class PVCheatsViewController: UITableViewController {

let alert = UIAlertController(title: "Delete this Cheat Code?", message: nil, preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.sourceView = self.view
alert.popoverPresentationController?.sourceRect = UIScreen.main.bounds
alert.popoverPresentationController?.sourceView = tableView?.cellForRow(at: indexPath)?.contentView
alert.popoverPresentationController?.sourceRect = tableView?.cellForRow(at: indexPath)?.contentView.bounds ?? UIScreen.main.bounds
alert.addAction(UIAlertAction(title: "Yes", style: .destructive) { [unowned self] _ in
do {
try PVCheats.delete(saveState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
}))

let webServerAction = UIAlertAction(title: "Web Server", style: .default, handler: { _ in
self.startWebServer()
self.startWebServer(sender: sender as? UIView)
})

actionSheet.addAction(webServerAction)
Expand Down Expand Up @@ -853,23 +853,27 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
WLOG("No WiFi. Cannot start web server.")
present(alert, animated: true) { () -> Void in }
} else {
startWebServer()
startWebServer(sender: sender as? UIView)
}
#endif
}

func startWebServer() {
func startWebServer(sender: UIView?) {
// start web transfer service
if PVWebServer.shared.startServers() {
// show alert view
showServerActiveAlert()
showServerActiveAlert(sender: self.collectionView, barButtonItem: navigationItem.rightBarButtonItem)
} else {
#if targetEnvironment(simulator) || targetEnvironment(macCatalyst) || os(macOS)
let message = "Check your network connection or settings and free up ports: 8080, 8081."
#else
let message = "Check your network connection or settings and free up ports: 80, 81."
#endif
let alert = UIAlertController(title: "Unable to start web server!", message: message, preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
alert.popoverPresentationController?.sourceView = self.collectionView
alert.popoverPresentationController?.sourceRect = self.collectionView?.bounds ?? UIScreen.main.bounds
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_: UIAlertAction) -> Void in
}))
present(alert, animated: true) { () -> Void in }
Expand Down Expand Up @@ -908,6 +912,10 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg

fileprivate func showConflictsAlert() {
let alert = UIAlertController(title: "Oops!", message: "There was a conflict while importing your game.", preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.barButtonItem = navigationItem.leftBarButtonItem
alert.popoverPresentationController?.sourceView = self.collectionView
alert.popoverPresentationController?.sourceRect = self.collectionView?.bounds ?? UIScreen.main.bounds
alert.addAction(UIAlertAction(title: "Let's go fix it!", style: .default, handler: { [unowned self] (_: UIAlertAction) -> Void in
self.displayConflictVC()
}))
Expand Down Expand Up @@ -1032,6 +1040,9 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
actionSheet.addAction(UIAlertAction(title: "Reset default core selection (\(coreName))", symbol:"bolt.circle", style: .default, handler: { [unowned self] _ in

let resetAlert = UIAlertController(title: "Reset core?", message: "Are you sure you want to reset \(game.title) to no longer default to use \(coreName)?", preferredStyle: .alert)
resetAlert.preferredContentSize = CGSize(width: 300, height: 150)
resetAlert.popoverPresentationController?.sourceView = sender
resetAlert.popoverPresentationController?.sourceRect = sender.bounds ?? UIScreen.main.bounds
resetAlert.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel"), style: .cancel, handler: nil))
resetAlert.addAction(UIAlertAction(title: "Yes", style: .destructive, handler: { _ in
try! RomDatabase.sharedInstance.writeTransaction {
Expand Down Expand Up @@ -1076,14 +1087,17 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
}))

actionSheet.addAction(UIAlertAction(title: "Rename", symbol: "rectangle.and.pencil.and.ellipsis", style: .default, handler: { (_: UIAlertAction) -> Void in
self.renameGame(game)
self.renameGame(game, sender: sender)
}))
#if os(iOS)

actionSheet.addAction(UIAlertAction(title: "Copy MD5 URL", symbol: "arrow.up.doc", style: .default, handler: { (_: UIAlertAction) -> Void in
let md5URL = "provenance://open?md5=\(game.md5Hash)"
UIPasteboard.general.string = md5URL
let alert = UIAlertController(title: nil, message: "URL copied to clipboard.", preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.sourceView = sender
alert.popoverPresentationController?.sourceRect = sender.bounds ?? UIScreen.main.bounds
self.present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
alert.dismiss(animated: true, completion: nil)
Expand Down Expand Up @@ -1154,6 +1168,9 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg

actionSheet.addAction(UIAlertAction(title: "Delete", symbol:"trash", style: .destructive, handler: { (_: UIAlertAction) -> Void in
let alert = UIAlertController(title: "Delete \(game.title)", message: "Any save states and battery saves will also be deleted, are you sure?", preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.sourceView = sender
alert.popoverPresentationController?.sourceRect = sender.bounds
alert.addAction(UIAlertAction(title: "Yes", style: .destructive, handler: { (_: UIAlertAction) -> Void in
// Delete from Realm
do {
Expand Down Expand Up @@ -1207,8 +1224,11 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
#endif
}

func renameGame(_ game: PVGame) {
func renameGame(_ game: PVGame, sender: UIView) {
let alert = UIAlertController(title: "Rename", message: "Enter a new name for \(game.title):", preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.sourceView = sender
alert.popoverPresentationController?.sourceRect = sender.bounds ?? UIScreen.main.bounds
alert.addTextField(configurationHandler: { (_ textField: UITextField) -> Void in
textField.placeholder = game.title
textField.text = game.title
Expand Down Expand Up @@ -1749,7 +1769,7 @@ extension PVGameLibraryViewController {
guard let focusedGame = focusedGame else {
return
}
renameGame(focusedGame)
renameGame(focusedGame, sender: self.collectionView!)
}

@objc
Expand Down Expand Up @@ -1807,6 +1827,9 @@ extension PVGameLibraryViewController {
extension PVGameLibraryViewController: GameLibraryCollectionViewDelegate {
func promptToDeleteGame(_ game: PVGame, completion: ((Bool) -> Void)? = nil) {
let alert = UIAlertController(title: "Delete \(game.title)", message: "Any save states and battery saves will also be deleted, are you sure?", preferredStyle: .alert)
alert.preferredContentSize = CGSize(width: 300, height: 150)
alert.popoverPresentationController?.sourceView = self.collectionView
alert.popoverPresentationController?.sourceRect = self.collectionView?.bounds ?? UIScreen.main.bounds
alert.addAction(UIAlertAction(title: "Yes", style: .destructive, handler: { (_: UIAlertAction) -> Void in
// Delete from Realm
do {
Expand Down
Loading

0 comments on commit 2c13463

Please sign in to comment.