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 &)
|
void DialogAutomation::OnAdd(wxCommandEvent &)
|
||||||
{
|
{
|
||||||
wxString fname = wxFileSelector(
|
wxFileDialog diag(this,
|
||||||
_("Add Automation script"),
|
_("Add Automation script"),
|
||||||
lagi_wxString(OPT_GET("Path/Last/Automation")->GetString()),
|
lagi_wxString(OPT_GET("Path/Last/Automation")->GetString()),
|
||||||
"", "",
|
"",
|
||||||
Automation4::ScriptFactory::GetWildcardStr(),
|
Automation4::ScriptFactory::GetWildcardStr(),
|
||||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
|
||||||
this);
|
|
||||||
|
|
||||||
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()));
|
OPT_SET("Path/Last/Automation")->SetString(STD_STR(fnpath.GetPath()));
|
||||||
|
|
||||||
if (has_file(local_manager->GetScripts(), fnpath) || has_file(global_manager->GetScripts(), fnpath)) {
|
if (has_file(local_manager->GetScripts(), fnpath) || has_file(global_manager->GetScripts(), fnpath)) {
|
||||||
wxLogError("Script '%s' is already loaded", fname);
|
wxLogError("Script '%s' is already loaded", fnames[i]);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fname, true);
|
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fnames[i], true);
|
||||||
local_manager->Add(script);
|
local_manager->Add(script);
|
||||||
AddScript(script, false);
|
AddScript(script, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DialogAutomation::OnRemove(wxCommandEvent &)
|
void DialogAutomation::OnRemove(wxCommandEvent &)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue