2.4
This commit is contained in:
parent
94343b3f3b
commit
834b7e6b02
@ -18,6 +18,7 @@ struct ContentView: View {
|
||||
@AppStorage("useTrollStore") var useTrollStore: Bool = false
|
||||
@AppStorage("showMetalHUD") var showMetalHUD: Bool = false
|
||||
@AppStorage("canShowMetalHUD") var canShowMetalHUD: Bool = false
|
||||
@AppStorage("HideMenuButton") private var HideMenuButton: Bool = true
|
||||
@State var core = Core(games: [], root: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0])
|
||||
var body: some View {
|
||||
//NavView(core: $core) // pain and suffering
|
||||
|
@ -38,7 +38,10 @@ class SudachiEmulationViewModel: ObservableObject {
|
||||
|
||||
iscustom = ((sudachiGame?.fileURL.startAccessingSecurityScopedResource()) != nil)
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async { [self] in
|
||||
print(sudachiGame)
|
||||
|
||||
print("is outside url? \(iscustom ? "Yes" : "no")")
|
||||
DispatchQueue.global(qos: .userInteractive).async { [self] in
|
||||
if let sudachiGame = self.sudachiGame {
|
||||
|
||||
if sudachiGame.fileURL == URL(string: "BootMii") {
|
||||
@ -61,12 +64,7 @@ class SudachiEmulationViewModel: ObservableObject {
|
||||
|
||||
private func step() {
|
||||
while true {
|
||||
if !isPaused {
|
||||
sudachi.step()
|
||||
} else {
|
||||
print("pased")
|
||||
}
|
||||
|
||||
sudachi.step()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ struct SudachiEmulationView: View {
|
||||
@State private var timer: Timer?
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@AppStorage("isairplay") private var isairplay: Bool = true
|
||||
@AppStorage("HideMenuButton") private var HideMenuButton: Bool = true
|
||||
let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
|
||||
@ -43,70 +44,71 @@ struct SudachiEmulationView: View {
|
||||
|
||||
|
||||
ControllerView()
|
||||
|
||||
VStack {
|
||||
HStack {
|
||||
Spacer()
|
||||
Menu {
|
||||
Button {
|
||||
if let metalView = mtkview {
|
||||
print("button pressed")
|
||||
|
||||
let lastDrawableDisplayed = metalView.currentDrawable?.texture
|
||||
|
||||
if let imageRef = lastDrawableDisplayed?.toImage() {
|
||||
let uiImage: UIImage = UIImage.init(cgImage: imageRef)
|
||||
if !HideMenuButton {
|
||||
VStack {
|
||||
HStack {
|
||||
Spacer()
|
||||
Menu {
|
||||
Button {
|
||||
if let metalView = mtkview {
|
||||
print("button pressed")
|
||||
|
||||
if let pngData = uiImage.pngData() {
|
||||
// Define the path to save the PNG file
|
||||
if let game = self.game {
|
||||
let fileURL = documentsDir.appendingPathComponent("screenshots/\(game.title)-(\(Date())).png")
|
||||
print(Date())
|
||||
do {
|
||||
// Write the PNG data to the file
|
||||
try pngData.write(to: fileURL)
|
||||
print("Image saved to: \(fileURL.path)")
|
||||
} catch {
|
||||
print("Error saving PNG: \(error)")
|
||||
let lastDrawableDisplayed = metalView.currentDrawable?.texture
|
||||
|
||||
if let imageRef = lastDrawableDisplayed?.toImage() {
|
||||
let uiImage: UIImage = UIImage.init(cgImage: imageRef)
|
||||
|
||||
if let pngData = uiImage.pngData() {
|
||||
// Define the path to save the PNG file
|
||||
if let game = self.game {
|
||||
let fileURL = documentsDir.appendingPathComponent("screenshots/\(game.title)-(\(Date())).png")
|
||||
print(Date())
|
||||
do {
|
||||
// Write the PNG data to the file
|
||||
try pngData.write(to: fileURL)
|
||||
print("Image saved to: \(fileURL.path)")
|
||||
} catch {
|
||||
print("Error saving PNG: \(error)")
|
||||
}
|
||||
} else {
|
||||
let fileURL = documentsDir.appendingPathComponent("screenshots/Home_Menu-(\(Date())).png")
|
||||
|
||||
do {
|
||||
// Write the PNG data to the file
|
||||
try pngData.write(to: fileURL)
|
||||
print("Image saved to: \(fileURL.path)")
|
||||
} catch {
|
||||
print("Error saving PNG: \(error)")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let fileURL = documentsDir.appendingPathComponent("screenshots/Home_Menu-(\(Date())).png")
|
||||
|
||||
do {
|
||||
// Write the PNG data to the file
|
||||
try pngData.write(to: fileURL)
|
||||
print("Image saved to: \(fileURL.path)")
|
||||
} catch {
|
||||
print("Error saving PNG: \(error)")
|
||||
}
|
||||
print("Failed to convert UIImage to PNG data")
|
||||
}
|
||||
} else {
|
||||
print("Failed to convert UIImage to PNG data")
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Text("Take Screenshot")
|
||||
.font(.title)
|
||||
.padding()
|
||||
}
|
||||
|
||||
Button {
|
||||
viewModel.customButtonTapped()
|
||||
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
} label: {
|
||||
Text("Exit (Unstable)")
|
||||
}
|
||||
|
||||
} label: {
|
||||
Text("Take Screenshot")
|
||||
.font(.title)
|
||||
.padding()
|
||||
Image(systemName: "ellipsis.circle.fill")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.foregroundColor(Color.gray)
|
||||
}
|
||||
|
||||
Button {
|
||||
viewModel.customButtonTapped()
|
||||
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
} label: {
|
||||
Text("Exit (Unstable)")
|
||||
}
|
||||
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle.fill")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.foregroundColor(Color.gray)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.overlay(
|
||||
|
@ -12,11 +12,28 @@ import Sudachi
|
||||
struct BottomMenuView: View {
|
||||
@Binding var core: Core
|
||||
@State var isImporting: Bool = false
|
||||
@State var isSelecting: Bool = false
|
||||
|
||||
@State var urlgame: PomeloGame?
|
||||
|
||||
@State var startgame = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 40) {
|
||||
|
||||
NavigationLink(
|
||||
destination: urlgame != nil ? AnyView(SudachiEmulationView(game: urlgame!)) : AnyView(EmptyView()),
|
||||
// destination: SudachiEmulationView(game: urlgame),
|
||||
isActive: $startgame,
|
||||
label: {
|
||||
EmptyView() // Keeps the link hidden
|
||||
}
|
||||
)
|
||||
.hidden()
|
||||
|
||||
Button {
|
||||
if let url = URL(string: "messages://") { // Replace appScheme with the actual URL scheme of the app
|
||||
if let url = URL(string: "messages://") {
|
||||
if UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [:]) { (success) in
|
||||
if success {
|
||||
@ -51,8 +68,19 @@ struct BottomMenuView: View {
|
||||
.foregroundColor(Color.init(uiColor: .darkGray))
|
||||
}
|
||||
|
||||
Button {
|
||||
isImporting = true
|
||||
Menu {
|
||||
Button {
|
||||
isImporting = true
|
||||
} label: {
|
||||
Text("Import Files")
|
||||
}
|
||||
|
||||
Button {
|
||||
isSelecting = true
|
||||
isImporting.toggle()
|
||||
} label: {
|
||||
Text("Open Game (without importing)")
|
||||
}
|
||||
} label: {
|
||||
Circle()
|
||||
.overlay {
|
||||
@ -63,6 +91,7 @@ struct BottomMenuView: View {
|
||||
.frame(width: 50, height: 50)
|
||||
.foregroundColor(Color.init(uiColor: .darkGray))
|
||||
}
|
||||
|
||||
|
||||
|
||||
NavigationLink(destination: SettingsView(core: core)) {
|
||||
@ -89,52 +118,86 @@ struct BottomMenuView: View {
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 20)
|
||||
|
||||
.fileImporter(isPresented: $isImporting, allowedContentTypes: [.zip, .item]) { result in
|
||||
switch result {
|
||||
case .success(let url):
|
||||
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
if url.lastPathComponent.hasSuffix(".zip") {
|
||||
core.AddFirmware(at: url)
|
||||
if isSelecting {
|
||||
startGame(url: url)
|
||||
isSelecting = false
|
||||
} else {
|
||||
addGame(url: url)
|
||||
}
|
||||
|
||||
if core.supportedFileTypes.contains(url.pathExtension.lowercased()) {
|
||||
let fileManager = FileManager.default
|
||||
let has = url.startAccessingSecurityScopedResource()
|
||||
do {
|
||||
// Move the file
|
||||
try fileManager.copyItem(at: url, to: directory.appendingPathComponent("roms").appendingPathComponent(url.lastPathComponent))
|
||||
} catch {
|
||||
print("Error moving file: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
if has {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
}
|
||||
|
||||
if url.lastPathComponent.hasSuffix(".keys") {
|
||||
let fileManager = FileManager.default
|
||||
let has = url.startAccessingSecurityScopedResource()
|
||||
do {
|
||||
// Move the file
|
||||
try fileManager.copyItem(at: url, to: directory.appendingPathComponent("keys").appendingPathComponent(url.lastPathComponent))
|
||||
} catch {
|
||||
print("Error moving file: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
if has {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
|
||||
let sudachi = Sudachi.shared
|
||||
|
||||
sudachi.refreshKeys()
|
||||
}
|
||||
|
||||
core.refreshcore(core: &core)
|
||||
case .failure(let err):
|
||||
print(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func startGame(url: URL) {
|
||||
if core.supportedFileTypes.contains(url.pathExtension.lowercased()) {
|
||||
let bool = url.startAccessingSecurityScopedResource()
|
||||
|
||||
defer {
|
||||
if bool {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
|
||||
startgame = true
|
||||
}
|
||||
}
|
||||
let sudachi = Sudachi.shared
|
||||
|
||||
let info = sudachi.information(for: url)
|
||||
|
||||
let game = PomeloGame(programid: Int(info.programID), ishomebrew: info.isHomebrew, developer: info.developer, fileURL: url, imageData: info.iconData, title: info.title)
|
||||
|
||||
|
||||
urlgame = game
|
||||
print(game)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func addGame(url: URL) {
|
||||
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
if url.lastPathComponent.hasSuffix(".zip") {
|
||||
core.AddFirmware(at: url)
|
||||
}
|
||||
|
||||
if core.supportedFileTypes.contains(url.pathExtension.lowercased()) {
|
||||
let fileManager = FileManager.default
|
||||
let has = url.startAccessingSecurityScopedResource()
|
||||
do {
|
||||
// Move the file
|
||||
try fileManager.copyItem(at: url, to: directory.appendingPathComponent("roms").appendingPathComponent(url.lastPathComponent))
|
||||
} catch {
|
||||
print("Error moving file: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
if has {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
}
|
||||
|
||||
if url.lastPathComponent.hasSuffix(".keys") {
|
||||
let fileManager = FileManager.default
|
||||
let has = url.startAccessingSecurityScopedResource()
|
||||
do {
|
||||
// Move the file
|
||||
try fileManager.copyItem(at: url, to: directory.appendingPathComponent("keys").appendingPathComponent(url.lastPathComponent))
|
||||
} catch {
|
||||
print("Error moving file: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
if has {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
|
||||
let sudachi = Sudachi.shared
|
||||
|
||||
sudachi.refreshKeys()
|
||||
}
|
||||
|
||||
core.refreshcore(core: &core)
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,7 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
<key>com.apple.developer.kernel.extended-virtual-addressing</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.kernel.increased-debugging-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.kernel.increased-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -2,21 +2,7 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
<key>com.apple.developer.kernel.extended-virtual-addressing</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.kernel.increased-debugging-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.kernel.increased-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -58,6 +58,7 @@ struct AdvancedSettingsView: View {
|
||||
.padding(.bottom)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray)
|
||||
|
||||
if canShowMetalHUD {// (Int(UIDevice.current.systemVersion) ?? 0 >= 16) || canShowMetalHUD {
|
||||
Rectangle()
|
||||
.fill(Color(uiColor: UIColor.secondarySystemBackground))
|
||||
|
@ -119,7 +119,7 @@ struct SettingsView: View {
|
||||
.frame(width: .infinity, height: 50) // Set the desired dimensions
|
||||
.overlay() {
|
||||
HStack {
|
||||
Text("Advanced Settings")
|
||||
Text("App Settings")
|
||||
.foregroundColor(.primary)
|
||||
.padding()
|
||||
Spacer()
|
||||
@ -128,31 +128,6 @@ struct SettingsView: View {
|
||||
|
||||
}
|
||||
.padding()
|
||||
if isshown {
|
||||
Rectangle()
|
||||
.fill(Color(uiColor: UIColor.secondarySystemBackground)) // Set the fill color (optional)
|
||||
.cornerRadius(10) // Apply rounded corners
|
||||
.frame(width: .infinity, height: 50) // Set the desired dimensions
|
||||
.overlay() {
|
||||
HStack(alignment: .center) {
|
||||
SignInApple()
|
||||
.frame(width: 200, height: 50)
|
||||
.foregroundColor(Color(uiColor: UIColor.secondarySystemBackground))
|
||||
}
|
||||
.onAppear {
|
||||
ASAuthorizationAppleIDProvider().getCredentialState(forUserID: deviceOwnerID ?? "0") { state, error in
|
||||
if state != .authorized {
|
||||
isshown = true
|
||||
UserDefaults.standard.set(nil, forKey: "deviceOwnerName")
|
||||
UserDefaults.standard.set(nil, forKey: "deviceOwnerID")
|
||||
} else {
|
||||
isshown = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
|
||||
NavigationLink(destination: AppIconSwitcherView()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user