Merge branch 'rr1-maint'
Conflicts: include/core/loadlib.hpp src/core/loadlib.cpp src/platform/wxwidgets/mainwindow.cpp
This commit is contained in:
commit
73fd1d4737
7 changed files with 53 additions and 24 deletions
|
@ -41,6 +41,12 @@ public:
|
|||
* Returns: The name of library.
|
||||
*/
|
||||
static const std::string& call_library() throw();
|
||||
/**
|
||||
* See what standard library extension is on this platform.
|
||||
*
|
||||
* Returns: The extension of library.
|
||||
*/
|
||||
static const std::string& call_library_ext() throw();
|
||||
private:
|
||||
loaded_library(const loaded_library&);
|
||||
loaded_library& operator=(const loaded_library&);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <library/utf8.hpp>
|
||||
#include "utf8.hpp"
|
||||
|
||||
/**
|
||||
* Strip trailing CR if any.
|
||||
|
|
|
@ -81,7 +81,8 @@ public:
|
|||
};
|
||||
|
||||
//Prompt for stuff. These all can throw canceled_exception.
|
||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave);
|
||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave,
|
||||
std::string ext = "");
|
||||
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,
|
||||
const std::vector<std::string>& choices);
|
||||
|
|
|
@ -10,11 +10,14 @@ namespace
|
|||
{
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
std::string callsign = "dynamic link library";
|
||||
std::string callsign_ext = "dll";
|
||||
#elif !defined(NO_DLFCN)
|
||||
#if defined(__APPLE__)
|
||||
std::string callsign = "dynamic library";
|
||||
std::string callsign_ext = "bundle";
|
||||
#else
|
||||
std::string callsign = "shared object";
|
||||
std::string callsign_ext = "so";
|
||||
#endif
|
||||
#else
|
||||
std::string callsign = "";
|
||||
|
@ -99,3 +102,8 @@ const std::string& loaded_library::call_library() throw()
|
|||
{
|
||||
return callsign;
|
||||
}
|
||||
|
||||
const std::string& loaded_library::call_library_ext() throw()
|
||||
{
|
||||
return callsign_ext;
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ void wxeditor_voicesub::on_export_o(wxCommandEvent& e)
|
|||
return;
|
||||
try {
|
||||
std::string filename;
|
||||
filename = pick_file(this, "Select opus file to export", ".", true);
|
||||
filename = pick_file(this, "Select opus file to export", ".", true, "odm");
|
||||
voicesub_export_stream(id, filename, EXTFMT_OPUSDEMO);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -244,7 +244,7 @@ void wxeditor_voicesub::on_export_p(wxCommandEvent& e)
|
|||
return;
|
||||
try {
|
||||
std::string filename;
|
||||
filename = pick_file(this, "Select sox file to export", ".", true);
|
||||
filename = pick_file(this, "Select sox file to export", ".", true, "sox");
|
||||
voicesub_export_stream(id, filename, EXTFMT_SOX);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -259,7 +259,7 @@ void wxeditor_voicesub::on_export_q(wxCommandEvent& e)
|
|||
return;
|
||||
try {
|
||||
std::string filename;
|
||||
filename = pick_file(this, "Select Ogg (Opus) file to export", ".", true);
|
||||
filename = pick_file(this, "Select Ogg (Opus) file to export", ".", true, "opus");
|
||||
voicesub_export_stream(id, filename, EXTFMT_OGGOPUS);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -271,7 +271,7 @@ void wxeditor_voicesub::on_export_s(wxCommandEvent& e)
|
|||
{
|
||||
try {
|
||||
std::string filename;
|
||||
filename = pick_file(this, "Select sox file to export (superstream)", ".", true);
|
||||
filename = pick_file(this, "Select sox file to export (superstream)", ".", true, "sox");
|
||||
voicesub_export_superstream(filename);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -286,7 +286,7 @@ void wxeditor_voicesub::on_import_o(wxCommandEvent& e)
|
|||
uint64_t ts;
|
||||
ts = voicesub_parse_timebase(pick_text(this, "Enter timebase", "Enter position for newly "
|
||||
"imported stream"));
|
||||
filename = pick_file(this, "Select opus file to import", ".", false);
|
||||
filename = pick_file(this, "Select opus file to import", ".", false, "odm");
|
||||
voicesub_import_stream(ts, filename, EXTFMT_OPUSDEMO);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -301,7 +301,7 @@ void wxeditor_voicesub::on_import_p(wxCommandEvent& e)
|
|||
uint64_t ts;
|
||||
ts = voicesub_parse_timebase(pick_text(this, "Enter timebase", "Enter position for newly "
|
||||
"imported stream"));
|
||||
filename = pick_file(this, "Select sox file to import", ".", false);
|
||||
filename = pick_file(this, "Select sox file to import", ".", false, "sox");
|
||||
voicesub_import_stream(ts, filename, EXTFMT_SOX);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -316,7 +316,7 @@ void wxeditor_voicesub::on_import_q(wxCommandEvent& e)
|
|||
uint64_t ts;
|
||||
ts = voicesub_parse_timebase(pick_text(this, "Enter timebase", "Enter position for newly "
|
||||
"imported stream"));
|
||||
filename = pick_file(this, "Select Ogg (Opus) file to import", ".", false);
|
||||
filename = pick_file(this, "Select Ogg (Opus) file to import", ".", false, "opus");
|
||||
voicesub_import_stream(ts, filename, EXTFMT_OGGOPUS);
|
||||
} catch(canceled_exception& e) {
|
||||
} catch(std::exception& e) {
|
||||
|
@ -361,7 +361,7 @@ void wxeditor_voicesub::on_load(wxCommandEvent& e)
|
|||
try {
|
||||
std::string filename;
|
||||
try {
|
||||
filename = pick_file(this, "Select collection to load", ".", false);
|
||||
filename = pick_file(this, "Select collection to load", ".", false, "lsvs");
|
||||
} catch(...) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -673,18 +673,31 @@ void _runuifun_async(void (*fn)(void*), void* arg)
|
|||
|
||||
canceled_exception::canceled_exception() : std::runtime_error("Dialog canceled") {}
|
||||
|
||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave)
|
||||
std::string pick_file(wxWindow* parent, const std::string& title, const std::string& startdir, bool forsave,
|
||||
std::string ext)
|
||||
{
|
||||
wxString _title = towxstring(title);
|
||||
wxString _startdir = towxstring(startdir);
|
||||
wxFileDialog* d = new wxFileDialog(parent, _title, _startdir, wxT(""), wxT("All files|*"), forsave ?
|
||||
std::string filespec;
|
||||
if(ext != "")
|
||||
filespec = ext + " files|*." + ext + "|All files|*";
|
||||
else
|
||||
filespec = "All files|*";
|
||||
wxFileDialog* d = new wxFileDialog(parent, _title, _startdir, wxT(""), towxstring(filespec), forsave ?
|
||||
wxFD_SAVE : wxFD_OPEN);
|
||||
if(d->ShowModal() == wxID_CANCEL)
|
||||
throw canceled_exception();
|
||||
std::string filename = tostdstring(d->GetPath());
|
||||
int findex = d->GetFilterIndex();
|
||||
d->Destroy();
|
||||
if(filename == "")
|
||||
throw canceled_exception();
|
||||
if(forsave && ext != "" && findex == 0) {
|
||||
//Append extension if needed.
|
||||
size_t dpos = filename.find_first_of(".");
|
||||
if(dpos > filename.length() || filename.substr(dpos + 1) != ext)
|
||||
filename = filename + "." + ext;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
|
|
@ -844,27 +844,27 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
|||
platform::queue("cancel-saves");
|
||||
return;
|
||||
case wxID_LOAD_MOVIE:
|
||||
filename = pick_file(this, "Load Movie", movie_path(), false);
|
||||
filename = pick_file(this, "Load Movie", movie_path(), false, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("load-movie " + filename);
|
||||
return;
|
||||
case wxID_LOAD_STATE:
|
||||
filename = pick_file(this, "Load State", movie_path(), false);
|
||||
filename = pick_file(this, "Load State", movie_path(), false, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("load " + filename);
|
||||
return;
|
||||
case wxID_LOAD_STATE_RO:
|
||||
filename = pick_file(this, "Load State (Read-Only)", movie_path(), false);
|
||||
filename = pick_file(this, "Load State (Read-Only)", movie_path(), false, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("load-readonly " + filename);
|
||||
return;
|
||||
case wxID_LOAD_STATE_RW:
|
||||
filename = pick_file(this, "Load State (Read-Write)", movie_path(), false);
|
||||
filename = pick_file(this, "Load State (Read-Write)", movie_path(), false, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("load-state " + filename);
|
||||
return;
|
||||
case wxID_LOAD_STATE_P:
|
||||
filename = pick_file(this, "Load State (Preserve)", movie_path(), false);
|
||||
filename = pick_file(this, "Load State (Preserve)", movie_path(), false, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("load-preserve " + filename);
|
||||
return;
|
||||
|
@ -872,26 +872,27 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
|||
platform::queue("rewind-movie");
|
||||
return;
|
||||
case wxID_SAVE_MOVIE:
|
||||
filename = pick_file(this, "Save Movie", movie_path(), true);
|
||||
filename = pick_file(this, "Save Movie", movie_path(), true, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("save-movie " + filename);
|
||||
return;
|
||||
case wxID_SAVE_SUBTITLES:
|
||||
platform::queue("save-subtitle " + pick_file(this, "Save Subtitle (.sub)", movie_path(), true));
|
||||
platform::queue("save-subtitle " + pick_file(this, "Save Subtitle (.sub)", movie_path(), true,
|
||||
"sub"));
|
||||
return;
|
||||
case wxID_SAVE_STATE:
|
||||
filename = pick_file(this, "Save State", movie_path(), true);
|
||||
filename = pick_file(this, "Save State", movie_path(), true, "lsmv");
|
||||
recent_movies->add(filename);
|
||||
platform::queue("save-state " + filename);
|
||||
return;
|
||||
case wxID_SAVE_SCREENSHOT:
|
||||
platform::queue("take-screenshot " + pick_file(this, "Save Screenshot", movie_path(), true));
|
||||
platform::queue("take-screenshot " + pick_file(this, "Save Screenshot", movie_path(), true, "png"));
|
||||
return;
|
||||
case wxID_RUN_SCRIPT:
|
||||
platform::queue("run-script " + pick_file_member(this, "Select Script", "."));
|
||||
return;
|
||||
case wxID_RUN_LUA:
|
||||
platform::queue("run-lua " + pick_file(this, "Select Lua Script", ".", false));
|
||||
platform::queue("run-lua " + pick_file(this, "Select Lua Script", ".", false, "lua"));
|
||||
return;
|
||||
case wxID_RESET_LUA:
|
||||
platform::queue("reset-lua");
|
||||
|
@ -930,7 +931,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
|||
modal_pause_holder hld;
|
||||
std::set<std::string> old_watches;
|
||||
runemufn([&old_watches]() { old_watches = get_watches(); });
|
||||
std::string filename = pick_file(this, "Save watches to file", ".", true);
|
||||
std::string filename = pick_file(this, "Save watches to file", ".", true, "lwch");
|
||||
std::ofstream out(filename.c_str());
|
||||
for(auto i : old_watches) {
|
||||
std::string val;
|
||||
|
@ -1081,7 +1082,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e)
|
|||
break;
|
||||
case wxID_LOAD_LIBRARY: {
|
||||
std::string name = std::string("load ") + loaded_library::call_library();
|
||||
new loaded_library(pick_file(this, name, ".", false));
|
||||
new loaded_library(pick_file(this, name, ".", false, loaded_library::call_library_ext()));
|
||||
handle_post_loadlibrary();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue