Skip to content

Commit

Permalink
Fix for epic games signin breaking (the previous 3 or so commits are …
Browse files Browse the repository at this point in the history
…nonfunctional due to a file path error)
  • Loading branch information
vapidinfinity committed Dec 11, 2023
1 parent 618b755 commit ba3ea6a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 45 deletions.
12 changes: 6 additions & 6 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
6A6923522AD6D83D00157E3E /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A6923512AD6D83D00157E3E /* Global.swift */; };
6A7F00B12B231EDF00D801CD /* StopDownloadAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7F00B02B231EDF00D801CD /* StopDownloadAlert.swift */; };
6A82830E2AC71DAF005CA9AC /* Uninstall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A82830D2AC71DAF005CA9AC /* Uninstall.swift */; };
6AA4A3302B27012F00633A44 /* legendary in Resources */ = {isa = PBXBuildFile; fileRef = 6AA4A32F2B27012F00633A44 /* legendary */; };
6AA5307F2AB5E1DD002D238E /* GameList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AA5307E2AB5E1DD002D238E /* GameList.swift */; };
6AA6CCE32AD52B2600F664A5 /* Legendary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AA6CCE22AD52B2600F664A5 /* Legendary.swift */; };
6AA6CCE72AD571C500F664A5 /* LegendaryExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AA6CCE62AD571C500F664A5 /* LegendaryExt.swift */; };
6AACB0932AC71757007D7CE8 /* UpdaterSettings[TEST].swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AACB0922AC71757007D7CE8 /* UpdaterSettings[TEST].swift */; };
6AAD31152B08693D0035FA69 /* SemanticVersion in Frameworks */ = {isa = PBXBuildFile; productRef = 6AAD31142B08693D0035FA69 /* SemanticVersion */; };
6AAF14DF2B271DF4000B1BA2 /* legendary in Resources */ = {isa = PBXBuildFile; fileRef = 6AAF14DE2B271DF4000B1BA2 /* legendary */; };
6AB474992AACBBE900AB9C63 /* MythicApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AB474982AACBBE900AB9C63 /* MythicApp.swift */; };
6AB4749D2AACBBEA00AB9C63 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6AB4749C2AACBBEA00AB9C63 /* Assets.xcassets */; };
6AB474A02AACBBEA00AB9C63 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6AB4749F2AACBBEA00AB9C63 /* Preview Assets.xcassets */; };
Expand Down Expand Up @@ -78,11 +78,11 @@
6A6923512AD6D83D00157E3E /* Global.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Global.swift; sourceTree = "<group>"; };
6A7F00B02B231EDF00D801CD /* StopDownloadAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopDownloadAlert.swift; sourceTree = "<group>"; };
6A82830D2AC71DAF005CA9AC /* Uninstall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Uninstall.swift; sourceTree = "<group>"; };
6AA4A32F2B27012F00633A44 /* legendary */ = {isa = PBXFileReference; lastKnownFileType = folder; path = legendary; sourceTree = "<group>"; };
6AA5307E2AB5E1DD002D238E /* GameList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameList.swift; sourceTree = "<group>"; };
6AA6CCE22AD52B2600F664A5 /* Legendary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Legendary.swift; sourceTree = "<group>"; };
6AA6CCE62AD571C500F664A5 /* LegendaryExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegendaryExt.swift; sourceTree = "<group>"; };
6AACB0922AC71757007D7CE8 /* UpdaterSettings[TEST].swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UpdaterSettings[TEST].swift"; sourceTree = "<group>"; };
6AAF14DE2B271DF4000B1BA2 /* legendary */ = {isa = PBXFileReference; lastKnownFileType = folder; path = legendary; sourceTree = "<group>"; };
6AB474952AACBBE900AB9C63 /* Mythic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Mythic.app; sourceTree = BUILT_PRODUCTS_DIR; };
6AB474982AACBBE900AB9C63 /* MythicApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MythicApp.swift; sourceTree = "<group>"; };
6AB4749C2AACBBEA00AB9C63 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -378,7 +378,7 @@
6A009E602AB596D400A1397F /* Controllers */,
6A0C668A2ABC5235004B0755 /* Extensions */,
6A009E612AB596E300A1397F /* Other */,
6AA4A32F2B27012F00633A44 /* legendary */,
6AAF14DE2B271DF4000B1BA2 /* legendary */,
6AB4749C2AACBBEA00AB9C63 /* Assets.xcassets */,
6AB474A12AACBBEA00AB9C63 /* Mythic.entitlements */,
6AB4749E2AACBBEA00AB9C63 /* Preview Content */,
Expand Down Expand Up @@ -510,7 +510,7 @@
files = (
6AB474A02AACBBEA00AB9C63 /* Preview Assets.xcassets in Resources */,
6AB4749D2AACBBEA00AB9C63 /* Assets.xcassets in Resources */,
6AA4A3302B27012F00633A44 /* legendary in Resources */,
6AAF14DF2B271DF4000B1BA2 /* legendary in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -719,7 +719,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2030;
CURRENT_PROJECT_VERSION = 2036;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down Expand Up @@ -758,7 +758,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2030;
CURRENT_PROJECT_VERSION = 2036;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down
4 changes: 2 additions & 2 deletions Mythic/Controllers/Base/Legendary/Legendary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private let defaults = UserDefaults.standard
/// the backbone of the launcher's EGS capabilities. See: https://github.com/derrod/legendary
class Legendary {
/// The file location for legendary's configuration files.
static let configLocation = "\(Bundle.appHome!.path)/legendary"
static let configLocation = Bundle.appHome!.appending(path: "Config").path

/// Logger instance for legendary
public static let log = Logger(
Expand Down Expand Up @@ -102,7 +102,7 @@ class Legendary {

task.arguments = args

var environment = ["LEGENDARY_CONFIG_PATH": Bundle.appHome!.appending(path: "Config").path]
var environment = ["LEGENDARY_CONFIG_PATH": configLocation]
if let additionalEnvironmentVariables = additionalEnvironmentVariables {
environment.merge(additionalEnvironmentVariables) { (_, new) in new }
}
Expand Down
88 changes: 51 additions & 37 deletions Mythic/Views/Navigation/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ struct MainView: View {

enum ActiveAlert {
case stopDownloadWarning
case signOutConfirmation
}
@State private var activeAlert: ActiveAlert? = .none
@State private var isAlertPresented: Bool = false

@State private var epicUserAsync: String = "Loading..."
@State private var signedIn: Bool = false

@State private var appVersion: String = String()
@State private var buildNumber: Int = 0

@State private var gameThumbnails: [String: String] = Dictionary()

@StateObject private var installing = Legendary.Installing.shared

func updateLegendaryAccountState() {
epicUserAsync = "Loading..."
DispatchQueue.global(qos: .userInitiated).async {
Expand All @@ -44,16 +45,16 @@ struct MainView: View {
}
}
}

init() { updateLegendaryAccountState() }

var body: some View {
NavigationView {
List {
Text("DASHBOARD")
.font(.system(size: 10))
.fontWeight(.bold)

Group {
NavigationLink(destination: HomeView()) {
Label("Home", systemImage: "house")
Expand All @@ -68,13 +69,13 @@ struct MainView: View {
.foregroundStyle(.primary)
}
}

Spacer()

Text("MANAGEMENT")
.font(.system(size: 10))
.fontWeight(.bold)

Group {
NavigationLink(destination: WineView()) {
Label("Wine", systemImage: "wineglass")
Expand All @@ -89,31 +90,31 @@ struct MainView: View {
.foregroundStyle(.primary)
}
}

Spacer()

if installing._value == true {
Divider()

/*
ZStack {
CachedAsyncImage(url: URL(string: gameThumbnails[installing._game] ?? String())) { phase in
if case .success(let image) = phase {
image
.resizable()
.aspectRatio(contentMode: .fit)
.blur(radius: 20)
}
}
CachedAsyncImage(url: URL(string: gameThumbnails[installing._game] ?? String())) { phase in
if case .success(let image) = phase {
image
.resizable()
.aspectRatio(contentMode: .fit)
.blur(radius: 20)
}
}
*/

VStack {
Text("INSTALLING")
.fontWeight(.bold)
.font(.system(size: 8))
.offset(x: -2, y: 0)
Text(installing._game == nil ? "Loading..." : installing._game!.title)

HStack {
Button {
isInstallStatusViewPresented = true
Expand All @@ -130,7 +131,7 @@ struct MainView: View {
.onChange(of: installing._finished) { _, newValue in
installing._value = !newValue
}

Button {
activeAlert = .stopDownloadWarning
isAlertPresented = true
Expand All @@ -146,9 +147,9 @@ struct MainView: View {
}
}
}

Divider()

HStack {
Image(systemName: "person")
.foregroundStyle(.primary)
Expand All @@ -157,16 +158,12 @@ struct MainView: View {
updateLegendaryAccountState()
}
}

if epicUserAsync != "Loading..." {
if signedIn {
Button {
Task(priority: .high) {
let command = await Legendary.command(args: ["auth", "--delete"], useCache: false, identifier: "userAreaSignOut")
if let commandStderrString = String(data: command.stderr, encoding: .utf8), commandStderrString.contains("User data deleted.") {
updateLegendaryAccountState()
}
}
activeAlert = .signOutConfirmation
isAlertPresented = true
} label: {
HStack {
Image(systemName: "person.slash")
Expand All @@ -187,7 +184,7 @@ struct MainView: View {
}
}
}

if let displayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String,
let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let bundleVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String {
Expand All @@ -210,12 +207,29 @@ struct MainView: View {
switch activeAlert {
case .stopDownloadWarning:
return stopDownloadAlert(isPresented: $isAlertPresented, game: Legendary.Installing.game)
case .signOutConfirmation:
return Alert(
title: .init("Are you sure you want to sign out?"),
message: .init("This will sign you out of the account \"\(Legendary.whoAmI())\"."),
primaryButton: .destructive(.init("Sign Out")) {
Task(priority: .high) { // progress view implementation in future
let command = await Legendary.command(args: ["auth", "--delete"], useCache: false, identifier: "userAreaSignOut")
if let commandStderrString = String(data: command.stderr, encoding: .utf8), commandStderrString.contains("User data deleted.") {
updateLegendaryAccountState()
}
}
},
secondaryButton: .cancel(.init("Cancel")) {
isAlertPresented = false
activeAlert = .none
}
)
case nil:
Logger.app.error("no activeAlert supplied. resultantly, there's no alert to be presented.")
return Alert(
title: .init("An error occurred."),
message: .init(
"\(Text("[ActiveAlert Fault]]").italic())"
"\(Text("[ActiveAlert Fault]").italic())"
+ "If this error appears, please consult support."
+ "\nMake sure to include what you were doing when the error occured."
)
Expand All @@ -237,7 +251,7 @@ struct MainView: View {
if !thumbnails.isEmpty { gameThumbnails = thumbnails }
}
}

HomeView()
}
}
Expand Down

0 comments on commit ba3ea6a

Please sign in to comment.