diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index 8edf529..6b4fbc5 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 9669DC6D27D55CD200DE5FAB /* Patches.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6C27D55CD200DE5FAB /* Patches.swift */; }; 9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */; }; 9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC7027D55F4700DE5FAB /* RomView.swift */; }; - 9670CE8F281986B5005AA0CD /* AlertToBool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9670CE8E281986B5005AA0CD /* AlertToBool.swift */; }; 96BB22E327E274F700057915 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB22E227E274F700057915 /* RepoView.swift */; }; 96CF3D4227DBD8C7008A26F5 /* CompilationSpeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */; }; 96DE71D327EB9C170090E7A0 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DE71D227EB9C170090E7A0 /* SettingsView.swift */; }; @@ -38,7 +37,6 @@ 9669DC6C27D55CD200DE5FAB /* Patches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Patches.swift; sourceTree = ""; }; 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchesView.swift; sourceTree = ""; }; 9669DC7027D55F4700DE5FAB /* RomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RomView.swift; sourceTree = ""; }; - 9670CE8E281986B5005AA0CD /* AlertToBool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertToBool.swift; sourceTree = ""; }; 96BB22E227E274F700057915 /* RepoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = ""; }; 96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilationSpeed.swift; sourceTree = ""; }; 96DE71D227EB9C170090E7A0 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; @@ -83,15 +81,14 @@ 9669DC6A27D5581F00DE5FAB /* Repos.swift */, 9669DC6C27D55CD200DE5FAB /* Patches.swift */, 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */, - 9669DC7027D55F4700DE5FAB /* RomView.swift */, 960D46F527D6850D0056E393 /* BuildingSteps.swift */, + 9669DC7027D55F4700DE5FAB /* RomView.swift */, 96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */, 96BB22E227E274F700057915 /* RepoView.swift */, 96DE71D227EB9C170090E7A0 /* SettingsView.swift */, 963F238227F8B211004E010E /* LauncherView.swift */, 963F238427F8B942004E010E /* DataStore.xcdatamodeld */, 963F238727F8BA01004E010E /* DataController.swift */, - 9670CE8E281986B5005AA0CD /* AlertToBool.swift */, ); path = sm_osx; sourceTree = ""; @@ -190,7 +187,6 @@ 9669DC6B27D5581F00DE5FAB /* Repos.swift in Sources */, 96BB22E327E274F700057915 /* RepoView.swift in Sources */, 9669DC5C27D5565000DE5FAB /* sm_osxApp.swift in Sources */, - 9670CE8F281986B5005AA0CD /* AlertToBool.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -325,7 +321,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 18; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; ENABLE_HARDENED_RUNTIME = NO; @@ -339,7 +335,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.1.6; + MARKETING_VERSION = 1.1.7; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -357,7 +353,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 18; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; ENABLE_HARDENED_RUNTIME = NO; @@ -371,7 +367,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.1.6; + MARKETING_VERSION = 1.1.7; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/sm_osx/AlertToBool.swift b/sm_osx/AlertToBool.swift deleted file mode 100644 index 27a140c..0000000 --- a/sm_osx/AlertToBool.swift +++ /dev/null @@ -1,7 +0,0 @@ - -import SwiftUI - -struct AlertToBool { - - -} diff --git a/sm_osx/CompilationSpeed.swift b/sm_osx/CompilationSpeed.swift index 0209476..94ae494 100644 --- a/sm_osx/CompilationSpeed.swift +++ b/sm_osx/CompilationSpeed.swift @@ -12,5 +12,5 @@ enum Speed: String { case normal = "-j2" case fast = "-j3" case veryFast = "-j6" - case fastest = "-j64" + case fastest = "-j" } diff --git a/sm_osx/LauncherView.swift b/sm_osx/LauncherView.swift index 6d1f483..e0ff12b 100644 --- a/sm_osx/LauncherView.swift +++ b/sm_osx/LauncherView.swift @@ -17,7 +17,7 @@ struct LauncherView: View { @FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults @State var existingRepo = URL(string: "") @State var repoTitle = "" - @State var currentVersion = "v1.1.6\n" + @State var currentVersion = "v1.1.7\n" @State var updateAlert = false @State var latestVersion = "" @State var repoArgs = "" @@ -25,10 +25,11 @@ struct LauncherView: View { @State var crashLog = "" @State var readableCrashLog = "" @State var allowAddingRepos = true + @State var beginLogging = false @AppStorage("firstLaunch") var firstLaunch = true @State var romURL = URL(string: "") - let sm64: UTType = .init(filenameExtension: "f3dex2e")! - let rom: UTType = .init(filenameExtension: "z64")! + let sm64: UTType = .init(filenameExtension: "f3dex2e") ?? UTType.unixExecutable + let rom: UTType = .init(filenameExtension: "z64") ?? UTType.unixExecutable func launcherShell(_ command: String) throws -> String { self.crashLog = "" @@ -44,7 +45,7 @@ struct LauncherView: View { let outHandle = pipe.fileHandleForReading outHandle.waitForDataInBackgroundAndNotify() - var obs1 : NSObjectProtocol! + var obs1 : NSObjectProtocol? obs1 = NotificationCenter.default.addObserver(forName: Notification.Name.NSFileHandleDataAvailable, object: outHandle, queue: nil) { notification -> Void in let data = outHandle.availableData @@ -63,7 +64,7 @@ struct LauncherView: View { } } - var obs2 : NSObjectProtocol! + var obs2 : NSObjectProtocol? obs2 = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: task, queue: nil) { notification -> Void in print("terminated") @@ -215,6 +216,23 @@ struct LauncherView: View { Image(systemName: "trash") } + Button(action: { + + for i in 0...launcherRepos.count - 1 { + launcherRepos[i].isEditing = false + } + + print(try? launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")")) + + beginLogging = true + + print(LauncherRepo.path ?? "") + }) { + Text("Log") + + Image(systemName: "arrow.right.circle.fill") + } + Button(action: { for i in 0...launcherRepos.count - 1 { @@ -246,8 +264,10 @@ struct LauncherView: View { if allowAddingRepos { Button(action:{ - for i in 0...launcherRepos.count - 1 { - launcherRepos[i].isEditing = false + if !launcherRepos.isEmpty { + for i in 0...launcherRepos.count - 1 { + launcherRepos[i].isEditing = false + } } romURL = showOpenPanelForRom() @@ -274,8 +294,10 @@ struct LauncherView: View { Button(action:{ - for i in 0...launcherRepos.count - 1 { - launcherRepos[i].isEditing = false + if !launcherRepos.isEmpty { + for i in 0...launcherRepos.count - 1 { + launcherRepos[i].isEditing = false + } } repoView = true @@ -288,8 +310,10 @@ struct LauncherView: View { Button("Add Existing Repo") { - for i in 0...launcherRepos.count - 1 { - launcherRepos[i].isEditing = false + if !launcherRepos.isEmpty { + for i in 0...launcherRepos.count - 1 { + launcherRepos[i].isEditing = false + } } existingRepo = showOpenPanel() @@ -324,11 +348,11 @@ struct LauncherView: View { launcherRepos[i].isEditing = false } - print(try! shell.shell("brew install make mingw-w64 gcc sdl2 pkg-config glew glfw3 libusb audiofile coreutils")) + print(try? shell.shell("brew install make mingw-w64 gcc sdl2 pkg-config glew glfw3 libusb audiofile coreutils")) print("its intel's turn nerd what an idiot man") - print(try! shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils")) + print(try? shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils")) let content = UNMutableNotificationContent() content.title = "Finished installing dependencies" @@ -349,14 +373,24 @@ struct LauncherView: View { } }.onAppear { - if try! checkRom("ls ~/SM64Repos/baserom.us.z64") { - allowAddingRepos = true + do { + if try checkRom("ls ~/SM64Repos/baserom.us.z64") { + allowAddingRepos = true + } + else { + allowAddingRepos = false + } } - else { - allowAddingRepos = false + catch { + print("Failed: \(error)") } - latestVersion = try! shell.shell("curl https://github.com/EmeraldLoc/sm_osx/releases/latest -s | grep -o 'v[0-9].[0-9].[0-9]*' | sort -u") + do { + latestVersion = try shell.shell("curl https://github.com/EmeraldLoc/sm_osx/releases/latest -s | grep -o 'v[0-9].[0-9].[0-9]*' | sort -u") + } + catch { + print("Failed: \(error)") + } print("Latest Version: \(latestVersion), Current Version: \(currentVersion)") @@ -382,7 +416,7 @@ struct LauncherView: View { }.alert("An Update is Avalible", isPresented: $updateAlert) { Button("Update", role: .none) { - print(try! shell.shell("cd ~/Downloads && wget https://github.com/EmeraldLoc/sm_osx/releases/latest/download/sm_osx.zip && unzip sm_osx.zip && rm -rf sm_osx.zip /Applications/sm_osx.app && mv sm_osx.app /Applications && open /Applications/sm_osx.app")) + print(try? shell.shell("cd ~/Downloads && wget https://github.com/EmeraldLoc/sm_osx/releases/latest/download/sm_osx.zip && unzip sm_osx.zip && rm -rf sm_osx.zip /Applications/sm_osx.app && mv sm_osx.app /Applications && open /Applications/sm_osx.app")) exit(0) } @@ -400,6 +434,8 @@ struct LauncherView: View { readableCrashLog = crashLog } .onAppear { + beginLogging = false + readableCrashLog = crashLog } } @@ -410,6 +446,25 @@ struct LauncherView: View { crashStatus = false } }.frame(minWidth: 350, maxHeight: 350) + }.sheet(isPresented: $beginLogging) { + VStack { + TextEditor(text: $readableCrashLog) + .frame(minWidth: 350, minHeight: 350) + .onChange(of: readableCrashLog) { _ in + readableCrashLog = crashLog + }.onChange(of: crashLog) { _ in + readableCrashLog = crashLog + } + .onAppear { + readableCrashLog = crashLog + } + + Spacer() + + Button("Finish") { + beginLogging = false + } + } } } }