WIP: re-write the preferences UI
This commit is contained in:
1 parent
9a5cee04c6
commit
be39a72e38
4 files changed
+178
No files matched your search
@@ -15,6 +15,7 @@ include_directories(
|
||||
"external/AFNetworking/AFNetworking"
|
||||
"external/AFNetworking/UIKit+AFNetworking"
|
||||
"external/DBNumberedSlider/Classes"
|
||||
"external/TOInsetGroupedTableView/TOInsetGroupedTableView"
|
||||
"external/fishhook"
|
||||
"external/mesa"
|
||||
)
|
||||
@@ -100,6 +101,7 @@ add_executable(PojavLauncher
|
||||
customcontrols/CustomControlsUtils.m
|
||||
|
||||
external/DBNumberedSlider/Classes/DBNumberedSlider.m
|
||||
external/TOInsetGroupedTableView/TOInsetGroupedTableView/TOInsetGroupedTableView.m
|
||||
|
||||
AboutLauncherViewController.m
|
||||
AccountListViewController.m
|
||||
@@ -113,6 +115,7 @@ add_executable(PojavLauncher
|
||||
LauncherMenuViewController.m
|
||||
LauncherPreferences.m
|
||||
LauncherPreferencesViewController.m
|
||||
LauncherPreferencesViewController2.m
|
||||
LauncherSplitViewController.m
|
||||
LauncherViewController.m
|
||||
LoginViewController.m
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define JRE8_NAME_JB @"Java 8"
|
||||
#define JRE16_NAME_JB @"Java 16"
|
||||
#define JRE17_NAME_JB @"Java 17"
|
||||
#define JRE8_NAME_SB @"Java 8 (sandbox)"
|
||||
|
||||
@interface LauncherPreferencesViewController2 : UITableViewController<UITextFieldDelegate>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,164 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DBNumberedSlider.h"
|
||||
#import "LauncherPreferences.h"
|
||||
#import "LauncherPreferencesViewController2.h"
|
||||
#import "TOInsetGroupedTableView.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@interface LauncherPreferencesViewController2() {}
|
||||
@property NSArray<NSString*>* prefSections;
|
||||
@property NSArray<NSDictionary<NSString*, NSDictionary*>*>* prefContents;
|
||||
@end
|
||||
|
||||
@implementation LauncherPreferencesViewController2
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.tableView = [[TOInsetGroupedTableView alloc] init];
|
||||
self.tableView.allowsSelection = NO;
|
||||
|
||||
self.prefSections = @[@"general", @"video", @"control", @"java"];
|
||||
|
||||
self.prefContents = @[
|
||||
@{
|
||||
// General settings
|
||||
@"game_directory": @{
|
||||
@"icon": @"folder",
|
||||
@"type": @"PickField",
|
||||
@"pickList": @[@"default", @"TODO"]
|
||||
}
|
||||
}, @{
|
||||
// Video and renderer settings
|
||||
@"renderer": @{
|
||||
@"icon": @"cpu",
|
||||
@"type": @"PickField",
|
||||
@"pickList": @[@"gl4es", @"zink", @"wip"]
|
||||
},
|
||||
@"resolution": @{
|
||||
@"icon": @"viewfinder",
|
||||
@"type": @"Slider"
|
||||
},
|
||||
}, @{
|
||||
// Control settings
|
||||
/*
|
||||
@"disable_gesture": @{
|
||||
@"type": @"Switch"
|
||||
},
|
||||
*/
|
||||
@"press_duration": @{
|
||||
@"icon": @"timer",
|
||||
@"type": @"Slider",
|
||||
@"min": @(100),
|
||||
@"max": @(1000)
|
||||
},
|
||||
@"button_scale": @{
|
||||
@"icon": @"aspectratio",
|
||||
@"type": @"Slider",
|
||||
@"min": @(50), // 80?
|
||||
@"max": @(500)
|
||||
},
|
||||
@"mouse_scale": @{
|
||||
@"icon": @"arrow.up.left.and.arrow.down.right.circle",
|
||||
@"type": @"Slider",
|
||||
@"min": @(25),
|
||||
@"max": @(300)
|
||||
},
|
||||
@"mouse_speed": @{
|
||||
@"icon": @"arrow.left.and.right",
|
||||
@"type": @"Slider",
|
||||
@"min": @(25),
|
||||
@"max": @(300)
|
||||
},
|
||||
@"virtmouse_enable": @{
|
||||
@"icon": @"cursorarrow.rays",
|
||||
@"type": @"Switch"
|
||||
},
|
||||
@"slideable_hotbar": @{
|
||||
@"icon": @"slider.horizontal.below.rectangle",
|
||||
@"type": @"Switch"
|
||||
}
|
||||
}, @{
|
||||
// Java tweaks
|
||||
@"java_home": @{
|
||||
@"icon": @"cube",
|
||||
@"type": @"PickField",
|
||||
@"pickList": @[@"java-8-openjdk", @"java-17-openjdk", @"TODO"]
|
||||
},
|
||||
@"java_args": @{
|
||||
@"icon": @"slider.vertical.3",
|
||||
@"type": @"TextField"
|
||||
},
|
||||
@"ram_unjb_enable": @{ // TODO: name as Auto RAM
|
||||
@"icon": @"slider.horizontal.3",
|
||||
@"type": @"Switch",
|
||||
@"hidden": @(getenv("POJAV_DETECTEDJB") != NULL)
|
||||
},
|
||||
@"allocated_memory": @{
|
||||
@"icon": @"memorychip",
|
||||
@"type": @"Slider",
|
||||
@"min": @(25),
|
||||
@"max": @(300)
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return self.prefSections.count;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
return NSLocalizedString(([NSString stringWithFormat:@"preference.section.%@", self.prefSections[section]]), nil);
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.prefContents[section].count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
|
||||
}
|
||||
|
||||
NSString *key = self.prefContents[indexPath.section].allKeys[indexPath.row];
|
||||
NSDictionary *item = self.prefContents[indexPath.section].allValues[indexPath.row];
|
||||
NSString *type = item[@"type"];
|
||||
if ([type isEqualToString:@"PickField"]) {
|
||||
cell.accessoryView = [[UITextField alloc] init];
|
||||
[(id)(cell.accessoryView) setText:getPreference(key)];
|
||||
} else if ([type isEqualToString:@"TextField"]) {
|
||||
UITextField *view = [[UITextField alloc] init];
|
||||
view.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||
view.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||
view.placeholder = NSLocalizedString(([NSString stringWithFormat:@"preference.placeholder.%@", key]), nil);
|
||||
view.text = getPreference(key);
|
||||
view.adjustsFontSizeToFitWidth = YES;
|
||||
cell.accessoryView = view;
|
||||
} else if ([type isEqualToString:@"Slider"]) {
|
||||
DBNumberedSlider *view = [[DBNumberedSlider alloc] init];
|
||||
view.minimumValue = [item[@"min"] intValue];
|
||||
view.maximumValue = [item[@"max"] intValue];
|
||||
view.continuous = YES;
|
||||
view.value = [getPreference(key) intValue];
|
||||
cell.accessoryView = view;
|
||||
} else if ([type isEqualToString:@"Switch"]) {
|
||||
cell.accessoryView = [[UISwitch alloc] init];
|
||||
[(id)(cell.accessoryView) setOn:[getPreference(key) boolValue] animated:NO];
|
||||
} else {
|
||||
NSAssert(NO, @"Unknown type: %@", type);
|
||||
}
|
||||
|
||||
if (@available(iOS 13.0, *)) {
|
||||
cell.imageView.image = [UIImage systemImageNamed:item[@"icon"]];
|
||||
}
|
||||
cell.textLabel.text = NSLocalizedString(([NSString stringWithFormat:@"preference.title.%@", key]), nil);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
+1
Submodule Natives/external/TOInsetGroupedTableView added at a17c55acd5.
Reference in new issue
Block a user