-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Noifications implementation * App delegate creation * Add Credits file (shows in about page) * Logical improvements * Add support for force quitting all games upon app termination
- Loading branch information
1 parent
8f1d66e
commit 4d1a571
Showing
20 changed files
with
201 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// AppDelegate.swift | ||
// Mythic | ||
// | ||
// Created by Esiayo Alegbe on 25/2/2024. | ||
// | ||
|
||
import SwiftUI | ||
import Sparkle | ||
import UserNotifications | ||
import OSLog | ||
|
||
class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate { | ||
var updaterController: SPUStandardUpdaterController? | ||
var networkMonitor: NetworkMonitor? | ||
|
||
func applicationDidFinishLaunching(_ notification: Notification) { | ||
#if !DEBUG // TODO: possibly turn this into an onboarding-style message. | ||
let appURL = Bundle.main.bundleURL | ||
|
||
// MARK: Move to Applications | ||
if !appURL.pathComponents.contains("Applications") { | ||
let alert = NSAlert() | ||
alert.messageText = "Move Mythic to the Applications folder?" | ||
alert.informativeText = """ | ||
Mythic has detected it's running outside of the applications folder. | ||
""" | ||
alert.addButton(withTitle: "Move") | ||
alert.addButton(withTitle: "Cancel") | ||
|
||
if alert.runModal() == .alertFirstButtonReturn, let globalApps = FileLocations.globalApplications { | ||
do { | ||
_ = try files.replaceItemAt(appURL, withItemAt: globalApps) | ||
workspace.open(globalApps.appending(path: "Mythic.app") | ||
) | ||
} catch { | ||
Logger.file.error("Unable to move Mythic to Applications: \(error)") | ||
} | ||
} | ||
} | ||
#endif | ||
|
||
notifications.delegate = self | ||
notifications.getNotificationSettings { settings in | ||
guard settings.authorizationStatus != .authorized else { return } | ||
|
||
notifications.requestAuthorization(options: [.alert, .sound, .badge]) { _, error in | ||
guard error == nil else { | ||
Logger.app.error("Unable to request notification authorization: \(error!.localizedDescription)") | ||
return | ||
} | ||
} | ||
} | ||
} | ||
|
||
func applicationWillTerminate(_ notification: Notification) { | ||
if defaults.bool(forKey: "quitOnAppClose") { _ = Wine.killAll() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf2759 | ||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} | ||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;} | ||
{\*\expandedcolortbl;;\cssrgb\c0\c1\c1;\cssrgb\c100000\c100000\c99985\c0;} | ||
\paperw12240\paperh15840\margl1440\margr1440\vieww9000\viewh8400\viewkind0 | ||
\deftab720 | ||
\pard\pardeftab720\sa320\partightenfactor0 | ||
|
||
\f0\fs32 \cf2 \cb3 \expnd0\expndtw0\kerning0 | ||
Copyright \'a9 2024 blackxfiied, Jecta\ | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\ | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\ | ||
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.