Skip to content

Commit

Permalink
Cleanup in installer, remove unexpectedly added includes
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Feb 10, 2024
1 parent d730232 commit a0f535d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
1 change: 0 additions & 1 deletion Natives/DownloadProgressViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
} else if (context == TotalProgressObserverContext) {
dispatch_async(dispatch_get_main_queue(), ^{
self.title = [NSString stringWithFormat:@"(%@) %@", progress.localizedAdditionalDescription, progress.localizedDescription];
static dispatch_once_t once;
if (self.needsReloadData) {
[self.tableView reloadData];
}
Expand Down
1 change: 0 additions & 1 deletion Natives/MinecraftResourceDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#import "authenticator/BaseAuthenticator.h"
#import "AFNetworking.h"
#import "AFURLSessionOperation.h"
#import "LauncherNavigationController.h"
#import "LauncherPreferences.h"
#import "MinecraftResourceDownloadTask.h"
Expand Down
2 changes: 0 additions & 2 deletions Natives/MinecraftResourceUtils.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <CommonCrypto/CommonDigest.h>

#import "authenticator/BaseAuthenticator.h"
#import "AFNetworking.h"
#import "AFURLSessionOperation.h"
#import "LauncherNavigationController.h"
#import "LauncherPreferences.h"
#import "MinecraftResourceUtils.h"
Expand Down
37 changes: 9 additions & 28 deletions Natives/installer/ForgeInstallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ - (void)viewDidLoad {
},
@"NeoForge": @{
@"installer": @"https://maven.neoforged.net/net/neoforged/forge/%1$@/forge-%1$@-installer.jar",
@"metadata": @"https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge"
@"metadata": @"https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml"
}
};
self.visibilityList = [NSMutableArray new];
self.versionList = [NSMutableArray new];
self.forgeList = [NSMutableArray new];
[self loadForgeMetadata];
[self loadMetadataFromVendor:@"Forge"];
}

- (void)actionCancelDownload {
Expand All @@ -57,10 +57,10 @@ - (void)actionClose {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

- (void)loadForgeMetadata {
- (void)loadMetadataFromVendor:(NSString *)vendor {
[self switchToLoadingState];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *url = [[NSURL alloc] initWithString:self.endpoints[@"Forge"][@"metadata"]];
NSURL *url = [[NSURL alloc] initWithString:self.endpoints[vendor][@"metadata"]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
parser.delegate = self;
if (![parser parse]) {
Expand All @@ -71,22 +71,6 @@ - (void)loadForgeMetadata {
});
}

- (void)loadNeoForgeMetadata {
[self switchToLoadingState];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:self.endpoints[@"NeoForge"][@"metadata"] parameters:nil headers:nil progress:nil
success:^(NSURLSessionTask *task, NSDictionary *response) {
for (NSString *version in response[@"versions"]) {
[self addVersionToList:version];
}
[self switchToReadyState];
[self.tableView reloadData];
} failure:^(NSURLSessionTask *operation, NSError *error) {
showDialog(localize(@"Error", nil), error.localizedDescription);
[self switchToReadyState];
}];
}

- (void)switchToLoadingState {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:indicator];
Expand All @@ -106,14 +90,8 @@ - (void)segmentChanged:(UISegmentedControl *)segment {
[self.versionList removeAllObjects];
[self.forgeList removeAllObjects];
[self.tableView reloadData];
switch (segment.selectedSegmentIndex) {
case 0:
[self loadForgeMetadata];
break;
case 1:
[self loadNeoForgeMetadata];
break;
}
NSString *vendor = [segment titleForSegmentAtIndex:segment.selectedSegmentIndex];
[self loadMetadataFromVendor:vendor];
}

#pragma mark UITableViewDataSource
Expand Down Expand Up @@ -206,6 +184,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}

- (void)addVersionToList:(NSString *)version {
if (![version containsString:@"-"]) {
return;
}
NSRange range = [version rangeOfString:@"-"];
NSString *gameVersion = [version substringToIndex:range.location];
//NSString *forgeVersion = [version substringFromIndex:range.location + 1];
Expand Down

0 comments on commit a0f535d

Please sign in to comment.