diff --git a/PlayTools/PlayLoader.m b/PlayTools/PlayLoader.m index ca928d69..6d3f6574 100644 --- a/PlayTools/PlayLoader.m +++ b/PlayTools/PlayLoader.m @@ -327,9 +327,29 @@ static int pt_usleep(useconds_t time) { DYLD_INTERPOSE(pt_unlink, unlink) DYLD_INTERPOSE(pt_usleep, usleep) +static void pt_applyUIScaleFactor(void) { + double uiScale = [[PlaySettings shared] uiScale]; + if (uiScale <= 0.0) { + uiScale = 0.77; + } + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + if (uiScale >= 0.76 && uiScale <= 0.78) { + [defaults removeObjectForKey:@"iOSMacScaleFactor"]; + [defaults removeObjectForKey:@"UINSLastUsedWindowScaleFactor"]; + } else if (uiScale >= 0.5 && uiScale <= 3.0) { + [defaults setDouble:uiScale forKey:@"iOSMacScaleFactor"]; + [defaults removeObjectForKey:@"UINSLastUsedWindowScaleFactor"]; + } else { + [defaults setDouble:1.0 forKey:@"iOSMacScaleFactor"]; + [defaults removeObjectForKey:@"UINSLastUsedWindowScaleFactor"]; + } + [defaults synchronize]; +} + @implementation PlayLoader static void __attribute__((constructor)) initialize(void) { + pt_applyUIScaleFactor(); [PlayCover launch]; if (ue_status == 0) { diff --git a/PlayTools/PlaySettings.swift b/PlayTools/PlaySettings.swift index a5f945b4..935a01fc 100644 --- a/PlayTools/PlaySettings.swift +++ b/PlayTools/PlaySettings.swift @@ -99,6 +99,8 @@ let settings = PlaySettings.shared @objc lazy var blockSleepSpamming = settingsData.blockSleepSpamming @objc lazy var ignoreUnityKeyboardInitializationError = settingsData.ignoreUnityKeyboardInitializationError + + @objc lazy var uiScale = settingsData.uiScale } struct AppSettingsData: Codable { @@ -134,4 +136,51 @@ struct AppSettingsData: Codable { var resizableAspectRatioHeight = 0 var blockSleepSpamming = false var ignoreUnityKeyboardInitializationError = false + var uiScale: Double = 0.77 + + init() {} + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + keymapping = try container.decodeIfPresent(Bool.self, forKey: .keymapping) ?? true + sensitivity = try container.decodeIfPresent(Float.self, forKey: .sensitivity) ?? 50 + disableTimeout = try container.decodeIfPresent(Bool.self, forKey: .disableTimeout) ?? false + 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) ?? 2 + aspectRatio = try container.decodeIfPresent(Int.self, forKey: .aspectRatio) ?? 1 + displayRotation = try container.decodeIfPresent(Int.self, forKey: .displayRotation) ?? 0 + notch = try container.decodeIfPresent(Bool.self, forKey: .notch) ?? false + bypass = try container.decodeIfPresent(Bool.self, forKey: .bypass) ?? false + discordActivity = try container.decodeIfPresent( + DiscordActivity.self, forKey: .discordActivity) ?? DiscordActivity() + version = try container.decodeIfPresent(String.self, forKey: .version) ?? "2.0.0" + playChain = try container.decodeIfPresent(Bool.self, forKey: .playChain) ?? false + playChainDebugging = try container.decodeIfPresent(Bool.self, forKey: .playChainDebugging) ?? false + inverseScreenValues = try container.decodeIfPresent(Bool.self, forKey: .inverseScreenValues) ?? false + windowFixMethod = try container.decodeIfPresent(Int.self, forKey: .windowFixMethod) ?? 0 + rootWorkDir = try container.decodeIfPresent(Bool.self, forKey: .rootWorkDir) ?? true + noKMOnInput = try container.decodeIfPresent(Bool.self, forKey: .noKMOnInput) ?? false + enableScrollWheel = try container.decodeIfPresent(Bool.self, forKey: .enableScrollWheel) ?? true + hideTitleBar = try container.decodeIfPresent(Bool.self, forKey: .hideTitleBar) ?? false + floatingWindow = try container.decodeIfPresent(Bool.self, forKey: .floatingWindow) ?? false + checkMicPermissionSync = try container.decodeIfPresent( + Bool.self, forKey: .checkMicPermissionSync) ?? false + limitMotionUpdateFrequency = try container.decodeIfPresent( + Bool.self, forKey: .limitMotionUpdateFrequency) ?? false + disableBuiltinMouse = try container.decodeIfPresent(Bool.self, forKey: .disableBuiltinMouse) ?? false + resizableAspectRatioType = try container.decodeIfPresent( + Int.self, forKey: .resizableAspectRatioType) ?? 0 + resizableAspectRatioWidth = try container.decodeIfPresent( + Int.self, forKey: .resizableAspectRatioWidth) ?? 0 + resizableAspectRatioHeight = try container.decodeIfPresent( + Int.self, forKey: .resizableAspectRatioHeight) ?? 0 + blockSleepSpamming = try container.decodeIfPresent(Bool.self, forKey: .blockSleepSpamming) ?? false + ignoreUnityKeyboardInitializationError = try container.decodeIfPresent( + Bool.self, forKey: .ignoreUnityKeyboardInitializationError) ?? false + let decodedUIScale = try container.decodeIfPresent(Double.self, forKey: .uiScale) ?? 0.77 + uiScale = decodedUIScale <= 0.0 ? 0.77 : decodedUIScale + } }