Skip to content

Commit

Permalink
Added Ui Improvements and other things
Browse files Browse the repository at this point in the history
  • Loading branch information
EmeraldLoc committed May 7, 2022
1 parent c4efd07 commit defb4c2
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 53 deletions.
8 changes: 4 additions & 4 deletions sm_osx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20;
CURRENT_PROJECT_VERSION = 21;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
ENABLE_HARDENED_RUNTIME = NO;
Expand All @@ -335,7 +335,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1.8;
MARKETING_VERSION = 1.1.9;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -353,7 +353,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20;
CURRENT_PROJECT_VERSION = 21;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
ENABLE_HARDENED_RUNTIME = NO;
Expand All @@ -367,7 +367,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1.8;
MARKETING_VERSION = 1.1.9;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
86 changes: 47 additions & 39 deletions sm_osx/LauncherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import UserNotifications
struct LauncherView: View {

@State var repoView = false
@AppStorage("devMode") var devMode = true
var shell = Shell()
@Environment(\.managedObjectContext) var moc
@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
@State var existingRepo = URL(string: "")
@State var repoTitle = ""
@State var currentVersion = "v1.1.8\n"
@State var currentVersion = "v1.1.9\n"
@State var updateAlert = false
@State var latestVersion = ""
@State var repoArgs = ""
Expand Down Expand Up @@ -143,6 +144,47 @@ struct LauncherView: View {

Spacer()

Menu {
Button(action: {

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

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

beginLogging = true

print(LauncherRepo.path ?? "")
}) {
Text("Log")

Image(systemName: "arrow.right.circle.fill")
}

Button(action: {

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

let launcherRepo = launcherRepos[i]

moc.delete(launcherRepo)

do {
try moc.save()
}
catch {
print("Error: its broken: \(error)")
}
}) {
Text("Remove Repo")
}
} label: {
Text("...")
}.frame(width: 40)

Button(action: {

for iEdit in 0...launcherRepos.count - 1 {
Expand Down Expand Up @@ -196,43 +238,6 @@ struct LauncherView: View {
}
}

Button(action: {

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

let launcherRepo = launcherRepos[i]

moc.delete(launcherRepo)

do {
try moc.save()
}
catch {
print("Error: its broken: \(error)")
}
}) {
Image(systemName: "trash")
}

Button(action: {

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

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

beginLogging = true

print(LauncherRepo.path ?? "")
}) {
Text("Log")

Image(systemName: "arrow.right.circle.fill")
}

Button(action: {

for i in 0...launcherRepos.count - 1 {
Expand Down Expand Up @@ -352,7 +357,10 @@ struct LauncherView: View {

print("its intel's turn nerd what an idiot man")

print(try? shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils"))
do {
try shell.intelShell("/usr/local/bin/brew install gcc gcc@9 sdl2 pkg-config glew glfw3 libusb audiofile coreutils")
}
catch {}

let content = UNMutableNotificationContent()
content.title = "Finished installing dependencies"
Expand Down
1 change: 1 addition & 0 deletions sm_osx/Patches.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
enum Patches: String {
case omm = "https://github.com/PeachyPeachSM64/sm64pc-omm.git"
case highfps = "60Fps"
case debug = "Debug"
case extMoveset = "Extended Moveset"
case bettercam = "Better Camera"
case drawdistance = "No Draw Distance"
Expand Down
25 changes: 22 additions & 3 deletions sm_osx/PatchesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct PatchesView: View {
@State var isCam = false
@State var isDist = false
@State var extData = false
@State var debug = false
@State var timeTrials = false
@State var isQOLFeat = false
@State var isQOLFix = false
Expand All @@ -34,6 +35,24 @@ struct PatchesView: View {
Spacer()

List {

if repo == .sm64ex_coop || repo == .sm64ex_coop_dev {
Toggle(isOn: $debug) {
Text("Debug")
.lineLimit(nil)
}.onChange(of: debug) { _ in

if debug {
patches.append(.debug)
}
else {
if let i = patches.firstIndex(of: .debug) {
patches.remove(at: i)
}
}
}
}

if repo == .sm64ex || repo == .moon64 || repo == .sm64ex_alo {
Toggle(isOn: $isFPS) {
Text("60 FPS")
Expand Down Expand Up @@ -114,8 +133,8 @@ struct PatchesView: View {
}

}
if repo == .sm64ex || repo == .sm64ex_coop || repo == .render96ex || repo == .moonshine || repo == .moon64 || repo == .sm64ex_master || repo == .sm64ex_alo {
if repo != .sm64ex_coop {
if repo == .sm64ex || repo == .sm64ex_coop || repo == .render96ex || repo == .moonshine || repo == .moon64 || repo == .sm64ex_master || repo == .sm64ex_alo || repo == .sm64ex_coop_dev {
if repo != .sm64ex_coop && repo != .sm64ex_coop_dev {
Toggle(isOn: $isCam) {
Text("Better Camera")
.lineLimit(nil)
Expand Down Expand Up @@ -150,7 +169,7 @@ struct PatchesView: View {
}
}

if repo != .sm64ex_coop {
if repo != .sm64ex_coop && repo != .sm64ex_coop_dev {
Toggle(isOn: $isDist) {
Text("No Draw Distance")
.lineLimit(nil)
Expand Down
9 changes: 9 additions & 0 deletions sm_osx/RepoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct RepoView: View {

@State var shell = RomView(patch: [Patches](), repo: .sm64ex, repoView: .constant(false))
@Binding var repoView: Bool
@AppStorage("devMode") var devMode = true

var body: some View {
NavigationView {
Expand Down Expand Up @@ -50,6 +51,14 @@ struct RepoView: View {
.lineLimit(nil)
}

if devMode {
NavigationLink(destination: PatchesView(repo: .sm64ex_coop_dev, repoView: $repoView)) {

Text("sm64ex-coop-dev (Only avalible to devs)")
.lineLimit(nil)
}
}

NavigationLink(destination: PatchesView(repo: .render96ex, repoView: $repoView)) {

Text("Render96ex")
Expand Down
1 change: 1 addition & 0 deletions sm_osx/Repos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ enum Repo: String {
case moon64 = "https://github.com/EmeraldLoc/Moon64"
case render96ex = "https://github.com/EmeraldLoc/sm64ex.git --branch alpha"
case sm64ex_coop = "https://github.com/djoslin0/sm64ex-coop.git"
case sm64ex_coop_dev = "https://github.com/sm64ex-coop-dev/sm64ex-coop.git"
}
18 changes: 11 additions & 7 deletions sm_osx/RomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Shell {

@State var log = ""

func intelShell(_ command: String) throws -> String {
func intelShell(_ command: String, _ doNonAsync: Bool = true) throws -> String {

var error: NSDictionary?
var returnOutput = ""
Expand All @@ -28,7 +28,7 @@ class Shell {
returnOutput.append("NSAppleScriptError: \(String(describing: error))")
}
}

return returnOutput
}

Expand Down Expand Up @@ -113,6 +113,7 @@ struct RomView: View {
@State var highFPS = 0
@State var qolFix = 0
@State var qolFeatures = 0
@State var debug = 0
@State var doLog = false
@State var compSpeed: Speed = .normal
@State var extData = 0
Expand All @@ -134,12 +135,12 @@ struct RomView: View {
ZStack {
VStack {

if repo == .sm64ex_coop || repo == .moon64 {
if repo == .sm64ex_coop || repo == .moon64 || repo == .sm64ex_coop_dev {
Text("\n For this repo, make sure you have the intel version of homebrew. To do this, launch your terminal with rosetta and follow install instructions at brew.sh")
.lineLimit(nil)
}

if repo == .sm64ex_coop {
if repo == .sm64ex_coop || repo == .sm64ex_coop_dev {
Button(action: {

log = ""
Expand Down Expand Up @@ -183,7 +184,7 @@ struct RomView: View {
//buffer
print(try shell.shell("ls ."))

log.append(try shell.intelShell("cd ~/SM64Repos/sm64ex-coop && gmake OSX_BUILD=1 TARGET_ARCH=x86_64-apple-darwin TARGET_BITS=64 EXTERNAL_DATA=\(extData) \(compSpeed.rawValue)"))
log.append(try shell.intelShell("cd ~/SM64Repos/sm64ex-coop && gmake OSX_BUILD=1 TARGET_ARCH=x86_64-apple-darwin TARGET_BITS=64 EXTERNAL_DATA=\(extData) DEBUG=\(debug) \(compSpeed.rawValue)"))
}
catch {
status = .error
Expand All @@ -193,7 +194,7 @@ struct RomView: View {

status = .finishingUp

var execPath = "sm64ex-coop-build"
var execPath = "\(repo)-build"

if doKeepRepo {
let checkExecPath = try? shell.shell("ls ~/SM64Repos/")
Expand Down Expand Up @@ -232,7 +233,7 @@ struct RomView: View {
if doLauncher {
let launcherRepo = LauncherRepos(context: moc)

launcherRepo.title = "sm64ex-coop"
launcherRepo.title = "\(repo)"
launcherRepo.isEditing = false
launcherRepo.path = "~/SM64Repos/\(execPath)/sm64.us.f3dex2e"
launcherRepo.args = ""
Expand Down Expand Up @@ -817,6 +818,9 @@ struct RomView: View {
if patch.contains(.highfps) {
highFPS = 1
}
if patch.contains(.debug) {
debug = 1
}

doLog = logData
compSpeed = compilationSpeed
Expand Down
5 changes: 5 additions & 0 deletions sm_osx/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct SettingsView: View {

@AppStorage("logData") var logData = false
@AppStorage("launchEntry") var launchEntry = true
@AppStorage("devMode") var devMode = true
@AppStorage("compilationSpeed") var compilationSpeed: Speed = .normal

var body: some View {
Expand All @@ -37,6 +38,10 @@ struct SettingsView: View {
Text("Fastest")
.tag(Speed.fastest)
}

Toggle(isOn: $devMode) {
Text("Enable dev repos (Not recommended)")
}
}
}
}
Expand Down

0 comments on commit defb4c2

Please sign in to comment.