diff --git a/Makefile b/Makefile index 0eabd5b4..a29add6a 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ WORKINGDIR := $(SOURCEDIR)/Natives/build DETECTPLAT := $(shell uname -s) DETECTARCH := $(shell uname -m) VERSION := $(shell cat $(SOURCEDIR)/DEBIAN/control.development | grep Version | cut -b 10-60) +BRANCH := $(shell git branch --show-current) COMMIT := $(shell git log --oneline | sed '2,10000000d' | cut -b 1-7) IOS15PREF := private/preboot/procursus @@ -236,6 +237,7 @@ check: @printf 'OUTPUTDIR - $(OUTPUTDIR)\n' @printf 'JOBS - $(JOBS)\n' @printf 'VERSION - $(VERSION)\n' + @printf 'BRANCH - $(BRANCH)\n' @printf 'COMMIT - $(COMMIT)\n' @printf 'RELEASE - $(RELEASE)\n' @printf 'IOS15PREF - $(IOS15PREF)\n' @@ -258,6 +260,7 @@ native: -DCMAKE_OSX_SYSROOT="$(SDKPATH)" \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DCMAKE_C_FLAGS="-arch arm64 -miphoneos-version-min=12.0" \ + -DCONFIG_BRANCH="$(BRANCH)" \ -DCONFIG_COMMIT="$(COMMIT)" \ -DCONFIG_RELEASE=$(RELEASE) \ .. diff --git a/Natives/AboutLauncherViewController.m b/Natives/AboutLauncherViewController.m index 5f9d9204..3889e2d7 100644 --- a/Natives/AboutLauncherViewController.m +++ b/Natives/AboutLauncherViewController.m @@ -5,17 +5,6 @@ #import -#if CONFIG_RELEASE == 1 -# define CONFIG_TYPE "release" -#else -# define CONFIG_TYPE "debug" -#endif - -#ifndef CONFIG_COMMIT -# define CONFIG_COMMIT unspecified -#endif - - @interface AboutLauncherViewController() @property (nonatomic, strong) UIActivityViewController *activityViewController; @end @@ -27,7 +16,7 @@ { [super viewDidLoad]; setViewBackgroundColor(self.view); - [self setTitle:@"About PojavLauncher"]; + [self setTitle:NSLocalizedString(@"login.menu.about", nil)]; CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; @@ -47,7 +36,7 @@ NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; UILabel *logoVerView = [[UILabel alloc] initWithFrame:CGRectMake(4, 0, width - 8, 30)]; - logoVerView.text = [NSString stringWithFormat:@"version 2.1 (%s - %s) on %@ with iOS %@", CONFIG_TYPE, CONFIG_COMMIT, deviceModel, currSysVer]; + logoVerView.text = [NSString stringWithFormat:@"version 2.1 %s (%s - %s) on %@ with iOS %@", CONFIG_TYPE, CONFIG_BRANCH, CONFIG_COMMIT, deviceModel, currSysVer]; logoVerView.lineBreakMode = NSLineBreakByWordWrapping; logoVerView.numberOfLines = 0; [scrollView addSubview:logoVerView]; diff --git a/Natives/CMakeLists.txt b/Natives/CMakeLists.txt index c78d0180..20bbf03d 100644 --- a/Natives/CMakeLists.txt +++ b/Natives/CMakeLists.txt @@ -24,6 +24,7 @@ include_directories( # For cacio support library set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rpath @loader_path -rpath @executable_path/jvm/java-8-openjdk/lib -rpath /usr/lib/jvm/java-8-openjdk/lib") +add_definitions(-DCONFIG_BRANCH="${CONFIG_BRANCH}") add_definitions(-DCONFIG_COMMIT="${CONFIG_COMMIT}") add_definitions(-DCONFIG_RELEASE=${CONFIG_RELEASE}) diff --git a/Natives/CustomControlsViewController.m b/Natives/CustomControlsViewController.m index df7149bb..e4b2c554 100644 --- a/Natives/CustomControlsViewController.m +++ b/Natives/CustomControlsViewController.m @@ -310,9 +310,9 @@ NSMutableArray *keyCodeMap, *keyValueMap; showDialog(self, @"Error while converting to JSON", error.localizedDescription); return; } - NSString *jsonStr = [NSString stringWithUTF8String:jsonData.bytes]; - BOOL success = [jsonStr writeToFile:[NSString stringWithFormat:@"%s/controlmap/%@.json", getenv("POJAV_HOME"), field.text] atomically:YES encoding:NSUTF8StringEncoding error:&error]; + BOOL success = [jsonData writeToFile:[NSString stringWithFormat:@"%s/controlmap/%@.json", getenv("POJAV_HOME"), field.text] options:NSDataWritingAtomic error:&error]; if (!success) { + NSLog(@"GOT ERROR %@", error); showDialog(self, @"Error while saving file", error.localizedDescription); return; } diff --git a/Natives/LauncherFAQViewController.m b/Natives/LauncherFAQViewController.m index 7b64adb8..ba919ffb 100644 --- a/Natives/LauncherFAQViewController.m +++ b/Natives/LauncherFAQViewController.m @@ -13,7 +13,7 @@ CGFloat faqcurrY = 4.0; { [super viewDidLoad]; setViewBackgroundColor(self.view); - [self setTitle:@"Launcher FAQ"]; + [self setTitle:NSLocalizedString(@"FAQ", nil)]; CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; diff --git a/Natives/LauncherPreferences.m b/Natives/LauncherPreferences.m index 5636dc8d..89599438 100644 --- a/Natives/LauncherPreferences.m +++ b/Natives/LauncherPreferences.m @@ -8,12 +8,6 @@ NSMutableDictionary *envPrefDict; // warnings dict NSMutableDictionary *warnPrefDict; -#if CONFIG_RELEASE == 1 -# define CONFIG_TYPE @NO -#else -# define CONFIG_TYPE @YES -#endif - id getPreference(NSString* key) { if (!(envPrefDict[key] == [NSNull null] || envPrefDict[key] == nil)) { return envPrefDict[key]; @@ -120,7 +114,7 @@ void loadPreferences(BOOL reset) { setDefaultValueForPref(envPrefDict, @"game_directory", @"default"); setDefaultValueForPref(envPrefDict, @"java_args", @""); setDefaultValueForPref(envPrefDict, @"allocated_memory", [NSNumber numberWithFloat:roundf(([[NSProcessInfo processInfo] physicalMemory] / 1048576) * 0.25)]); - setDefaultValueForPref(prefDict, @"debug_logging", CONFIG_TYPE); + setDefaultValueForPref(prefDict, @"debug_logging", @(CONFIG_RELEASE != 1)); setDefaultValueForPref(prefDict, @"arccapes_enable", @YES); setDefaultValueForPref(envPrefDict, @"java_home", @""); setDefaultValueForPref(envPrefDict, @"renderer", @"auto"); diff --git a/Natives/LoginViewController.m b/Natives/LoginViewController.m index bda5d3f5..5d381ed6 100644 --- a/Natives/LoginViewController.m +++ b/Natives/LoginViewController.m @@ -107,11 +107,7 @@ extern NSMutableDictionary *prefDict; } UIButton *button_faq = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - if(@available (iOS 13.0, *)) { - [button_faq setTitle:@" FAQ" forState:UIControlStateNormal]; - } else { - [button_faq setTitle:@"FAQ" forState:UIControlStateNormal]; - } + [button_faq setTitle:NSLocalizedString(@"FAQ", @"Frequently asked questions") forState:UIControlStateNormal]; button_faq.frame = CGRectMake(widthSplit2 - (((width - widthSplit * 2.0) / 2) / 2), (height - 80.0), (width - widthSplit * 2.0) / 2, 40.0); if([date isEqualToString:@"06-29"] || [date isEqualToString:@"06-30"] || [date isEqualToString:@"07-01"]) { button_faq.backgroundColor = [UIColor colorWithRed:67/255.0 green:0/255.0 blue:8/255.0 alpha:1.0]; @@ -129,11 +125,7 @@ extern NSMutableDictionary *prefDict; [scrollView addSubview:button_faq]; UIButton *button_login = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - if(@available (iOS 13.0, *)) { - [button_login setTitle:@" Sign In" forState:UIControlStateNormal]; - } else { - [button_login setTitle:@"Sign In" forState:UIControlStateNormal]; - } + [button_login setTitle:NSLocalizedString(@"Sign in", nil) forState:UIControlStateNormal]; button_login.frame = CGRectMake(button_faq.frame.origin.x - button_faq.frame.size.width - 20, (height - 80.0), (width - widthSplit * 2.0) / 2, 40.0); if([date isEqualToString:@"06-29"] || [date isEqualToString:@"06-30"] || [date isEqualToString:@"07-01"]) { button_login.backgroundColor = [UIColor colorWithRed:67/255.0 green:0/255.0 blue:8/255.0 alpha:1.0]; @@ -163,11 +155,7 @@ extern NSMutableDictionary *prefDict; [scrollView addSubview:button_login]; UIButton *button_accounts = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - if(@available (iOS 13.0, *)) { - [button_accounts setTitle:@" Accounts" forState:UIControlStateNormal]; - } else { - [button_accounts setTitle:@"Accounts" forState:UIControlStateNormal]; - } + [button_accounts setTitle:NSLocalizedString(@"Accounts", nil) forState:UIControlStateNormal]; button_accounts.frame = CGRectMake(button_faq.frame.origin.x + button_faq.frame.size.width + 20, (height - 80.0), (width - widthSplit * 2.0) / 2, 40.0); if([date isEqualToString:@"06-29"] || [date isEqualToString:@"06-30"] || [date isEqualToString:@"07-01"]) { button_accounts.backgroundColor = [UIColor colorWithRed:67/255.0 green:0/255.0 blue:8/255.0 alpha:1.0]; @@ -332,7 +320,7 @@ extern NSMutableDictionary *prefDict; [offlineAlert addAction:cancel]; setPreference(@"local_warn", @NO); } else { - UIAlertController *controller = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"login.alert.title", nil) message:NSLocalizedString(@"login.option.local", nil) preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *controller = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Sign in", nil) message:NSLocalizedString(@"login.option.local", nil) preferredStyle:UIAlertControllerStyleAlert]; [controller addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = NSLocalizedString(@"login.alert.field.username", nil); textField.clearButtonMode = UITextFieldViewModeWhileEditing; diff --git a/Natives/UpdateHistoryViewController.m b/Natives/UpdateHistoryViewController.m index d00d898d..de9463d9 100644 --- a/Natives/UpdateHistoryViewController.m +++ b/Natives/UpdateHistoryViewController.m @@ -2,12 +2,6 @@ #include "utils.h" -#if CONFIG_RELEASE == 1 -# define CONFIG_TYPE "release" -#else -# define CONFIG_TYPE "debug" -#endif - @interface UpdateHistoryViewController () { } -(UILabel *)uhContent:(bool)isHeading size:(int)size text:(NSString *)text width:(int)width; @@ -20,7 +14,7 @@ CGFloat uhcurrY = 4.0; [super viewDidLoad]; setViewBackgroundColor(self.view); - [self setTitle:@"Update History"]; + [self setTitle:NSLocalizedString(@"login.menu.updates", nil)]; CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; diff --git a/Natives/en.lproj/Localizable.strings b/Natives/en.lproj/Localizable.strings index 65ae8940..03d5f07e 100644 --- a/Natives/en.lproj/Localizable.strings +++ b/Natives/en.lproj/Localizable.strings @@ -8,6 +8,7 @@ "game.menu.log_output" = "Log output"; "game.menu.custom_controls" = "Custom controls"; +// Version categories "Installed" = "Installed"; "Snapshot" = "Snapshot"; "Releases" = "Releases"; @@ -18,7 +19,6 @@ "login.error.username.outOfRange" = "Username must be at least 3 characters and maximum 16 characters"; -"login.alert.title" = "Login"; "login.alert.field.username" = "Username"; "login.jit.checking" = "Checking for JIT"; @@ -26,6 +26,11 @@ "login.jit.fail.JitStreamer" = "JitStreamer error: %@"; "login.jit.found.JitStreamer" = "Found JitStreamer, enabling JIT"; +// Login buttons +"Sign in" = "Sign in"; +"FAQ" = "FAQ"; +"Accounts" = "Accounts"; + "login.menu.about" = "About PojavLauncher"; "login.menu.sendlogs" = "Send your logs"; "login.menu.updates" = "Recent updates"; @@ -133,5 +138,3 @@ "preference.warn.allocated_memory" = "Due to limitations in the operating system itself, this option may cause instability at this and higher values. Proceed with caution."; "preference.title.custom_env" = "Environment variables"; "preference.detail.custom_env" = "This option is under construction."; -// sha check -// home symlink diff --git a/Natives/main.m b/Natives/main.m index 4be355f0..822b432b 100644 --- a/Natives/main.m +++ b/Natives/main.m @@ -25,16 +25,6 @@ #define CS_PLATFORM_BINARY 0x4000000 -#if CONFIG_RELEASE == 1 -# define CONFIG_TYPE "release" -#else -# define CONFIG_TYPE "debug" -#endif - -#ifndef CONFIG_COMMIT -# define CONFIG_COMMIT unspecified -#endif - #define fm NSFileManager.defaultManager void printEntitlementAvailability(NSString *key) { @@ -112,7 +102,7 @@ void init_logDeviceAndVer(char *argument) { const char *deviceSoftware = [[[UIDevice currentDevice] systemVersion] cStringUsingEncoding:NSUTF8StringEncoding]; // PojavLauncher version - regLog("[Pre-Init] PojavLauncher version: %s - %s", CONFIG_TYPE, CONFIG_COMMIT); + regLog("[Pre-Init] PojavLauncher version: %s - branch %s commit %s", CONFIG_TYPE, CONFIG_BRANCH, CONFIG_COMMIT); setenv("POJAV_DETECTEDHW", deviceHardware, 1); setenv("POJAV_DETECTEDSW", deviceSoftware, 1); diff --git a/Natives/utils.h b/Natives/utils.h index 2266300b..734d7a95 100644 --- a/Natives/utils.h +++ b/Natives/utils.h @@ -5,6 +5,22 @@ #include #include "jni.h" +// Configuration macros +#if CONFIG_RELEASE == 1 +# define CONFIG_TYPE "release" +#else +# define CONFIG_TYPE "debug" +#endif + +#ifndef CONFIG_BRANCH +# define CONFIG_BRANCH "unspecified" +#endif + +#ifndef CONFIG_COMMIT +# define CONFIG_COMMIT "unspecified" +#endif + +// Control button actions #define ACTION_DOWN 0 #define ACTION_UP 1 #define ACTION_MOVE 2 @@ -14,6 +30,7 @@ #define BUTTON2_DOWN_MASK 1 << 11 // mid btn #define BUTTON3_DOWN_MASK 1 << 12 // right btn +// GLFW event types #define EVENT_TYPE_CHAR 1000 #define EVENT_TYPE_CHAR_MODS 1001 #define EVENT_TYPE_CURSOR_ENTER 1002