| 446 | } |
| 447 | |
| 448 | std::unique_ptr<Script> ScriptFactory::CreateFromFile(agi::fs::path const& filename, bool complain_about_unrecognised, bool create_unknown) |
| 449 | { |
| 450 | for (auto& factory : Factories()) { |
| 451 | auto s = factory->Produce(filename); |
| 452 | if (s) { |
| 453 | if (!s->GetLoadedState()) { |
| 454 | wxLogError(_("Failed to load Automation script '%s':\n%s"), filename.wstring(), s->GetDescription()); |
| 455 | } |
| 456 | return s; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | if (complain_about_unrecognised) { |
| 461 | wxLogError(_("The file was not recognised as an Automation script: %s"), filename.wstring()); |
| 462 | } |
| 463 | |
| 464 | return create_unknown ? std::make_unique<UnknownScript>(filename) : nullptr; |
| 465 | } |
| 466 | |
| 467 | std::vector<std::unique_ptr<ScriptFactory>>& ScriptFactory::Factories() |
| 468 | { |
nothing calls this directly
no test coverage detected