From 0668d016bff0270e85630e0bbe11f1e29ab57165 Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Sun, 1 Aug 2021 10:41:02 +0700 Subject: [PATCH] Changes - Added Caciocavallo (libawt_xawt stubs) support library. - Added support lauching Minecraft 1.5.2 and older (requires latest JRE8 build) - [Custom controls] Implemented opacity property. - Version info is now updated through macro instead of `sed` command. --- .github/workflows/ios.yml | 2 +- .../java/net/kdt/pojavlaunch/PLaunchApp.java | 6 + Makefile | 34 +-- Natives/AboutLauncherViewController.m | 12 +- Natives/CMakeLists.txt | 39 ++- Natives/CustomControlsViewController.h | 4 +- Natives/CustomControlsViewController.m | 86 ++++-- Natives/JavaLauncher.m | 13 +- Natives/SurfaceViewController.m | 4 +- Natives/awt_xawt/empty.m | 0 Natives/awt_xawt/xawt_fake.m | 261 ++++++++++++++++++ Natives/customcontrols/ControlButton.h | 2 +- Natives/customcontrols/ControlButton.m | 4 +- 13 files changed, 408 insertions(+), 59 deletions(-) create mode 100644 Natives/awt_xawt/empty.m create mode 100644 Natives/awt_xawt/xawt_fake.m diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 79787ae8..5dda8500 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -23,7 +23,7 @@ jobs: run: brew install ldid dpkg fakeroot gsed - name: Build the native application - run: make version native + run: make native - name: Build the Java application run: make java diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java index d941faa4..40b0ce25 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java @@ -17,6 +17,12 @@ public class PLaunchApp { public static boolean mIsAssetsProcessing = false; public static void main(String[] args) throws Throwable { + try { + sun.font.FontUtilities.isLinux = true; + } catch (Throwable th) { + // Not on JRE8, ignore exception + } + // User might remove the minecraft folder, this can cause crashes, safety re-create it try { File mcDir = new File(Tools.DIR_GAME_NEW); diff --git a/Makefile b/Makefile index b7a8fa5f..7355ef59 100644 --- a/Makefile +++ b/Makefile @@ -91,17 +91,7 @@ else ifneq ($(filter 0,$(IOS)),) endif -all: clean version native java extras package - -version: - @echo 'Starting build task - version change' - @export PATH='/usr/local/opt/gnu-sed/libexec/gnubin:$PATH' - @if [ '$(RELEASE)' != '1' ]; then \ - $(SED) -i "s/version$(VERSION) \(.*\) on/version$(VERSION) \(dev - $(COMMIT)\) on/" Natives/AboutLauncherViewController.m || exit 1; \ - elif [ '$(RELEASE)' = '1' ]; then \ - $(SED) -i "s/version$(VERSION) \(.*\) on/version$(VERSION) \(release\) on/" Natives/AboutLauncherViewController.m || exit 1; \ - fi - @echo 'Finished build task - version change' +all: clean native java extras package native: @echo 'Starting build task - native application' @@ -114,8 +104,10 @@ native: -DCMAKE_OSX_SYSROOT="$(SDKPATH)" \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DCMAKE_C_FLAGS="-arch arm64 -miphoneos-version-min=12.0" \ + -DCONFIG_COMMIT="$(COMMIT)" \ .. - @cd Natives/build && cmake --build . --config Release --target pojavexec PojavLauncher + @cd Natives/build && cmake --build . --config Release --target awt_headless awt_xawt pojavexec PojavLauncher + @rm Natives/build/libawt_headless.dylib || exit 1 @echo 'Finished build task - native application' java: @@ -143,7 +135,7 @@ package: @echo 'Starting build task - package for external devices' @if [ '$(IOS)' = '0' ]; then \ cp -R Natives/resources/* Natives/build/PojavLauncher.app/ || exit 1; \ - cp Natives/build/libpojavexec.dylib Natives/build/PojavLauncher.app/Frameworks/ || exit 1; \ + cp Natives/build/*.dylib Natives/build/PojavLauncher.app/Frameworks/ || exit 1; \ mkdir Natives/build/PojavLauncher.app/{libs,libs_caciocavallo}; \ cp JavaApp/local_out/launcher.jar Natives/build/PojavLauncher.app/libs/launcher.jar || exit 1; \ cp -R JavaApp/libs/* Natives/build/PojavLauncher.app/libs/ || exit 1; \ @@ -155,12 +147,11 @@ package: ldid -Sentitlements.xml packages/pojavlauncher_iphoneos-arm/Applications/PojavLauncher.app || exit 1; \ fakeroot dpkg-deb -b packages/pojavlauncher_iphoneos-arm || exit 1; \ elif [ '$(IOS)' = '1' ]; then \ - mkdir -p Natives/build/PojavLauncher.app/Frameworks; \ - mkdir -p Natives/build/PojavLauncher.app/Base.lproj; \ + mkdir -p Natives/build/PojavLauncher.app/{Frameworks,Base.lproj}; \ cp -R Natives/en.lproj/*.storyboardc Natives/build/PojavLauncher.app/Base.lproj/ || exit 1; \ cp -R Natives/Info.plist Natives/build/PojavLauncher.app/Info.plist || exit 1;\ cp -R Natives/PkgInfo Natives/build/PojavLauncher.app/PkgInfo || exit 1; \ - cp -R Natives/build/libpojavexec.dylib Natives/build/PojavLauncher.app/Frameworks/libpojavexec.dylib || exit 1; \ + cp -R Natives/build/*.dylib Natives/build/PojavLauncher.app/Frameworks/ || exit 1; \ cp -R Natives/resources/* Natives/build/PojavLauncher.app/ || exit 1; \ cp -R JavaApp/libs Natives/build/PojavLauncher.app/libs || exit 1; \ cp -R JavaApp/libs_caciocavallo Natives/build/PojavLauncher.app/libs_caciocavallo || exit 1; \ @@ -205,16 +196,18 @@ deploy: ldid -Sentitlements.xml Natives/build/PojavLauncher.app/PojavLauncher; \ if [ '$(DEVICE_PORT)' != '' ]; then \ scp -P $(DEVICE_PORT) -o "StrictHostKeyChecking no" -o "UserKnownHostsFile=/dev/null" Natives/build/libpojavexec.dylib \ + Natives/build/libawt_xawt.dylib \ Natives/build/PojavLauncher.app/PojavLauncher \ JavaApp/local_out/launcher.jar \ root@$(DEVICE_IP):/var/tmp; \ - ssh root@$(DEVICE_IP) -p $(DEVICE_PORT) -t "mv /var/tmp/libpojavexec.dylib /Applications/PojavLauncher.app/Frameworks/libpojavexec.dylib && mv /var/tmp/PojavLauncher /Applications/PojavLauncher.app/PojavLauncher && mv /var/tmp/launcher.jar /Applications/PojavLauncher.app/libs/launcher.jar && killall PojavLauncher"; \ + ssh root@$(DEVICE_IP) -p $(DEVICE_PORT) -t "mv /var/tmp/libawt_xawt.dylib /Applications/PojavLauncher.app/Frameworks/libawt_xawt.dylib && mv /var/tmp/libpojavexec.dylib /Applications/PojavLauncher.app/Frameworks/libpojavexec.dylib && mv /var/tmp/PojavLauncher /Applications/PojavLauncher.app/PojavLauncher && mv /var/tmp/launcher.jar /Applications/PojavLauncher.app/libs/launcher.jar && killall PojavLauncher"; \ else \ scp -o "StrictHostKeyChecking no" -o "UserKnownHostsFile=/dev/null" Natives/build/libpojavexec.dylib \ + Natives/build/libawt_xawt.dylib \ Natives/build/PojavLauncher.app/PojavLauncher \ JavaApp/local_out/launcher.jar \ root@$(DEVICE_IP):/var/tmp; \ - ssh root@$(DEVICE_IP) -t "mv /var/tmp/libpojavexec.dylib /Applications/PojavLauncher.app/Frameworks/libpojavexec.dylib && mv /var/tmp/PojavLauncher /Applications/PojavLauncher.app/PojavLauncher && mv /var/tmp/launcher.jar /Applications/PojavLauncher.app/libs/launcher.jar && killall PojavLauncher"; \ + ssh root@$(DEVICE_IP) -t "mv /var/tmp/libawt_xawt.dylib /Applications/PojavLauncher.app/Frameworks/libawt_xawt.dylib && mv /var/tmp/libpojavexec.dylib /Applications/PojavLauncher.app/Frameworks/libpojavexec.dylib && mv /var/tmp/PojavLauncher /Applications/PojavLauncher.app/PojavLauncher && mv /var/tmp/launcher.jar /Applications/PojavLauncher.app/libs/launcher.jar && killall PojavLauncher"; \ fi; \ else \ echo 'You need to run '\''export DEVICE_IP='\'' to use make deploy.'; \ @@ -224,7 +217,7 @@ deploy: sudo ldid -Sentitlements.xml Natives/build/PojavLauncher.app/PojavLauncher; \ sudo cp JavaApp/local_out/launcher.jar /Applications/PojavLauncher.app/libs/launcher.jar; \ sudo cp Natives/build/PojavLauncher.app/PojavLauncher /Applications/PojavLauncher.app/PojavLauncher; \ - sudo cp Natives/build/libpojavexec.dylib /Applications/PojavLauncher.app/Frameworks/libpojavexec.dylib; \ + sudo cp Natives/build/*.dylib /Applications/PojavLauncher.app/Frameworks/; \ sudo killall PojavLauncher; \ fi @echo 'Finished build task - deploy to local device' @@ -242,7 +235,6 @@ help: @echo 'Usage: ' @echo ' make Makes everything under all ' @echo ' make all Builds natives, javaapp, extras, and package ' - @echo ' make version Changes the About view's information ' @echo ' make native Builds the native app ' @echo ' make java Builds the Java app ' @echo ' make package Builds deb of PojavLauncher ' @@ -250,4 +242,4 @@ help: @echo ' make deploy Copy package to local iDevice ' @echo ' make clean Cleans build directories ' -. PHONY: all clean version native java extras package install deploy +. PHONY: all clean native java extras package install deploy diff --git a/Natives/AboutLauncherViewController.m b/Natives/AboutLauncherViewController.m index eb626297..d2f695ce 100644 --- a/Natives/AboutLauncherViewController.m +++ b/Natives/AboutLauncherViewController.m @@ -5,6 +5,16 @@ #import +#ifndef NDEBUG +# define CONFIG_TYPE "release" +#else +# define CONFIG_TYPE "debug" +#endif + +#ifndef CONFIG_COMMIT +# define CONFIG_COMMIT unspecified +#endif + @interface AboutLauncherViewController () { } @@ -44,7 +54,7 @@ NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; UILabel *logoVerView = [[UILabel alloc] initWithFrame:CGRectMake(4, 0, width - 8, 30)]; - logoVerView.text = [NSString stringWithFormat:@"version 1.3 (placeholder) on %@ with iOS %@", deviceModel, currSysVer]; + logoVerView.text = [NSString stringWithFormat:@"version 1.3 (%s - %s) on %@ with iOS %@", CONFIG_TYPE, CONFIG_COMMIT, deviceModel, currSysVer]; logoVerView.lineBreakMode = NSLineBreakByWordWrapping; logoVerView.numberOfLines = 0; [scrollView addSubview:logoVerView]; diff --git a/Natives/CMakeLists.txt b/Natives/CMakeLists.txt index e450a103..89e382d3 100644 --- a/Natives/CMakeLists.txt +++ b/Natives/CMakeLists.txt @@ -4,9 +4,29 @@ project(PojavLauncher) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon -fobjc-arc -ObjC -I'${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks/MetalANGLE.framework/Headers' -I'${CMAKE_CURRENT_LIST_DIR}/external/DBNumberedSlider/Classes'" ) -set(CMAKE_SHARED_LINKER_FLAGS "'${CMAKE_SHARED_LINKER_FLAGS}' -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") -set(CMAKE_EXE_LINKER_FLAGS "'${CMAKE_EXE_LINKER_FLAGS}' -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") + +# For cacio support library +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rpath /usr/lib/jvm/java-8-openjdk/lib") + +add_definitions(-DCONFIG_COMMIT="${CONFIG_COMMIT}") + +# EXT: stub library, delete after compile awt_xawt +add_library(awt_headless SHARED + awt_xawt/empty.m +) +target_link_libraries(awt_headless) + +# EXT: cacio support library +add_library(awt_xawt SHARED + awt_xawt/xawt_fake.m +) +target_link_libraries(awt_xawt + "-L'${CMAKE_CURRENT_LIST_DIR}/build'" + "-lawt_headless" +) add_library(pojavexec SHARED AboutLauncherViewController.m @@ -30,12 +50,11 @@ add_library(pojavexec SHARED utils.m ) target_link_libraries(pojavexec - "-F'${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks'" - "-framework UIKit" - "-framework MetalANGLE" - "-framework CoreGraphics" - "-framework AuthenticationServices" - "-Wl,-undefined -Wl,dynamic_lookup" + "-F'${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks'" + "-framework UIKit" + "-framework MetalANGLE" + "-framework CoreGraphics" + "-framework AuthenticationServices" ) add_executable(PojavLauncher @@ -43,8 +62,8 @@ add_executable(PojavLauncher log.m JavaLauncher.m) target_link_libraries(PojavLauncher - "-L'${CMAKE_CURRENT_LIST_DIR}/build'" - "-framework UIKit -lpojavexec" + "-L'${CMAKE_CURRENT_LIST_DIR}/build'" + "-framework UIKit -lpojavexec" ) set_target_properties(PojavLauncher PROPERTIES MACOSX_BUNDLE TRUE diff --git a/Natives/CustomControlsViewController.h b/Natives/CustomControlsViewController.h index 16fb23ec..ed86559e 100644 --- a/Natives/CustomControlsViewController.h +++ b/Natives/CustomControlsViewController.h @@ -1,4 +1,5 @@ #import +#import "customcontrols/ControlButton.h" @interface CustomControlsViewController : UIViewController @@ -6,6 +7,7 @@ @interface CCMenuViewController : UIViewController -@property (nonatomic, assign) BOOL shouldDisplayButtonEditor; +@property(nonatomic, assign) BOOL shouldDisplayButtonEditor; +@property(nonatomic, weak) ControlButton* targetButton; @end diff --git a/Natives/CustomControlsViewController.m b/Natives/CustomControlsViewController.m index 206a580a..46ccef1e 100644 --- a/Natives/CustomControlsViewController.m +++ b/Natives/CustomControlsViewController.m @@ -1,4 +1,3 @@ -#import "customcontrols/ControlButton.h" #import "CustomControlsViewController.h" #import "LauncherPreferences.h" #import "ios_uikit_bridge.h" @@ -11,17 +10,18 @@ ControlButton *button_##KEY = [ControlButton initWithName:NAME keycode:KEY rect:CGRectMake(RECT.origin.x * buttonScale, RECT.origin.y * buttonScale, RECT.size.width * buttonScale, RECT.size.height * buttonScale) transparency:0.0f]; \ [button_##KEY addGestureRecognizer:[[UITapGestureRecognizer alloc] \ initWithTarget:self action:@selector(showControlPopover:)]]; \ - [self.view addSubview:button_##KEY]; + [self.offsetView addSubview:button_##KEY]; #define APPLY_SCALE(KEY) \ KEY = @([(NSNumber *)KEY floatValue] * savedScale / currentScale); -int notchOffset; +int width; @interface CustomControlsViewController () { } -@property (nonatomic, strong) NSMutableDictionary* cc_dictionary; +@property(nonatomic, strong) NSMutableDictionary* cc_dictionary; +@property(nonatomic) UIView* offsetView; // - (void)method @@ -46,15 +46,21 @@ int notchOffset; CGRect screenBounds = [[UIScreen mainScreen] bounds]; UIEdgeInsets insets = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets; - int width = (int) roundf(screenBounds.size.width); + + self.offsetView = [[UIView alloc] initWithFrame:CGRectMake( + insets.left, 0, + self.view.frame.size.width - insets.left - insets.right, + self.view.frame.size.height + )]; + [self.view addSubview:self.offsetView]; + int height = (int) roundf(screenBounds.size.height); - notchOffset = insets.left; - width = width - notchOffset * 2; + width = width - insets.left - insets.right; CGFloat buttonScale = ((NSNumber *) getPreference(@"button_scale")).floatValue / 100.0; UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showControlPopover:)]; longpressGesture.minimumPressDuration = 0.5; - [self.view addGestureRecognizer:longpressGesture]; + [self.offsetView addGestureRecognizer:longpressGesture]; NSString *controlFilePath = [NSString stringWithFormat:@"%s/%@", getenv("POJAV_PATH_CONTROL"), (NSString *)getPreference(@"default_ctrl")]; @@ -88,7 +94,7 @@ int notchOffset; ControlButton *button = [ControlButton initWithProperties:cc_buttonDict]; [button addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControlPopover:)]]; - [self.view addSubview:button]; + [self.offsetView addSubview:button]; } self.cc_dictionary[@"scaledAt"] = @(savedScale); } @@ -121,6 +127,7 @@ int notchOffset; CGPoint point = [sender locationInView:sender.view]; popoverController.sourceRect = CGRectMake(point.x, point.y, 1.0, 1.0); } else { + vc.targetButton = (ControlButton *)sender.view; popoverController.sourceRect = sender.view.bounds; } popoverController.permittedArrowDirections = UIPopoverArrowDirectionAny; @@ -157,6 +164,8 @@ int notchOffset; @interface CCMenuViewController () { } +@property(nonatomic) UIScrollView* scrollView; + @end @implementation CCMenuViewController @@ -164,19 +173,62 @@ int notchOffset; - (void)viewDidLoad { [super viewDidLoad]; - UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - [button setTitle:@"This is not yet finished. Click here to exit" forState:UIControlStateNormal]; - button.frame = self.view.frame; - [button addTarget:self action:@selector(tempExit) forControlEvents:UIControlEventTouchUpInside]; - [self.view addSubview:button]; + self.view.frame = CGRectMake(0, 0, self.preferredContentSize.width, self.preferredContentSize.height); + + self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(20.0, 0.0, self.preferredContentSize.width - 40.0, self.preferredContentSize.height - 40.0)]; + [self.view addSubview:self.scrollView]; + + if (self.shouldDisplayButtonEditor) { + [self displayButtonEditor]; + } else { + [self displayControlMenu]; + } } -- (void)tempExit { +- (void)displayButtonEditor { + CGFloat width = self.view.frame.size.width; + CGFloat height = self.view.frame.size.height; + + UILabel *labelName = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)]; + labelName.text = @"Name"; + labelName.numberOfLines = 0; + [labelName sizeToFit]; + [self.scrollView addSubview:labelName]; + UITextField *editName = [[UITextField alloc] initWithFrame:CGRectMake(labelName.frame.size.width + 4.0, 0.0, width - labelName.frame.size.width - 4.0, labelName.frame.size.height)]; + [editName addTarget:editName action:@selector(resignFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit]; + editName.placeholder = @"Name"; + editName.text = self.targetButton.properties[@"name"]; + //editName.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; + //editName.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; + [self.scrollView addSubview:editName]; + + UILabel *labelSize = [[UILabel alloc] initWithFrame:CGRectMake(0.0, labelName.frame.size.height + 4.0, 0.0, 0.0)]; + labelSize.text = @"Size"; + labelSize.numberOfLines = 0; + [labelSize sizeToFit]; + [self.scrollView addSubview:labelSize]; + UITextField *editSizeWidth = [[UITextField alloc] initWithFrame:CGRectMake(labelSize.frame.size.width + 4.0, labelSize.frame.origin.y, width - labelSize.frame.size.width - 4.0, labelSize.frame.size.height)]; + [editSizeWidth addTarget:editSizeWidth action:@selector(resignFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit]; + editSizeWidth.placeholder = @"width"; + editSizeWidth.text = ((NSNumber *)self.targetButton.properties[@"width"]).stringValue; + editSizeWidth.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; + editSizeWidth.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; + [self.scrollView addSubview:editSizeWidth]; +} + +- (void)displayControlMenu { + UIButton *buttonExit = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + buttonExit.autoresizingMask = UIViewAutoresizingFlexibleWidth; + [buttonExit setTitle:@"Exit" forState:UIControlStateNormal]; + buttonExit.frame = CGRectMake(0.0, 0.0, self.scrollView.frame.size.width, 50.0); + [buttonExit addTarget:self action:@selector(actionExit) forControlEvents:UIControlEventTouchUpInside]; + [self.scrollView addSubview:buttonExit]; +} + +- (void)actionExit { [self dismissViewControllerAnimated:YES completion:nil]; [((UINavigationController *)self.presentingViewController) setNavigationBarHidden:NO animated:YES]; [((UINavigationController *)self.presentingViewController) popViewControllerAnimated:YES]; - // [((UINavigationController *)self.presentingViewController).topViewController dismissViewControllerAnimated:YES completion:nil]; - // NSLog(@"ok=%@", ((UINavigationController *)self.presentingViewController).topViewController); } @end diff --git a/Natives/JavaLauncher.m b/Natives/JavaLauncher.m index 8514d436..fa2a4305 100644 --- a/Natives/JavaLauncher.m +++ b/Natives/JavaLauncher.m @@ -162,6 +162,12 @@ int launchJVM(int argc, char *argv[]) { } debug("[Pre-init] Beginning JVM launch\n"); + + char javaAwtPath[4096]; + // accidentally patched a bit wrong, the value should be a path containing libawt_xawt.dylib, but here is libawt.dylib path (no need to exist) + sprintf(javaAwtPath, "%s/Frameworks/libawt.dylib", getenv("BUNDLE_PATH")); + setenv("JAVA_AWT_PATH", javaAwtPath, 1); + // setenv("LIBGL_FB", "2", 1); setenv("LIBGL_MIPMAP", "3", 1); @@ -241,8 +247,6 @@ int launchJVM(int argc, char *argv[]) { margv[margc++] = userHome; margv[margc++] = gl4esPath; margv[margc++] = "-Dorg.lwjgl.system.allocator=system"; - - init_loadCustomJvmFlags(); } else { setenv("GL4ES_LIBNAME", gl4esLibname, 1); debug("[Pre-init] OpenGL library name: %s", getenv("GL4ES_LIBNAME")); @@ -265,7 +269,7 @@ int launchJVM(int argc, char *argv[]) { if (!started) { // Setup Caciocavallo - margv[margc++] = "-Djava.awt.headless=true"; // TODO: register natives to make this false + margv[margc++] = "-Djava.awt.headless=false"; margv[margc++] = "-Dcacio.font.fontmanager=sun.awt.X11FontManager"; margv[margc++] = "-Dcacio.font.fontscaler=sun.font.FreetypeFontScaler"; margv[margc++] = "-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel"; @@ -287,6 +291,9 @@ int launchJVM(int argc, char *argv[]) { margv[margc++] = cacio_classpath; } } + if (!started) { + init_loadCustomJvmFlags(); + } debug("[Init] Found JLI lib"); if (!started) { diff --git a/Natives/SurfaceViewController.m b/Natives/SurfaceViewController.m index ed46dda1..0aa9d91b 100644 --- a/Natives/SurfaceViewController.m +++ b/Natives/SurfaceViewController.m @@ -50,8 +50,8 @@ int notchOffset; @interface SurfaceViewController () { } -@property (nonatomic, strong) MGLContext *context; -@property (nonatomic, strong) NSMutableDictionary* cc_dictionary; +@property(nonatomic, strong) MGLContext *context; +@property(nonatomic, strong) NSMutableDictionary* cc_dictionary; - (void)setupGL; diff --git a/Natives/awt_xawt/empty.m b/Natives/awt_xawt/empty.m new file mode 100644 index 00000000..e69de29b diff --git a/Natives/awt_xawt/xawt_fake.m b/Natives/awt_xawt/xawt_fake.m new file mode 100644 index 00000000..dfa29694 --- /dev/null +++ b/Natives/awt_xawt/xawt_fake.m @@ -0,0 +1,261 @@ +#include "../jni.h" + +jfieldID colorValueID; + +// java.awt.* +JNIEXPORT void JNICALL +Java_java_awt_Button_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Color_initIDs + (JNIEnv *env, jclass clazz) +{ + colorValueID = (*env)->GetFieldID(env, clazz, "value", "I"); +} + +JNIEXPORT void JNICALL +Java_java_awt_Component_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Container_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Checkbox_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_CheckboxMenuItem_initIDs + (JNIEnv *env, jclass clazz) +{ +} +JNIEXPORT void JNICALL +Java_java_awt_Choice_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Cursor_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_Cursor_finalizeImpl(JNIEnv *env, jclass clazz, jlong pData) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_Dialog_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_Dimension_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_Event_initIDs(JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_FileDialog_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_FontMetrics_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Frame_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_KeyboardFocusManager_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL +Java_java_awt_Label_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL Java_java_awt_Menu_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_MenuBar_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_MenuComponent_initIDs(JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL Java_java_awt_MenuItem_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Rectangle_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Scrollbar_initIDs + (JNIEnv *env, jclass cls) +{ + +} + +JNIEXPORT void JNICALL Java_java_awt_ScrollPane_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_ScrollPaneAdjustable_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_TextArea_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_TextField_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Toolkit_initIDs + (JNIEnv *env, jclass cls) +{ +} + +JNIEXPORT void JNICALL Java_java_awt_TrayIcon_initIDs(JNIEnv *env , jclass clazz) +{ +} + +JNIEXPORT void JNICALL +Java_java_awt_Window_initIDs + (JNIEnv *env, jclass cls) +{ +} + +// java.awt.event.* +JNIEXPORT void JNICALL +Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self, jobject newSource) +{ + // Maybe implement this? +} + +JNIEXPORT void JNICALL +Java_java_awt_event_MouseEvent_initIDs + (JNIEnv *env, jclass clazz) +{ +} + +// sun.awt.SunToolkit +JNIEXPORT void JNICALL +Java_sun_awt_SunToolkit_closeSplashScreen + (JNIEnv *env, jclass cls) +{ + +} +// sun.awt.UNIXToolkit +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass, jint version) { + return JNI_FALSE; +} + +JNIEXPORT jint JNICALL +Java_sun_awt_UNIXToolkit_get_1gtk_1version(JNIEnv *env, jclass klass) +{ + // return GTK_ANY; + return (jint) 1; +} + +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl(JNIEnv *env, jobject this, + jint major, jint minor, jint micro) +{ + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass, jint version, + jboolean verbose) { + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_load_1gtk_1icon(JNIEnv *env, jobject this, + jstring filename) +{ + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_load_1stock_1icon(JNIEnv *env, jobject this, + jint widget_type, jstring stock_id, jint icon_size, + jint text_direction, jstring detail) +{ + return JNI_FALSE; +} + +JNIEXPORT void JNICALL +Java_sun_awt_UNIXToolkit_nativeSync(JNIEnv *env, jobject this) +{ + +} + +JNIEXPORT jboolean JNICALL +Java_sun_awt_UNIXToolkit_unload_1gtk(JNIEnv *env, jclass klass) +{ + return JNI_FALSE; +} + + + diff --git a/Natives/customcontrols/ControlButton.h b/Natives/customcontrols/ControlButton.h index 55113ebb..088c1140 100644 --- a/Natives/customcontrols/ControlButton.h +++ b/Natives/customcontrols/ControlButton.h @@ -11,7 +11,7 @@ @interface ControlButton : UIButton { } -@property (nonatomic, strong) NSMutableDictionary* properties; +@property(nonatomic, strong) NSMutableDictionary* properties; + (id)initWithProperties:(NSMutableDictionary *)propArray; + (id)initWithName:(NSString *)name keycode:(int)keycode rect:(CGRect)rect transparency:(float)transparency; diff --git a/Natives/customcontrols/ControlButton.m b/Natives/customcontrols/ControlButton.m index 8970dbf2..02fb2283 100644 --- a/Natives/customcontrols/ControlButton.m +++ b/Natives/customcontrols/ControlButton.m @@ -39,7 +39,7 @@ properties[@"width"] = @(rect.size.width); properties[@"height"] = @(rect.size.height); properties[@"keycode"] = @(keycode); - properties[@"transparency"] = @(transparency); + properties[@"opacity"] = @(100 - transparency); properties[@"cornerRadius"] = @(0); return [ControlButton initWithProperties:properties]; @@ -120,7 +120,7 @@ // Update other properties self.frame = CGRectMake(propX + insets.left, propY, propW, propH); - self.alpha = 1.0f - NUM2F([properties valueForKey:@"transparency"]) / 100.0f; + self.alpha = NUM2F([properties valueForKey:@"opacity"]) / 100.0f; // self.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.3f]; self.backgroundColor = convertARGB2UIColor(propBackgroundColor);