Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Merge Dev
  • Loading branch information
EmeraldLoc committed Mar 17, 2023
2 parents e9b2bb5 + 61ebd99 commit aa62059
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 107 deletions.
Binary file added sm-osx-Info.plist
Binary file not shown.
12 changes: 10 additions & 2 deletions sm_osx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
9669DC6D27D55CD200DE5FAB /* Patches.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6C27D55CD200DE5FAB /* Patches.swift */; };
9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC6E27D55D5300DE5FAB /* PatchesView.swift */; };
9669DC7127D55F4700DE5FAB /* RomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669DC7027D55F4700DE5FAB /* RomView.swift */; };
9697DF5B29C3883D008FD602 /* sm_osx_updater.app in Resources */ = {isa = PBXBuildFile; fileRef = 9697DF5A29C3883D008FD602 /* sm_osx_updater.app */; };
96A3D83A29B52328007AF78A /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A3D83929B52328007AF78A /* ImagePicker.swift */; };
96AC85B1286670B800CCFF58 /* MenuBarCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AC85B0286670B800CCFF58 /* MenuBarCommands.swift */; };
96BB22E327E274F700057915 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB22E227E274F700057915 /* RepoView.swift */; };
Expand All @@ -31,6 +32,7 @@
96C54E6D285930D7003B4A2D /* GlobalFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C54E6C285930D7003B4A2D /* GlobalFunctions.swift */; };
96CF3D4227DBD8C7008A26F5 /* CompilationSpeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */; };
96DE71D327EB9C170090E7A0 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DE71D227EB9C170090E7A0 /* SettingsView.swift */; };
96E529D729C511F000E8E14D /* InternetChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E529D629C511F000E8E14D /* InternetChecker.swift */; };
96EBED1329BA51970033771E /* UpdatesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EBED1229BA51970033771E /* UpdatesSettingsView.swift */; };
/* End PBXBuildFile section */

Expand All @@ -50,6 +52,7 @@
9669DC6C27D55CD200DE5FAB /* Patches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Patches.swift; sourceTree = "<group>"; };
9669DC6E27D55D5300DE5FAB /* PatchesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchesView.swift; sourceTree = "<group>"; };
9669DC7027D55F4700DE5FAB /* RomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RomView.swift; sourceTree = "<group>"; };
9697DF5A29C3883D008FD602 /* sm_osx_updater.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = sm_osx_updater.app; sourceTree = "<group>"; };
96A3D83929B52328007AF78A /* ImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePicker.swift; sourceTree = "<group>"; };
96AC85B0286670B800CCFF58 /* MenuBarCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarCommands.swift; sourceTree = "<group>"; };
96BB22E227E274F700057915 /* RepoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = "<group>"; };
Expand All @@ -62,6 +65,7 @@
96CF3D4127DBD8C7008A26F5 /* CompilationSpeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompilationSpeed.swift; sourceTree = "<group>"; };
96DE71D227EB9C170090E7A0 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
96DE71D427EB9C7D0090E7A0 /* sm-osx-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "sm-osx-Info.plist"; sourceTree = SOURCE_ROOT; };
96E529D629C511F000E8E14D /* InternetChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternetChecker.swift; sourceTree = "<group>"; };
96EBED1229BA51970033771E /* UpdatesSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatesSettingsView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -79,6 +83,7 @@
9669DC4F27D5565000DE5FAB = {
isa = PBXGroup;
children = (
9697DF5A29C3883D008FD602 /* sm_osx_updater.app */,
9669DC5A27D5565000DE5FAB /* sm_osx */,
9669DC5927D5565000DE5FAB /* Products */,
);
Expand Down Expand Up @@ -122,6 +127,7 @@
960A559829B2A50100F5CC37 /* LauncherEditView.swift */,
96A3D83929B52328007AF78A /* ImagePicker.swift */,
96EBED1229BA51970033771E /* UpdatesSettingsView.swift */,
96E529D629C511F000E8E14D /* InternetChecker.swift */,
);
path = sm_osx;
sourceTree = "<group>";
Expand Down Expand Up @@ -197,6 +203,7 @@
buildActionMask = 2147483647;
files = (
9669DC6327D5565100DE5FAB /* Preview Assets.xcassets in Resources */,
9697DF5B29C3883D008FD602 /* sm_osx_updater.app in Resources */,
9669DC6027D5565100DE5FAB /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -226,6 +233,7 @@
960A559729B29DC600F5CC37 /* PlayHover.swift in Sources */,
96BDA2F7283D283200A4DFF3 /* CrashView.swift in Sources */,
960A559929B2A50100F5CC37 /* LauncherEditView.swift in Sources */,
96E529D729C511F000E8E14D /* InternetChecker.swift in Sources */,
9669DC6F27D55D5300DE5FAB /* PatchesView.swift in Sources */,
9669DC6B27D5581F00DE5FAB /* Repos.swift in Sources */,
96BB22E327E274F700057915 /* RepoView.swift in Sources */,
Expand Down Expand Up @@ -382,7 +390,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.2.7.1;
MARKETING_VERSION = 1.2.8;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -415,7 +423,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.2.7.1;
MARKETING_VERSION = 1.2.8;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
90 changes: 49 additions & 41 deletions sm_osx/CompilationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct CompilationView: View {

Text(compilationStatusString)
.onChange(of: compilationStatus) { _ in

print(compilationStatus)

switch compilationStatus {
case .instDependencies:
compilationStatusString = "Installing Dependencies..."
Expand Down Expand Up @@ -128,56 +131,26 @@ struct CompilationView: View {
}
}

if log.contains("Installing Deps") {
compilationStatus = .instDependencies

log = prevLog
}
else if log.contains("Started Clone") {
compilationStatus = .instRepo

log = prevLog
}
else if log.contains("Patching Files") {
compilationStatus = .patching

log = prevLog
}
else if log.contains("Rom Files Done") {
compilationStatus = .copyingFiles

log = prevLog
}
else if log.contains("Compiling Now") {
compilationStatus = .compiling

log = prevLog
}
else if log.contains("Finishing Up") {
compilationStatus = .finishingUp

log = prevLog
}
else if log.contains("Finished Doin Stonks") {
if log.contains("Finished Doin Stonks") {
task.terminate()

log = prevLog

compilationStatus = .finished

if try! shell.shell("ls ~/SM64Repos/\(execPath)/sm64.us.f3dex2e | echo y", true) == "y\n" && repo != .moon64 {

let content = UNMutableNotificationContent()
content.title = "Build Finished Successfully"
content.subtitle = "The build \(repo) has finished successfully."
content.sound = UNNotificationSound.default

// show this notification instantly
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)

// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

// add our notification request
UNUserNotificationCenter.current().add(request)

Expand Down Expand Up @@ -213,13 +186,13 @@ struct CompilationView: View {
content.title = "Build Finished Successfully"
content.subtitle = "The build \(repo) has finished successfully."
content.sound = UNNotificationSound.default

// show this notification instantly
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)

// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

// add our notification request
UNUserNotificationCenter.current().add(request)

Expand Down Expand Up @@ -255,13 +228,13 @@ struct CompilationView: View {
content.title = "Build Failed"
content.subtitle = "The build \(repo) has failed."
content.sound = UNNotificationSound.default

// show this notification instantly
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)

// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

// add our notification request
UNUserNotificationCenter.current().add(request)

Expand All @@ -273,6 +246,41 @@ struct CompilationView: View {
try? shell.shell("cd ~/SM64Repos && rm -rf \(repo)", false)
}
}
else if log.contains("Finishing Up") {
compilationStatus = .finishingUp

log = prevLog
}
else if log.contains("Compiling Now") {
compilationStatus = .compiling

print(compilationStatus)

log = prevLog
}
else if log.contains("Patching Files") {
compilationStatus = .patching

log = prevLog
}
else if log.contains("Rom Files Done") {
compilationStatus = .copyingFiles

log = prevLog
}
else if log.contains("Started Clone") {
compilationStatus = .instRepo

log = prevLog
}
else if log.contains("Installing Deps") {
compilationStatus = .instDependencies

log = prevLog
}



} else {
print("Error decoding data. why do I program...: \(pipe.availableData)")
}
Expand Down
8 changes: 4 additions & 4 deletions sm_osx/GeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UserNotifications

struct GeneralView: View {

func depsShell(_ command: String, _ waitTillExit: Bool = false) {
public func depsShell(_ command: String, _ waitTillExit: Bool = false) {
let task = Process()

task.executableURL = URL(fileURLWithPath: "/bin/zsh")
Expand Down Expand Up @@ -55,6 +55,7 @@ struct GeneralView: View {
}

@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
@EnvironmentObject var network: NetworkMonitor
@AppStorage("launchEntry") var launchEntry = true
@AppStorage("compilationSpeed") var compilationSpeed: Speed = .normal
@AppStorage("keepRepo") var keepRepo = false
Expand Down Expand Up @@ -98,7 +99,7 @@ struct GeneralView: View {
}
}

withAnimation(.spring()) {
withAnimation() {
isInstallingDeps = true
}

Expand All @@ -109,12 +110,11 @@ struct GeneralView: View {
}
}) {
Text("Install Package Dependencies")
}.buttonStyle(.bordered).padding(.bottom)
}.buttonStyle(.bordered).padding(.bottom).disabled(!network.isConnected)

ProgressView()
.progressViewStyle(.linear)
.padding(.bottom)
.scaleEffect(isInstallingDeps ? 1 : 0.2)
.opacity(isInstallingDeps ? 1 : 0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion sm_osx/GlobalFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public func checkForUpdates() async -> Int {
var latestVersion = ""

do {
latestVersion = try await Shell().shell("curl -s https://raw.githubusercontent.com/EmeraldLoc/sm_osx/main/CurVer")
latestVersion = try Shell().shell("curl -s https://raw.githubusercontent.com/EmeraldLoc/sm_osx/main/CurVer")
}
catch {
print("Failed: \(error)")
Expand Down
2 changes: 1 addition & 1 deletion sm_osx/ImagePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ImagePicker: View {
Image(systemName: "trash")
}.disabled(image == nil)

if image != nil {
if image != nil && NSImage(contentsOf: URL(fileURLWithPath: image ?? "")) != nil {
Image(nsImage: NSImage(contentsOf: URL(fileURLWithPath: image ?? ""))!)
.resizable()
.frame(width: 35.56, height: 20)
Expand Down
22 changes: 22 additions & 0 deletions sm_osx/InternetChecker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


import Foundation
import Network

class NetworkMonitor: ObservableObject {
private let networkMonitor = NWPathMonitor()
private let workerQueue = DispatchQueue(label: "Monitor")
var isConnected = false

init() {
networkMonitor.pathUpdateHandler = { path in
self.isConnected = path.status == .satisfied
Task {
await MainActor.run {
self.objectWillChange.send()
}
}
}
networkMonitor.start(queue: workerQueue)
}
}
Loading

0 comments on commit aa62059

Please sign in to comment.