diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 7ba991eea..51e47fde1 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -701,6 +701,12 @@ bool AssFile::CompEnd(const AssDialogue* lft, const AssDialogue* rgt) { bool AssFile::CompStyle(const AssDialogue* lft, const AssDialogue* rgt) { return lft->Style < rgt->Style; } +bool AssFile::CompActor(const AssDialogue* lft, const AssDialogue* rgt) { + return lft->Actor < rgt->Actor; +} +bool AssFile::CompEffect(const AssDialogue* lft, const AssDialogue* rgt) { + return lft->Effect < rgt->Effect; +} void AssFile::Sort(CompFunc comp) { Sort(Line, comp); diff --git a/aegisub/src/ass_file.h b/aegisub/src/ass_file.h index 1d638567b..112ae1003 100644 --- a/aegisub/src/ass_file.h +++ b/aegisub/src/ass_file.h @@ -226,12 +226,16 @@ public: /// Comparison function for use when sorting typedef bool (*CompFunc)(const AssDialogue* lft, const AssDialogue* rgt); - /// @brief Compare based on start time + /// Compare based on start time static bool CompStart(const AssDialogue* lft, const AssDialogue* rgt); - /// @brief Compare based on end time + /// Compare based on end time static bool CompEnd(const AssDialogue* lft, const AssDialogue* rgt); - /// @brief Compare based on end time + /// Compare based on style name static bool CompStyle(const AssDialogue* lft, const AssDialogue* rgt); + /// Compare based on actor name + static bool CompActor(const AssDialogue* lft, const AssDialogue* rgt); + /// Compare based on effect + static bool CompEffect(const AssDialogue* lft, const AssDialogue* rgt); /// @brief Sort the dialogue lines in this file /// @param comp Comparison function to use. Defaults to sorting by start time. diff --git a/aegisub/src/command/grid.cpp b/aegisub/src/command/grid.cpp index d8f9c06fd..a19ff5ece 100644 --- a/aegisub/src/command/grid.cpp +++ b/aegisub/src/command/grid.cpp @@ -99,8 +99,34 @@ struct grid_line_prev : public Command { void operator()(agi::Context *c) { c->selectionController->PrevLine(); } -} -; +}; + +/// Sort all subtitles by their actor names +struct grid_sort_actor : public Command { + CMD_NAME("grid/sort/actor") + STR_MENU("&Actor Name") + STR_DISP("Actor Name") + STR_HELP("Sort all subtitles by their actor names.") + + void operator()(agi::Context *c) { + c->ass->Sort(AssFile::CompActor); + c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); + } +}; + +/// Sort all subtitles by their effects +struct grid_sort_effect : public Command { + CMD_NAME("grid/sort/effect") + STR_MENU("&Effect") + STR_DISP("Effect") + STR_HELP("Sort all subtitles by their effects") + + void operator()(agi::Context *c) { + c->ass->Sort(AssFile::CompEffect); + c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER); + } +}; + /// Sort all subtitles by their end times. struct grid_sort_end : public Command { CMD_NAME("grid/sort/end") @@ -127,7 +153,7 @@ struct grid_sort_start : public Command { } }; -/// Sort all subtitles by their style names. +/// Sort all subtitles by their style names struct grid_sort_style : public Command { CMD_NAME("grid/sort/style") STR_MENU("St&yle Name") @@ -309,6 +335,8 @@ namespace cmd { reg(new grid_line_next); reg(new grid_line_next_create); reg(new grid_line_prev); + reg(new grid_sort_actor); + reg(new grid_sort_effect); reg(new grid_sort_end); reg(new grid_sort_start); reg(new grid_sort_style); diff --git a/aegisub/src/libresrc/default_menu.json b/aegisub/src/libresrc/default_menu.json index c872fc0db..015ae646c 100644 --- a/aegisub/src/libresrc/default_menu.json +++ b/aegisub/src/libresrc/default_menu.json @@ -102,7 +102,9 @@ "main/subtitle/sort lines" : [ { "command" : "grid/sort/start" }, { "command" : "grid/sort/end" }, - { "command" : "grid/sort/style" } + { "command" : "grid/sort/style" }, + { "command" : "grid/sort/actor" }, + { "command" : "grid/sort/effect" } ], "main/timing" : [ { "command" : "time/shift" },