Support for opening saves/scenarios in Windows by dropping them on the app icon

This commit is contained in:
2015-06-08 21:27:19 -04:00
committed by Celtic Minstrel
parent 2b7e754fdc
commit 459c68a668
11 changed files with 77 additions and 21 deletions

View File

@@ -27,8 +27,8 @@ extern bool change_made, ae_loading;
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*) sender;
@end
void set_up_apple_events(); // Suppress "no prototype" warning
void set_up_apple_events() {
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];
[[NSApplication sharedApplication] setDelegate: aeHandler];
}

View File

@@ -54,10 +54,10 @@ cScenario scenario;
rectangle right_sbar_rect;
extern rectangle terrain_buttons_rect;
extern void set_up_apple_events();
extern void set_up_apple_events(int argc, char* argv[]);
//Changed to ISO C specified argument and return type.
int main(int, char* argv[]) {
int main(int argc, char* argv[]) {
try {
init_directories(argv[0]);
@@ -75,7 +75,7 @@ int main(int, char* argv[]) {
init_graph_tool();
check_for_intel();
set_up_apple_events();
set_up_apple_events(argc, argv);
cen_x = 18;
cen_y = 18;

View File

@@ -207,3 +207,25 @@ LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lPara
}
return CallWindowProc(reinterpret_cast<WNDPROC>(mainProc), handle, message, wParam, lParam);
}
#include "fileio.hpp"
#include "scen.actions.hpp"
extern short cur_town;
extern location cur_out;
extern cTown* town;
extern cOutdoors* current_terrain;
extern bool change_made, ae_loading;
void set_up_apple_events(int argc, char* argv[]) {
if(argc > 1) {
if(load_scenario(argv[1], scenario)) {
cur_town = scenario.last_town_edited;
town = scenario.towns[cur_town];
cur_out = scenario.last_out_edited;
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
change_made = false;
ae_loading = true;
set_up_main_screen();
}
}
}