Skip to content

Commit 68aeb7f

Browse files
committed
Added args and fixed id bug
1 parent 5e7108e commit 68aeb7f

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21E230" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
33
<entity name="LauncherRepos" representedClassName="LauncherRepos" syncable="YES" codeGenerationType="class">
4+
<attribute name="args" optional="YES" attributeType="String"/>
5+
<attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
46
<attribute name="isEditing" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
57
<attribute name="path" optional="YES" attributeType="String"/>
68
<attribute name="title" optional="YES" attributeType="String"/>
79
</entity>
810
<elements>
9-
<element name="LauncherRepos" positionX="-63" positionY="-18" width="128" height="74"/>
11+
<element name="LauncherRepos" positionX="-63" positionY="-18" width="128" height="104"/>
1012
</elements>
1113
</model>

sm_osx/LauncherView.swift

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ struct LauncherView: View {
1616
@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
1717
@State var existingRepo = URL(string: "")
1818
@State var repoTitle = ""
19-
@State var currentVersion = "v1.1.0\n"
19+
@State var currentVersion = "v1.1.2\n"
2020
@State var updateAlert = false
2121
@State var latestVersion = ""
22+
@State var repoArgs = ""
2223
@AppStorage("firstLaunch") var firstLaunch = true
2324
let sm64: UTType = .init(filenameExtension: "f3dex2e")!
2425

@@ -50,19 +51,33 @@ struct LauncherView: View {
5051

5152
Button(action: {
5253

53-
for i in 0...launcherRepos.count - 1 {
54-
launcherRepos[i].isEditing = false
54+
for iEdit in 0...launcherRepos.count - 1 {
55+
launcherRepos[iEdit].isEditing = false
5556
}
5657

5758
launcherRepos[i].isEditing = true
5859
}) {
5960
Image(systemName: "pencil")
6061
}.popover(isPresented: Binding.constant(launcherRepos[i].isEditing)) {
6162

62-
HStack {
63+
VStack {
6364
TextField("Name of Repo", text: $repoTitle)
65+
.lineLimit(nil)
66+
.scaledToFill()
6467
.onChange(of: repoTitle) { _ in
6568
launcherRepos[i].title = repoTitle
69+
do {
70+
try moc.save()
71+
}
72+
catch {
73+
print("Its broken \(error)")
74+
}
75+
}
76+
TextField("Arguments", text: $repoArgs)
77+
.lineLimit(nil)
78+
.scaledToFill()
79+
.onChange(of: repoArgs) { _ in
80+
launcherRepos[i].args = repoArgs
6681

6782
do {
6883
try moc.save()
@@ -71,7 +86,10 @@ struct LauncherView: View {
7186
print("Its broken \(error)")
7287
}
7388
}
74-
}.onAppear {repoTitle = launcherRepos[i].title ?? ""}
89+
}.onAppear {
90+
repoTitle = launcherRepos[i].title ?? ""
91+
repoArgs = launcherRepos[i].args ?? ""
92+
}
7593
}
7694

7795
Button(action: {
@@ -91,7 +109,7 @@ struct LauncherView: View {
91109
}
92110

93111
Button(action: {
94-
try? print(shell.shell("\(LauncherRepo.path ?? "its broken")"))
112+
try? print(shell.shell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")"))
95113

96114
print(LauncherRepo.path ?? "")
97115
}) {
@@ -131,6 +149,8 @@ struct LauncherView: View {
131149

132150
repo.title = "Repo \(launcherRepos.count)"
133151
repo.path = existingRepo?.path
152+
repo.args = ""
153+
repo.id = UUID()
134154

135155
do {
136156
try moc.save()
@@ -161,7 +181,7 @@ struct LauncherView: View {
161181
}
162182

163183
if firstLaunch {
164-
try? shell.shell("cd ~/ && mkdir SM64Repos")
184+
try? print(shell.shell("cd ~/ && mkdir SM64Repos"))
165185
}
166186

167187
if launcherRepos.isEmpty {return}

sm_osx/RomView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ struct RomView: View {
133133
launcherRepo.title = "sm64ex-coop"
134134
launcherRepo.isEditing = false
135135
launcherRepo.path = "~/SM64Repos/sm64ex-coop-build/sm64.us.f3dex2e"
136+
launcherRepo.args = ""
137+
launcherRepo.id = UUID()
136138

137139
do {
138140
try moc.save()
@@ -316,6 +318,8 @@ struct RomView: View {
316318
launcherRepo.title = "\(repo)"
317319
launcherRepo.isEditing = false
318320
launcherRepo.path = "~/SM64Repos/\(repo)-build/moon64.us.f3dex2e"
321+
launcherRepo.args = ""
322+
launcherRepo.id = UUID()
319323

320324
do {
321325
try moc.save()
@@ -330,6 +334,8 @@ struct RomView: View {
330334
launcherRepo.title = "\(repo)"
331335
launcherRepo.isEditing = false
332336
launcherRepo.path = "~/SM64Repos/\(repo)-build/sm64.us.f3dex2e"
337+
launcherRepo.args = ""
338+
launcherRepo.id = UUID()
333339

334340
do {
335341
try moc.save()
@@ -422,6 +428,8 @@ struct RomView: View {
422428
launcherRepo.title = "sm64port"
423429
launcherRepo.isEditing = false
424430
launcherRepo.path = "~/SM64Repos/sm64port-build/sm64.us.f3dex2e"
431+
launcherRepo.args = ""
432+
launcherRepo.id = UUID()
425433

426434
do {
427435
try moc.save()

0 commit comments

Comments
 (0)