Add RAM slider, part 2
Fully functional.
This commit is contained in:
1 parent
44b3fe879a
commit
b3fe21efb4
2 files changed
+33
-19
No files matched your search
+12
-6
@@ -71,11 +71,10 @@ static pthread_t logger;
|
||||
|
||||
const char *javaHome;
|
||||
const char *renderer;
|
||||
const char *allocmem;
|
||||
NSString *javaHome_pre;
|
||||
NSString *renderer_pre;
|
||||
|
||||
NSString *javaHome_pre;
|
||||
NSString *gl4esLibname_pre;
|
||||
NSString *allocmem_pre;
|
||||
|
||||
void init_loadCustomEnv() {
|
||||
FILE *envFile = fopen(env_path, "r");
|
||||
@@ -358,6 +357,8 @@ int launchJVM(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
allocmem_pre = [getPreference(@"allocated_memory") stringValue];
|
||||
allocmem = [allocmem_pre cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
char controlPath[2048];
|
||||
sprintf(controlPath, "%s/controlmap", homeDir);
|
||||
mkdir(controlPath, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
@@ -365,9 +366,9 @@ int launchJVM(int argc, char *argv[]) {
|
||||
generateAndSaveDefaultControl();
|
||||
|
||||
char classpath[10000];
|
||||
|
||||
|
||||
// "/Applications/PojavLauncher.app/libs/launcher.jar:/Applications/PojavLauncher.app/libs/ExagearApacheCommons.jar:/Applications/PojavLauncher.app/libs/gson-2.8.6.jar:/Applications/PojavLauncher.app/libs/jsr305.jar:/Applications/PojavLauncher.app/libs/lwjgl3-minecraft.jar";
|
||||
|
||||
|
||||
// Generate classpath
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
@@ -386,19 +387,24 @@ int launchJVM(int argc, char *argv[]) {
|
||||
if (!started) {
|
||||
char *frameworkPath = calloc(1, 2048);
|
||||
char *javaPath = calloc(1, 2048);
|
||||
char *rendererPath = calloc(1, 2048);
|
||||
char *userDir = calloc(1, 2048);
|
||||
char *userHome = calloc(1, 2048);
|
||||
char *memMin = calloc(1, 2048);
|
||||
char *memMax = calloc(1, 2048);
|
||||
snprintf(frameworkPath, 2048, "-Djava.library.path=%s/Frameworks", getenv("BUNDLE_PATH"));
|
||||
snprintf(javaPath, 2048, "%s/bin/java", javaHome);
|
||||
snprintf(userDir, 2048, "-Duser.dir=%s/Documents/minecraft", getenv("HOME"));
|
||||
snprintf(userHome, 2048, "-Duser.home=%s/Documents", getenv("HOME"));
|
||||
snprintf(memMin, 2048, "-Xms%sM", allocmem);
|
||||
snprintf(memMax, 2048, "-Xmx%sM", allocmem);
|
||||
|
||||
chdir(userDir);
|
||||
|
||||
margv[margc++] = javaPath;
|
||||
margv[margc++] = "-XstartOnFirstThread";
|
||||
margv[margc++] = "-Djava.system.class.loader=net.kdt.pojavlaunch.PojavClassLoader";
|
||||
margv[margc++] = memMin;
|
||||
margv[margc++] = memMax;
|
||||
margv[margc++] = frameworkPath;
|
||||
margv[margc++] = userDir;
|
||||
margv[margc++] = userHome;
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
|
||||
#define BTNSCALE 0
|
||||
#define RESOLUTION 1
|
||||
#define JARGS 2
|
||||
#define REND 3
|
||||
#define JHOME 4
|
||||
#define NOSHADERCONV 5
|
||||
#define ALLOCMEM 2
|
||||
#define JARGS 3
|
||||
#define REND 4
|
||||
#define JHOME 5
|
||||
#define NOSHADERCONV 6
|
||||
|
||||
@interface LauncherPreferencesViewController () <UIPopoverPresentationControllerDelegate> {
|
||||
}
|
||||
@@ -181,16 +182,18 @@
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:BTNSCALE];}];
|
||||
UIAction *option2 = [UIAction actionWithTitle:@"Resolution" image:[[UIImage systemImageNamed:@"viewfinder"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:RESOLUTION];}];
|
||||
UIAction *option3 = [UIAction actionWithTitle:@"Java arguments" image:[[UIImage systemImageNamed:@"character.cursor.ibeam"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
UIAction *option3 = [UIAction actionWithTitle:@"Allocated RAM" image:[[UIImage systemImageNamed:@"memorychip"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:ALLOCMEM];}];
|
||||
UIAction *option4 = [UIAction actionWithTitle:@"Java arguments" image:[[UIImage systemImageNamed:@"character.cursor.ibeam"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:JARGS];}];
|
||||
UIAction *option4 = [UIAction actionWithTitle:@"Renderer" image:[[UIImage systemImageNamed:@"cpu"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
UIAction *option5 = [UIAction actionWithTitle:@"Renderer" image:[[UIImage systemImageNamed:@"cpu"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:REND];}];
|
||||
UIAction *option5 = [UIAction actionWithTitle:@"Java home" image:[[UIImage systemImageNamed:@"folder"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
UIAction *option6 = [UIAction actionWithTitle:@"Java home" image:[[UIImage systemImageNamed:@"folder"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:JHOME];}];
|
||||
UIAction *option6 = [UIAction actionWithTitle:@"Disable shaderconv" image:[[UIImage systemImageNamed:@"circle.lefthalf.fill"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
UIAction *option7 = [UIAction actionWithTitle:@"Disable shaderconv" image:[[UIImage systemImageNamed:@"circle.lefthalf.fill"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:NOSHADERCONV];}];
|
||||
UIMenu *menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil
|
||||
options:UIMenuOptionsDisplayInline children:@[option1, option2, option3, option4, option5, option6]];
|
||||
options:UIMenuOptionsDisplayInline children:@[option1, option2, option3, option4, option5, option6, option7]];
|
||||
self.navigationItem.rightBarButtonItem.action = nil;
|
||||
self.navigationItem.rightBarButtonItem.primaryAction = nil;
|
||||
self.navigationItem.rightBarButtonItem.menu = menu;
|
||||
@@ -225,6 +228,7 @@
|
||||
UIAlertController *helpAlert = [UIAlertController alertControllerWithTitle:@"Needing help with these preferences?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction *btnscale = [UIAlertAction actionWithTitle:@"Button scale" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:BTNSCALE];}];
|
||||
UIAlertAction *resolution = [UIAlertAction actionWithTitle:@"Resolution" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:RESOLUTION];}];
|
||||
UIAlertAction *allocmem = [UIAlertAction actionWithTitle:@"Allocated RAM" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:ALLOCMEM];}];
|
||||
UIAlertAction *jargs = [UIAlertAction actionWithTitle:@"Java arguments" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:JARGS];}];
|
||||
UIAlertAction *renderer = [UIAlertAction actionWithTitle:@"Renderer" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:REND];}];
|
||||
UIAlertAction *jhome = [UIAlertAction actionWithTitle:@"Java home" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:JHOME];}];
|
||||
@@ -234,6 +238,7 @@
|
||||
[self presentViewController:helpAlert animated:YES completion:nil];
|
||||
[helpAlert addAction:btnscale];
|
||||
[helpAlert addAction:resolution];
|
||||
[helpAlert addAction:allocmem];
|
||||
[helpAlert addAction:jargs];
|
||||
[helpAlert addAction:renderer];
|
||||
[helpAlert addAction:jhome];
|
||||
@@ -251,6 +256,9 @@
|
||||
} else if(setting == RESOLUTION) {
|
||||
title = @"Resolution";
|
||||
message = @"This option allows you to downscale the resolution of the game. Reducing resolution reduces GPU workload for better performance. The minimum resolution scale is 25%.";
|
||||
} else if(setting == ALLOCMEM) {
|
||||
title = @"Allocated RAM";
|
||||
message = @"This option allows you to change the amount of memory used by the game. The minimum is 25% (default) and the maximum is 85%. Any value over 40% will require that you use a tool like overb0ard to prevent jetsam crashes. Take note that Java uses some of the memory itself, so the value you set will be lowered slightly in game. This option also requires a restart of the launcher to take effect.";
|
||||
} else if(setting == JARGS) {
|
||||
title = @"Java arguments";
|
||||
message = @"This option allows you to edit arguments that can be passed to Minecraft. Not all arguments work with PojavLauncher, so be aware. This option also requires a restart of the launcher to take effect.";
|
||||
@@ -283,11 +291,11 @@
|
||||
case 100:
|
||||
memVal = roundf(([[NSProcessInfo processInfo] physicalMemory] / 1048576) * 0.40);
|
||||
if(sender.value >= memVal && [getPreference(@"mem_warn") boolValue] == YES) {
|
||||
UIAlertController *offlineAlert = [UIAlertController alertControllerWithTitle:@"High memory value selected." message:@"Due to limitations in the operating system itself, you will need to use a tool like overb0ard to prevent jetsam crashes." preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
[self setPopoverProperties:offlineAlert.popoverPresentationController sender:(UIButton *)sender];
|
||||
UIAlertController *memAlert = [UIAlertController alertControllerWithTitle:@"High memory value selected." message:@"Due to limitations in the operating system itself, you will need to use a tool like overb0ard to prevent jetsam crashes." preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
[self setPopoverProperties:memAlert.popoverPresentationController sender:(UIButton *)sender];
|
||||
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
|
||||
[self presentViewController:offlineAlert animated:YES completion:nil];
|
||||
[offlineAlert addAction:ok];
|
||||
[self presentViewController:memAlert animated:YES completion:nil];
|
||||
[memAlert addAction:ok];
|
||||
setPreference(@"mem_warn", @NO);
|
||||
}
|
||||
setPreference(@"allocated_memory", @((int)sender.value));
|
||||
|
||||
Reference in new issue
Block a user