Only show TouchBar reset button when enableReset is true

This commit is contained in:
Struma 2022-07-04 11:33:46 -04:00
parent 4b46d6e47d
commit 22138c855a

View file

@ -27,6 +27,7 @@ MKXPZTouchBar *_sharedTouchBar;
} }
@property (retain,nonatomic) NSString *gameTitle; @property (retain,nonatomic) NSString *gameTitle;
@property (retain,nonatomic) NSNumber *showResetButton;
-(void)updateFPSDisplay:(uint32_t)value; -(void)updateFPSDisplay:(uint32_t)value;
@end @end
@ -34,6 +35,7 @@ MKXPZTouchBar *_sharedTouchBar;
@implementation MKXPZTouchBar @implementation MKXPZTouchBar
@synthesize gameTitle; @synthesize gameTitle;
@synthesize showResetButton;
+(MKXPZTouchBar*)sharedTouchBar { +(MKXPZTouchBar*)sharedTouchBar {
if (!_sharedTouchBar) if (!_sharedTouchBar)
@ -44,7 +46,11 @@ MKXPZTouchBar *_sharedTouchBar;
-(instancetype)init { -(instancetype)init {
self = [super init]; self = [super init];
self.delegate = self; self.delegate = self;
self.defaultItemIdentifiers = @[@"function", NSTouchBarItemIdentifierFlexibleSpace, @"icon", @"fps", NSTouchBarItemIdentifierFlexibleSpace, @"rebind", @"reset"];
NSMutableArray *items = [NSMutableArray arrayWithArray:@[@"function", NSTouchBarItemIdentifierFlexibleSpace, @"icon", @"fps", NSTouchBarItemIdentifierFlexibleSpace, @"rebind"]];
// Only show the reset button if resetting is enabled
if ([showResetButton boolValue]) [items addObject:@"reset"];
self.defaultItemIdentifiers = items;
fpsLabel = [NSTextField labelWithString:@"Loading..."]; fpsLabel = [NSTextField labelWithString:@"Loading..."];
fpsLabel.alignment = NSTextAlignmentCenter; fpsLabel.alignment = NSTextAlignmentCenter;
@ -156,6 +162,7 @@ void initTouchBar(SDL_Window *win, Config &conf) {
windowinfo.info.cocoa.window.touchBar = MKXPZTouchBar.sharedTouchBar; windowinfo.info.cocoa.window.touchBar = MKXPZTouchBar.sharedTouchBar;
MKXPZTouchBar.sharedTouchBar.parent = windowinfo.info.cocoa.window; MKXPZTouchBar.sharedTouchBar.parent = windowinfo.info.cocoa.window;
MKXPZTouchBar.sharedTouchBar.gameTitle = @(conf.game.title.c_str()); MKXPZTouchBar.sharedTouchBar.gameTitle = @(conf.game.title.c_str());
MKXPZTouchBar.sharedTouchBar.showResetButton = [NSNumber numberWithBool:conf.enableReset];
} }
void updateTouchBarFPSDisplay(uint32_t value) { void updateTouchBarFPSDisplay(uint32_t value) {