oopsie-poopsie I did a #$*&ky-wucky

Also, in other news, apparently SDL runs fast enough that it outpaced
the rest of the program and caused infinite loops if you called two
window-related functions too fast (like Graphics.scale + Graphics.center)
This commit is contained in:
Snowdream 2022-07-24 03:05:04 -04:00
parent e492bd0cf5
commit 1424a19189
4 changed files with 28 additions and 33 deletions

View file

@ -141,7 +141,8 @@ $(LIBDIR)/libpixman-1.a: $(DOWNLOADS)/pixman/Makefile
$(DOWNLOADS)/pixman/Makefile: $(DOWNLOADS)/pixman/autogen.sh $(DOWNLOADS)/pixman/Makefile: $(DOWNLOADS)/pixman/autogen.sh
cd $(DOWNLOADS)/pixman; \ cd $(DOWNLOADS)/pixman; \
$(AUTOGEN) --enable-static=yes --enable-shared=no $(AUTOGEN) --enable-static=yes --enable-shared=no \
--disable-arm-a64-neon
$(DOWNLOADS)/pixman/autogen.sh: $(DOWNLOADS)/pixman/autogen.sh:
$(CLONE) $(GITLAB)/mkxp-z/pixman $(DOWNLOADS)/pixman $(CLONE) $(GITLAB)/mkxp-z/pixman $(DOWNLOADS)/pixman

View file

@ -27,17 +27,14 @@ MKXPZTouchBar *_sharedTouchBar;
} }
@property (retain,nonatomic) NSString *gameTitle; @property (retain,nonatomic) NSString *gameTitle;
@property (retain,nonatomic) NSNumber *showResetButton;
@property (retain,nonatomic) NSNumber *showSettingsButton;
-(void)updateFPSDisplay:(uint32_t)value; -(void)updateFPSDisplay:(uint32_t)value;
-(void)setBarLayoutWithSettingsButton:(bool)showSettings andResetButton:(bool)showReset;
@end @end
@implementation MKXPZTouchBar @implementation MKXPZTouchBar
@synthesize gameTitle; @synthesize gameTitle;
@synthesize showResetButton;
@synthesize showSettingsButton;
+(MKXPZTouchBar*)sharedTouchBar { +(MKXPZTouchBar*)sharedTouchBar {
if (!_sharedTouchBar) if (!_sharedTouchBar)
@ -45,12 +42,16 @@ MKXPZTouchBar *_sharedTouchBar;
return _sharedTouchBar; return _sharedTouchBar;
} }
-(instancetype)init { -(void)setBarLayoutWithSettingsButton:(bool)showSettings andResetButton:(bool)showReset {
self = [super init]; if (!functionKeys) {
self.delegate = self; functionKeys = [NSSegmentedControl segmentedControlWithLabels:@[@"F5", @"F6", @"F7", @"F8", @"F9"] trackingMode:NSSegmentSwitchTrackingMomentary target:self action:@selector(simFunctionKey)];
functionKeys.segmentStyle = NSSegmentStyleSeparated;
bool showReset = [showResetButton boolValue]; }
bool showSettings = [showSettingsButton boolValue]; if (!fpsLabel) {
fpsLabel = [NSTextField labelWithString:@"Loading..."];
fpsLabel.alignment = (showReset || showSettings) ? NSTextAlignmentCenter : NSTextAlignmentRight;
fpsLabel.font = [NSFont labelFontOfSize:NSFont.smallSystemFontSize];
}
NSMutableArray *items = [NSMutableArray arrayWithArray:@[@"function", NSTouchBarItemIdentifierFlexibleSpace]]; NSMutableArray *items = [NSMutableArray arrayWithArray:@[@"function", NSTouchBarItemIdentifierFlexibleSpace]];
@ -58,20 +59,18 @@ MKXPZTouchBar *_sharedTouchBar;
[items addObject:@"icon"]; [items addObject:@"icon"];
[items addObject:@"fps"]; [items addObject:@"fps"];
[items addObject:NSTouchBarItemIdentifierFlexibleSpace]; [items addObject:NSTouchBarItemIdentifierFlexibleSpace];
if (showReset) [items addObject:@"reset"];
if (showSettings) [items addObject:@"rebind"]; if (showSettings) [items addObject:@"rebind"];
if (showReset) [items addObject:@"reset"];
} else { } else {
[items addObject:@"fps"]; [items addObject:@"fps"];
[items addObject:@"icon"]; [items addObject:@"icon"];
} }
self.defaultItemIdentifiers = items; self.defaultItemIdentifiers = items;
}
fpsLabel = [NSTextField labelWithString:@"Loading..."];
fpsLabel.alignment = (showReset || showSettings) ? NSTextAlignmentCenter : NSTextAlignmentRight; -(instancetype)init {
fpsLabel.font = [NSFont labelFontOfSize:NSFont.smallSystemFontSize]; self = [super init];
self.delegate = self;
functionKeys = [NSSegmentedControl segmentedControlWithLabels:@[@"F5", @"F6", @"F7", @"F8", @"F9"] trackingMode:NSSegmentSwitchTrackingMomentary target:self action:@selector(simFunctionKey)];
functionKeys.segmentStyle = NSSegmentStyleSeparated;
return self; return self;
} }
@ -173,11 +172,11 @@ void initTouchBar(SDL_Window *win, Config &conf) {
SDL_SysWMinfo windowinfo{}; SDL_SysWMinfo windowinfo{};
SDL_GetWindowWMInfo(win, &windowinfo); SDL_GetWindowWMInfo(win, &windowinfo);
windowinfo.info.cocoa.window.touchBar = MKXPZTouchBar.sharedTouchBar; MKXPZTouchBar *tb = MKXPZTouchBar.sharedTouchBar;
MKXPZTouchBar.sharedTouchBar.parent = windowinfo.info.cocoa.window; windowinfo.info.cocoa.window.touchBar = tb;
MKXPZTouchBar.sharedTouchBar.gameTitle = @(conf.game.title.c_str()); tb.parent = windowinfo.info.cocoa.window;
MKXPZTouchBar.sharedTouchBar.showResetButton = [NSNumber numberWithBool:conf.enableReset]; tb.gameTitle = @(conf.game.title.c_str());
MKXPZTouchBar.sharedTouchBar.showSettingsButton = [NSNumber numberWithBool:conf.enableSettings]; [tb setBarLayoutWithSettingsButton:conf.enableSettings andResetButton:conf.enableReset];
} }
void updateTouchBarFPSDisplay(uint32_t value) { void updateTouchBarFPSDisplay(uint32_t value) {

View file

@ -128,7 +128,6 @@ Config::Config() {}
void Config::read(int argc, char *argv[]) { void Config::read(int argc, char *argv[]) {
auto optsJ = json::object({ auto optsJ = json::object({
{"rgssVersion", 0}, {"rgssVersion", 0},
{"preferMetalRenderer", true},
{"debugMode", false}, {"debugMode", false},
{"printFPS", false}, {"printFPS", false},
{"winResizable", true}, {"winResizable", true},
@ -143,12 +142,10 @@ void Config::read(int argc, char *argv[]) {
{"frameSkip", false}, {"frameSkip", false},
{"syncToRefreshrate", false}, {"syncToRefreshrate", false},
{"solidFonts", false}, {"solidFonts", false},
#ifdef __APPLE__ #if defined(__APPLE__) && defined(__aarch64__)
#ifdef __x86_64__
{"preferMetalRenderer", false},
#else
{"preferMetalRenderer", true}, {"preferMetalRenderer", true},
#endif #else
{"preferMetalRenderer", false},
#endif #endif
{"subImageFix", false}, {"subImageFix", false},
#ifdef __WIN32__ #ifdef __WIN32__

View file

@ -28,9 +28,7 @@ struct AtomicFlag
void wait() void wait()
{ {
while (SDL_AtomicGet(&atom)) { while (SDL_AtomicGet(&atom)) {}
usleep(5000);
}
} }
void reset() void reset()