// SPDX-License-Identifier: GPL-3.0-only #pragma once #include "modern/ui/catalog.hpp" #include #include namespace bmh::modern_ui { struct UiModEntry { // IDs are current library directory names. Rename returns the new identity. // path is always the installed MOD DIRECTORY; its package is path/content.obw. std::string id, name, type, source, version, description, format, content_id; std::string token, error; fs::path path; uint64_t file_count = 0, bytes = 0; bool active = false; bool valid() const { return error.empty(); } }; struct ModSnapshot { std::vector entries; std::optional active; std::string selection_token, error; }; struct ModImportPlan { // Suggested name and validated source details. This is not yet a member: // metadata.id/path stay empty until commit. Public metadata is display-only. UiModEntry metadata; fs::path source; std::string source_token; int start_year = 2026; private: struct Payload; std::shared_ptr payload_; friend class UiModLibrary; }; using ModProgress = std::function; class UiModLibrary { public: // portable_root contains mods/ and .ui-active-mod.json, never source content. explicit UiModLibrary(fs::path portable_root); static std::string clean_name(const std::string &); static std::string name_key(const std::string &); ModSnapshot snapshot() const; ModImportPlan inspect(const fs::path &, int start_year = 2026) const; UiModEntry commit(const ModImportPlan &, const std::string &name, const ModProgress &progress = {}); void activate(const UiModEntry &, const std::string &selection_token); void deactivate(const std::string &selection_token); UiModEntry rename(const UiModEntry &, const std::string &name, const std::string &selection_token); void remove(const UiModEntry &, const std::string &selection_token); const fs::path &root() const { return root_; } private: fs::path root_; }; } // namespace bmh::modern_ui