Skip to content

Commit 6704be3

Browse files
committed
Polish up transparency, improve source code.
1 parent f39fb7d commit 6704be3

File tree

10 files changed

+152
-128
lines changed

10 files changed

+152
-128
lines changed

sm_osx.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
CODE_SIGN_IDENTITY = "Apple Development";
416416
CODE_SIGN_STYLE = Automatic;
417417
COMBINE_HIDPI_IMAGES = YES;
418-
CURRENT_PROJECT_VERSION = 3;
418+
CURRENT_PROJECT_VERSION = 4;
419419
DEAD_CODE_STRIPPING = YES;
420420
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
421421
DEVELOPMENT_TEAM = 25RK3JMVLT;
@@ -431,7 +431,7 @@
431431
"@executable_path/../Frameworks",
432432
);
433433
MACOSX_DEPLOYMENT_TARGET = 13.0;
434-
MARKETING_VERSION = 1.3.0.1;
434+
MARKETING_VERSION = 1.3.0.2;
435435
ONLY_ACTIVE_ARCH = NO;
436436
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
437437
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -449,7 +449,7 @@
449449
CODE_SIGN_IDENTITY = "Apple Development";
450450
CODE_SIGN_STYLE = Automatic;
451451
COMBINE_HIDPI_IMAGES = YES;
452-
CURRENT_PROJECT_VERSION = 3;
452+
CURRENT_PROJECT_VERSION = 4;
453453
DEAD_CODE_STRIPPING = YES;
454454
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
455455
DEVELOPMENT_TEAM = 25RK3JMVLT;
@@ -465,7 +465,7 @@
465465
"@executable_path/../Frameworks",
466466
);
467467
MACOSX_DEPLOYMENT_TARGET = 13.0;
468-
MARKETING_VERSION = 1.3.0.1;
468+
MARKETING_VERSION = 1.3.0.2;
469469
ONLY_ACTIVE_ARCH = NO;
470470
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
471471
PRODUCT_NAME = "$(TARGET_NAME)";

sm_osx/AppearenceView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct AppearenceSettingsView: View {
66
@AppStorage("isGrid") var isGrid = false
77
@AppStorage("transparentBar") var transparentBar = TitlebarAppearence.normal
88
@AppStorage("transparency") var transparency = TransparencyAppearence.normal
9+
@AppStorage("transparencyDuringNotSelected") var transparencyDuringNotSelected = false
910

1011
var body: some View {
1112
List {
@@ -32,6 +33,11 @@ struct AppearenceSettingsView: View {
3233
Text("More")
3334
.tag(TransparencyAppearence.more)
3435
}
36+
37+
Toggle("Transparency When Window is not Selected", isOn: $transparencyDuringNotSelected)
38+
.disabled(transparency != .more)
39+
40+
3541
}.transparentListStyle().scrollDisabled(true)
3642
}
3743
}

sm_osx/DeveloperView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ struct DeveloperView: View {
1010
Toggle(isOn: $devMode.animation()) {
1111
Text("Enable development repos (Not recommended)")
1212
}
13-
}.scrollDisabled(true).transparentListStyle()
13+
}.transparentListStyle().scrollDisabled(true)
1414
}
1515
}

sm_osx/GlobalFunctions.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ public func showExecFilePanel() -> URL? {
3030
public func showApp() {
3131
NSApp.setActivationPolicy(.regular)
3232

33-
var openedWindow = false
34-
3533
for window in NSApplication.shared.windows {
3634
if window.title == "sm_osx" {
37-
window.orderFrontRegardless()
38-
39-
openedWindow = true
35+
window.orderFrontRegardless()
4036
}
4137
}
4238
}

sm_osx/LauncherListView.swift

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,72 @@ struct LauncherListView: View {
4343

4444
try? process.run()
4545
}
46-
46+
4747
var body: some View {
48-
ForEach(launcherRepos) { LauncherRepo in
49-
50-
let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0
51-
52-
HStack {
53-
Text(LauncherRepo.title ?? "Unknown Title")
48+
VStack {
49+
ForEach(launcherRepos) { LauncherRepo in
5450

55-
Spacer()
51+
let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0
5652

57-
Menu {
58-
Button {
59-
if launcherRepos.isEmpty { return }
60-
61-
for i in 0...launcherRepos.count - 1 {
62-
launcherRepos[i].isEditing = false
63-
}
64-
65-
openWindow(id: "regular-log", value: i)
66-
67-
print(LauncherRepo.path ?? "")
68-
} label: {
69-
Label("Log", systemImage: "play.fill")
70-
.labelStyle(.titleAndIcon)
71-
}
53+
HStack {
54+
Text(LauncherRepo.title ?? "Unknown Title")
7255

73-
Button {
74-
if launcherRepos.isEmpty { return }
56+
Spacer()
57+
58+
Menu {
59+
Button {
60+
if launcherRepos.isEmpty { return }
61+
62+
for i in 0...launcherRepos.count - 1 {
63+
launcherRepos[i].isEditing = false
64+
}
65+
66+
openWindow(id: "regular-log", value: i)
67+
68+
print(LauncherRepo.path ?? "")
69+
} label: {
70+
Label("Log", systemImage: "play.fill")
71+
.labelStyle(.titleAndIcon)
72+
}
7573

76-
for iEdit in 0...launcherRepos.count - 1 {
77-
launcherRepos[iEdit].isEditing = false
74+
Button {
75+
if launcherRepos.isEmpty { return }
76+
77+
for iEdit in 0...launcherRepos.count - 1 {
78+
launcherRepos[iEdit].isEditing = false
79+
}
80+
81+
launcherRepos[i].isEditing = true
82+
} label: {
83+
Label("Edit", systemImage: "pencil")
84+
.labelStyle(.titleAndIcon)
7885
}
7986

80-
launcherRepos[i].isEditing = true
87+
Button {
88+
if launcherRepos.isEmpty { return }
89+
90+
for i in 0...launcherRepos.count - 1 {
91+
launcherRepos[i].isEditing = false
92+
}
93+
94+
let launcherRepo = launcherRepos[i]
95+
96+
moc.delete(launcherRepo)
97+
98+
do {
99+
try moc.save()
100+
reloadMenuBarLauncher = true
101+
}
102+
catch {
103+
print("Error: its broken: \(error)")
104+
}
105+
} label: {
106+
Label("Trash", systemImage: "trash")
107+
.labelStyle(.titleAndIcon)
108+
}
81109
} label: {
82-
Label("Edit", systemImage: "pencil")
83-
.labelStyle(.titleAndIcon)
84-
}
110+
Text("Options")
111+
}.frame(idealWidth: 80, maxWidth: 80)
85112

86113
Button {
87114
if launcherRepos.isEmpty { return }
@@ -90,42 +117,17 @@ struct LauncherListView: View {
90117
launcherRepos[i].isEditing = false
91118
}
92119

93-
let launcherRepo = launcherRepos[i]
94-
95-
moc.delete(launcherRepo)
120+
launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")")
96121

97-
do {
98-
try moc.save()
99-
reloadMenuBarLauncher = true
100-
}
101-
catch {
102-
print("Error: its broken: \(error)")
103-
}
122+
print(LauncherRepo.path ?? "")
104123
} label: {
105-
Label("Trash", systemImage: "trash")
124+
Label("Play", systemImage: "play.fill")
106125
.labelStyle(.titleAndIcon)
107126
}
108-
} label: {
109-
Text("Options")
110-
}.frame(idealWidth: 80, maxWidth: 80)
111-
112-
Button {
113-
if launcherRepos.isEmpty { return }
114-
115-
for i in 0...launcherRepos.count - 1 {
116-
launcherRepos[i].isEditing = false
117-
}
118-
119-
try? launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")")
120-
121-
print(LauncherRepo.path ?? "")
122-
} label: {
123-
Label("Play", systemImage: "play.fill")
124-
.labelStyle(.titleAndIcon)
127+
}.sheet(isPresented: .constant(LauncherRepo.isEditing)) {
128+
LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher)
125129
}
126-
}.sheet(isPresented: .constant(LauncherRepo.isEditing)) {
127-
LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher)
128130
}
129-
}
131+
}.padding([.top, .horizontal], 5)
130132
}
131133
}

sm_osx/LauncherView.swift

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -96,56 +96,27 @@ struct LauncherView: View {
9696

9797
var body: some View {
9898
VStack {
99-
List {
100-
if !launcherRepos.isEmpty {
99+
if !launcherRepos.isEmpty {
100+
List {
101101
if isGrid {
102102
LauncherGridView(reloadMenuBarLauncher: $reloadMenuBarLauncher, existingRepo: $existingRepo)
103103
} else {
104104
LauncherListView(reloadMenuBarLauncher: $reloadMenuBarLauncher, existingRepo: $existingRepo)
105105
}
106106
}
107-
108-
if allowAddingRepos {
109-
Button(action:{
110-
111-
if !launcherRepos.isEmpty {
112-
for i in 0...launcherRepos.count - 1 {
113-
launcherRepos[i].isEditing = false
114-
}
115-
}
116-
117-
romURL = showOpenPanelForRom()
118-
119-
romURL? = URL(fileURLWithPath: romURL?.path.replacingOccurrences(of: " ", with: #"\ "#
120-
, options: .literal, range: nil) ?? "")
121-
122-
try? Shell().shell("cp \(romURL?.path ?? "") ~/SM64Repos/baserom.us.z64")
123-
124-
if let doesExist = try? checkRom("ls ~/SM64Repos/baserom.us.z64") {
125-
if doesExist {
126-
allowAddingRepos = true
127-
}
128-
else {
129-
allowAddingRepos = false
107+
.padding(.top, 0.1)
108+
.onChange(of: launchRepoAppleScript.repoID) { repoID in
109+
if !showMenuExtra {
110+
for i in 0...launcherRepos.count - 1 {
111+
if launcherRepos[i].id?.uuidString == repoID {
112+
launcherShell("\(launcherRepos[i].path ?? "its broken") \(launcherRepos[i].args ?? "")")
113+
114+
launchRepoAppleScript.repoID = ""
130115
}
131116
}
132-
}) {
133-
Text("Select Rom")
134-
}.buttonStyle(.borderedProminent)
135-
}
136-
}
137-
.transparentListStyle()
138-
.padding(.top, 0.1)
139-
.onChange(of: launchRepoAppleScript.repoID) { repoID in
140-
if !showMenuExtra {
141-
for i in 0...launcherRepos.count - 1 {
142-
if launcherRepos[i].id?.uuidString == repoID {
143-
launcherShell("\(launcherRepos[i].path ?? "its broken") \(launcherRepos[i].args ?? "")")
144-
145-
launchRepoAppleScript.repoID = ""
146-
}
147117
}
148118
}
119+
.scrollContentBackground(.hidden)
149120
}
150121

151122
if launcherRepos.isEmpty {
@@ -162,6 +133,35 @@ struct LauncherView: View {
162133
}
163134
}
164135

136+
if allowAddingRepos {
137+
Button(action:{
138+
139+
if !launcherRepos.isEmpty {
140+
for i in 0...launcherRepos.count - 1 {
141+
launcherRepos[i].isEditing = false
142+
}
143+
}
144+
145+
romURL = showOpenPanelForRom()
146+
147+
romURL? = URL(fileURLWithPath: romURL?.path.replacingOccurrences(of: " ", with: #"\ "#
148+
, options: .literal, range: nil) ?? "")
149+
150+
try? Shell().shell("cp \(romURL?.path ?? "") ~/SM64Repos/baserom.us.z64")
151+
152+
if let doesExist = try? checkRom("ls ~/SM64Repos/baserom.us.z64") {
153+
if doesExist {
154+
allowAddingRepos = true
155+
}
156+
else {
157+
allowAddingRepos = false
158+
}
159+
}
160+
}) {
161+
Text("Select Rom")
162+
}.buttonStyle(.borderedProminent)
163+
}
164+
165165
if !homebrewText.isEmpty {
166166
Text(homebrewText)
167167
.padding(.horizontal)
@@ -305,6 +305,6 @@ struct LauncherView: View {
305305
}.sheet(isPresented: $repoView) {
306306
RepoView(repoView: $repoView, reloadMenuBarLauncher: $reloadMenuBarLauncher)
307307
.frame(minWidth: 650, idealWidth: 750, maxWidth: 850, minHeight: 400, idealHeight: 500, maxHeight: 550)
308-
}.frame(minWidth: 300, minHeight: 250)
308+
}.frame(minWidth: 300, minHeight: 250).transparentBackgroundStyle()
309309
}
310310
}

sm_osx/RepoView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ struct RepoView: View {
7676
repoView = false
7777
}.padding(.vertical)
7878
}
79-
}.transparentListStyle().transparentBackgroundStyle()
79+
}.transparentBackgroundStyle()
8080
}
8181
}

sm_osx/UpdatesSettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ struct UpdatesSettingsView: View {
3737
}) {
3838
Text("Check Latest Changelog")
3939
}
40-
}.scrollDisabled(true).transparentListStyle()
40+
}.transparentListStyle().scrollDisabled(true)
4141
}
4242
}

0 commit comments

Comments
 (0)