.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 argc, char* argv[]); // Suppress "no prototype" warning
|
||||||
void set_up_apple_events(int, char*[]) {
|
void set_up_apple_events(int, char*[]) {
|
||||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
static AppleEventHandler* aeHandler;
|
||||||
|
aeHandler = [[AppleEventHandler alloc] init];
|
||||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,14 +47,7 @@ void set_up_apple_events(int, char*[]) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long len = [file length], sz = len + 1;
|
if(!load_party(file.fileSystemRepresentation, univ))
|
||||||
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))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if(!finished_init) {
|
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 argc, char* argv[]); // Suppress "no prototype" warning
|
||||||
void set_up_apple_events(int, char*[]) {
|
void set_up_apple_events(int, char*[]) {
|
||||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
static AppleEventHandler* aeHandler;
|
||||||
|
aeHandler = [[AppleEventHandler alloc] init];
|
||||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,13 +34,7 @@ void set_up_apple_events(int, char*[]) {
|
|||||||
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file {
|
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file {
|
||||||
(void) app; // Suppress "unused parameter" warning
|
(void) app; // Suppress "unused parameter" warning
|
||||||
|
|
||||||
unsigned long len = [file length], sz = len + 1;
|
std::string fileName=file.fileSystemRepresentation;
|
||||||
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(fileName, univ)) {
|
||||||
file_in_mem = fileName;
|
file_in_mem = fileName;
|
||||||
party_in_scen = !univ.party.scen_name.empty();
|
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 argc, char* argv[]); // Suppress "no prototype" warning
|
||||||
void set_up_apple_events(int, char*[]) {
|
void set_up_apple_events(int, char*[]) {
|
||||||
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
|
static AppleEventHandler* aeHandler;
|
||||||
|
aeHandler = [[AppleEventHandler alloc] init];
|
||||||
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
[[NSApplication sharedApplication] setDelegate: aeHandler];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,13 +44,8 @@ void set_up_apple_events(int, char*[]) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long len = [file length], sz = len + 1;
|
std::string fileName=file.fileSystemRepresentation;
|
||||||
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_scenario(fileName, scenario)) {
|
if(load_scenario(fileName, scenario)) {
|
||||||
set_current_town(scenario.last_town_edited);
|
set_current_town(scenario.last_town_edited);
|
||||||
cur_out = scenario.last_out_edited;
|
cur_out = scenario.last_out_edited;
|
||||||
|
Reference in New Issue
Block a user