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

@@ -29,8 +29,8 @@ typedef NSAppleEventDescriptor AEDescr;
-(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

@@ -103,7 +103,7 @@ short store_current_pc = 0;
sf::Clock animTimer;
int main(int /*argc*/, char* argv[]) {
int main(int argc, char* argv[]) {
#if 0
void debug_oldstructs();
debug_oldstructs();
@@ -121,7 +121,7 @@ int main(int /*argc*/, char* argv[]) {
init_buf();
check_for_intel();
set_up_apple_events();
set_up_apple_events(argc, argv);
make_cursor_watch();
plop_fancy_startup();

View File

@@ -8,7 +8,7 @@ void Handle_Update();
void Mouse_Pressed();
void close_program();
void change_cursor(location where_curs);
void set_up_apple_events();
void set_up_apple_events(int argc, char* argv[]);
void move_sound(ter_num_t ter,short step);
void incidental_noises(bool on_surface);
void pause(short length);

View File

@@ -312,3 +312,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 "boe.graphics.hpp"
#include "boe.actions.hpp"
#include "boe.fileio.hpp"
extern bool ae_loading, finished_init, startup_loaded;
void set_up_apple_events(int argc, char* argv[]) {
if(argc > 1) {
if(!load_party(argv[1], univ))
return;
if(!finished_init) {
ae_loading = true;
overall_mode = MODE_STARTUP;
} else finish_load_party();
if(overall_mode != MODE_STARTUP && startup_loaded)
end_startup();
if(overall_mode != MODE_STARTUP)
post_load();
}
}

View File

@@ -23,8 +23,8 @@ extern fs::path file_in_mem;
-(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,14 +54,14 @@ void Handle_Activate();
void Handle_Update();
void Mouse_Pressed();
bool verify_restore_quit(std::string dlog);
void set_up_apple_events();
void set_up_apple_events(int argc, char* argv[]);
extern bool cur_scen_is_mac;
extern fs::path progDir;
short specials_res_id;
char start_name[256];
//MW specified return type was 'void', changed to ISO C style for Carbonisation -jmr
int main(int /*argc*/, char* argv[]) {
int main(int argc, char* argv[]) {
try {
init_directories(argv[0]);
init_menubar();
@@ -72,7 +72,7 @@ int main(int /*argc*/, char* argv[]) {
init_graph_tool();
init_snd_tool();
set_up_apple_events();
set_up_apple_events(argc, argv);
cDialog::init();
redraw_screen();

View File

@@ -170,3 +170,21 @@ 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 "pc.fileio.hpp"
extern bool party_in_scen, scen_items_loaded;
extern fs::path file_in_mem;
void set_up_apple_events(int argc, char* argv[]) {
if(argc > 1) {
if(load_party(argv[1], univ)) {
file_in_mem = argv[1];
party_in_scen = !univ.party.scen_name.empty();
if(!party_in_scen) load_base_item_defs();
scen_items_loaded = true;
update_item_menu();
menu_activate();
}
}
}

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();
}
}
}

View File

@@ -235,12 +235,6 @@ ModalSession::~ModalSession() {
RedrawWindow(parent->getSystemHandle(), NULL, NULL, RDW_NOCHILDREN | RDW_UPDATENOW);
}
void set_up_apple_events() {
// TODO: Probably nothing to do here on Windows?
// Basically what might possibly happen here is to set up stuff to handle dragging a file onto the application icon.
// The Mac version also handles requests from the operating system for the application to quit.
}
int getMenubarHeight() {
return GetSystemMetrics(SM_CYMENU);
}