| 452 | }; |
| 453 | |
| 454 | void Regenerate() { |
| 455 | for (auto item : all_items) |
| 456 | cm->Remove(item); |
| 457 | |
| 458 | wxMenuItemList &items = GetMenuItems(); |
| 459 | // Remove everything but automation manager and the separator |
| 460 | for (size_t i = items.size() - 1; i >= 2; --i) |
| 461 | Delete(items[i]); |
| 462 | |
| 463 | auto macros = config::global_scripts->GetMacros(); |
| 464 | boost::push_back(macros, c->local_scripts->GetMacros()); |
| 465 | if (macros.empty()) { |
| 466 | Append(-1, _("No Automation macros loaded"))->Enable(false); |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | WorkItem top(""); |
| 471 | for (auto macro : macros) { |
| 472 | const auto name = from_wx(macro->StrMenu(c)); |
| 473 | WorkItem *parent = ⊤ |
| 474 | for (auto section : agi::Split(name, wxS('/'))) { |
| 475 | std::string sectionname(section.begin(), section.end()); |
| 476 | |
| 477 | if (section.end() == std::string_view(name).end()) { |
| 478 | parent->subitems.emplace_back(sectionname, macro); |
| 479 | } |
| 480 | else { |
| 481 | parent = parent->FindOrMakeSubitem(sectionname); |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | top.Sort(); |
| 486 | top.GenerateMenu(this, this); |
| 487 | } |
| 488 | public: |
| 489 | AutomationMenu(agi::Context *c, CommandManager *cm) |
| 490 | : c(c) |
nothing calls this directly
no test coverage detected