Skip to content

Commit 2dc5306

Browse files
committed
v1.2.6
1 parent 8e249d9 commit 2dc5306

19 files changed

+406
-311
lines changed

sm_osx.xcodeproj/project.pbxproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
960A559729B29DC600F5CC37 /* PlayHover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 960A559629B29DC600F5CC37 /* PlayHover.swift */; };
11+
960A559929B2A50100F5CC37 /* LauncherEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 960A559829B2A50100F5CC37 /* LauncherEditView.swift */; };
1012
960D46F627D6850D0056E393 /* BuildingSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 960D46F527D6850D0056E393 /* BuildingSteps.swift */; };
1113
963F238327F8B211004E010E /* LauncherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963F238227F8B211004E010E /* LauncherView.swift */; };
1214
963F238627F8B942004E010E /* DataStore.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 963F238427F8B942004E010E /* DataStore.xcdatamodeld */; };
@@ -18,6 +20,7 @@
1820
9669DC6D27D55CD200DE5FAB /* Patches.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6C27D55CD200DE5FAB /* Patches.swift */; };
1921
9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */; };
2022
9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC7027D55F4700DE5FAB /* RomView.swift */; };
23+
96A3D83A29B52328007AF78A /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A3D83929B52328007AF78A /* ImagePicker.swift */; };
2124
96AC85B1286670B800CCFF58 /* MenuBarCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AC85B0286670B800CCFF58 /* MenuBarCommands.swift */; };
2225
96BB22E327E274F700057915 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB22E227E274F700057915 /* RepoView.swift */; };
2326
96BDA2F3283D216500A4DFF3 /* General View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BDA2F2283D216500A4DFF3 /* General View.swift */; };
@@ -31,6 +34,8 @@
3134
/* End PBXBuildFile section */
3235

3336
/* Begin PBXFileReference section */
37+
960A559629B29DC600F5CC37 /* PlayHover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayHover.swift; sourceTree = "<group>"; };
38+
960A559829B2A50100F5CC37 /* LauncherEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LauncherEditView.swift; sourceTree = "<group>"; };
3439
960D46F527D6850D0056E393 /* BuildingSteps.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildingSteps.swift; sourceTree = "<group>"; };
3540
963F238227F8B211004E010E /* LauncherView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LauncherView.swift; sourceTree = "<group>"; };
3641
963F238527F8B942004E010E /* DataStore.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DataStore.xcdatamodel; sourceTree = "<group>"; };
@@ -44,6 +49,7 @@
4449
9669DC6C27D55CD200DE5FAB /* Patches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Patches.swift; sourceTree = "<group>"; };
4550
9669DC6E27D55D5300DE5FAB /* PatchesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchesView.swift; sourceTree = "<group>"; };
4651
9669DC7027D55F4700DE5FAB /* RomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RomView.swift; sourceTree = "<group>"; };
52+
96A3D83929B52328007AF78A /* ImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePicker.swift; sourceTree = "<group>"; };
4753
96AC85B0286670B800CCFF58 /* MenuBarCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarCommands.swift; sourceTree = "<group>"; };
4854
96BB22E227E274F700057915 /* RepoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = "<group>"; };
4955
96BDA2F2283D216500A4DFF3 /* General View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "General View.swift"; sourceTree = "<group>"; };
@@ -110,6 +116,9 @@
110116
96BDA2F8283D29E300A4DFF3 /* LogView.swift */,
111117
96C54E6C285930D7003B4A2D /* GlobalFunctions.swift */,
112118
96AC85B0286670B800CCFF58 /* MenuBarCommands.swift */,
119+
960A559629B29DC600F5CC37 /* PlayHover.swift */,
120+
960A559829B2A50100F5CC37 /* LauncherEditView.swift */,
121+
96A3D83929B52328007AF78A /* ImagePicker.swift */,
113122
);
114123
path = sm_osx;
115124
sourceTree = "<group>";
@@ -203,13 +212,16 @@
203212
96BEADAE2839986200FF72E3 /* CompilationView.swift in Sources */,
204213
96CF3D4227DBD8C7008A26F5 /* CompilationSpeed.swift in Sources */,
205214
963F238327F8B211004E010E /* LauncherView.swift in Sources */,
215+
96A3D83A29B52328007AF78A /* ImagePicker.swift in Sources */,
206216
96BDA2F9283D29E300A4DFF3 /* LogView.swift in Sources */,
207217
9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */,
208218
96BDA2F3283D216500A4DFF3 /* General View.swift in Sources */,
209219
96DE71D327EB9C170090E7A0 /* SettingsView.swift in Sources */,
210220
96C54E6D285930D7003B4A2D /* GlobalFunctions.swift in Sources */,
211221
960D46F627D6850D0056E393 /* BuildingSteps.swift in Sources */,
222+
960A559729B29DC600F5CC37 /* PlayHover.swift in Sources */,
212223
96BDA2F7283D283200A4DFF3 /* CrashView.swift in Sources */,
224+
960A559929B2A50100F5CC37 /* LauncherEditView.swift in Sources */,
213225
9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */,
214226
9669DC6B27D5581F00DE5FAB /* Repos.swift in Sources */,
215227
96BB22E327E274F700057915 /* RepoView.swift in Sources */,
@@ -363,7 +375,7 @@
363375
"$(inherited)",
364376
"@executable_path/../Frameworks",
365377
);
366-
MARKETING_VERSION = 1.2.4;
378+
MARKETING_VERSION = 1.2.5;
367379
ONLY_ACTIVE_ARCH = NO;
368380
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
369381
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -395,7 +407,7 @@
395407
"$(inherited)",
396408
"@executable_path/../Frameworks",
397409
);
398-
MARKETING_VERSION = 1.2.4;
410+
MARKETING_VERSION = 1.2.5;
399411
ONLY_ACTIVE_ARCH = NO;
400412
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
401413
PRODUCT_NAME = "$(TARGET_NAME)";

sm_osx/CompilationView.swift

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ struct CompilationView: View {
1717
@Binding var execPath: String
1818
@Binding var doLauncher: Bool
1919
@State var shell = Shell()
20-
@State var log = ""
20+
@State var log = "Starting..."
2121
@State var totalLog = ""
22-
@State var height = 80
22+
@State var height = 100
2323
@Environment(\.dismiss) var dismiss
2424
@Environment(\.managedObjectContext) var moc
2525

@@ -30,8 +30,15 @@ struct CompilationView: View {
3030

3131
Spacer()
3232

33-
Text(log)
34-
.lineLimit(2)
33+
if !log.isEmpty {
34+
Text(log)
35+
.lineLimit(2)
36+
.padding([.horizontal, .top], 5)
37+
} else {
38+
Text(" ")
39+
.padding([.horizontal, .top], 5)
40+
.lineLimit(2)
41+
}
3542

3643
ProgressView(value: compilationStatus.rawValue, total: 100)
3744
.progressViewStyle(.linear)
@@ -43,19 +50,22 @@ struct CompilationView: View {
4350

4451
Button("Finish") {
4552
dismiss.callAsFunction()
46-
}
53+
}.padding(.bottom)
4754
}
4855

4956
if compilationStatus != .finished {
5057
HStack {
5158
Spacer()
5259

5360
Button("Cancel") {
61+
62+
log = "Canceling"
63+
5464
try? shell.shell("cd ~/SM64Repos && rm -rf \(execPath)", false)
5565
try? shell.shell("cd ~/SM64Repos && rm -rf \(repo)", false)
5666

5767
dismiss.callAsFunction()
58-
}.padding(.bottom).padding(.trailing)
68+
}.padding([.bottom, .trailing])
5969
}
6070
}
6171

@@ -76,11 +86,8 @@ struct CompilationView: View {
7686

7787
outHandle.readabilityHandler = { pipe in
7888
if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) {
79-
// Update your view with the new text here
80-
81-
let number = CharacterSet(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"])
82-
let lowerLetters = CharacterSet.lowercaseLetters
83-
let upperLetters = CharacterSet.uppercaseLetters
89+
let number = CharacterSet.decimalDigits
90+
let letters = CharacterSet.letters
8491

8592
print(line)
8693

@@ -92,10 +99,7 @@ struct CompilationView: View {
9299
if line.rangeOfCharacter(from: number) != nil {
93100
log = line
94101
}
95-
else if line.rangeOfCharacter(from: lowerLetters) != nil {
96-
log = line
97-
}
98-
else if line.rangeOfCharacter(from: upperLetters) != nil {
102+
else if line.rangeOfCharacter(from: letters) != nil {
99103
log = line
100104
}
101105
}

sm_osx/CrashView.swift

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,19 @@ struct CrashView: View {
1818
var body: some View {
1919
VStack {
2020
Text("Your Game Crashed")
21+
.padding(.top)
2122

22-
ScrollView {
23-
24-
TextEditor(text: $readableCrashLog)
25-
.frame(minWidth: 350, minHeight: 350)
26-
.onChange(of: readableCrashLog) { _ in
27-
readableCrashLog = launcherRepos[index].log ?? "Error, could not get log data. We are sorry for the inconvienience"
28-
}
29-
.onAppear {
30-
readableCrashLog = launcherRepos[index].log ?? "Error, could not get log data. We are sorry for the inconvienience"
31-
}
23+
ZStack {
24+
TextEditor(text: .constant(launcherRepos[index].log ?? "Error, could not get log data. We are sorry for the inconvienience"))
25+
.padding(.vertical)
26+
3227
}
3328

3429
Button("Close") {
3530
launcherRepos[index].log? = ""
3631

3732
crashStatus = false
38-
}
39-
}.frame(minWidth: 350, maxHeight: 350)
33+
}.padding(.bottom)
34+
}.frame(width: 400, height: 400)
4035
}
4136
}

sm_osx/DataController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ class DataController: ObservableObject {
1919
}
2020
}
2121
}
22-
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21E258" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
2+
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="22D68" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
33
<entity name="LauncherRepos" representedClassName="LauncherRepos" syncable="YES" codeGenerationType="class">
44
<attribute name="args" optional="YES" attributeType="String"/>
55
<attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
6+
<attribute name="imagePath" optional="YES" attributeType="String" valueTransformerName="" customClassName="NSImage"/>
67
<attribute name="isEditing" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
78
<attribute name="log" optional="YES" attributeType="String"/>
89
<attribute name="path" optional="YES" attributeType="String"/>
910
<attribute name="title" optional="YES" attributeType="String"/>
1011
</entity>
11-
<elements>
12-
<element name="LauncherRepos" positionX="-63" positionY="-18" width="128" height="119"/>
13-
</elements>
1412
</model>

sm_osx/General View.swift

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,57 @@
66
//
77

88
import SwiftUI
9+
import UserNotifications
910

1011
struct General_View: View {
1112

13+
func depsShell(_ command: String, _ waitTillExit: Bool = false) {
14+
let task = Process()
15+
16+
task.executableURL = URL(fileURLWithPath: "/bin/zsh")
17+
task.arguments = ["-cl", command]
18+
19+
let pipe = Pipe()
20+
task.standardOutput = pipe
21+
task.standardError = pipe
22+
let outHandle = pipe.fileHandleForReading
23+
24+
outHandle.readabilityHandler = { pipe in
25+
if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) {
26+
if line.contains("Finished installing deps") {
27+
isInstallingDeps = false
28+
29+
let content = UNMutableNotificationContent()
30+
content.title = "Finished installing dependencies"
31+
content.subtitle = "Dependencies are now installed."
32+
content.sound = UNNotificationSound.default
33+
34+
// show this notification instantly
35+
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)
36+
37+
// choose a random identifier
38+
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
39+
40+
// add our notification request
41+
UNUserNotificationCenter.current().add(request)
42+
}
43+
} else {
44+
print("Error decoding data. why do I program...: \(pipe.availableData)")
45+
}
46+
}
47+
48+
try? task.run()
49+
if waitTillExit {
50+
task.waitUntilExit()
51+
}
52+
}
53+
54+
@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
1255
@AppStorage("launchEntry") var launchEntry = true
1356
@AppStorage("compilationSpeed") var compilationSpeed: Speed = .normal
1457
@AppStorage("keepRepo") var keepRepo = false
1558
@AppStorage("checkUpdateAuto") var checkUpdateAuto = true
59+
@State var isInstallingDeps = false
1660

1761
var body: some View {
1862
ZStack {
@@ -42,14 +86,26 @@ struct General_View: View {
4286
Text("Fastest")
4387
.tag(Speed.fastest)
4488
}.frame(idealWidth: 200, maxWidth: 200)
89+
90+
Button(action:{
91+
if !launcherRepos.isEmpty {
92+
for i in 0...launcherRepos.count - 1 {
93+
launcherRepos[i].isEditing = false
94+
}
95+
}
96+
97+
isInstallingDeps = true
98+
99+
if isArm() {
100+
depsShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils; brew install make mingw-w64 gcc sdl2 pkg-config glew glfw3 libusb audiofile coreutils; echo 'Finished installing deps'")
101+
} else {
102+
depsShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils; echo 'Finished installing deps'")
103+
}
104+
}) {
105+
Text("Install Package Dependencies")
106+
}.buttonStyle(.bordered).padding(.bottom)
45107
}
46108
}
47109
}
48110
}
49111
}
50-
51-
struct General_View_Previews: PreviewProvider {
52-
static var previews: some View {
53-
General_View()
54-
}
55-
}

sm_osx/GlobalFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UniformTypeIdentifiers
1010
import AppKit
1111

1212
struct CurrentVersion {
13-
public let currentVersion = "v1.2.5\n"
13+
public let currentVersion = "v1.2.6\n"
1414
}
1515

1616
public func isArm() -> Bool {

sm_osx/ImagePicker.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import SwiftUI
2+
3+
struct ImagePicker: View {
4+
5+
@State var text: String
6+
@Binding var image: String?
7+
8+
var body: some View {
9+
HStack {
10+
Button(text) {
11+
let openPanel = NSOpenPanel()
12+
openPanel.prompt = "Select File"
13+
openPanel.allowsMultipleSelection = false
14+
openPanel.canChooseDirectories = false
15+
openPanel.canCreateDirectories = false
16+
openPanel.canChooseFiles = true
17+
openPanel.allowedContentTypes = [.image]
18+
openPanel.begin { (result) -> Void in
19+
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
20+
let selectedPath = openPanel.url!.path
21+
image = selectedPath
22+
}
23+
}
24+
}
25+
26+
Button {
27+
image = nil
28+
} label: {
29+
Image(systemName: "trash")
30+
}.disabled(image == nil)
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)