Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into MaaTools
Browse files Browse the repository at this point in the history
  • Loading branch information
hguandl committed Apr 3, 2023
2 parents 5446811 + e5c99b4 commit 9db495f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PlayCover/AppInstaller/Installer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Installer {
return response == .alertFirstButtonReturn
}

// swiftlint:disable function_body_length
// swiftlint:disable:next function_body_length
static func install(ipaUrl: URL, export: Bool, returnCompletion: @escaping (URL?) -> Void) {
// If (the option key is held or the install playtools popup settings is true) and its not an export,
// then show the installer dialog
Expand Down
2 changes: 2 additions & 0 deletions PlayCover/Model/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct AppSettingsData: Codable {
var iosDeviceModel = "iPad13,8"
var windowWidth = 1920
var windowHeight = 1080
var customScaler = 2.0
var resolution = 1
var aspectRatio = 1
var notch: Bool = NSScreen.hasNotch()
Expand Down Expand Up @@ -44,6 +45,7 @@ struct AppSettingsData: Codable {
iosDeviceModel = try container.decodeIfPresent(String.self, forKey: .iosDeviceModel) ?? "iPad13,8"
windowWidth = try container.decodeIfPresent(Int.self, forKey: .windowWidth) ?? 1920
windowHeight = try container.decodeIfPresent(Int.self, forKey: .windowHeight) ?? 1080
customScaler = try container.decodeIfPresent(Double.self, forKey: .customScaler) ?? 2.0
resolution = try container.decodeIfPresent(Int.self, forKey: .resolution) ?? 1
aspectRatio = try container.decodeIfPresent(Int.self, forKey: .aspectRatio) ?? 1
notch = try container.decodeIfPresent(Bool.self, forKey: .notch) ?? NSScreen.hasNotch()
Expand Down
4 changes: 2 additions & 2 deletions PlayCover/Utils/Extensions/DataExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
// PlayCover
//

// swiftlint:disable force_unwrapping

import Foundation

// swiftlint:disable force_unwrapping
extension String {
init(data: Data, offset: Int, commandSize: Int, loadCommandString: lc_str) {
let loadCommandStringOffset = Int(loadCommandString.offset)
Expand All @@ -32,3 +31,4 @@ extension Data {
return result
}
}
// swiftlint:enable force_unwrapping
6 changes: 3 additions & 3 deletions PlayCover/Utils/PlayTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PlayTools {
try Macho.stripBinary(&binary)

Inject.injectMachO(machoPath: exec.path,
cmdType: .loadDylib,
cmdType: .LOAD_DYLIB,
backup: false,
injectPath: playToolsPath.path,
finishHandle: { result in
Expand Down Expand Up @@ -118,7 +118,7 @@ class PlayTools {
try Macho.stripBinary(&binary)

Inject.injectMachO(machoPath: exec.path,
cmdType: .loadDylib,
cmdType: .LOAD_DYLIB,
backup: false,
injectPath: "@executable_path/Frameworks/PlayTools.dylib",
finishHandle: { result in
Expand Down Expand Up @@ -172,7 +172,7 @@ class PlayTools {

static func removeFromApp(_ exec: URL) {
Inject.removeMachO(machoPath: exec.path,
cmdType: .loadDylib,
cmdType: .LOAD_DYLIB,
backup: false,
injectPath: playToolsPath.path,
finishHandle: { result in
Expand Down
42 changes: 40 additions & 2 deletions PlayCover/Views/AppSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct AppSettingsView: View {
Text("settings.tab.info")
}
}
.frame(minWidth: 450, minHeight: 200)
.frame(minWidth: 500, minHeight: 250)
HStack {
Spacer()
Button("settings.resetSettings") {
Expand Down Expand Up @@ -184,6 +184,16 @@ struct GraphicsView: View {
return formatter
}

@State var customScaler = 2.0
static var fractionFormatter: NumberFormatter {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.maximumFractionDigits = 1
formatter.minimumFractionDigits = 1
formatter.decimalSeparator = "."
return formatter
}

var body: some View {
ScrollView {
VStack {
Expand Down Expand Up @@ -285,6 +295,28 @@ struct GraphicsView: View {
Spacer()
}
}
HStack {
Text("settings.picker.scaler")
Spacer()
Stepper {
TextField(
"settings.text.scaler",
value: $customScaler,
formatter: GraphicsView.fractionFormatter,
onCommit: {
Task { @MainActor in
NSApp.keyWindow?.makeFirstResponder(nil)
}
})
.frame(width: 125)
} onIncrement: {
customScaler += 0.1
} onDecrement: {
if customScaler > 0.5 {
customScaler -= 0.1
}
}
}
VStack(alignment: .leading) {
if #available(macOS 13.2, *) {
HStack {
Expand Down Expand Up @@ -316,6 +348,7 @@ struct GraphicsView: View {
.onAppear {
customWidth = settings.settings.windowWidth
customHeight = settings.settings.windowHeight
customScaler = settings.settings.customScaler
}
.onChange(of: settings.settings.resolution) { _ in
setResolution()
Expand All @@ -329,6 +362,9 @@ struct GraphicsView: View {
.onChange(of: customHeight) { _ in
setResolution()
}
.onChange(of: customScaler) { _ in
setResolution()
}
}
}

Expand Down Expand Up @@ -365,8 +401,10 @@ struct GraphicsView: View {

settings.settings.windowWidth = width
settings.settings.windowHeight = height
settings.settings.customScaler = customScaler

showResolutionWarning = width*height >= 2621440 // Tends to crash when the number of pixels exceeds that
showResolutionWarning = Double(width * height) * customScaler >= 2621440 * 2.0
// Tends to crash when the number of pixels exceeds that
}

func getWidthFromAspectRatio(_ height: Int) -> Int {
Expand Down
1 change: 1 addition & 0 deletions PlayCover/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"settings.toggle.disableDisplaySleep.help" = "Prevent display from turning off while this app is running";
"settings.noPlayTools" = "PlayTools is not installed in this app";
"settings.highResolution" = "High resolution may cause crashing";
"settings.picker.scaler" = "Resolution Scaler";

"settings.tab.bypasses" = "Bypasses";
"settings.toggle.jbBypass" = "Enable Jailbreak Bypass (Experimental)";
Expand Down

0 comments on commit 9db495f

Please sign in to comment.