Skip to content

Commit

Permalink
Polish up transparency, improve source code.
Browse files Browse the repository at this point in the history
  • Loading branch information
EmeraldLoc committed Apr 18, 2023
1 parent f39fb7d commit 6704be3
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 128 deletions.
8 changes: 4 additions & 4 deletions sm_osx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
Expand All @@ -431,7 +431,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.3.0.1;
MARKETING_VERSION = 1.3.0.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -449,7 +449,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
Expand All @@ -465,7 +465,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.3.0.1;
MARKETING_VERSION = 1.3.0.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
6 changes: 6 additions & 0 deletions sm_osx/AppearenceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct AppearenceSettingsView: View {
@AppStorage("isGrid") var isGrid = false
@AppStorage("transparentBar") var transparentBar = TitlebarAppearence.normal
@AppStorage("transparency") var transparency = TransparencyAppearence.normal
@AppStorage("transparencyDuringNotSelected") var transparencyDuringNotSelected = false

var body: some View {
List {
Expand All @@ -32,6 +33,11 @@ struct AppearenceSettingsView: View {
Text("More")
.tag(TransparencyAppearence.more)
}

Toggle("Transparency When Window is not Selected", isOn: $transparencyDuringNotSelected)
.disabled(transparency != .more)


}.transparentListStyle().scrollDisabled(true)
}
}
2 changes: 1 addition & 1 deletion sm_osx/DeveloperView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ struct DeveloperView: View {
Toggle(isOn: $devMode.animation()) {
Text("Enable development repos (Not recommended)")
}
}.scrollDisabled(true).transparentListStyle()
}.transparentListStyle().scrollDisabled(true)
}
}
6 changes: 1 addition & 5 deletions sm_osx/GlobalFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ public func showExecFilePanel() -> URL? {
public func showApp() {
NSApp.setActivationPolicy(.regular)

var openedWindow = false

for window in NSApplication.shared.windows {
if window.title == "sm_osx" {
window.orderFrontRegardless()

openedWindow = true
window.orderFrontRegardless()
}
}
}
Expand Down
126 changes: 64 additions & 62 deletions sm_osx/LauncherListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,45 +43,72 @@ struct LauncherListView: View {

try? process.run()
}

var body: some View {
ForEach(launcherRepos) { LauncherRepo in

let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0

HStack {
Text(LauncherRepo.title ?? "Unknown Title")
VStack {
ForEach(launcherRepos) { LauncherRepo in

Spacer()
let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0

Menu {
Button {
if launcherRepos.isEmpty { return }

for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}

openWindow(id: "regular-log", value: i)

print(LauncherRepo.path ?? "")
} label: {
Label("Log", systemImage: "play.fill")
.labelStyle(.titleAndIcon)
}
HStack {
Text(LauncherRepo.title ?? "Unknown Title")

Button {
if launcherRepos.isEmpty { return }
Spacer()

Menu {
Button {
if launcherRepos.isEmpty { return }

for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}

openWindow(id: "regular-log", value: i)

print(LauncherRepo.path ?? "")
} label: {
Label("Log", systemImage: "play.fill")
.labelStyle(.titleAndIcon)
}

for iEdit in 0...launcherRepos.count - 1 {
launcherRepos[iEdit].isEditing = false
Button {
if launcherRepos.isEmpty { return }

for iEdit in 0...launcherRepos.count - 1 {
launcherRepos[iEdit].isEditing = false
}

launcherRepos[i].isEditing = true
} label: {
Label("Edit", systemImage: "pencil")
.labelStyle(.titleAndIcon)
}

launcherRepos[i].isEditing = true
Button {
if launcherRepos.isEmpty { return }

for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}

let launcherRepo = launcherRepos[i]

moc.delete(launcherRepo)

do {
try moc.save()
reloadMenuBarLauncher = true
}
catch {
print("Error: its broken: \(error)")
}
} label: {
Label("Trash", systemImage: "trash")
.labelStyle(.titleAndIcon)
}
} label: {
Label("Edit", systemImage: "pencil")
.labelStyle(.titleAndIcon)
}
Text("Options")
}.frame(idealWidth: 80, maxWidth: 80)

Button {
if launcherRepos.isEmpty { return }
Expand All @@ -90,42 +117,17 @@ struct LauncherListView: View {
launcherRepos[i].isEditing = false
}

let launcherRepo = launcherRepos[i]

moc.delete(launcherRepo)
launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")")

do {
try moc.save()
reloadMenuBarLauncher = true
}
catch {
print("Error: its broken: \(error)")
}
print(LauncherRepo.path ?? "")
} label: {
Label("Trash", systemImage: "trash")
Label("Play", systemImage: "play.fill")
.labelStyle(.titleAndIcon)
}
} label: {
Text("Options")
}.frame(idealWidth: 80, maxWidth: 80)

Button {
if launcherRepos.isEmpty { return }

for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}

try? launcherShell("\(LauncherRepo.path ?? "its broken") \(LauncherRepo.args ?? "")")

print(LauncherRepo.path ?? "")
} label: {
Label("Play", systemImage: "play.fill")
.labelStyle(.titleAndIcon)
}.sheet(isPresented: .constant(LauncherRepo.isEditing)) {
LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher)
}
}.sheet(isPresented: .constant(LauncherRepo.isEditing)) {
LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher)
}
}
}.padding([.top, .horizontal], 5)
}
}
82 changes: 41 additions & 41 deletions sm_osx/LauncherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,56 +96,27 @@ struct LauncherView: View {

var body: some View {
VStack {
List {
if !launcherRepos.isEmpty {
if !launcherRepos.isEmpty {
List {
if isGrid {
LauncherGridView(reloadMenuBarLauncher: $reloadMenuBarLauncher, existingRepo: $existingRepo)
} else {
LauncherListView(reloadMenuBarLauncher: $reloadMenuBarLauncher, existingRepo: $existingRepo)
}
}

if allowAddingRepos {
Button(action:{

if !launcherRepos.isEmpty {
for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}
}

romURL = showOpenPanelForRom()

romURL? = URL(fileURLWithPath: romURL?.path.replacingOccurrences(of: " ", with: #"\ "#
, options: .literal, range: nil) ?? "")

try? Shell().shell("cp \(romURL?.path ?? "") ~/SM64Repos/baserom.us.z64")

if let doesExist = try? checkRom("ls ~/SM64Repos/baserom.us.z64") {
if doesExist {
allowAddingRepos = true
}
else {
allowAddingRepos = false
.padding(.top, 0.1)
.onChange(of: launchRepoAppleScript.repoID) { repoID in
if !showMenuExtra {
for i in 0...launcherRepos.count - 1 {
if launcherRepos[i].id?.uuidString == repoID {
launcherShell("\(launcherRepos[i].path ?? "its broken") \(launcherRepos[i].args ?? "")")

launchRepoAppleScript.repoID = ""
}
}
}) {
Text("Select Rom")
}.buttonStyle(.borderedProminent)
}
}
.transparentListStyle()
.padding(.top, 0.1)
.onChange(of: launchRepoAppleScript.repoID) { repoID in
if !showMenuExtra {
for i in 0...launcherRepos.count - 1 {
if launcherRepos[i].id?.uuidString == repoID {
launcherShell("\(launcherRepos[i].path ?? "its broken") \(launcherRepos[i].args ?? "")")

launchRepoAppleScript.repoID = ""
}
}
}
.scrollContentBackground(.hidden)
}

if launcherRepos.isEmpty {
Expand All @@ -162,6 +133,35 @@ struct LauncherView: View {
}
}

if allowAddingRepos {
Button(action:{

if !launcherRepos.isEmpty {
for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}
}

romURL = showOpenPanelForRom()

romURL? = URL(fileURLWithPath: romURL?.path.replacingOccurrences(of: " ", with: #"\ "#
, options: .literal, range: nil) ?? "")

try? Shell().shell("cp \(romURL?.path ?? "") ~/SM64Repos/baserom.us.z64")

if let doesExist = try? checkRom("ls ~/SM64Repos/baserom.us.z64") {
if doesExist {
allowAddingRepos = true
}
else {
allowAddingRepos = false
}
}
}) {
Text("Select Rom")
}.buttonStyle(.borderedProminent)
}

if !homebrewText.isEmpty {
Text(homebrewText)
.padding(.horizontal)
Expand Down Expand Up @@ -305,6 +305,6 @@ struct LauncherView: View {
}.sheet(isPresented: $repoView) {
RepoView(repoView: $repoView, reloadMenuBarLauncher: $reloadMenuBarLauncher)
.frame(minWidth: 650, idealWidth: 750, maxWidth: 850, minHeight: 400, idealHeight: 500, maxHeight: 550)
}.frame(minWidth: 300, minHeight: 250)
}.frame(minWidth: 300, minHeight: 250).transparentBackgroundStyle()
}
}
2 changes: 1 addition & 1 deletion sm_osx/RepoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ struct RepoView: View {
repoView = false
}.padding(.vertical)
}
}.transparentListStyle().transparentBackgroundStyle()
}.transparentBackgroundStyle()
}
}
2 changes: 1 addition & 1 deletion sm_osx/UpdatesSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ struct UpdatesSettingsView: View {
}) {
Text("Check Latest Changelog")
}
}.scrollDisabled(true).transparentListStyle()
}.transparentListStyle().scrollDisabled(true)
}
}
Loading

0 comments on commit 6704be3

Please sign in to comment.