48 lines
1.7 KiB
C++
48 lines
1.7 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)
|
|
|
|
FontBufferInfo prim_buffer;
|
|
GPU::TexPage::Linked tex_page;
|
|
FontPrimitive* cur_primitive;
|
|
|
|
void setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const GPU::SizeI16& font_size);
|
|
|
|
public:
|
|
static constexpr FontWriter empty() {
|
|
FontWriter instance;
|
|
|
|
instance.prim_buffer = FontBufferInfo::empty();
|
|
instance.tex_page = {0};
|
|
instance.cur_primitive = nullptr;
|
|
return instance;
|
|
}
|
|
|
|
void setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const FontInfo& font_info) {
|
|
FontWriter::setup(buffer_info, vram_dst, Make::SizeI16(font_info.font_size.width, font_info.font_size.height));
|
|
}
|
|
|
|
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, Wiggle* wiggle, ...) {
|
|
__write_impl(wiggle, color, wiggle);
|
|
}
|
|
void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list b);
|
|
void render();
|
|
|
|
#undef __write_impl
|
|
};
|
|
} |