Scenario Editor: try to correct a problem when displaying terrain in zoom out mode,

Mac: add hack to avoid crashing when receiving an apple event,
+ various minor modifications
This commit is contained in:
ALONSO Laurent
2021-10-26 10:31:06 +02:00
committed by Celtic Minstrel
parent c20878ecd6
commit 2106f45840
23 changed files with 159 additions and 60 deletions

View File

@@ -8,15 +8,15 @@
#include "universe.hpp" // Include before Cocoa because the Cocoa header defines things that cause compilation errors in here
#include <Cocoa/Cocoa.h>
#include <iostream>
#include <string>
#include "fileio.hpp"
#include "pc.menus.hpp"
#include "pc.fileio.hpp"
extern bool verify_restore_quit(std::string dlog);
extern bool All_Done, party_in_scen, scen_items_loaded;
extern cUniverse univ;
extern fs::path file_in_mem;
extern bool All_Done, party_in_scen;
extern bool pending_quit;
extern fs::path pending_file_to_load;
@interface AppleEventHandler : NSObject<NSApplicationDelegate>
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file;
@@ -33,22 +33,30 @@ void set_up_apple_events(int, char*[]) {
@implementation AppleEventHandler
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file {
(void) app; // Suppress "unused parameter" warning
std::string fileName=file.fileSystemRepresentation;
if(load_party(fileName, univ)) {
file_in_mem = fileName;
party_in_scen = !univ.party.scen_name.empty();
if(!party_in_scen) load_base_item_defs();
scen_items_loaded = true;
menu_activate();
if(file == nil) {
std::cerr << "Error: filename was nil" << std::endl;
return NO;
}
return TRUE;
pending_file_to_load=file.fileSystemRepresentation;
return YES;
}
-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication*)sender {
(void) sender; // Suppress "unused parameter" warning
// REMOVEME when we solve the causes of the crash
// note: this is actually very bad because we will cancel a shutdown,
// and this does not work if a dialog is opened, ...
// but at least this does not lead to a crash
if (!party_in_scen) {
All_Done = true;
return NSTerminateNow;
}
pending_quit=true;
return NSTerminateCancel;
#if 0
All_Done = verify_restore_quit("save-quit");
return All_Done ? NSTerminateNow : NSTerminateCancel;
#endif
}
@end