diff --git a/aegisub/auto4_base.cpp b/aegisub/auto4_base.cpp index a39ce7582..4e4c6d12a 100644 --- a/aegisub/auto4_base.cpp +++ b/aegisub/auto4_base.cpp @@ -211,10 +211,9 @@ namespace Automation4 { // FeatureMacro - FeatureMacro::FeatureMacro(const wxString &_name, const wxString &_description, MacroMenu _menu) + FeatureMacro::FeatureMacro(const wxString &_name, const wxString &_description) : Feature(SCRIPTFEATURE_MACRO, _name) , description(_description) - , menu(_menu) { // nothing to do } @@ -224,11 +223,6 @@ namespace Automation4 { return description; } - MacroMenu FeatureMacro::GetMenu() const - { - return menu; - } - // FeatureFilter @@ -580,19 +574,18 @@ namespace Automation4 { return scripts; } - const std::vector& ScriptManager::GetMacros(MacroMenu menu) + const std::vector& ScriptManager::GetMacros() { - macros[menu].clear(); + macros.clear(); for (std::vector::iterator i = scripts.begin(); i != scripts.end(); ++i) { std::vector &sfs = (*i)->GetFeatures(); for (std::vector::iterator j = sfs.begin(); j != sfs.end(); ++j) { FeatureMacro *m = dynamic_cast(*j); if (!m) continue; - if (menu == MACROMENU_ALL || m->GetMenu() == menu) - macros[menu].push_back(m); + macros.push_back(m); } } - return macros[menu]; + return macros; } diff --git a/aegisub/auto4_base.h b/aegisub/auto4_base.h index bf0751d9c..ecd8f1524 100644 --- a/aegisub/auto4_base.h +++ b/aegisub/auto4_base.h @@ -61,18 +61,6 @@ namespace Automation4 { bool CalculateTextExtents(AssStyle *style, wxString &text, int &width, int &height, int &descent, int &extlead); - // The top-level menus a macro can appear in - enum MacroMenu { - MACROMENU_NONE = 0, // pseudo-index, dunno if this has any real meaning - MACROMENU_ALL = 0, // pseudo-index, used to retrieve information about all macros loaded - MACROMENU_EDIT, - MACROMENU_VIDEO, - MACROMENU_AUDIO, - MACROMENU_TOOLS, - MACROMENU_RIGHT, // right-click menu - - MACROMENU_MAX // must be last, one higher than the last, used for array sizing - }; // The class of a Feature... enum ScriptFeatureClass { SCRIPTFEATURE_MACRO = 0, @@ -112,16 +100,14 @@ namespace Automation4 { class FeatureMacro : public virtual Feature { private: wxString description; - MacroMenu menu; protected: - FeatureMacro(const wxString &_name, const wxString &_description, MacroMenu _menu); + FeatureMacro(const wxString &_name, const wxString &_description); public: virtual ~FeatureMacro() { } const wxString& GetDescription() const; - MacroMenu GetMenu() const; virtual bool Validate(AssFile *subs, std::vector &selected, int active) = 0; virtual void Process(AssFile *subs, std::vector &selected, int active, wxWindow *progress_parent) = 0; @@ -304,7 +290,7 @@ namespace Automation4 { private: std::vector scripts; - std::vector macros[MACROMENU_MAX]; // array of vectors... + std::vector macros; public: ScriptManager(); @@ -315,7 +301,7 @@ namespace Automation4 { const std::vector& GetScripts() const; - const std::vector& GetMacros(MacroMenu menu); + const std::vector& GetMacros(); // No need to have getters for the other kinds of features, I think. // They automatically register themselves in the relevant places. }; diff --git a/aegisub/auto4_lua.cpp b/aegisub/auto4_lua.cpp index af1c2b4a3..1605aee8f 100644 --- a/aegisub/auto4_lua.cpp +++ b/aegisub/auto4_lua.cpp @@ -503,41 +503,28 @@ namespace Automation4 { { wxString _name(lua_tostring(L, 1), wxConvUTF8); wxString _description(lua_tostring(L, 2), wxConvUTF8); - const char *_menustring = lua_tostring(L, 3); - MacroMenu _menu = MACROMENU_NONE; - if (strcmp(_menustring, "edit") == 0) _menu = MACROMENU_EDIT; - else if (strcmp(_menustring, "video") == 0) _menu = MACROMENU_VIDEO; - else if (strcmp(_menustring, "audio") == 0) _menu = MACROMENU_AUDIO; - else if (strcmp(_menustring, "tools") == 0) _menu = MACROMENU_TOOLS; - else if (strcmp(_menustring, "right") == 0) _menu = MACROMENU_RIGHT; - - if (_menu == MACROMENU_NONE) { - lua_pushstring(L, "Error registering macro: Invalid menu name."); - lua_error(L); - } - - LuaFeatureMacro *macro = new LuaFeatureMacro(_name, _description, _menu, L); + LuaFeatureMacro *macro = new LuaFeatureMacro(_name, _description, L); return 0; } - LuaFeatureMacro::LuaFeatureMacro(const wxString &_name, const wxString &_description, MacroMenu _menu, lua_State *_L) + LuaFeatureMacro::LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L) : LuaFeature(_L, SCRIPTFEATURE_MACRO, _name) - , FeatureMacro(_name, _description, _menu) + , FeatureMacro(_name, _description) , Feature(SCRIPTFEATURE_MACRO, _name) { // new table for containing the functions for this feature lua_newtable(L); // store processing function - if (!lua_isfunction(L, 4)) { + if (!lua_isfunction(L, 3)) { lua_pushstring(L, "The macro processing function must be a function"); lua_error(L); } - lua_pushvalue(L, 4); + lua_pushvalue(L, 3); lua_rawseti(L, -2, 1); // and validation function - lua_pushvalue(L, 5); + lua_pushvalue(L, 4); no_validate = !lua_isfunction(L, -1); lua_rawseti(L, -2, 2); // make the feature known diff --git a/aegisub/auto4_lua.h b/aegisub/auto4_lua.h index 4d18c7474..12537c818 100644 --- a/aegisub/auto4_lua.h +++ b/aegisub/auto4_lua.h @@ -208,7 +208,7 @@ namespace Automation4 { private: bool no_validate; protected: - LuaFeatureMacro(const wxString &_name, const wxString &_description, MacroMenu _menu, lua_State *_L); + LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L); public: static int LuaRegister(lua_State *L); virtual ~LuaFeatureMacro() { } diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 5a9c03d81..5c2097c9f 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -490,8 +490,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Automation menu else if (curMenu == automationMenu) { - AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros(Automation4::MACROMENU_ALL)); - AddMacroMenuItems(automationMenu, local_scripts->GetMacros(Automation4::MACROMENU_ALL)); + AddMacroMenuItems(automationMenu, wxGetApp().global_scripts->GetMacros()); + AddMacroMenuItems(automationMenu, local_scripts->GetMacros()); } //Thaw(); diff --git a/automation/demos/macro-1-edgeblur.lua b/automation/demos/macro-1-edgeblur.lua index 94ba44e14..fc83ae004 100644 --- a/automation/demos/macro-1-edgeblur.lua +++ b/automation/demos/macro-1-edgeblur.lua @@ -2,7 +2,7 @@ -- Macro that adds \be1 tags in front of every selected line script_name = "Add edgeblur macro" -script_description = "A testmacro showing how to do simple line modification in Automation 4" +script_description = "A demo macro showing how to do simple line modification in Automation 4" script_author = "Niels Martin Hansen" script_version = "1" @@ -16,4 +16,4 @@ function add_edgeblur(subtitles, selected_lines, active_line) aegisub.set_undo_point("Add edgeblur") end -aegisub.register_macro("Add edgeblur", "Adds \be1 tags to all selected lines", "edit", add_edgeblur) +aegisub.register_macro("Add edgeblur", "Adds \be1 tags to all selected lines", add_edgeblur) diff --git a/automation/autoload/test1.lua b/automation/tests/test1.lua similarity index 84% rename from automation/autoload/test1.lua rename to automation/tests/test1.lua index ba50becaf..8ee13073e 100644 --- a/automation/autoload/test1.lua +++ b/automation/tests/test1.lua @@ -12,4 +12,4 @@ function macro_test1(subtitles, selected_lines, active_line) aegisub.debug.out("Hello Automation 4 World!") end -aegisub.register_macro("Hello", "Shows a message", "tools", macro_test1) +aegisub.register_macro("Hello", "Shows a message", macro_test1) diff --git a/automation/autoload/test2.lua b/automation/tests/test2.lua similarity index 93% rename from automation/autoload/test2.lua rename to automation/tests/test2.lua index 87ae52026..46be3e701 100644 --- a/automation/autoload/test2.lua +++ b/automation/tests/test2.lua @@ -43,8 +43,8 @@ function inserttest(subtitles, selected_lines, active_line) end -aegisub.register_macro("File line count", "Count the number of lines in the ASS file", "tools", macro_test2, nil) +aegisub.register_macro("File line count", "Count the number of lines in the ASS file", macro_test2, nil) -aegisub.register_macro("Dump", "Dumps info on every line in the file", "tools", dumper, nil) +aegisub.register_macro("Dump", "Dumps info on every line in the file", dumper, nil) -aegisub.register_macro("Insert stuff", "Inserts some lines near the active line", "edit", inserttest, nil) +aegisub.register_macro("Insert stuff", "Inserts some lines near the active line", inserttest, nil) diff --git a/automation/autoload/test3.lua b/automation/tests/test3.lua similarity index 97% rename from automation/autoload/test3.lua rename to automation/tests/test3.lua index af3bcca34..802b01dda 100644 --- a/automation/autoload/test3.lua +++ b/automation/tests/test3.lua @@ -30,4 +30,4 @@ function karatest(subtitles, selected_lines, active_line) end -aegisub.register_macro("Karaoke fun", "Makes karaoke-like stuff", "edit", karatest, nil) +aegisub.register_macro("Karaoke fun", "Makes karaoke-like stuff", karatest, nil) diff --git a/automation/autoload/test4.lua b/automation/tests/test4.lua similarity index 96% rename from automation/autoload/test4.lua rename to automation/tests/test4.lua index e55f678d9..4e8304bcb 100644 --- a/automation/autoload/test4.lua +++ b/automation/tests/test4.lua @@ -37,4 +37,4 @@ function progression(subtitles, selected_lines, active_line) end -aegisub.register_macro("Progress fun", "Does absolutely nothing", "video", progression, nil) +aegisub.register_macro("Progress fun", "Does absolutely nothing", progression, nil) diff --git a/automation/autoload/test5.lua b/automation/tests/test5.lua similarity index 96% rename from automation/autoload/test5.lua rename to automation/tests/test5.lua index fb29b53e8..c81c9f31c 100644 --- a/automation/autoload/test5.lua +++ b/automation/tests/test5.lua @@ -37,4 +37,4 @@ function test5(subtitles, selected_lines, active_line) end -aegisub.register_macro("More karaoke fun", "Makes some more karaoke-like stuff", "tools", test5, nil) +aegisub.register_macro("More karaoke fun", "Makes some more karaoke-like stuff", test5, nil) diff --git a/automation/autoload/test6.lua b/automation/tests/test6.lua similarity index 100% rename from automation/autoload/test6.lua rename to automation/tests/test6.lua diff --git a/automation/autoload/test7.lua b/automation/tests/test7.lua similarity index 98% rename from automation/autoload/test7.lua rename to automation/tests/test7.lua index 5fa4e2448..acc6bcacf 100644 --- a/automation/autoload/test7.lua +++ b/automation/tests/test7.lua @@ -88,5 +88,5 @@ function export_config_dialog(subs, store) end -aegisub.register_macro("Config Dialog 1", "Show a stupid config dialog", "video", test7, nil) +aegisub.register_macro("Config Dialog 1", "Show a stupid config dialog", test7, nil) aegisub.register_filter("Export Config", "Test export filter config dialog stuff", 500, exporter, export_config_dialog) diff --git a/automation/v4-docs/basic-function-interface.txt b/automation/v4-docs/basic-function-interface.txt index 007ccfd6b..aa50108f5 100644 --- a/automation/v4-docs/basic-function-interface.txt +++ b/automation/v4-docs/basic-function-interface.txt @@ -14,7 +14,6 @@ a new Macro Feature. function aegisub.register_macro( name, description, - menu, processing_function, validation_function) @@ -25,15 +24,6 @@ function aegisub.register_macro( A longer description of the function of this macro. This will appear on the status bar when hovering over the menu item. -@menu (string) - The menu this macro will appear in. Must be one of: - o "edit" - o "video" - o "audio" - o "tools" - o "right" (the subtitles grid right-click menu) - The menu chosen should be relevant to the function of the macro. - @processing_function (function) The actual function called for the macro execution. This function must be an instance of the Macro Processing Function