mirror of https://github.com/odrling/Aegisub
Show ghosted notice if no Automation macros are loaded.
Better checking for whether Automation autoload dir is present. Originally committed to SVN as r718.
This commit is contained in:
parent
cc81523bbe
commit
1d87fd3934
|
@ -599,9 +599,11 @@ namespace Automation4 {
|
||||||
|
|
||||||
void AutoloadScriptManager::Reload()
|
void AutoloadScriptManager::Reload()
|
||||||
{
|
{
|
||||||
wxDir dir(path);
|
wxDir dir;
|
||||||
if (!dir.IsOpened()) {
|
if (!dir.Exists(path)) {
|
||||||
// crap
|
return;
|
||||||
|
}
|
||||||
|
if (!dir.Open(path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ private:
|
||||||
Automation4::ScriptManager *local_scripts;
|
Automation4::ScriptManager *local_scripts;
|
||||||
|
|
||||||
std::vector<Automation4::FeatureMacro*> activeMacroItems;
|
std::vector<Automation4::FeatureMacro*> activeMacroItems;
|
||||||
void AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> ¯os);
|
int AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> ¯os);
|
||||||
|
|
||||||
void InitToolbar();
|
void InitToolbar();
|
||||||
void InitContents();
|
void InitContents();
|
||||||
|
|
|
@ -246,15 +246,6 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
||||||
//Freeze();
|
//Freeze();
|
||||||
wxMenu *curMenu = event.GetMenu();
|
wxMenu *curMenu = event.GetMenu();
|
||||||
|
|
||||||
// Start by cleaning up in macro menu items
|
|
||||||
for (unsigned int i = 0; i < activeMacroItems.size(); i++) {
|
|
||||||
wxMenu *p = 0;
|
|
||||||
wxMenuItem *it = MenuBar->FindItem(Menu_Automation_Macro + i, &p);
|
|
||||||
if (it)
|
|
||||||
p->Delete(it);
|
|
||||||
}
|
|
||||||
activeMacroItems.clear();
|
|
||||||
|
|
||||||
// File menu
|
// File menu
|
||||||
if (curMenu == fileMenu) {
|
if (curMenu == fileMenu) {
|
||||||
// Wipe recent
|
// Wipe recent
|
||||||
|
@ -490,8 +481,25 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
||||||
|
|
||||||
// Automation menu
|
// Automation menu
|
||||||
else if (curMenu == automationMenu) {
|
else if (curMenu == automationMenu) {
|
||||||
AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros());
|
// Remove old macro items
|
||||||
AddMacroMenuItems(automationMenu, local_scripts->GetMacros());
|
for (unsigned int i = 0; i < activeMacroItems.size(); i++) {
|
||||||
|
wxMenu *p = 0;
|
||||||
|
wxMenuItem *it = MenuBar->FindItem(Menu_Automation_Macro + i, &p);
|
||||||
|
if (it)
|
||||||
|
p->Delete(it);
|
||||||
|
}
|
||||||
|
activeMacroItems.clear();
|
||||||
|
|
||||||
|
// Add new ones
|
||||||
|
int added = 0;
|
||||||
|
added += AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros());
|
||||||
|
added += AddMacroMenuItems(automationMenu, local_scripts->GetMacros());
|
||||||
|
|
||||||
|
// If none were added, show a ghosted notice
|
||||||
|
if (added == 0) {
|
||||||
|
automationMenu->Append(Menu_Automation_Macro, _("No Automation macros loaded"))->Enable(false);
|
||||||
|
activeMacroItems.push_back(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Thaw();
|
//Thaw();
|
||||||
|
@ -500,9 +508,9 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Macro menu creation helper
|
// Macro menu creation helper
|
||||||
void FrameMain::AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> ¯os) {
|
int FrameMain::AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::FeatureMacro*> ¯os) {
|
||||||
if (macros.empty()) {
|
if (macros.empty()) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = activeMacroItems.size();;
|
int id = activeMacroItems.size();;
|
||||||
|
@ -512,6 +520,8 @@ void FrameMain::AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::F
|
||||||
activeMacroItems.push_back(*i);
|
activeMacroItems.push_back(*i);
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return macros.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue