30 std::vector<gfx::SnesColor> colors;
32 for (
int i = 0; i < 32; ++i) {
33 const float value =
static_cast<float>(i % 16) / 15.0f;
34 colors.emplace_back(ImVec4(value, value, value, 1.0f));
41 if (!colors.empty()) {
42 colors[0].set_transparent(
true);
50 if (!
rom() || !
rom()->is_loaded()) {
51 LOG_WARN(
"MessageEditor",
"ROM not loaded - skipping font graphics load");
57 const size_t rom_size =
rom()->
size();
58 if (rom_size >
static_cast<size_t>(
kGfxFont)) {
60 rom_size -
static_cast<size_t>(
kGfxFont));
65 "Font graphics truncated (ROM size %zu, read %zu bytes)",
70 "ROM size %zu too small for font graphics offset 0x%X", rom_size,
81 const std::string error_message(load_font.status().message());
82 LOG_WARN(
"MessageEditor",
"LoadFontGraphics failed: %s",
83 error_message.c_str());
94 const std::vector<uint8_t>& font_data) {
95 if (font_data.empty()) {
96 LOG_WARN(
"MessageEditor",
"Font graphics data missing - atlas stays empty");
101 const size_t row_count = (font_data.size() + atlas_width - 1) / atlas_width;
102 const int atlas_height =
static_cast<int>(std::max<size_t>(1, row_count));
104 const size_t expected_size =
static_cast<size_t>(atlas_width) * atlas_height;
105 std::vector<uint8_t> padded(font_data.begin(), font_data.end());
106 if (padded.size() < expected_size) {
107 padded.resize(expected_size, 0);
108 }
else if (padded.size() > expected_size) {
109 padded.resize(expected_size);
129 if (!bitmap.is_active()) {
132 const auto command = bitmap.texture()
176 tr(
"2bpp dialogue font at $070000. Click a tile to inspect it."));
zelda3::GameData * game_data() const
void ResolveFontPalette()
void EnsureFontTexturesReady()
bool font_graphics_loaded_
gui::Canvas font_gfx_canvas_
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).
void DrawBitmap(Bitmap &bitmap, int border_offset, float scale)
bool DrawTileSelector(int size, int size_y=0)
CanvasConfig & GetConfig()
#define ICON_MD_FONT_DOWNLOAD
#define LOG_WARN(category, format,...)
Editors are the view controllers for the application.
constexpr int kDialogueFontPalette
constexpr int kFontGfxMessageSize
constexpr int kFontGfxMessageDepth
std::vector< uint8_t > SnesTo8bppSheet(std::span< const uint8_t > sheet, int bpp, int num_sheets)
void EndCanvas(Canvas &canvas)
void BeginCanvas(Canvas &canvas, ImVec2 child_size)
void SectionHeader(const char *icon, const char *label, const ImVec4 &color)
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