Allow changing resolution while in game (1.13+)

For now, this only works properly on Minecraft 1.13+. Older version
doesn't seem to get the new resolution (will be fixed later)

Additional changes:
- Make ingame settings background transparent
- Set prefersHomeIndicatorAutoHidden to YES
This commit is contained in:
Duy Tran Khanh committed 2022-09-05 19:38:39 +07:00
1 parent 4726cf6e3c
commit d42d4e963e
2 files changed
+20 -9

No files matched your search

+4 -1
View File
@@ -30,6 +30,10 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *);
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
self.tableView.sectionHeaderHeight = 50;
if (self.navigationController == nil) {
self.tableView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
}
BOOL(^whenNotInGame)() = ^BOOL(){
return self.navigationController != nil;
};
@@ -108,7 +112,6 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *);
@{@"key": @"resolution",
@"icon": @"viewfinder",
@"type": self.typeSlider,
@"enableCondition": whenNotInGame,
@"min": @(25),
@"max": @(150)
},
+16 -8
View File
@@ -222,8 +222,8 @@ BOOL slideableHotbar;
resolutionScale = ((NSNumber *)getPreference(@"resolution")).floatValue / 100.0;
savedWidth = roundf(screenBounds.size.width * screenScale);
savedHeight = roundf(screenBounds.size.height * screenScale);
savedWidth = roundf(screenBounds.size.width * screenScale * resolutionScale);
savedHeight = roundf(screenBounds.size.height * screenScale * resolutionScale);
self.rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width + 30.0, self.view.frame.size.height)];
[self.view addSubview:self.rootView];
@@ -410,11 +410,12 @@ self.view.frame.size.width * 0.3 - 36.0 * 0.7, self.view.frame.size.height)];
slideableHotbar = [getPreference(@"slideable_hotbar") boolValue];
virtualMouseEnabled = [getPreference(@"virtmouse_enable") boolValue];
if (!isGrabbing) {
self.mousePointerView.hidden = !virtualMouseEnabled;
}
self.mousePointerView.hidden = isGrabbing || !virtualMouseEnabled;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGRect screenBounds = UIScreen.mainScreen.bounds;
CGFloat screenScale = UIScreen.mainScreen.scale;
// Update virtual mouse scale
CGFloat mouseScale = [getPreference(@"mouse_scale") floatValue] / 100.0;
virtualMouseFrame = CGRectMake(screenBounds.size.width / 2, screenBounds.size.height / 2, 18.0 * mouseScale, 27 * mouseScale);
self.mousePointerView.frame = virtualMouseFrame;
@@ -425,6 +426,13 @@ self.view.frame.size.width * 0.3 - 36.0 * 0.7, self.view.frame.size.height)];
self.ctrlView.frame = CGRectFromString(getPreference(@"control_safe_area"));
[self loadCustomControls];
// Update resolution
resolutionScale = [getPreference(@"resolution") floatValue] / 100.0;
self.surfaceView.layer.contentsScale = screenScale * resolutionScale;
savedWidth = roundf(screenBounds.size.width * screenScale * resolutionScale);
savedHeight = roundf(screenBounds.size.height * screenScale * resolutionScale);
CallbackBridge_nativeSendScreenSize(savedWidth, savedHeight);
}
- (void)launchMinecraft {
@@ -434,7 +442,7 @@ self.view.frame.size.width * 0.3 - 36.0 * 0.7, self.view.frame.size.height)];
launchJVM(
BaseAuthenticator.current.authData[@"username"],
json,
savedWidth * resolutionScale, savedHeight * resolutionScale,
savedWidth, savedHeight,
[json[@"javaVersion"][@"majorVersion"] intValue]
);
}];
@@ -484,7 +492,7 @@ self.view.frame.size.width * 0.3 - 36.0 * 0.7, self.view.frame.size.height)];
}
- (BOOL)prefersHomeIndicatorAutoHidden {
return NO;
return YES;
}
#pragma mark - Menu functions