| 114 | } |
| 115 | |
| 116 | auto Sorcery::ComponentStore::get_custom(std::string_view screen) |
| 117 | -> std::optional<std::vector<Component>> { |
| 118 | |
| 119 | // First check if we need to reload if anything has changed! |
| 120 | if (need_refresh()) |
| 121 | load(_file); |
| 122 | |
| 123 | // Else return the requested components for the screen |
| 124 | std::vector<Component> results; |
| 125 | if (_loaded) { |
| 126 | |
| 127 | for (const auto &[unique_key, component] : _components) { |
| 128 | if ((component.form == screen) && |
| 129 | (component.drawmode == Enums::Layout::DrawMode::MANUAL)) { |
| 130 | results.push_back(component); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Sort by priority |
| 135 | std::sort(results.begin(), results.end(), |
| 136 | [](const auto &first, const auto &second) { |
| 137 | return first.priority < second.priority; |
| 138 | }); |
| 139 | |
| 140 | return results; |
| 141 | } |
| 142 | |
| 143 | return std::nullopt; |
| 144 | } |
| 145 | |
| 146 | auto Sorcery::ComponentStore::load(const std::filesystem::path filename) |
| 147 | -> bool { |
nothing calls this directly
no outgoing calls
no test coverage detected