Paleta UI compartida (sega-cube.pal) i constants semàntiques UiColor (v0.7.1)

This commit is contained in:
JailDesigner committed 2026-04-19 09:30:29 +02:00
1 parent e6f3c888e6
commit bee9b650db
12 files changed
+396 -19

No files matched your search

+16
View File
@@ -4,6 +4,7 @@
#include <iostream>
#include <stdexcept>
#include "core/resources/palette_loader.hpp"
#include "core/resources/resource_helper.hpp"
#include "utils/utils.hpp"
@@ -28,6 +29,12 @@ namespace Resource {
printWithDots("Animation : ", getFileName(file_path), "[ LOADED ]");
}
void Cache::loadPalette(const std::string& name, const std::string& file_path) {
auto palette = PaletteLoader::loadFromFile(file_path);
palettes_.emplace_back(PaletteResource{.name = name, .palette = palette});
printWithDots("Palette : ", getFileName(file_path), "[ LOADED ]");
}
auto Cache::getSurface(const std::string& name) -> std::shared_ptr<Surface> {
auto it = std::ranges::find_if(surfaces_, [&name](const auto& s) { return s.name == name; });
if (it == surfaces_.end()) {
@@ -46,4 +53,13 @@ namespace Resource {
return *it;
}
auto Cache::getPalette(const std::string& name) -> const Palette& {
auto it = std::ranges::find_if(palettes_, [&name](const auto& p) { return p.name == name; });
if (it == palettes_.end()) {
std::cerr << "Cache: palette not found: " << name << '\n';
throw std::runtime_error("Palette not found: " + name);
}
return it->palette;
}
} // namespace Resource