Allow playing without network connection
Also Login UI WIP: add account list
This commit is contained in:
1 parent
86b53581d8
commit
c2e4e993ab
5 files changed
+54
-18
No files matched your search
@@ -24,6 +24,8 @@ public class PLaunchApp {
|
||||
try {
|
||||
File mcDir = new File("/var/mobile/Documents/minecraft");
|
||||
mcDir.mkdirs();
|
||||
File pojavDir = new File("/var/mobile/Documents/.pojavlauncher/accounts");
|
||||
pojavDir.mkdirs();
|
||||
if (!new File(mcDir, "config_ver.txt").exists()) {
|
||||
Tools.write(mcDir.getAbsolutePath() + "/config_ver.txt", "1.16.5");
|
||||
}
|
||||
@@ -92,10 +94,16 @@ public class PLaunchApp {
|
||||
JAssets assets = null;
|
||||
|
||||
UIKit.updateProgressSafe(0, "Downloading version list");
|
||||
mVersionList = Tools.GLOBAL_GSON.fromJson(DownloadUtils.downloadString("https://launchermeta.mojang.com/mc/game/version_manifest.json"), JMinecraftVersionList.class);
|
||||
try {
|
||||
mVersionList = Tools.GLOBAL_GSON.fromJson(DownloadUtils.downloadString("https://launchermeta.mojang.com/mc/game/version_manifest.json"), JMinecraftVersionList.class);
|
||||
} catch (IOException e) {
|
||||
UIKit.updateProgressSafe(0, "Error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
verInfo = findVersion(mcver);
|
||||
if (verInfo.url != null && !new File(verJsonDir).exists()) {
|
||||
if (verInfo.url != null && !new File(verJsonDir).exists() && mVersionList != null) {
|
||||
// mVersionList != null is for checking if user have network connection
|
||||
UIKit.updateProgressSafe(0, "Downloading " + mcver + ".json");
|
||||
Tools.downloadFile(verInfo.url, verJsonDir);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface LoginListViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
|
||||
@interface LoginListViewController : UITableViewController
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#import "LauncherViewController.h"
|
||||
#import "LoginViewController.h"
|
||||
|
||||
@@ -109,8 +112,8 @@ alertTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
|
||||
[alertTableView setAllowsSelection:YES];
|
||||
*/
|
||||
|
||||
LoginListViewController *controller = [[LoginListViewController alloc] init];
|
||||
[self presentViewController:controller animated:YES completion:nil];
|
||||
LoginListViewController *vc = [[LoginListViewController alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)enterLauncher {
|
||||
@@ -132,29 +135,43 @@ NSMutableArray *accountList;
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[self setTitle:@"Select account"];
|
||||
|
||||
if (accountList == nil) {
|
||||
accountList = [NSMutableArray array];
|
||||
} else {
|
||||
[accountList removeAllObjects];
|
||||
}
|
||||
|
||||
[accountList addObject:@"mojangacc1"];
|
||||
[accountList addObject:@"themsacc"];
|
||||
[accountList addObject:@"offlineme"];
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
d = opendir("/var/mobile/Documents/.pojavlauncher/accounts");
|
||||
if (d) {
|
||||
int i = 0;
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// Skip "." and ".."
|
||||
if (i < 2) {
|
||||
i++;
|
||||
continue;
|
||||
} else if ([@(dir->d_name) hasSuffix:@".json"]) {
|
||||
NSString *trimmedName= [@(dir->d_name) substringToIndex:((int)[@(dir->d_name) length] - 5)];
|
||||
[accountList addObject:trimmedName];
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
|
||||
int width = (int) roundf(screenBounds.size.width);
|
||||
int height = (int) roundf(screenBounds.size.height) - self.navigationController.navigationBar.frame.size.height;
|
||||
|
||||
self.view.frame = CGRectMake(width / 6, height / 6, width - width / 3, height);
|
||||
// self.view.frame = CGRectMake(width / 6, height / 6, width - width / 3, height);
|
||||
|
||||
UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.frame];
|
||||
tableView.delegate = self;
|
||||
tableView.dataSource = self;
|
||||
tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
|
||||
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
|
||||
[self.view addSubview:tableView];
|
||||
// UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.frame];
|
||||
// tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
|
||||
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
|
||||
// [self.view addSubview:tableView];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
@@ -164,8 +181,7 @@ NSMutableArray *accountList;
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString *simpleTableIdentifier = @"SimpleTableCell";
|
||||
|
||||
NSString *simpleTableIdentifier = @"cell";
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
|
||||
|
||||
if (cell == nil) {
|
||||
@@ -176,4 +192,15 @@ NSMutableArray *accountList;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSInteger rowNo = indexPath.row;
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||
// delete
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "jni.h"
|
||||
#include "login_bridge.h"
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p packages/pojavlauncher_iphoneos-arm/{DEBIAN,Applications,var/mobile/Documents/minecraft}
|
||||
mkdir -p packages/pojavlauncher_iphoneos-arm/{DEBIAN,Applications,var/mobile/Documents/minecraft,var/mobile/Documents/.pojavlauncher}
|
||||
cp -R Natives/build/Release-iphoneos/PojavLauncher.app packages/pojavlauncher_iphoneos-arm/Applications
|
||||
cp control packages/pojavlauncher_iphoneos-arm/DEBIAN
|
||||
|
||||
|
||||
Reference in new issue
Block a user