Skip to content

Commit 8c8d1c4

Browse files
committed
Revamp repo and patch system to be more expandable
1 parent 5d6a423 commit 8c8d1c4

File tree

13 files changed

+156
-433
lines changed

13 files changed

+156
-433
lines changed

sm_osx.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
96E529D729C511F000E8E14D /* InternetChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E529D629C511F000E8E14D /* InternetChecker.swift */; };
4646
96EBED1329BA51970033771E /* UpdatesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EBED1229BA51970033771E /* UpdatesSettingsView.swift */; };
4747
96F79CC62AC622CE009FC622 /* CustomRepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F79CC52AC622CE009FC622 /* CustomRepoView.swift */; };
48-
96F79CC82AC6388F009FC622 /* CustomRepo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F79CC72AC6388F009FC622 /* CustomRepo.swift */; };
48+
96F79CC82AC6388F009FC622 /* Repos.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F79CC72AC6388F009FC622 /* Repos.swift */; };
49+
96FA91072CE80449004BFD60 /* Patches.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FA91062CE80446004BFD60 /* Patches.swift */; };
4950
/* End PBXBuildFile section */
5051

5152
/* Begin PBXCopyFilesBuildPhase section */
@@ -104,7 +105,8 @@
104105
96E529D629C511F000E8E14D /* InternetChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternetChecker.swift; sourceTree = "<group>"; };
105106
96EBED1229BA51970033771E /* UpdatesSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatesSettingsView.swift; sourceTree = "<group>"; };
106107
96F79CC52AC622CE009FC622 /* CustomRepoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRepoView.swift; sourceTree = "<group>"; };
107-
96F79CC72AC6388F009FC622 /* CustomRepo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRepo.swift; sourceTree = "<group>"; };
108+
96F79CC72AC6388F009FC622 /* Repos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Repos.swift; sourceTree = "<group>"; };
109+
96FA91062CE80446004BFD60 /* Patches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Patches.swift; sourceTree = "<group>"; };
108110
/* End PBXFileReference section */
109111

110112
/* Begin PBXFrameworksBuildPhase section */
@@ -187,7 +189,8 @@
187189
964C6F7629E889C100506DBD /* CreateAppShortcutView.swift */,
188190
961C0A5029E9C6E000D50A80 /* Enums.swift */,
189191
9639868029EB011A00E6218B /* ViewModifiers.swift */,
190-
96F79CC72AC6388F009FC622 /* CustomRepo.swift */,
192+
96F79CC72AC6388F009FC622 /* Repos.swift */,
193+
96FA91062CE80446004BFD60 /* Patches.swift */,
191194
);
192195
path = sm_osx;
193196
sourceTree = "<group>";
@@ -287,7 +290,7 @@
287290
96892C8329E5D5E90083526B /* LauncherGridView.swift in Sources */,
288291
9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */,
289292
966A0E8D2ACF4A8C00199378 /* DevelopmentEnvironment.swift in Sources */,
290-
96F79CC82AC6388F009FC622 /* CustomRepo.swift in Sources */,
293+
96F79CC82AC6388F009FC622 /* Repos.swift in Sources */,
291294
96BDA2F3283D216500A4DFF3 /* GeneralView.swift in Sources */,
292295
96DE71D327EB9C170090E7A0 /* SettingsView.swift in Sources */,
293296
96C54E6D285930D7003B4A2D /* GlobalFunctions.swift in Sources */,
@@ -303,6 +306,7 @@
303306
96F79CC62AC622CE009FC622 /* CustomRepoView.swift in Sources */,
304307
96BB22E327E274F700057915 /* RepoView.swift in Sources */,
305308
9669DC5C27D5565000DE5FAB /* sm_osxApp.swift in Sources */,
309+
96FA91072CE80449004BFD60 /* Patches.swift in Sources */,
306310
96CCFB7729E7158B00BE8CC7 /* LaunchScriptCommand.swift in Sources */,
307311
96BDA2F5283D221700A4DFF3 /* DeveloperView.swift in Sources */,
308312
);

sm_osx/AboutView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import SwiftUI
33

44
struct AboutView: View {
55

6-
let sm_osx_about_text = """
7-
sm_osx is a app that allows you to compile Super Mario 64 Pc Port repos with ease. It has a launcher, so that you can launch all your repos from one place, and an auto updater, so no need to worry about checking the github every five seconds. sm_osx also includes multiple sections in the menu bar, so you can use the app without the big window being there at all times.
8-
"""
6+
let sm_osx_about_text = "sm_osx is a app that allows you to compile Super Mario 64 Pc Port repos with ease. It has a launcher, so that you can launch all your repos from one place, and an auto updater, so no need to worry about checking the github every five seconds. sm_osx also includes multiple sections in the menu bar, so you can use the app without the big window being there at all times."
97

108
var body: some View {
119
VStack {

sm_osx/CompilationView.swift

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ struct CompilationView: View {
66

77
@Binding var compileCommands: String
88
@Binding var repo: Repo
9-
@Binding var customRepo: CustomRepo
109
@Binding var execPath: String
1110
@Binding var doLauncher: Bool
1211
@Binding var reloadMenuBarLauncher: Bool
@@ -144,11 +143,7 @@ struct CompilationView: View {
144143

145144
if !developmentEnvironment {
146145
shell.shell("cd ~/SM64Repos && rm -rf \(execPath)", false)
147-
if repo != .custom {
148-
shell.shell("cd ~/SM64Repos && rm -rf \(repo)", false)
149-
} else {
150-
shell.shell("cd ~/SM64Repos && rm -rf \(customRepo.name)", false)
151-
}
146+
shell.shell("cd ~/SM64Repos && rm -rf \(repo.name)", false)
152147
}
153148

154149
dismiss()
@@ -175,24 +170,16 @@ struct CompilationView: View {
175170
compilationStatus = .finished
176171
var execDir = ""
177172

178-
if repo == .custom {
179-
if developmentEnvironment {
180-
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(customRepo.name)/build/us_pc/\(customRepo.customEndFileName.isEmpty ? "sm64.us.f3dex2e" : customRepo.customEndFileName)"
181-
} else {
182-
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(execPath)/\(customRepo.customEndFileName.isEmpty ? "sm64.us.f3dex2e" : customRepo.customEndFileName)"
183-
}
173+
if developmentEnvironment {
174+
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(repo.name)/build/us_pc/\(repo.customEndFileName.isEmpty ? "sm64.us.f3dex2e" : repo.customEndFileName)"
184175
} else {
185-
if developmentEnvironment {
186-
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(repo)/build/us_pc/\(repo == .sm64coopdx ? "sm64coopdx" : "sm64.us.f3dex2e")"
187-
} else {
188-
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(execPath)/\(repo == .sm64coopdx ? "sm64coopdx" : "sm64.us.f3dex2e")"
189-
}
176+
execDir = "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(execPath)/\(repo.customEndFileName.isEmpty ? "sm64.us.f3dex2e" : repo.customEndFileName)"
190177
}
191178

192179
if FileManager.default.fileExists(atPath: execDir) {
193180
let content = UNMutableNotificationContent()
194181
content.title = "Build Finished Successfully"
195-
content.subtitle = "The repo \(repo == .custom ? customRepo.name : "\(repo)") has finished building successfully."
182+
content.subtitle = "The repo \(repo.name) has finished building successfully."
196183
content.sound = UNNotificationSound.default
197184

198185
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)
@@ -206,9 +193,9 @@ struct CompilationView: View {
206193
if doLauncher {
207194
let launcherRepo = LauncherRepos(context: moc)
208195

209-
launcherRepo.title = "\(repo == .custom ? customRepo.name : "\(repo)")"
196+
launcherRepo.title = repo.name
210197
launcherRepo.isEditing = false
211-
launcherRepo.path = "~/SM64Repos/\(execPath)/\(customRepo.customEndFileName.isEmpty || repo != .custom ? repo == .sm64coopdx ? "sm64coopdx" : "sm64.us.f3dex2e" : customRepo.customEndFileName)"
198+
launcherRepo.path = "~/SM64Repos/\(execPath)/\(repo.customEndFileName.isEmpty ? "sm64.us.f3dex2e" : repo.customEndFileName)"
212199
launcherRepo.args = ""
213200
launcherRepo.id = UUID()
214201

sm_osx/CustomRepo.swift

Lines changed: 0 additions & 12 deletions
This file was deleted.

sm_osx/CustomRepoView.swift

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import SwiftUI
33

44
struct CustomRepoView: View {
55

6-
let repo: Repo
7-
@State var customRepo = CustomRepo()
6+
@State var repo: Repo
87
@Binding var repoView: Bool
98
@Binding var reloadMenuBarLauncher: Bool
109
@Environment(\.dismiss) var dismiss
@@ -17,36 +16,36 @@ struct CustomRepoView: View {
1716

1817
GroupBox {
1918
VStack(alignment: .leading) {
20-
TextField("Name", text: $customRepo.name)
21-
.onChange(of: customRepo.name) { _ in
19+
TextField("Name", text: $repo.name)
20+
.onChange(of: repo.name) { _ in
2221
let filteredName
23-
= customRepo.name
22+
= repo.name
2423
.replacingOccurrences(of: " ", with: "")
25-
customRepo.name = filteredName
24+
repo.name = filteredName
2625
}
27-
TextField("Clone URL", text: $customRepo.cloneURL)
28-
.onChange(of: customRepo.cloneURL) { _ in
26+
TextField("Clone URL", text: $repo.cloneURL)
27+
.onChange(of: repo.cloneURL) { _ in
2928
let filteredCloneURL
30-
= customRepo.cloneURL
29+
= repo.cloneURL
3130
.replacingOccurrences(of: " ", with: "")
32-
customRepo.cloneURL = filteredCloneURL
31+
repo.cloneURL = filteredCloneURL
3332
}
34-
TextField("Branch", text: $customRepo.branch)
35-
.onChange(of: customRepo.cloneURL) { _ in
33+
TextField("Branch", text: $repo.branch)
34+
.onChange(of: repo.cloneURL) { _ in
3635
let filteredCloneURL
37-
= customRepo.cloneURL
36+
= repo.cloneURL
3837
.replacingOccurrences(of: " ", with: "")
39-
customRepo.cloneURL = filteredCloneURL
38+
repo.cloneURL = filteredCloneURL
4039
}
41-
TextField("Build Flags", text: $customRepo.buildFlags)
42-
TextField("Exec File Name (Usually leave empty)", text: $customRepo.customEndFileName)
43-
.onChange(of: customRepo.customEndFileName) { _ in
44-
let filteredCustomEndFileName = customRepo.customEndFileName.replacingOccurrences(of: " ", with: "")
45-
customRepo.customEndFileName = filteredCustomEndFileName
40+
TextField("Build Flags", text: $repo.buildFlags)
41+
TextField("Exec File Name (Usually leave empty)", text: $repo.customEndFileName)
42+
.onChange(of: repo.customEndFileName) { _ in
43+
let filteredCustomEndFileName = repo.customEndFileName.replacingOccurrences(of: " ", with: "")
44+
repo.customEndFileName = filteredCustomEndFileName
4645
}
47-
Toggle("Use OSX_BUILD=1 Build Flag", isOn: $customRepo.useOsxBuildFlag)
46+
Toggle("Use OSX_BUILD=1 Build Flag", isOn: $repo.useOsxBuildFlag)
4847
if isArm() {
49-
Toggle("Uses x86_64 (Intel)", isOn: $customRepo.x86_64)
48+
Toggle("Uses x86_64 (Intel)", isOn: $repo.x86_64)
5049
}
5150

5251
Spacer()
@@ -70,9 +69,9 @@ struct CustomRepoView: View {
7069

7170
Spacer()
7271

73-
NavigationLink("Next", value: customRepo)
72+
NavigationLink("Next", value: repo)
7473
.buttonStyle(.borderedProminent)
75-
.disabled(!customRepo.cloneURL.hasSuffix(".git") || customRepo.name.isEmpty)
74+
.disabled(!repo.cloneURL.hasSuffix(".git") || repo.name.isEmpty)
7675
}
7776
}
7877
.padding([.horizontal, .bottom])

sm_osx/DevelopmentEnvironment.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ struct DevelopmentEnvironment: View {
66
@Environment(\.dismiss) var dismiss
77
@Binding var fullCompileCommands: String
88
@Binding var repo: Repo
9-
@Binding var customRepo: CustomRepo
109
@Binding var execPath: String
1110
@Binding var doLauncher: Bool
1211
@Binding var reloadMenuBarLauncher: Bool
@@ -77,7 +76,7 @@ struct DevelopmentEnvironment: View {
7776
.disabled(!alreadyCompiled)
7877

7978
Button("Open Repo in Finder") {
80-
NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(repo == .custom ? customRepo.name : "\(repo)")")
79+
NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: "\(FileManager.default.homeDirectoryForCurrentUser.path())SM64Repos/\(repo.name)")
8180
}.disabled(!alreadyCompiled)
8281

8382
Button("Recompile from Scratch") {
@@ -99,7 +98,7 @@ struct DevelopmentEnvironment: View {
9998
}
10099
.frame(maxWidth: .infinity, maxHeight: .infinity)
101100
.sheet(isPresented: $compileRepo) {
102-
CompilationView(compileCommands: $compileCommand, repo: $repo, customRepo: $customRepo, execPath: $execPath, doLauncher: $doLauncher, reloadMenuBarLauncher: $reloadMenuBarLauncher, finishedCompiling: $alreadyCompiled, developmentEnvironment: .constant(true), fullExecPath: $fullExecPath)
101+
CompilationView(compileCommands: $compileCommand, repo: $repo, execPath: $execPath, doLauncher: $doLauncher, reloadMenuBarLauncher: $reloadMenuBarLauncher, finishedCompiling: $alreadyCompiled, developmentEnvironment: .constant(true), fullExecPath: $fullExecPath)
103102
}
104103
}
105104

sm_osx/Enums.swift

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11

22
import Foundation
33

4-
public enum Repo: String {
5-
case none = ""
6-
case sm64ex = "https://github.com/sm64pc/sm64ex.git"
7-
case sm64ex_alo = "https://github.com/AloUltraExt/sm64ex-alo.git"
8-
case moonshine = "https://github.com/EmeraldLoc/sm64-moonshine"
9-
case render96ex = "https://github.com/EmeraldLoc/Render96ex"
10-
case sm64ex_coop = "https://github.com/djoslin0/sm64ex-coop.git"
11-
case sm64coopdx = "https://github.com/coop-deluxe/sm64coopdx"
12-
case sm64ex_coop_dev = "https://github.com/sm64ex-coop-dev/sm64ex-coop.git -b dev"
13-
case custom = "custom"
14-
}
15-
16-
public enum Patches: String {
17-
case highfps = "60Fps"
18-
case debug = "Debug"
19-
case dev = "Dev"
20-
case extMoveset = "Extended Moveset"
21-
case bettercam = "Better Camera"
22-
case drawdistance = "No Draw Distance"
23-
case extData = "External Data"
24-
case timeTrials = "Time Trials"
25-
case captainToadStars = "Captain Toad Stars"
26-
case qolFixes = "Quality of Life Fixes"
27-
case qolFeatures = "Quality of Life Features"
28-
case star_road = "Super Mario Star Road"
29-
case nothing = ""
30-
}
31-
324
public enum CompStatus: Double {
33-
case patching = 45
5+
case nothing = 0
346
case instDependencies = 2
357
case instRepo = 15
368
case copyingFiles = 20
9+
case patching = 45
3710
case compiling = 65
3811
case finishingUp = 90
3912
case finished = 100
40-
case nothing = 0
4113
}
4214

4315
public enum Speed: String {

sm_osx/Patches.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
3+
public struct Patch: Hashable {
4+
var name = ""
5+
var repoCompatibility = [String()]
6+
var patchInstallationCommand = ""
7+
var buildFlags = ""
8+
}
9+
10+
public var builtinPatches = [
11+
"highfps": Patch(name: "60 FPS", repoCompatibility: ["sm64ex"], patchInstallationCommand: "git apply ./enhancements/60fps_ex.patch --ignore-whitespace --reject", buildFlags: ""),
12+
"highfpsalo": Patch(name: "60 FPS", repoCompatibility: ["sm64ex_alo"], patchInstallationCommand: "", buildFlags: "HIGH_FPS_PC=1"),
13+
"debug": Patch(name: "Debug", repoCompatibility: ["sm64coopdx"], patchInstallationCommand: "", buildFlags: "DEBUG=1"),
14+
"betterCam": Patch(name: "Better Camera (Puppycam)", repoCompatibility: ["sm64ex", "sm64ex_alo", "render96ex"], patchInstallationCommand: "", buildFlags: "BETTERCAMERA=1"),
15+
"noDrawDist": Patch(name: "No Draw Distance", repoCompatibility: ["sm64ex", "sm64ex_alo", "render96ex"], patchInstallationCommand: "", buildFlags: "NODRAWDISTANCE=1"),
16+
"extData": Patch(name: "External Data", repoCompatibility: ["sm64ex", "sm64ex_alo", "render96ex"], patchInstallationCommand: "", buildFlags: "EXTERNAL_DATA=1"),
17+
"timeTrials": Patch(name: "Time Trials", repoCompatibility: ["sm64ex"], patchInstallationCommand: "wget https://sm64pc.info/downloads/patches/time_trials.2.4.hotfix.patch && git apply --reject --ignore-whitespace 'time_trials.2.4.hotfix.patch'", buildFlags: ""),
18+
"qolFixes": Patch(name: "Quality of Life Fixes", repoCompatibility: ["sm64ex_alo"], patchInstallationCommand: "", buildFlags: "QOL_FIXES=1"),
19+
"qolFeatures": Patch(name: "Quality of Life Features", repoCompatibility: ["sm64ex_alo"], patchInstallationCommand: "", buildFlags: "QOL_FEATURES=1"),
20+
"star_road": Patch(name: "Super Mario Star Road", repoCompatibility: ["sm64ex_alo"], patchInstallationCommand: "wget -O star_road_release.patch http://drive.google.com/uc\\?id\\=1kXskWESOTUJDoeCGVV9JMUkn0tLd_GXO && git apply --reject --ignore-whitespace star_road_release.patch", buildFlags: ""),
21+
]
22+
23+
/*public enum Patches: String {
24+
case highfps = "60Fps"
25+
case debug = "Debug"
26+
case extMoveset = "Extended Moveset"
27+
case bettercam = "Better Camera"
28+
case drawdistance = "No Draw Distance"
29+
case extData = "External Data"
30+
case timeTrials = "Time Trials"
31+
case captainToadStars = "Captain Toad Stars"
32+
case qolFixes = "Quality of Life Fixes"
33+
case qolFeatures = "Quality of Life Features"
34+
case star_road = "Super Mario Star Road"
35+
case nothing = ""
36+
}*/

0 commit comments

Comments
 (0)