[WIP] Add ability to skip download assets
This commit is contained in:
1 parent
bcbbde5ee9
commit
2f99a5ecd7
7 files changed
+40
-14
No files matched your search
@@ -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++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
UIProgressView* install_progress_bar;
|
||||
UILabel* install_progress_text;
|
||||
UIButton* install_button;
|
||||
|
||||
@interface LauncherViewController : UIViewController
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
void UIKit_updateProgress(float progress, char* message);
|
||||
void UIKit_launchMinecraftSurfaceVC();
|
||||
void UIKit_setButtonSkippable();
|
||||
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user