diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java index 686cf213..ccad0a2d 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java @@ -181,12 +181,13 @@ public class PLaunchApp { File objectsDir = new File(outputDir, "objects"); int downloadedSs = 0; for (JAssetInfo asset : assetsObjects.values()) { + currProgress++; + mIsAssetsProcessing = !UIKit.updateProgressSafe(currProgress / maxProgress, "Downloading " + assetsObjects.keySet().toArray(new String[0])[downloadedSs]); + if (!mIsAssetsProcessing) { return; } - currProgress++; - UIKit.updateProgressSafe(currProgress / maxProgress, "Downloading " + assetsObjects.keySet().toArray(new String[0])[downloadedSs]); if(!assets.map_to_resources) downloadAsset(asset, objectsDir); else downloadAssetMapped(asset,(assetsObjects.keySet().toArray(new String[0])[downloadedSs]),outputDir); downloadedSs++; diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java index e70de797..66e1e6b9 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java @@ -45,9 +45,9 @@ public class UIKit { CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY); } - public static void updateProgressSafe(final float progress, final String message) { + public static boolean updateProgressSafe(final float progress, final String message) { System.out.println(message); - updateProgress(progress, ((int) progress)*100 + "% - " + message); + return updateProgress(progress, ((int) (progress * 100)) + "% - " + message); } static { @@ -58,7 +58,7 @@ public class UIKit { // public static native void runOnUIThread(UIKitCallback callback); // Update progress - public static native void updateProgress(float progress, String message); + public static native boolean updateProgress(float progress, String message); // Start SurfaceViewController public static native void launchMinecraftSurface(boolean isUseStackQueueBool); diff --git a/Natives/LauncherViewController.h b/Natives/LauncherViewController.h index be88ba0d..398e37eb 100644 --- a/Natives/LauncherViewController.h +++ b/Natives/LauncherViewController.h @@ -2,6 +2,7 @@ UIProgressView* install_progress_bar; UILabel* install_progress_text; +UIButton* install_button; @interface LauncherViewController : UIViewController diff --git a/Natives/LauncherViewController.m b/Natives/LauncherViewController.m index 080eae14..43b985dd 100644 --- a/Natives/LauncherViewController.m +++ b/Natives/LauncherViewController.m @@ -54,12 +54,12 @@ UITextField* versionTextField; install_progress_bar = [[UIProgressView alloc] initWithFrame:CGRectMake(4.0, height - 58.0, width - 8.0, 6.0)]; [scrollView addSubview:install_progress_bar]; - UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth; - [button setTitle:@"Play" forState:UIControlStateNormal]; - button.frame = CGRectMake(10.0, height - 54.0, 100.0, 50.0); - [button addTarget:self action:@selector(launchMinecraft:) forControlEvents:UIControlEventTouchUpInside]; - [scrollView addSubview:button]; + install_button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + install_button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth; + [install_button setTitle:@"Play" forState:UIControlStateNormal]; + install_button.frame = CGRectMake(10.0, height - 54.0, 100.0, 50.0); + [install_button addTarget:self action:@selector(launchMinecraft:) forControlEvents:UIControlEventTouchUpInside]; + [scrollView addSubview:install_button]; install_progress_text = [[UILabel alloc] initWithFrame:CGRectMake(120.0, height - 54.0, width - 124.0, 50.0)]; [scrollView addSubview:install_progress_text]; diff --git a/Natives/input_bridge_v3.c b/Natives/input_bridge_v3.c index ef201418..b3c86dc3 100644 --- a/Natives/input_bridge_v3.c +++ b/Natives/input_bridge_v3.c @@ -211,10 +211,15 @@ void callback_SurfaceViewController_onTouch(int event, int x, int y) { ); } -JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_uikit_UIKit_updateProgress(JNIEnv* env, jclass clazz, jfloat progress, jstring message) { +JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_uikit_UIKit_setButtonSkippable(JNIEnv* env, jclass clazz) { + UIKit_setButtonSkippable(); +} + +JNIEXPORT jboolean JNICALL Java_net_kdt_pojavlaunch_uikit_UIKit_updateProgress(JNIEnv* env, jclass clazz, jfloat progress, jstring message) { const char *message_c = (*env)->GetStringUTFChars(env, message, 0); - UIKit_updateProgress(progress, message_c); + jboolean skipDownloadAssets = UIKit_updateProgress(progress, message_c); (*env)->ReleaseStringUTFChars(env, message, message_c); + return skipDownloadAssets; } JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_uikit_UIKit_launchMinecraftSurface(JNIEnv* env, jclass clazz, jboolean isUseStackQueueBool) { diff --git a/Natives/ios_uikit_bridge.h b/Natives/ios_uikit_bridge.h index 2fa0eb78..2245bc80 100644 --- a/Natives/ios_uikit_bridge.h +++ b/Natives/ios_uikit_bridge.h @@ -3,3 +3,4 @@ void UIKit_updateProgress(float progress, char* message); void UIKit_launchMinecraftSurfaceVC(); +void UIKit_setButtonSkippable(); diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 1084e844..109543f0 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -8,11 +8,29 @@ #include "ios_uikit_bridge.h" #include "utils.h" -void UIKit_updateProgress(float progress, char* message) { +jboolean skipDownloadAssets; + +jboolean UIKit_updateProgress(float progress, char* message) { dispatch_async(dispatch_get_main_queue(), ^{ install_progress_bar.progress = progress; install_progress_text.text = [NSString stringWithUTF8String:message]; }); + return skipDownloadAssets; +} + +void UIKit_skipDownloadAssets() { + [install_button setEnabled:NO]; + skipDownloadAssets = JNI_TRUE; +} + +void UIKit_setButtonSkippable() { + dispatch_async(dispatch_get_main_queue(), ^{ + [install_button setEnabled:YES]; + [install_button setTitle:@"Skip" forState:UIControlStateNormal]; + [install_button addTarget:self action:@selector(UIKit_skipDownloadAssets) forControlEvents:UIControlEventTouchUpInside]; + }); + + skipDownloadAssets = JNI_FALSE; } void UIKit_launchMinecraftSurfaceVC() {