Skip to content

Commit a6a1f8b

Browse files
committed
add launch args
1 parent 081f287 commit a6a1f8b

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

Resources/en.lproj/Localizable.strings

+3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,12 @@
161161
"developer" = "Developer";
162162
"developer.warning.title" = "Are you sure you want to enable Developer Mode?";
163163
"developer.warning.msg" = "Developer Mode exposes options that might be unstable, corrupt your game files, and break your install, and are meant for development purposes only.";
164+
"developer.completedsetup" = "Completed Setup";
164165
"developer.webserver" = "Web Server";
165166
"developer.webserver.msg" = "Restart the launcher to start the web server! The default port is 8080.";
167+
"developer.testbundleaccess" = "Test GD Bundle Access";
166168
"developer.importipa" = "Import IPA";
169+
"developer.launchargs" = "Launch Args";
167170

168171
// Logs
169172
"logs.error" = "%@ could not be read.";

src/SettingsVC.m

+24-9
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)
8686
case 6: // Credits
8787
return [self.creditsArray count];
8888
case 7: // Developer
89-
return 5;
89+
return 6;
9090
default:
9191
return 0;
9292
}
@@ -351,25 +351,37 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
351351
}
352352
case 7: {
353353
if (indexPath.row == 0) {
354+
UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
355+
textField.textAlignment = NSTextAlignmentRight;
356+
textField.delegate = self;
357+
textField.returnKeyType = UIReturnKeyDone;
358+
textField.autocorrectionType = UITextAutocorrectionTypeNo;
359+
textField.keyboardType = UIKeyboardTypeURL;
360+
textField.tag = 3;
361+
cell.accessoryView = textField;
362+
cell.textLabel.text = @"developer.launchargs".loc;
363+
textField.placeholder = @"--geode:safe-mode";
364+
textField.text = [[Utils getPrefs] stringForKey:@"LAUNCH_ARGS"];
365+
} else if (indexPath.row == 1) {
354366
cellval1.selectionStyle = UITableViewCellSelectionStyleNone;
355367
cellval1.textLabel.text = @"advanced.dev-mode".loc;
356368
cellval1.accessoryView = [self createSwitch:[[Utils getPrefs] boolForKey:@"DEVELOPER_MODE"] tag:2 disable:NO];
357369
return cellval1;
358-
} else if (indexPath.row == 1) {
370+
} else if (indexPath.row == 2) {
359371
cellval1.selectionStyle = UITableViewCellSelectionStyleNone;
360-
cellval1.textLabel.text = @"Completed Setup";
372+
cellval1.textLabel.text = @"developer.completedsetup".loc;
361373
cellval1.accessoryView = [self createSwitch:[[Utils getPrefs] boolForKey:@"CompletedSetup"] tag:6 disable:NO];
362374
return cellval1;
363-
} else if (indexPath.row == 2) {
375+
} else if (indexPath.row == 3) {
364376
cellval1.selectionStyle = UITableViewCellSelectionStyleNone;
365377
cellval1.textLabel.text = @"developer.webserver".loc;
366378
cellval1.accessoryView = [self createSwitch:[[Utils getPrefs] boolForKey:@"WEB_SERVER"] tag:12 disable:NO];
367379
return cellval1;
368-
} else if (indexPath.row == 3) {
369-
cell.textLabel.text = @"Test GD Bundle Access";
380+
} else if (indexPath.row == 4) {
381+
cell.textLabel.text = @"developer.testbundleaccess".loc;
370382
cell.textLabel.textColor = [Theming getAccentColor];
371383
cell.accessoryType = UITableViewCellAccessoryNone;
372-
} else if (indexPath.row == 4) {
384+
} else if (indexPath.row == 5) {
373385
cell.textLabel.text = @"developer.importipa".loc;
374386
cell.textLabel.textColor = [Theming getAccentColor];
375387
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -749,11 +761,11 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)
749761
}
750762
} else if (indexPath.section == 7) {
751763
switch (indexPath.row) {
752-
case 3: { // Test GD Bundle Access
764+
case 4: { // Test GD Bundle Access
753765
[Utils showNotice:self title:[Utils getGDDocPath]];
754766
break;
755767
}
756-
case 4: { // Import IPA
768+
case 5: { // Import IPA
757769
UTType* type = [UTType typeWithIdentifier:@"com.apple.itunes.ipa"];
758770
UIDocumentPickerViewController* picker = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes:@[ type ] asCopy:YES];
759771
picker.delegate = self;
@@ -879,6 +891,9 @@ - (void)textFieldDidEndEditing:(UITextField*)textField {
879891
case 2: // reinstall addr
880892
[[Utils getPrefs] setValue:textField.text forKey:@"DEV_REINSTALL_ADDR"];
881893
break;
894+
case 3: // launch args
895+
[[Utils getPrefs] setValue:textField.text forKey:@"LAUNCH_ARGS"];
896+
break;
882897
}
883898
}
884899

src/Utils.m

+10
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ + (const char*)getKillAllPath {
365365

366366
+ (void)tweakLaunch_withSafeMode:(BOOL)safemode {
367367
AppLog(@"tweakLaunching GD %@", safemode ? @"in safe mode" : @"normally");
368+
NSString* launchArgs = [[Utils getPrefs] stringForKey:@"LAUNCH_ARGS"];
368369
if (safemode) {
369370
// https://github.com/geode-catgirls/geode-inject-ios/blob/meow/src/geode.m
370371
NSString* appSupportDirectory = [[Utils getGDDocPath] stringByAppendingString:@"Library/Application Support"];
@@ -374,6 +375,15 @@ + (void)tweakLaunch_withSafeMode:(BOOL)safemode {
374375
NSString* safeModeEnv = @"LAUNCHARGS=--geode:safe-mode";
375376
NSFileManager* fm = [NSFileManager defaultManager];
376377
[fm createFileAtPath:geode_env contents:[safeModeEnv dataUsingEncoding:NSUTF8StringEncoding] attributes:@{}];
378+
} else if (launchArgs && [launchArgs length] > 1) {
379+
// https://github.com/geode-catgirls/geode-inject-ios/blob/meow/src/geode.m
380+
NSString* appSupportDirectory = [[Utils getGDDocPath] stringByAppendingString:@"Library/Application Support"];
381+
NSString* geode_dir = [appSupportDirectory stringByAppendingString:@"/GeometryDash/game/geode"];
382+
NSString* geode_env = [geode_dir stringByAppendingString:@"/geode.env"];
383+
384+
NSString* safeModeEnv = [NSString stringWithFormat:@"LAUNCHARGS=%@", launchArgs];
385+
NSFileManager* fm = [NSFileManager defaultManager];
386+
[fm createFileAtPath:geode_env contents:[safeModeEnv dataUsingEncoding:NSUTF8StringEncoding] attributes:@{}];
377387
}
378388

379389
[[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:@"com.robtop.geometryjump"];

src/main.m

+5
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ static void overwriteExecPath(NSString* bundlePath) {
397397
setenv("CFFIXED_USER_HOME", newHomePath.UTF8String, 1);
398398
setenv("HOME", newHomePath.UTF8String, 1);
399399
setenv("TMPDIR", newTmpPath.UTF8String, 1);
400+
NSString* launchArgs = [gcUserDefaults stringForKey:@"LAUNCH_ARGS"];
401+
if (launchArgs && [launchArgs length] > 1) {
402+
setenv("LAUNCHARGS", launchArgs.UTF8String, 1);
403+
}
404+
// safe mode
400405
if (safeMode) {
401406
setenv("LAUNCHARGS", "--geode:safe-mode", 1);
402407
}

0 commit comments

Comments
 (0)