Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions PlayTools/PlayLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
49 changes: 49 additions & 0 deletions PlayTools/PlaySettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}