Get stuff to sync
This commit is contained in:
1 parent
2a64640c19
commit
b6813c22e6
3 files changed
+37
-8
No files matched your search
@@ -34,6 +34,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeSelectionTo:(NSString *)name {
|
||||
setPreference(@"game_directory", name);
|
||||
NSString *multidirPath = [NSString stringWithFormat:@"%s/instances/%@", getenv("POJAV_HOME"), name];
|
||||
NSString *lasmPath = [NSString stringWithFormat:@"%s/Library/Application Support/minecraft", getenv("POJAV_HOME")];
|
||||
[NSFileManager.defaultManager removeItemAtPath:lasmPath error:nil];
|
||||
[NSFileManager.defaultManager createSymbolicLinkAtPath:lasmPath withDestinationPath:multidirPath error:nil];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.array.count;
|
||||
@@ -89,7 +97,7 @@ viewForFooterInSection:(NSInteger)section
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
setPreference(@"game_directory", self.array[indexPath.row]);
|
||||
[self changeSelectionTo:self.array[indexPath.row]];
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
||||
for (int i = 0; i < self.array.count; i++) {
|
||||
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
|
||||
@@ -154,9 +162,9 @@ viewForFooterInSection:(NSInteger)section
|
||||
UIAlertAction *ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
||||
NSString *directory = [NSString stringWithFormat:@"%s/instances/%@", getenv("POJAV_HOME"), self.array[indexPath.row]];
|
||||
NSError *error;
|
||||
if([[NSFileManager defaultManager] removeItemAtPath:directory error:&error]) {
|
||||
if([NSFileManager.defaultManager removeItemAtPath:directory error:&error]) {
|
||||
if ([getPreference(@"game_directory") isEqualToString:self.array[indexPath.row]]) {
|
||||
setPreference(@"game_directory", self.array[0]);
|
||||
[self changeSelectionTo:self.array[0]];
|
||||
[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
}
|
||||
[self.array removeObjectAtIndex:indexPath.row];
|
||||
@@ -187,14 +195,14 @@ viewForFooterInSection:(NSInteger)section
|
||||
|
||||
NSString *dest = [NSString stringWithFormat:@"%s/instances/%@", getenv("POJAV_HOME"), sender.text];
|
||||
if (isFooterView) {
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:dest withIntermediateDirectories:NO attributes:nil error:&error];
|
||||
[NSFileManager.defaultManager createDirectoryAtPath:dest withIntermediateDirectories:NO attributes:nil error:&error];
|
||||
} else {
|
||||
NSString *source = [NSString stringWithFormat:@"%s/instances/%@", getenv("POJAV_HOME"), sender.placeholder];
|
||||
[NSFileManager.defaultManager moveItemAtPath:source toPath:dest error:&error];
|
||||
}
|
||||
|
||||
if (error == nil) {
|
||||
setPreference(@"game_directory", sender.text);
|
||||
[self changeSelectionTo:sender.text];
|
||||
if (isFooterView) {
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.array.count inSection:0];
|
||||
[self.array addObject:sender.text];
|
||||
@@ -207,6 +215,8 @@ viewForFooterInSection:(NSInteger)section
|
||||
} else {
|
||||
int index = [self.array indexOfObject:sender.placeholder];
|
||||
self.array[index] = sender.placeholder = sender.text;
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath];
|
||||
}
|
||||
} else {
|
||||
// Restore to the previous name if we encounter an error
|
||||
|
||||
@@ -168,6 +168,22 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *);
|
||||
];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
// Scan for child pane cells and reload them
|
||||
// FIXME: any cheaper operations?
|
||||
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
|
||||
for (int section = 0; section < self.prefContents.count; section++) {
|
||||
for (int row = 0; row < self.prefContents[section].count; row++) {
|
||||
if (self.prefContents[section][row][@"type"] == self.typeChildPane) {
|
||||
[indexPaths addObject:[NSIndexPath indexPathForRow:row inSection:section]];
|
||||
}
|
||||
}
|
||||
}
|
||||
[self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return self.prefSections.count;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,6 @@ int versionSelectedAt = 0;
|
||||
|
||||
|
||||
self.versionList = [[NSMutableArray alloc] init];
|
||||
int selectedVersionType = [getPreference(@"selected_version_type") intValue];
|
||||
[self reloadVersionList:selectedVersionType];
|
||||
versionPickerView = [[UIPickerView alloc] init];
|
||||
versionPickerView.delegate = self;
|
||||
versionPickerView.dataSource = self;
|
||||
@@ -68,7 +66,7 @@ int versionSelectedAt = 0;
|
||||
NSLocalizedString(@"Old-beta", nil),
|
||||
NSLocalizedString(@"Old-alpha", nil)
|
||||
]];
|
||||
versionTypeControl.selectedSegmentIndex = selectedVersionType;
|
||||
versionTypeControl.selectedSegmentIndex = [getPreference(@"selected_version_type") intValue];
|
||||
[versionTypeControl addTarget:self action:@selector(changeVersionType:) forControlEvents:UIControlEventValueChanged];
|
||||
UIBarButtonItem *versionTypeItem = [[UIBarButtonItem alloc] initWithCustomView:versionTypeControl];
|
||||
UIBarButtonItem *versionFlexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
|
||||
@@ -114,6 +112,11 @@ int versionSelectedAt = 0;
|
||||
[scrollView addSubview:self.progressText];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self reloadVersionList:[getPreference(@"selected_version_type") intValue]];
|
||||
}
|
||||
|
||||
- (BOOL)isVersionInstalled:(NSString *)versionId
|
||||
{
|
||||
NSString *localPath = [NSString stringWithFormat:@"%s/versions/%@", getenv("POJAV_GAME_DIR"), versionId];
|
||||
|
||||
Reference in new issue
Block a user