add read from zip

This commit is contained in:
Vlad committed 2026-01-09 20:08:09 +06:00
1 parent b055faf882
commit 112684b40a
6 files changed
+124 -45

No files matched your search

+17 -4
View File
@@ -152,15 +152,28 @@ namespace ZL {
}
void UiManager::loadFromFile(const std::string& path, Renderer& renderer, const std::string& zipFile) {
std::ifstream in(path);
if (!in.is_open()) {
std::cerr << "UiManager: failed to open " << path << std::endl;
std::string content;
try {
if (zipFile.empty()) {
content = readTextFile(path);
}
else {
auto buf = readFileFromZIP(path, zipFile);
if (buf.empty()) {
std::cerr << "UiManager: failed to read " << path << " from zip " << zipFile << std::endl;
throw std::runtime_error("Failed to load UI file: " + path);
}
content.assign(buf.begin(), buf.end());
}
}
catch (const std::exception& e) {
std::cerr << "UiManager: failed to open " << path << " : " << e.what() << std::endl;
throw std::runtime_error("Failed to load UI file: " + path);
}
json j;
try {
in >> j;
j = json::parse(content);
}
catch (const std::exception& e) {
std::cerr << "UiManager: json parse error: " << e.what() << std::endl;