Fix save dialogs not working right on Mac OS X.
This commit is contained in:
parent
f1fb905554
commit
d013491c22
3 changed files with 17 additions and 16 deletions
|
@ -67,7 +67,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
//Prompt for stuff. These all can throw canceled_exception.
|
//Prompt for stuff. These all can throw canceled_exception.
|
||||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir);
|
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave);
|
||||||
std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir);
|
std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir);
|
||||||
std::string pick_among(wxWindow* parent, const std::string& title, const std::string& prompt,
|
std::string pick_among(wxWindow* parent, const std::string& title, const std::string& prompt,
|
||||||
const std::vector<std::string>& choices);
|
const std::vector<std::string>& choices);
|
||||||
|
|
|
@ -475,11 +475,12 @@ void _runuifun_async(void (*fn)(void*), void* arg)
|
||||||
|
|
||||||
canceled_exception::canceled_exception() : std::runtime_error("Dialog canceled") {}
|
canceled_exception::canceled_exception() : std::runtime_error("Dialog canceled") {}
|
||||||
|
|
||||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir)
|
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave)
|
||||||
{
|
{
|
||||||
wxString _title = towxstring(title);
|
wxString _title = towxstring(title);
|
||||||
wxString _startdir = towxstring(startdir);
|
wxString _startdir = towxstring(startdir);
|
||||||
wxFileDialog* d = new wxFileDialog(parent, _title, _startdir);
|
wxFileDialog* d = new wxFileDialog(parent, _title, _startdir, wxT(""), wxT("All files|*"), forsave ?
|
||||||
|
wxFD_SAVE : wxFD_OPEN);
|
||||||
if(d->ShowModal() == wxID_CANCEL)
|
if(d->ShowModal() == wxID_CANCEL)
|
||||||
throw canceled_exception();
|
throw canceled_exception();
|
||||||
std::string filename = tostdstring(d->GetPath());
|
std::string filename = tostdstring(d->GetPath());
|
||||||
|
@ -491,7 +492,7 @@ std::string pick_file(wxWindow* parent, const std::string& title, const std::str
|
||||||
|
|
||||||
std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir)
|
std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir)
|
||||||
{
|
{
|
||||||
std::string filename = pick_file(parent, title, startdir);
|
std::string filename = pick_file(parent, title, startdir, false);
|
||||||
//Did we pick a .zip file?
|
//Did we pick a .zip file?
|
||||||
try {
|
try {
|
||||||
zip_reader zr(filename);
|
zip_reader zr(filename);
|
||||||
|
|
|
@ -902,40 +902,40 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
||||||
platform::queue("cancel-saves");
|
platform::queue("cancel-saves");
|
||||||
return;
|
return;
|
||||||
case wxID_LOAD_MOVIE:
|
case wxID_LOAD_MOVIE:
|
||||||
platform::queue("load-movie " + pick_file(this, "Load Movie", movie_path()));
|
platform::queue("load-movie " + pick_file(this, "Load Movie", movie_path(), false));
|
||||||
return;
|
return;
|
||||||
case wxID_LOAD_STATE:
|
case wxID_LOAD_STATE:
|
||||||
platform::queue("load " + pick_file(this, "Load State", movie_path()));
|
platform::queue("load " + pick_file(this, "Load State", movie_path(), false));
|
||||||
return;
|
return;
|
||||||
case wxID_LOAD_STATE_RO:
|
case wxID_LOAD_STATE_RO:
|
||||||
platform::queue("load-readonly " + pick_file(this, "Load State (Read-Only)", movie_path()));
|
platform::queue("load-readonly " + pick_file(this, "Load State (Read-Only)", movie_path(), false));
|
||||||
return;
|
return;
|
||||||
case wxID_LOAD_STATE_RW:
|
case wxID_LOAD_STATE_RW:
|
||||||
platform::queue("load-state " + pick_file(this, "Load State (Read-Write)", movie_path()));
|
platform::queue("load-state " + pick_file(this, "Load State (Read-Write)", movie_path(), false));
|
||||||
return;
|
return;
|
||||||
case wxID_LOAD_STATE_P:
|
case wxID_LOAD_STATE_P:
|
||||||
platform::queue("load-preserve " + pick_file(this, "Load State (Preserve)", movie_path()));
|
platform::queue("load-preserve " + pick_file(this, "Load State (Preserve)", movie_path(), false));
|
||||||
return;
|
return;
|
||||||
case wxID_REWIND_MOVIE:
|
case wxID_REWIND_MOVIE:
|
||||||
platform::queue("rewind-movie");
|
platform::queue("rewind-movie");
|
||||||
return;
|
return;
|
||||||
case wxID_SAVE_MOVIE:
|
case wxID_SAVE_MOVIE:
|
||||||
platform::queue("save-movie " + pick_file(this, "Save Movie", movie_path()));
|
platform::queue("save-movie " + pick_file(this, "Save Movie", movie_path(), true));
|
||||||
return;
|
return;
|
||||||
case wxID_SAVE_SUBTITLES:
|
case wxID_SAVE_SUBTITLES:
|
||||||
platform::queue("save-subtitle " + pick_file(this, "Save Subtitle (.sub)", movie_path()));
|
platform::queue("save-subtitle " + pick_file(this, "Save Subtitle (.sub)", movie_path(), true));
|
||||||
return;
|
return;
|
||||||
case wxID_SAVE_STATE:
|
case wxID_SAVE_STATE:
|
||||||
platform::queue("save-state " + pick_file(this, "Save State", movie_path()));
|
platform::queue("save-state " + pick_file(this, "Save State", movie_path(), true));
|
||||||
return;
|
return;
|
||||||
case wxID_SAVE_SCREENSHOT:
|
case wxID_SAVE_SCREENSHOT:
|
||||||
platform::queue("take-screenshot " + pick_file(this, "Save Screenshot", movie_path()));
|
platform::queue("take-screenshot " + pick_file(this, "Save Screenshot", movie_path(), true));
|
||||||
return;
|
return;
|
||||||
case wxID_RUN_SCRIPT:
|
case wxID_RUN_SCRIPT:
|
||||||
platform::queue("run-script " + pick_file_member(this, "Select Script", "."));
|
platform::queue("run-script " + pick_file_member(this, "Select Script", "."));
|
||||||
return;
|
return;
|
||||||
case wxID_RUN_LUA:
|
case wxID_RUN_LUA:
|
||||||
platform::queue("run-lua " + pick_file(this, "Select Lua Script", "."));
|
platform::queue("run-lua " + pick_file(this, "Select Lua Script", ".", false));
|
||||||
return;
|
return;
|
||||||
case wxID_RESET_LUA:
|
case wxID_RESET_LUA:
|
||||||
platform::queue("reset-lua");
|
platform::queue("reset-lua");
|
||||||
|
@ -965,7 +965,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
||||||
modal_pause_holder hld;
|
modal_pause_holder hld;
|
||||||
std::set<std::string> old_watches;
|
std::set<std::string> old_watches;
|
||||||
runemufn([&old_watches]() { old_watches = get_watches(); });
|
runemufn([&old_watches]() { old_watches = get_watches(); });
|
||||||
std::string filename = pick_file(this, "Save watches to file", ".");
|
std::string filename = pick_file(this, "Save watches to file", ".", true);
|
||||||
std::ofstream out(filename.c_str());
|
std::ofstream out(filename.c_str());
|
||||||
for(auto i : old_watches) {
|
for(auto i : old_watches) {
|
||||||
std::string val;
|
std::string val;
|
||||||
|
@ -1109,7 +1109,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
||||||
break;
|
break;
|
||||||
case wxID_LOAD_LIBRARY: {
|
case wxID_LOAD_LIBRARY: {
|
||||||
std::string name = std::string("load ") + library_is_called;
|
std::string name = std::string("load ") + library_is_called;
|
||||||
load_library(pick_file(this, name, "."));
|
load_library(pick_file(this, name, ".", false));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxID_SETTINGS:
|
case wxID_SETTINGS:
|
||||||
|
|
Loading…
Add table
Reference in a new issue