Skip to content

Commit

Permalink
Merge branch 'main' into l10n_main
Browse files Browse the repository at this point in the history
  • Loading branch information
blackxfiied authored Oct 15, 2024
2 parents 8e03e56 + 6993b0f commit 4ce5942
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 41 deletions.
8 changes: 4 additions & 4 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2833;
CURRENT_PROJECT_VERSION = 2840;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand All @@ -742,7 +742,7 @@
);
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Mythic/legendary/_internal";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = "0.3.1-dirty";
MARKETING_VERSION = "0.3.2-dirty";
PRODUCT_BUNDLE_IDENTIFIER = xyz.blackxfiied.Mythic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -764,7 +764,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2833;
CURRENT_PROJECT_VERSION = 2840;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand All @@ -787,7 +787,7 @@
);
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Mythic/legendary/_internal";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.3.1;
MARKETING_VERSION = 0.3.2;
PRODUCT_BUNDLE_IDENTIFIER = xyz.blackxfiied.Mythic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
6 changes: 4 additions & 2 deletions Mythic/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { // https://arc.net/l/quote/

// MARK: initialize default UserDefaults Values
defaults.register(defaults: [
"discordRPC": true
"discordRPC": true,
"engineAutomaticallyChecksForUpdates": true,
"quitOnAppClose": false
])

// MARK: Bottle cleanup in the event of external deletion
Expand Down Expand Up @@ -64,7 +66,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { // https://arc.net/l/quote/
settings.msync = oldSettings["msync"] ?? settings.msync
settings.retinaMode = oldSettings["retinaMode"] ?? settings.retinaMode

DispatchQueue.main.async {
Task { @MainActor in
convertedBottles.append(.init(name: name, url: url, settings: settings))
Wine.bottleURLs.insert(url)
}
Expand Down
1 change: 1 addition & 0 deletions Mythic/MythicApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct MythicApp: App {
}
}
.disabled(isOnboardingPresented)
.keyboardShortcut("O", modifiers: [.command])
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mythic/Utilities/Engine/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class Engine {
while true {
downloadHandler(download.progress)
log.debug("[engine] [download] \(download.progress.fractionCompleted * 100)% complete")
try await Task.sleep(nanoseconds: 500000000) // 0.5 s
try await Task.sleep(for: .seconds(0.5))
if download.progress.isFinished { if !debounce { debounce = true } else { break } }
}
}
Expand Down
14 changes: 7 additions & 7 deletions Mythic/Utilities/Game.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ enum GameModificationType: String {
var status: [String: [String: Any]]?

static func reset() {
DispatchQueue.main.async {
Task { @MainActor in
shared.game = nil
shared.type = nil
shared.status = nil
Expand Down Expand Up @@ -212,7 +212,7 @@ class GameOperation: ObservableObject {
trigger: nil)
)
} catch {
DispatchQueue.main.async {
Task { @MainActor in
let alert = NSAlert()
alert.messageText = "Error \(GameOperation.shared.current?.type.rawValue ?? "modifying") \"\(GameOperation.shared.current?.game.title ?? "Unknown")\"."
alert.informativeText = error.localizedDescription
Expand Down Expand Up @@ -248,11 +248,11 @@ class GameOperation: ObservableObject {
static func advance() {
log.debug("[operation.advance] attempting operation advancement")
guard shared.current == nil, let first = shared.queue.first else { return }
DispatchQueue.main.async {
Task { @MainActor in
shared.status = InstallStatus()
}
log.debug("[operation.advance] queuing configuration can advance, no active downloads, game present in queue")
DispatchQueue.main.async {
Task { @MainActor in
shared.current = first; shared.queue.removeFirst()
log.debug("[operation.advance] queuing configuration advanced. current game will now begin installation. (\(shared.current!.game.title))")
}
Expand All @@ -277,7 +277,7 @@ class GameOperation: ObservableObject {

GameOperation.log.debug("now monitoring \(gamePlatform.rawValue) game \(game.title)")

DispatchQueue.main.async {
Task { @MainActor in
GameOperation.shared.runningGames.insert(game)
}

Expand All @@ -303,10 +303,10 @@ class GameOperation: ObservableObject {
}()

if !isRunning {
DispatchQueue.main.async { GameOperation.shared.runningGames.remove(game) }
Task { @MainActor in GameOperation.shared.runningGames.remove(game) }
isOpen = false
} else {
sleep(3)
try? await Task.sleep(for: .seconds(3))
}

GameOperation.log.debug("\(game.title) \(isRunning ? "is still running" : "has been quit" )")
Expand Down
14 changes: 7 additions & 7 deletions Mythic/Utilities/Legendary/LegendaryInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ final class Legendary {
}

if let match = try? progressRegex.firstMatch(in: output.stderr) {
DispatchQueue.main.async {
Task { @MainActor in
operation.status.progress = GameOperation.InstallStatus.Progress(
percentage: Double(match["percentage"]?.substring ?? "") ?? 0.0,
downloadedObjects: Int(match["downloadedObjects"]?.substring ?? "") ?? 0,
Expand All @@ -278,31 +278,31 @@ final class Legendary {
}
}
if let match = try? downloadRegex.firstMatch(in: output.stderr) {
DispatchQueue.main.async {
Task { @MainActor in
operation.status.download = GameOperation.InstallStatus.Download(
downloaded: Double(match["downloaded"]?.substring ?? "") ?? 0.0,
written: Double(match["written"]?.substring ?? "") ?? 0.0
)
}
}
if let match = try? cacheRegex.firstMatch(in: output.stderr) {
DispatchQueue.main.async {
Task { @MainActor in
operation.status.cache = GameOperation.InstallStatus.Cache(
usage: Double(match["usage"]?.substring ?? "") ?? 0.0,
activeTasks: Int(match["activeTasks"]?.substring ?? "") ?? 0
)
}
}
if let match = try? downloadSpeedRegex.firstMatch(in: output.stderr) {
DispatchQueue.main.async {
Task { @MainActor in
operation.status.downloadSpeed = GameOperation.InstallStatus.DownloadSpeed(
raw: Double(match["raw"]?.substring ?? "") ?? 0.0,
decompressed: Double(match["decompressed"]?.substring ?? "") ?? 0.0
)
}
}
if let match = try? diskSpeedRegex.firstMatch(in: output.stderr) {
DispatchQueue.main.async {
Task { @MainActor in
operation.status.diskSpeed = GameOperation.InstallStatus.DiskSpeed(
write: Double(match["write"]?.substring ?? "") ?? 0.0,
read: Double(match["read"]?.substring ?? "") ?? 0.0
Expand Down Expand Up @@ -364,7 +364,7 @@ final class Legendary {
guard let bottleURL = game.bottleURL else { throw Wine.BottleDoesNotExistError() } // FIXME: Bottle Revamp
let bottle = try Wine.getBottleObject(url: bottleURL)

DispatchQueue.main.async {
Task { @MainActor in
GameOperation.shared.launching = game
}

Expand All @@ -388,7 +388,7 @@ final class Legendary {

try await command(arguments: arguments, identifier: "launch_\(game.id)", environment: environmentVariables) { _ in }

DispatchQueue.main.async {
Task { @MainActor in
GameOperation.shared.launching = nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Mythic/Utilities/Local/LocalGames.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class LocalGames {
throw GameDoesNotExistError(game)
}

DispatchQueue.main.async {
Task { @MainActor in
GameOperation.shared.launching = game
}

Expand Down Expand Up @@ -85,7 +85,7 @@ final class LocalGames {
case .none: do { /* TODO: Error */ }
}

DispatchQueue.main.async {
Task { @MainActor in
GameOperation.shared.launching = nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Mythic/Utilities/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class NetworkMonitor: ObservableObject {
guard let self = self else { return }
guard isCheckingEpicAccessibility == false else { return }

DispatchQueue.global(qos: .background).async {
Task(priority: .background) {
self.isConnected = (path.status == .satisfied)
guard self.isConnected == true else { self.updateAccessibility(false); return }

Expand All @@ -57,7 +57,7 @@ final class NetworkMonitor: ObservableObject {
}

private func updateAccessibility(_ isAccessible: Bool) {
DispatchQueue.main.async { [weak self] in
Task { @MainActor [weak self] in
self?.isEpicAccessible = isAccessible
self?.isCheckingEpicAccessibility = false
}
Expand Down
4 changes: 2 additions & 2 deletions Mythic/Utilities/VariableManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Foundation

/// Set variable data within the variable manager.
func setVariable(_ key: String, value: Any) {
DispatchQueue.main.async {
Task { @MainActor in
self.objectWillChange.send()
self.variables[key] = value
}
Expand All @@ -61,7 +61,7 @@ import Foundation

/// Remove variable data from the variable manager.
func removeVariable(_ key: String) {
DispatchQueue.main.async {
Task { @MainActor in
self.objectWillChange.send()
self.variables[key] = nil
}
Expand Down
1 change: 1 addition & 0 deletions Mythic/Views/Navigation/DownloadsViewEvo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct DownloadsEvo: View {
}
.animation(.easeInOut, value: cardsUpdated)
}

Spacer()
}
.padding()
Expand Down
3 changes: 1 addition & 2 deletions Mythic/Views/Navigation/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ struct HomeView: View {
HStack {
// MARK: - Recent Game Display
if let recentlyPlayedObject = defaults.object(forKey: "recentlyPlayed") as? Data,
var recentlyPlayedGame: Game = try? PropertyListDecoder().decode(Game.self, from: recentlyPlayedObject
) {
var recentlyPlayedGame: Game = try? PropertyListDecoder().decode(Game.self, from: recentlyPlayedObject) {
GameCard(game: .init(get: { recentlyPlayedGame }, set: { recentlyPlayedGame = $0 }))
}

Expand Down
17 changes: 9 additions & 8 deletions Mythic/Views/Navigation/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SettingsView: View {

@State private var isEpicCloudSynchronising: Bool = false

@State private var isEngineChangeAlertPresented: Bool = false
@State private var isEngineStreamChangeAlertPresented: Bool = false
@State private var isEngineRemovalAlertPresented: Bool = false
@State private var isResetAlertPresented: Bool = false
@State private var isResetSettingsAlertPresented: Bool = false
Expand Down Expand Up @@ -170,14 +170,18 @@ struct SettingsView: View {
""")
}
.onChange(of: engineBranch) {
isEngineChangeAlertPresented = true
isEngineStreamChangeAlertPresented = true
}
.alert(isPresented: $isEngineChangeAlertPresented) {
.alert(isPresented: $isEngineStreamChangeAlertPresented) {
.init(
title: .init("Would you like to remove Mythic Engine?"),
title: .init("Would you like to reinstall Mythic Engine?"),
message: .init("To change the engine type, Mythic Engine must be reinstalled through onboarding."),
primaryButton: .destructive(.init("OK")) {
try? Engine.remove()

let app = MythicApp() // FIXME: is this dangerous or just stupid
app.onboardingPhase = .engineDisclaimer
app.isOnboardingPresented = true
},
secondaryButton: .cancel()
)
Expand Down Expand Up @@ -321,10 +325,7 @@ struct SettingsView: View {
set: { sparkle.updater.automaticallyDownloadsUpdates = $0 }
))

Toggle("Automatically check for Mythic Engine updates", isOn: Binding(
get: { sparkle.updater.automaticallyChecksForUpdates },
set: { sparkle.updater.automaticallyChecksForUpdates = $0 }
))
Toggle("Automatically check for Mythic Engine updates", isOn: $engineAutomaticallyChecksForUpdates)
}

/* FIXME: TODO: Temporarily disabled; awaiting view that directly edits Wine.defaultBottleSettings.
Expand Down
8 changes: 7 additions & 1 deletion Mythic/Views/Unified/Modules/GameCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ struct GameCard: View {
}
.clipShape(.circle)
.help(game.path != nil ? "Play \"\(game.title)\"" : "Unable to locate \(game.title) at its specified path (\(game.path ?? "Unknown"))")
.disabled(game.path != nil ? !files.fileExists(atPath: game.path!) : false)
.disabled({
if let path = game.path {
return !files.fileExists(atPath: path)
} else {
return false
}
}())
.disabled(operation.runningGames.contains(game))
.disabled(Wine.bottleURLs.isEmpty)
.alert(isPresented: $isLaunchErrorAlertPresented) {
Expand Down
6 changes: 3 additions & 3 deletions Mythic/Views/Unified/Modules/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct WebView: NSViewRepresentable {
// MARK: Provisional Navigation Failure
/// Called when a navigation fails.
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation, withError error: Error) {
DispatchQueue.main.async { [self] in
Task { @MainActor [self] in
parent.log.error("\(error.localizedDescription)")
parent.error = error
}
Expand All @@ -71,7 +71,7 @@ struct WebView: NSViewRepresentable {
// MARK: - Provisional Navigation Completion
/// Called when navigation finishes successfully.
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) {
DispatchQueue.main.async { [self] in
Task { @MainActor [self] in
parent.isLoading = false
parent.canGoBack = webView.canGoBack
parent.canGoForward = webView.canGoForward
Expand All @@ -81,7 +81,7 @@ struct WebView: NSViewRepresentable {
// MARK: - Provisional Navigation Commencing
/// Called when the WebView starts provisional navigation.
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation) {
DispatchQueue.main.async { [self] in
Task { @MainActor [self] in
parent.isLoading = true
}
}
Expand Down

0 comments on commit 4ce5942

Please sign in to comment.