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

+8 -7
View File
@@ -8,14 +8,11 @@
#include "core/rendering/text.hpp"
#include "core/resources/resource_cache.hpp"
#include "game/options.hpp"
#include "game/ui/ui_palette.hpp"
#include "utils/defines.hpp"
namespace {
// La paleta de 8bithud.gif només té 2 entrades (0=negre, 1=blanc); per a
// poder colorar el text lliurement caldrà una paleta compartida, com al
// projecte_2026. De moment ens quedem amb blanc.
constexpr Uint8 TEXT_COLOR = 1;
constexpr int TEXT_SIZE = 8;
constexpr int PADDING_V = (RenderInfo::HEIGHT - TEXT_SIZE) / 2;
@@ -35,10 +32,14 @@ auto RenderInfo::get() -> RenderInfo& {
RenderInfo::~RenderInfo() = default;
void RenderInfo::init() {
// El fitxer s'indexa al Cache perquè també el puguen reutilitzar altres
// HUDs que vulguen la mateixa font sense recarregar-la.
// Paleta compartida de UI: qualsevol HUD que la vulga només ha de cridar
// Cache::getPalette("ui") i aplicar-la a la seua surface. El .gif propi
// de la font (2 colors) es descarta a favor d'aquesta.
Resource::Cache::get().loadPalette("ui", "data/palettes/sega-cube.pal");
Resource::Cache::get().loadSurface("8bithud.gif", "data/font/8bithud.gif");
auto font_surface = Resource::Cache::get().getSurface("8bithud.gif");
font_surface->setPalette(Resource::Cache::get().getPalette("ui"));
text_ = std::make_unique<Text>(font_surface, "data/font/8bithud.fnt");
// Restaura l'estat guardat a config.yaml (video.render_info).
@@ -93,7 +94,7 @@ void RenderInfo::render() {
static_cast<int>(y_) + PADDING_V,
line,
1,
TEXT_COLOR);
UiColor::RENDER_INFO_TEXT);
}
void RenderInfo::toggle() {
-8
View File
@@ -63,14 +63,6 @@ auto Surface::loadSurface(const std::string& file_path) -> SurfaceData {
return {static_cast<int>(w), static_cast<int>(h), pixels};
}
void Surface::loadPalette(const std::string& file_path) {
palette_ = loadPaletteFromGif(file_path);
}
void Surface::loadPalette(const Palette& palette) {
palette_ = palette;
}
void Surface::clear(Uint8 color) {
const std::size_t TOTAL = static_cast<std::size_t>(surface_data_->width) * static_cast<std::size_t>(surface_data_->height);
std::fill(surface_data_->data.get(), surface_data_->data.get() + TOTAL, color);
-3
View File
@@ -47,9 +47,6 @@ class Surface {
static auto loadSurface(const std::string& file_path) -> SurfaceData;
void loadPalette(const std::string& file_path);
void loadPalette(const Palette& palette);
// Vobla la regió indicada al framebuffer ARGB del joc usant la paleta propia.
void render(int x, int y, const SDL_FRect* src_rect = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE) const;
// Igual que render() però substituint els píxels amb valor source_color per