Skip to content

Commit

Permalink
feat: prototype of new "hub" style launcher.
Browse files Browse the repository at this point in the history
upstreamed from branch `refactor/rewrite`, e8f32ec

Co-authored-by: Josh <[email protected]>
  • Loading branch information
vapidinfinity and JoshuaBrest committed Nov 16, 2024
1 parent 56b86be commit 18537a1
Show file tree
Hide file tree
Showing 21 changed files with 679 additions and 43 deletions.
72 changes: 64 additions & 8 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
6A2935602BFCFAFD0035CE4B /* ContainerListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934E82BFCFAFD0035CE4B /* ContainerListView.swift */; };
6A2935612BFCFAFD0035CE4B /* GameListViewEvo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934E92BFCFAFD0035CE4B /* GameListViewEvo.swift */; };
6A2935622BFCFAFD0035CE4B /* NotImplementedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934EA2BFCFAFD0035CE4B /* NotImplementedView.swift */; };
6A2935632BFCFAFD0035CE4B /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934EB2BFCFAFD0035CE4B /* WebView.swift */; };
6A2935632BFCFAFD0035CE4B /* LegacyWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934EB2BFCFAFD0035CE4B /* LegacyWebView.swift */; };
6A2935642BFCFAFD0035CE4B /* OnboardingR2.old.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934ED2BFCFAFD0035CE4B /* OnboardingR2.old.swift */; };
6A2935662BFCFAFD0035CE4B /* AppDelegate.old.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2934F02BFCFAFD0035CE4B /* AppDelegate.old.swift */; };
6A2935682BFCFAFD0035CE4B /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 6A2934F22BFCFAFD0035CE4B /* Credits.rtf */; };
Expand Down Expand Up @@ -110,6 +110,12 @@
6A541C4D2CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C412CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift */; };
6A541C502CE7013800AD8A98 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 6A541C4F2CE7013800AD8A98 /* MarkdownUI */; };
6A541C562CE7029A00AD8A98 /* BackgroundEventServiceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C552CE7029A00AD8A98 /* BackgroundEventServiceModel.swift */; };
6A5489972CE8B9E100817721 /* GenericWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A5489962CE8B9E100817721 /* GenericWebView.swift */; };
6A5489A12CE8BA4B00817721 /* HubSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A5489982CE8BA4B00817721 /* HubSettingsView.swift */; };
6A5489A22CE8BA4B00817721 /* HubStoreEpicGamesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A54899C2CE8BA4B00817721 /* HubStoreEpicGamesView.swift */; };
6A5489A32CE8BA4B00817721 /* HubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A54899F2CE8BA4B00817721 /* HubView.swift */; };
6A5489A42CE8BA4B00817721 /* HubStoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A54899D2CE8BA4B00817721 /* HubStoreView.swift */; };
6A5489A52CE8BA4B00817721 /* HubLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A54899A2CE8BA4B00817721 /* HubLibraryView.swift */; };
6A71D3D92BFD01AB00A2C74D /* legendary in Resources */ = {isa = PBXBuildFile; fileRef = 6A71D3D82BFD01AB00A2C74D /* legendary */; };
6A71D3DD2BFD024D00A2C74D /* Auth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A71D3DC2BFD024D00A2C74D /* Auth.swift */; };
6A7A81162B77093600D19E32 /* ColorfulX in Frameworks */ = {isa = PBXBuildFile; productRef = 6A7A81152B77093600D19E32 /* ColorfulX */; };
Expand Down Expand Up @@ -213,7 +219,7 @@
6A2934E82BFCFAFD0035CE4B /* ContainerListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerListView.swift; sourceTree = "<group>"; };
6A2934E92BFCFAFD0035CE4B /* GameListViewEvo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameListViewEvo.swift; sourceTree = "<group>"; };
6A2934EA2BFCFAFD0035CE4B /* NotImplementedView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotImplementedView.swift; sourceTree = "<group>"; };
6A2934EB2BFCFAFD0035CE4B /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
6A2934EB2BFCFAFD0035CE4B /* LegacyWebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LegacyWebView.swift; sourceTree = "<group>"; };
6A2934ED2BFCFAFD0035CE4B /* OnboardingR2.old.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingR2.old.swift; sourceTree = "<group>"; };
6A2934F02BFCFAFD0035CE4B /* AppDelegate.old.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.old.swift; sourceTree = "<group>"; };
6A2934F22BFCFAFD0035CE4B /* Credits.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
Expand Down Expand Up @@ -242,6 +248,12 @@
6A541C442CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterFinishView.swift; sourceTree = "<group>"; };
6A541C452CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterSheetViewModifier.swift; sourceTree = "<group>"; };
6A541C552CE7029A00AD8A98 /* BackgroundEventServiceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundEventServiceModel.swift; sourceTree = "<group>"; };
6A5489962CE8B9E100817721 /* GenericWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericWebView.swift; sourceTree = "<group>"; };
6A5489982CE8BA4B00817721 /* HubSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubSettingsView.swift; sourceTree = "<group>"; };
6A54899A2CE8BA4B00817721 /* HubLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubLibraryView.swift; sourceTree = "<group>"; };
6A54899C2CE8BA4B00817721 /* HubStoreEpicGamesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubStoreEpicGamesView.swift; sourceTree = "<group>"; };
6A54899D2CE8BA4B00817721 /* HubStoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubStoreView.swift; sourceTree = "<group>"; };
6A54899F2CE8BA4B00817721 /* HubView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubView.swift; sourceTree = "<group>"; };
6A71D3D82BFD01AB00A2C74D /* legendary */ = {isa = PBXFileReference; lastKnownFileType = folder; path = legendary; sourceTree = "<group>"; };
6A71D3DC2BFD024D00A2C74D /* Auth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
6A9FE1152CDEED7200C36058 /* WhatsNewCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNewCollection.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -427,8 +439,7 @@
6A448E0D2CC4A531001E9F47 /* GameListCard.swift */,
6A2934DD2BFCFAFD0035CE4B /* GameInstallProgressView.swift */,
6A2934DE2BFCFAFD0035CE4B /* SubscriptedTextView.swift */,
6A2934EB2BFCFAFD0035CE4B /* WebView.swift */,
6AEEFA462CA9173C0025C840 /* WindowBlurView.swift */,
6A2934EB2BFCFAFD0035CE4B /* LegacyWebView.swift */,
);
path = Modules;
sourceTree = "<group>";
Expand Down Expand Up @@ -465,11 +476,12 @@
6A2934EF2BFCFAFD0035CE4B /* Views */ = {
isa = PBXGroup;
children = (
6A22B13E2CE6EE280055D837 /* Onboarding */,
6A2934D62BFCFAFD0035CE4B /* ContentView.swift */,
6A2C39912CE4EF9600B303AE /* Components */,
6A541C462CE700CF00AD8A98 /* SparkleUpdater */,
6A2934DA2BFCFAFD0035CE4B /* Navigation */,
6A22B13E2CE6EE280055D837 /* Onboarding */,
6A5489A02CE8BA4B00817721 /* Hub */,
6A2934EC2BFCFAFD0035CE4B /* Unified */,
6A2C39932CE4F01C00B303AE /* Legacy */,
);
Expand Down Expand Up @@ -509,9 +521,11 @@
6A2C39912CE4EF9600B303AE /* Components */ = {
isa = PBXGroup;
children = (
6A5489962CE8B9E100817721 /* GenericWebView.swift */,
6A2C39902CE4EF9600B303AE /* ColorfulBackgroundView.swift */,
6A541C3B2CE7001000AD8A98 /* BundleIconView.swift */,
6A541C3D2CE7001300AD8A98 /* RichAlertView.swift */,
6AEEFA462CA9173C0025C840 /* WindowBlurView.swift */,
);
path = Components;
sourceTree = "<group>";
Expand All @@ -538,6 +552,42 @@
path = SparkleUpdater;
sourceTree = "<group>";
};
6A5489992CE8BA4B00817721 /* Settings */ = {
isa = PBXGroup;
children = (
6A5489982CE8BA4B00817721 /* HubSettingsView.swift */,
);
path = Settings;
sourceTree = "<group>";
};
6A54899B2CE8BA4B00817721 /* Library */ = {
isa = PBXGroup;
children = (
6A54899A2CE8BA4B00817721 /* HubLibraryView.swift */,
);
path = Library;
sourceTree = "<group>";
};
6A54899E2CE8BA4B00817721 /* Store */ = {
isa = PBXGroup;
children = (
6A54899C2CE8BA4B00817721 /* HubStoreEpicGamesView.swift */,
6A54899D2CE8BA4B00817721 /* HubStoreView.swift */,
);
path = Store;
sourceTree = "<group>";
};
6A5489A02CE8BA4B00817721 /* Hub */ = {
isa = PBXGroup;
children = (
6A5489992CE8BA4B00817721 /* Settings */,
6A54899B2CE8BA4B00817721 /* Library */,
6A54899E2CE8BA4B00817721 /* Store */,
6A54899F2CE8BA4B00817721 /* HubView.swift */,
);
path = Hub;
sourceTree = "<group>";
};
6A91FEC02C2BFB8100D9F153 /* Models */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -823,6 +873,7 @@
6A2935382BFCFAFD0035CE4B /* Logger.swift in Sources */,
6A2935372BFCFAFD0035CE4B /* Data.swift in Sources */,
6A2935482BFCFAFD0035CE4B /* EpicImport.swift in Sources */,
6A5489972CE8B9E100817721 /* GenericWebView.swift in Sources */,
6A1E35102CE4EC31008DCE33 /* AppDelegate.swift in Sources */,
6AC45E092C1B2FD500ED9F64 /* SettingsFormView.swift in Sources */,
6A29353D2BFCFAFD0035CE4B /* LegendaryInterface.swift in Sources */,
Expand All @@ -845,7 +896,12 @@
6A2935442BFCFAFD0035CE4B /* Global.swift in Sources */,
6AF495F42CE4EF1300C251EA /* HubWindowController.swift in Sources */,
6AF495F52CE4EF1300C251EA /* SetupWindowController.swift in Sources */,
6A2935632BFCFAFD0035CE4B /* WebView.swift in Sources */,
6A5489A12CE8BA4B00817721 /* HubSettingsView.swift in Sources */,
6A5489A22CE8BA4B00817721 /* HubStoreEpicGamesView.swift in Sources */,
6A5489A32CE8BA4B00817721 /* HubView.swift in Sources */,
6A5489A42CE8BA4B00817721 /* HubStoreView.swift in Sources */,
6A5489A52CE8BA4B00817721 /* HubLibraryView.swift in Sources */,
6A2935632BFCFAFD0035CE4B /* LegacyWebView.swift in Sources */,
6A541C3E2CE7001300AD8A98 /* RichAlertView.swift in Sources */,
6AAD47152CE6513F00B08564 /* DirectoriesUtility.swift in Sources */,
6A2935582BFCFAFD0035CE4B /* SubscriptedTextView.swift in Sources */,
Expand Down Expand Up @@ -1025,7 +1081,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3480;
CURRENT_PROJECT_VERSION = 3556;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
Expand Down Expand Up @@ -1073,7 +1129,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3480;
CURRENT_PROJECT_VERSION = 3556;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
Expand Down
10 changes: 8 additions & 2 deletions Mythic/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class AppDelegate: NSObject, NSApplicationDelegate {

/// Listen for events
@MainActor private func listenEvents() {
// Flush old cancellables
cancellables.forEach({ $0.cancel() })
cancellables.removeAll()

// Listen for onboarding state changes
Expand All @@ -53,6 +51,14 @@ public class AppDelegate: NSObject, NSApplicationDelegate {
appMenuController.setRestartOnboardingVisibility(true)
}
}).store(in: &cancellables)

SparkleUpdateControllerModel.shared.$state.sink(receiveValue: { [self] value in
switch value {
case .updateAvailable, .checkingForUpdates, .readyToRelaunch, .noUpdateAvailable:
restoreActiveRootWindow()
default: ()
}
}).store(in: &cancellables)
}

/// Get the setup window or switch to it.
Expand Down
36 changes: 36 additions & 0 deletions Mythic/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9234,18 +9234,30 @@
}
}
}
},
"common.back" : {

},
"common.cancel" : {

},
"common.finish" : {

},
"common.forward" : {

},
"common.homepage" : {

},
"common.next" : {

},
"common.okay" : {

},
"common.refresh" : {

},
"common.skip" : {

Expand Down Expand Up @@ -16095,6 +16107,12 @@
}
}
}
},
"genericWebView.error" : {

},
"genericWebView.retry" : {

},
"Get support/Support Mythic" : {
"localizations" : {
Expand Down Expand Up @@ -17429,6 +17447,18 @@
}
}
}
},
"hubLibraryView.title" : {

},
"hubSettingsView.title" : {

},
"hubStoreEpicGamesView.title" : {

},
"hubStoreView.title" : {

},
"I have read and agreed to the terms of the software license agreement." : {
"localizations" : {
Expand Down Expand Up @@ -21419,6 +21449,9 @@
}
}
}
},
"Library View!" : {

},
"List" : {
"localizations" : {
Expand Down Expand Up @@ -32963,6 +32996,9 @@
}
}
}
},
"Settings!" : {

},
"Show in Finder" : {
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public struct AppSettingsPersistentStateModel: StorablePersistentStateModel.Stat
.init()
}

/// Library Display Mode.
public enum LibraryDisplayMode: String, Codable, Hashable {
case list
case grid
}

/// Auto update settings.
public enum AutoUpdateAction: String, Codable, Hashable {
case off
Expand All @@ -49,9 +43,6 @@ public struct AppSettingsPersistentStateModel: StorablePersistentStateModel.Stat
/// Engine update action.
public var engineUpdateAction: AutoUpdateAction = .check

/// Library display mode.
public var libraryDisplayMode: LibraryDisplayMode = .grid

/// Hide the main window on game launch.
public var hideOnGameLaunch: Bool = false
/// Close opened games on quit.
Expand Down
38 changes: 30 additions & 8 deletions Mythic/Models/SparkleUpdateControllerModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,18 @@ public class SparkleUpdateControllerModel: NSObject, SPUUserDriver, ObservableOb
/// Check for updates
/// - Parameter userInitiated: If the check was initiated by the user.
@MainActor public func checkForUpdates(userInitiated: Bool = false) {
if let updater = sparkleUpdater, !updater.sessionInProgress {
logger.info("\(userInitiated ? "User-initiated" : "Automatic") update check initiated...")
_ = clearState()
userInitiatedCheck = userInitiated
guard let updater = sparkleUpdater, !updater.sessionInProgress else {
logger.info("\(userInitiated ? "User-initiated" : "Automatic") update check ignored due to in-progress update session.")
if userInitiated {
userInitiatedCheck = true
}
return
}

logger.info("\(userInitiated ? "User-initiated" : "Automatic") update check ignored due to in-progress update session.")
if userInitiated {
userInitiatedCheck = true
}
logger.info("\(userInitiated ? "User-initiated" : "Automatic") update check initiated...")
_ = clearState()
userInitiatedCheck = userInitiated
updater.checkForUpdates()
}

/// Get the updater action
Expand All @@ -181,6 +182,15 @@ public class SparkleUpdateControllerModel: NSObject, SPUUserDriver, ObservableOb
return action
}

/// Get the updater action
private func preferSilent() -> Bool {
var action: Bool = false
DispatchQueue.main.sync {
action = !AppSettingsPersistentStateModel.shared.store.inOnboarding
}
return action
}

/// Initialize the settings for the updater.
/// Implementation of `SPUUserDriver` protocol.
public func show(_ request: SPUUpdatePermissionRequest) async -> SUUpdatePermissionResponse {
Expand Down Expand Up @@ -210,6 +220,8 @@ public class SparkleUpdateControllerModel: NSObject, SPUUserDriver, ObservableOb
reply(.install)
self.state = .initializingUpdate
return
} else if getUpdaterAction() == .check && !preferSilent() {
userInitiatedCheck = true
}

self.state = .updateAvailable(choice: { choice in
Expand Down Expand Up @@ -332,6 +344,11 @@ public class SparkleUpdateControllerModel: NSObject, SPUUserDriver, ObservableOb
/// Implementation of `SPUUserDriver` protocol.
public func showReady(toInstallAndRelaunch reply: @escaping (SPUUserUpdateChoice) -> Void) {
logger.debug("Update ready to install.")

if !userInitiatedCheck && !preferSilent() {
userInitiatedCheck = true
}

state = .readyToRelaunch { choice in
switch choice {
case .update:
Expand Down Expand Up @@ -365,6 +382,11 @@ public class SparkleUpdateControllerModel: NSObject, SPUUserDriver, ObservableOb
/// Dismiss the updater.
/// Implementation of `SPUUserDriver` protocol.
public func dismissUpdateInstallation() {
guard userInitiatedCheck else {
self.state = .idle
return
}

if case .checkingForUpdates(_) = state {
// No updates were found.
state = .noUpdateAvailable {
Expand Down
20 changes: 20 additions & 0 deletions Mythic/Utilities/Legendary/LegendaryInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,26 @@ final class Legendary {
return String(describing: json["displayName"])
}

/// Queries for the user that is currently signed into epic games.
static var refreshToken: String? {
let json: URL = .init(filePath: "\(configLocation)/user.json")
guard let json = try? JSON(data: .init(contentsOf: json)) else {
return nil
}

return String(describing: json["refresh_token"])
}

/// Queries for the user that is currently signed into epic games.
static var accessToken: String? {
let json: URL = .init(filePath: "\(configLocation)/user.json")
guard let json = try? JSON(data: .init(contentsOf: json)) else {
return nil
}

return String(describing: json["access_token"])
}

/// Checks account signin state.
static var signedIn: Bool { return user != nil }

Expand Down
Loading

0 comments on commit 18537a1

Please sign in to comment.