.mm: try to simplify load of .mm files
This commit is contained in:
@@ -32,7 +32,8 @@ typedef NSAppleEventDescriptor AEDescr;
|
||||
|
||||
void set_up_apple_events(int argc, char* argv[]); // Suppress "no prototype" warning
|
||||
void set_up_apple_events(int, char*[]) {
|
||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
||||
static AppleEventHandler* aeHandler;
|
||||
aeHandler = [[AppleEventHandler alloc] init];
|
||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||
}
|
||||
|
||||
@@ -46,14 +47,7 @@ void set_up_apple_events(int, char*[]) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
unsigned long len = [file length], sz = len + 1;
|
||||
auto msg = std::shared_ptr<unichar>(new unichar[sz], std::default_delete<unichar[]>());
|
||||
std::fill(msg.get(), msg.get() + sz, 0);
|
||||
[file getCharacters: msg.get() range: (NSRange){0, len}];
|
||||
std::string fileName;
|
||||
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
|
||||
|
||||
if(!load_party(fileName, univ))
|
||||
if(!load_party(file.fileSystemRepresentation, univ))
|
||||
return FALSE;
|
||||
|
||||
if(!finished_init) {
|
||||
|
@@ -25,7 +25,8 @@ extern fs::path file_in_mem;
|
||||
|
||||
void set_up_apple_events(int argc, char* argv[]); // Suppress "no prototype" warning
|
||||
void set_up_apple_events(int, char*[]) {
|
||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
||||
static AppleEventHandler* aeHandler;
|
||||
aeHandler = [[AppleEventHandler alloc] init];
|
||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||
}
|
||||
|
||||
@@ -33,13 +34,7 @@ void set_up_apple_events(int, char*[]) {
|
||||
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file {
|
||||
(void) app; // Suppress "unused parameter" warning
|
||||
|
||||
unsigned long len = [file length], sz = len + 1;
|
||||
auto msg = std::shared_ptr<unichar>(new unichar[sz], std::default_delete<unichar[]>());
|
||||
std::fill(msg.get(), msg.get() + sz, 0);
|
||||
[file getCharacters: msg.get() range: (NSRange){0, len}];
|
||||
std::string fileName;
|
||||
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
|
||||
|
||||
std::string fileName=file.fileSystemRepresentation;
|
||||
if(load_party(fileName, univ)) {
|
||||
file_in_mem = fileName;
|
||||
party_in_scen = !univ.party.scen_name.empty();
|
||||
|
@@ -29,7 +29,8 @@ extern bool change_made, ae_loading;
|
||||
|
||||
void set_up_apple_events(int argc, char* argv[]); // Suppress "no prototype" warning
|
||||
void set_up_apple_events(int, char*[]) {
|
||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
||||
static AppleEventHandler* aeHandler;
|
||||
aeHandler = [[AppleEventHandler alloc] init];
|
||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||
}
|
||||
|
||||
@@ -43,12 +44,7 @@ void set_up_apple_events(int, char*[]) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
unsigned long len = [file length], sz = len + 1;
|
||||
auto msg = std::shared_ptr<unichar>(new unichar[sz], std::default_delete<unichar[]>());
|
||||
std::fill(msg.get(), msg.get() + sz, 0);
|
||||
[file getCharacters: msg.get() range: (NSRange){0, len}];
|
||||
std::string fileName;
|
||||
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
|
||||
std::string fileName=file.fileSystemRepresentation;
|
||||
|
||||
if(load_scenario(fileName, scenario)) {
|
||||
set_current_town(scenario.last_town_edited);
|
||||
|
Reference in New Issue
Block a user