macOS: Add option for not showing dialogs, and revert the try/catch for showing dialog

This commit is contained in:
UnknownShadow200 2023-06-21 23:22:47 +10:00
parent f34c725d8c
commit 3ad0966590
2 changed files with 5 additions and 7 deletions

View File

@ -15,6 +15,7 @@ int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }
static int cursorPrevX, cursorPrevY;
static cc_bool cursorVisible = true;
static cc_bool showDialogs = true;
/* Gets the position of the cursor in screen or window coordinates */
static void Cursor_GetRawPos(int* x, int* y);
/* Sets whether the cursor is visible when over this window */
@ -64,6 +65,7 @@ static void ShowDialogCore(const char* title, const char* msg);
void Window_ShowDialog(const char* title, const char* msg) {
/* Ensure cursor is usable while showing message box */
cc_bool rawMode = Input_RawMode;
if (!showDialogs) return;
if (rawMode) Window_DisableRawMouse();
ShowDialogCore(title, msg);

View File

@ -150,6 +150,7 @@ static void LogUnhandledNSErrors(NSException* ex) {
static NSAutoreleasePool* pool;
void Window_Init(void) {
NSSetUncaughtExceptionHandler(LogUnhandledNSErrors);
showDialogs = Options_GetBool("show-dialogs", true);
// https://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
pool = [[NSAutoreleasePool alloc] init];
@ -546,13 +547,8 @@ void ShowDialogCore(const char* title, const char* msg) {
titleCF = CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII);
msgCF = CFStringCreateWithCString(NULL, msg, kCFStringEncodingASCII);
// backwards compatible @try @catch
NS_DURING {
alert = [NSAlert alloc];
alert = [alert init];
} NS_HANDLER {
LogUnhandledNSErrors(localException);
} NS_ENDHANDLER
alert = [NSAlert alloc];
alert = [alert init];
[alert setMessageText: titleCF];
[alert setInformativeText: msgCF];