forked from mia/Aegisub
Allow adding multiple scripts at once in the automation dialog
Originally committed to SVN as r5768.
This commit is contained in:
parent
5cb7bdcbaf
commit
4e1e68c88b
1 changed files with 18 additions and 14 deletions
|
@ -181,28 +181,32 @@ static bool has_file(Container const& c, wxFileName const& fn)
|
|||
|
||||
void DialogAutomation::OnAdd(wxCommandEvent &)
|
||||
{
|
||||
wxString fname = wxFileSelector(
|
||||
wxFileDialog diag(this,
|
||||
_("Add Automation script"),
|
||||
lagi_wxString(OPT_GET("Path/Last/Automation")->GetString()),
|
||||
"", "",
|
||||
"",
|
||||
Automation4::ScriptFactory::GetWildcardStr(),
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
|
||||
this);
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
|
||||
|
||||
if (fname.empty()) return;
|
||||
if (diag.ShowModal() == wxID_CANCEL) return;
|
||||
|
||||
wxFileName fnpath(fname);
|
||||
wxArrayString fnames;
|
||||
diag.GetPaths(fnames);
|
||||
|
||||
for (size_t i = 0; i < fnames.size(); ++i) {
|
||||
wxFileName fnpath(fnames[i]);
|
||||
OPT_SET("Path/Last/Automation")->SetString(STD_STR(fnpath.GetPath()));
|
||||
|
||||
if (has_file(local_manager->GetScripts(), fnpath) || has_file(global_manager->GetScripts(), fnpath)) {
|
||||
wxLogError("Script '%s' is already loaded", fname);
|
||||
return;
|
||||
wxLogError("Script '%s' is already loaded", fnames[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fname, true);
|
||||
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fnames[i], true);
|
||||
local_manager->Add(script);
|
||||
AddScript(script, false);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogAutomation::OnRemove(wxCommandEvent &)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue