26 std::vector<gfx::SnesColor> colors;
28 for (
int i = 0; i < 16; ++i) {
29 const float value =
static_cast<float>(i) / 15.0f;
30 colors.emplace_back(ImVec4(value, value, value, 1.0f));
33 if (!colors.empty()) {
34 colors[0].set_transparent(
true);
42 if (!
rom() || !
rom()->is_loaded()) {
43 LOG_WARN(
"MessageEditor",
"ROM not loaded - skipping font graphics load");
49 const size_t rom_size =
rom()->
size();
50 if (rom_size >
static_cast<size_t>(
kGfxFont)) {
52 rom_size -
static_cast<size_t>(
kGfxFont));
57 "Font graphics truncated (ROM size %zu, read %zu bytes)",
62 "ROM size %zu too small for font graphics offset 0x%X", rom_size,
73 const std::string error_message(load_font.status().message());
74 LOG_WARN(
"MessageEditor",
"LoadFontGraphics failed: %s",
75 error_message.c_str());
86 const std::vector<uint8_t>& font_data) {
87 if (font_data.empty()) {
88 LOG_WARN(
"MessageEditor",
"Font graphics data missing - atlas stays empty");
93 const size_t row_count = (font_data.size() + atlas_width - 1) / atlas_width;
94 const int atlas_height =
static_cast<int>(std::max<size_t>(1, row_count));
96 const size_t expected_size =
static_cast<size_t>(atlas_width) * atlas_height;
97 std::vector<uint8_t> padded(font_data.begin(), font_data.end());
98 if (padded.size() < expected_size) {
99 padded.resize(expected_size, 0);
100 }
else if (padded.size() > expected_size) {
101 padded.resize(expected_size);
121 if (!bitmap.is_active()) {
124 const auto command = bitmap.texture()
zelda3::GameData * game_data() const
void ResolveFontPalette()
void EnsureFontTexturesReady()
bool font_graphics_loaded_
void RefreshFontAtlasBitmap(const std::vector< uint8_t > &font_data)
std::array< uint8_t, 0x4000 > raw_font_gfx_data_
gfx::SnesPalette BuildFallbackFontPalette() const
void DrawMessagePreview()
gfx::SnesPalette font_preview_colors_
MessageData current_message_
MessagePreview message_preview_
gfx::Bitmap current_font_gfx16_bitmap_
gfx::Bitmap font_gfx_bitmap_
void QueueTextureCommand(TextureCommandType type, Bitmap *bitmap)
Represents a bitmap image optimized for SNES ROM hacking.
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.
TextureHandle texture() const
void SetPalette(const SnesPalette &palette)
Set the palette for the bitmap using SNES palette format.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
#define LOG_WARN(category, format,...)
Editors are the view controllers for the application.
constexpr int kFontGfxMessageSize
constexpr int kFontGfxMessageDepth
std::vector< uint8_t > SnesTo8bppSheet(std::span< const uint8_t > sheet, int bpp, int num_sheets)
absl::StatusOr< gfx::Bitmap > LoadFontGraphics(const Rom &rom)
Loads font graphics from ROM.
std::vector< uint8_t > Data
std::vector< uint8_t > font_gfx16_data_2_
std::vector< uint8_t > font_gfx16_data_
auto palette(int i) const
gfx::PaletteGroupMap palette_groups