62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#pragma once
|
|
#include "Type/types.hpp"
|
|
#include <stdarg.h>
|
|
|
|
namespace JabyEngine {
|
|
class FontWriter {
|
|
private:
|
|
#define __write_impl(start, color, wiggle) \
|
|
va_list list; \
|
|
va_start(list, start); \
|
|
FontWriter::write(state, str, color, wiggle, list); \
|
|
va_end(list)
|
|
|
|
GPU::TexPage::Linked tex_page[2];
|
|
GPU::SizeI16 font_size;
|
|
GPU::PageClut clut;
|
|
GPU::Link* last_primitive;
|
|
|
|
public:
|
|
static constexpr FontWriter empty() {
|
|
FontWriter instance;
|
|
|
|
instance.tex_page[0] = {0};
|
|
instance.tex_page[1] = {0};
|
|
instance.font_size = Make::SizeI16();
|
|
instance.clut = Make::PageClut();
|
|
instance.last_primitive = nullptr;
|
|
return instance;
|
|
}
|
|
|
|
void setup(const SimpleTIM& vram_dst, const GPU::SizeI16& font_size);
|
|
|
|
void setup(const SimpleTIM& vram_dst, const FontInfo& font_info) {
|
|
FontWriter::setup(vram_dst, Make::SizeI16(font_info.font_size.width, font_info.font_size.height));
|
|
}
|
|
|
|
void clear();
|
|
|
|
void write(State& state, const char* str, ...) {
|
|
__write_impl(str, GPU::Color24::Grey(), nullptr);
|
|
}
|
|
void write(State& state, const char* str, GPU::Color24 color, ...) {
|
|
__write_impl(color, color, nullptr);
|
|
}
|
|
void write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, ...) {
|
|
__write_impl(wiggle, color, wiggle);
|
|
}
|
|
void write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list);
|
|
void render();
|
|
|
|
#undef __write_impl
|
|
};
|
|
|
|
struct GlobalFontPrimitivePool {
|
|
static void setup(FontPrimitive* start, size_t length);
|
|
|
|
template<size_t Size>
|
|
static void setup(FontPrimitive (&buffer)[Size]) {
|
|
GlobalFontPrimitivePool::setup(buffer, Size);
|
|
}
|
|
};
|
|
} |