Change yaze_run_cocoa_app_delegate to return an int for better error handling; update main to reflect this change
This commit is contained in:
@@ -51,7 +51,7 @@ void yaze_initialize_cocoa();
|
|||||||
/**
|
/**
|
||||||
* @brief Run the Cocoa application delegate.
|
* @brief Run the Cocoa application delegate.
|
||||||
*/
|
*/
|
||||||
void yaze_run_cocoa_app_delegate(const char *filename);
|
int yaze_run_cocoa_app_delegate(const char *filename);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
@@ -236,20 +236,26 @@ extern "C" void yaze_initialize_cococa() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void yaze_run_cocoa_app_delegate(const char *filename) {
|
extern "C" int yaze_run_cocoa_app_delegate(const char *filename) {
|
||||||
yaze_initialize_cococa();
|
yaze_initialize_cococa();
|
||||||
yaze::core::Controller controller;
|
yaze::core::Controller controller;
|
||||||
RETURN_VOID_IF_ERROR(controller.OnEntry(filename));
|
EXIT_IF_ERROR(controller.OnEntry(filename));
|
||||||
while (controller.IsActive()) {
|
while (controller.IsActive()) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
controller.OnInput();
|
controller.OnInput();
|
||||||
if (auto status = controller.OnLoad(); !status.ok()) {
|
if (auto status = controller.OnLoad(); !status.ok()) {
|
||||||
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
|
[alert setMessageText:@"Error"];
|
||||||
|
[alert setInformativeText:[NSString stringWithUTF8String:status.message().data()]];
|
||||||
|
[alert addButtonWithTitle:@"OK"];
|
||||||
|
[alert runModal];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
controller.DoRender();
|
controller.DoRender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controller.OnExit();
|
controller.OnExit();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
yaze_run_cocoa_app_delegate(rom_filename.c_str());
|
return yaze_run_cocoa_app_delegate(rom_filename.c_str());
|
||||||
return EXIT_SUCCESS;
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
// We set SDL_MAIN_HANDLED for Win32 to avoid SDL hijacking main()
|
// We set SDL_MAIN_HANDLED for Win32 to avoid SDL hijacking main()
|
||||||
SDL_SetMainReady();
|
SDL_SetMainReady();
|
||||||
|
|||||||
Reference in New Issue
Block a user