- Rewrote LauncherPreferences -> PLPreferences + Now the file layout is the same as UI layout + (get/set)Preference are replaced with corresponding get/set types + Getting/setting is now done through keyPath instead of manually iterating over subdictionaries. + Implemented an isolation layer, allowing an instance to have its own settings. This is off by default - Implemented launcher_profiles + Added Profile manager that can be accessed from the sidebar + Moved "Game directory (instances)" to this screen + Replaced version selector with profile selector. Version selector is moved into profile editor. - Other changes + Cleanup code by using NSPredicate instead of huge for loops + Titles in settings are made multilined + Controller config: replaced bar button items with localized ones Due to how large the changes are, this is committed directly to the mainline branch. Bugs are expected to be found (although I did enough tests for this locally)
84 lines
2.5 KiB
Objective-C
84 lines
2.5 KiB
Objective-C
#import "ControlButton.h"
|
|
#import "ControlLayout.h"
|
|
#import "ControlSubButton.h"
|
|
#import "CustomControlsUtils.h"
|
|
#import "../LauncherPreferences.h"
|
|
#import "../ios_uikit_bridge.h"
|
|
#import "../utils.h"
|
|
|
|
@interface ControlLayout ()
|
|
@end
|
|
|
|
@implementation ControlLayout
|
|
|
|
- (void)loadControlLayout:(NSMutableDictionary *)layoutDictionary {
|
|
self.layoutDictionary = layoutDictionary;
|
|
|
|
CGFloat currentScale = [self.layoutDictionary[@"scaledAt"] floatValue];
|
|
CGFloat savedScale = getPrefFloat(@"control.button_scale");
|
|
loadControlObject(self, self.layoutDictionary);
|
|
|
|
self.layoutDictionary[@"scaledAt"] = @(savedScale);
|
|
}
|
|
|
|
- (void)loadControlFile:(NSString *)name {
|
|
[self removeAllButtons];
|
|
|
|
NSString *controlFilePath = [NSString stringWithFormat:@"%s/controlmap/%@", getenv("POJAV_HOME"), name];
|
|
|
|
self.layoutDictionary = parseJSONFromFile(controlFilePath);
|
|
if (self.layoutDictionary[@"error"] != nil) {
|
|
showDialog(localize(@"Error", nil), [NSString stringWithFormat:@"Could not open %@: %@", controlFilePath, [self.layoutDictionary[@"error"] localizedDescription]]);
|
|
return;
|
|
}
|
|
[self loadControlLayout:self.layoutDictionary];
|
|
}
|
|
|
|
- (void)removeAllButtons {
|
|
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
|
[self.layoutDictionary removeAllObjects];
|
|
}
|
|
|
|
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
|
{
|
|
return action == @selector(actionMenuExit:) ||
|
|
action == @selector(actionMenuSave:) ||
|
|
action == @selector(actionMenuLoad:) ||
|
|
action == @selector(actionMenuSetDef:) ||
|
|
action == @selector(actionMenuAddButton:) ||
|
|
action == @selector(actionMenuAddDrawer:) ||
|
|
action == @selector(actionMenuAddSubButton:) ||
|
|
action == @selector(actionMenuBtnCopy:) ||
|
|
action == @selector(actionMenuBtnDelete:) ||
|
|
action == @selector(actionMenuBtnEdit:) ||
|
|
action == @selector(actionMenuBtnSafeArea:);
|
|
}
|
|
|
|
- (BOOL)canBecomeFirstResponder {
|
|
return YES;
|
|
}
|
|
|
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
UIView *result = [super hitTest:point withEvent:event];
|
|
if (result == self && !isControlModifiable) {
|
|
return nil;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
- (void)setFrame:(CGRect)frame {
|
|
[super setFrame:frame];
|
|
|
|
for (UIView *view in self.subviews) {
|
|
if (![view isKindOfClass:ControlButton.class]) {
|
|
continue;
|
|
}
|
|
[(ControlButton *)view update];
|
|
}
|
|
|
|
CGFloat savedScale = getPrefFloat(@"control.button_scale");
|
|
self.layoutDictionary[@"scaledAt"] = @(savedScale);
|
|
}
|
|
|
|
@end
|