Allow disabling the F1 menu through mkxp.json

This commit is contained in:
Struma 2022-07-04 13:06:35 -04:00
parent 22138c855a
commit d568423774
5 changed files with 23 additions and 5 deletions

View file

@ -28,6 +28,7 @@ MKXPZTouchBar *_sharedTouchBar;
@property (retain,nonatomic) NSString *gameTitle;
@property (retain,nonatomic) NSNumber *showResetButton;
@property (retain,nonatomic) NSNumber *showSettingsButton;
-(void)updateFPSDisplay:(uint32_t)value;
@end
@ -36,6 +37,7 @@ MKXPZTouchBar *_sharedTouchBar;
@synthesize gameTitle;
@synthesize showResetButton;
@synthesize showSettingsButton;
+(MKXPZTouchBar*)sharedTouchBar {
if (!_sharedTouchBar)
@ -47,13 +49,20 @@ MKXPZTouchBar *_sharedTouchBar;
self = [super init];
self.delegate = self;
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"];
bool showReset = [showResetButton boolValue];
bool showSettings = [showSettingsButton boolValue];
NSMutableArray *items = [NSMutableArray arrayWithArray:@[@"function", NSTouchBarItemIdentifierFlexibleSpace, @"icon", @"fps"]];
if (showReset || showSettings) {
[items addObject:NSTouchBarItemIdentifierFlexibleSpace];
if (showReset) [items addObject:@"reset"];
if (showSettings) [items addObject:@"rebind"];
}
self.defaultItemIdentifiers = items;
fpsLabel = [NSTextField labelWithString:@"Loading..."];
fpsLabel.alignment = NSTextAlignmentCenter;
fpsLabel.alignment = (showReset || showSettings) ? NSTextAlignmentCenter : NSTextAlignmentRight;
fpsLabel.font = [NSFont labelFontOfSize:NSFont.smallSystemFontSize];
functionKeys = [NSSegmentedControl segmentedControlWithLabels:@[@"F5", @"F6", @"F7", @"F8", @"F9"] trackingMode:NSSegmentSwitchTrackingMomentary target:self action:@selector(simFunctionKey)];
@ -163,6 +172,7 @@ void initTouchBar(SDL_Window *win, Config &conf) {
MKXPZTouchBar.sharedTouchBar.parent = windowinfo.info.cocoa.window;
MKXPZTouchBar.sharedTouchBar.gameTitle = @(conf.game.title.c_str());
MKXPZTouchBar.sharedTouchBar.showResetButton = [NSNumber numberWithBool:conf.enableReset];
MKXPZTouchBar.sharedTouchBar.showSettingsButton = [NSNumber numberWithBool:conf.enableSettings];
}
void updateTouchBarFPSDisplay(uint32_t value) {

View file

@ -200,6 +200,11 @@
//
// "enableReset": true,
// Enable F1/keybinding menu
// (default: enabled)
//
// "enableSettings": true,
// Allow symlinks for game assets to be followed
// (default: disabled)

View file

@ -130,6 +130,7 @@ void Config::read(int argc, char *argv[]) {
{"gameFolder", ""},
{"anyAltToggleFS", false},
{"enableReset", true},
{"enableSettings", true},
{"allowSymlinks", false},
{"dataPathOrg", ""},
{"dataPathApp", ""},
@ -235,6 +236,7 @@ try { exp } catch (...) {}
SET_STRINGOPT(gameFolder, gameFolder);
SET_OPT(anyAltToggleFS, boolean);
SET_OPT(enableReset, boolean);
SET_OPT(enableSettings, boolean);
SET_OPT(allowSymlinks, boolean);
SET_STRINGOPT(dataPathOrg, dataPathOrg);
SET_STRINGOPT(dataPathApp, dataPathApp);

View file

@ -69,6 +69,7 @@ struct Config {
bool anyAltToggleFS;
bool enableReset;
bool enableSettings;
bool allowSymlinks;
bool pathCache;

View file

@ -326,7 +326,7 @@ void EventThread::process(RGSSThreadData &rtData)
break;
}
if (event.key.keysym.scancode == SDL_SCANCODE_F1)
if (event.key.keysym.scancode == SDL_SCANCODE_F1 && rtData.config.enableSettings)
{
#ifndef MKXPZ_BUILD_XCODE
if (!sMenu)