diff --git a/support/include/FontWriter/Type/types.hpp b/support/include/FontWriter/Type/types.hpp index 5fb392bf..bfff7a7d 100644 --- a/support/include/FontWriter/Type/types.hpp +++ b/support/include/FontWriter/Type/types.hpp @@ -32,23 +32,14 @@ namespace JabyEngine { } }; - struct State { + struct Cursor { GPU::PositionI16 pos; uint8_t wiggle_count; - static constexpr State create(GPU::PositionI16 pos, uint8_t wiggle_count = 0) { - return State{.pos = pos, .wiggle_count = wiggle_count}; + static constexpr Cursor create(GPU::PositionI16 pos, uint8_t wiggle_count = 0) { + return Cursor{.pos = pos, .wiggle_count = wiggle_count}; } }; using Wiggle = GPU::PositionI8[8]; - - /*struct Wiggle { - GPU::PositionI8 offset[8]; - uint8_t count; - - GPU::PositionI8 next() { - return this->offset[(this->count++)&0x7]; - } - };*/ } diff --git a/support/include/FontWriter/font_writer.hpp b/support/include/FontWriter/font_writer.hpp index 49d95bcc..f5380d56 100644 --- a/support/include/FontWriter/font_writer.hpp +++ b/support/include/FontWriter/font_writer.hpp @@ -8,7 +8,7 @@ namespace JabyEngine { #define __write_impl(start, color, wiggle) \ va_list list; \ va_start(list, start); \ - FontWriter::write(state, str, color, wiggle, list); \ + FontWriter::write(cursor, str, color, wiggle, list); \ va_end(list) GPU::TexPage::Linked tex_page[2]; @@ -36,16 +36,16 @@ namespace JabyEngine { void clear(); - void write(State& state, const char* str, ...) { + void write(Cursor& cursor, const char* str, ...) { __write_impl(str, GPU::Color24::Grey(), nullptr); } - void write(State& state, const char* str, GPU::Color24 color, ...) { + void write(Cursor& cursor, const char* str, GPU::Color24 color, ...) { __write_impl(color, color, nullptr); } - void write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, ...) { + void write(Cursor& cursor, 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 write(Cursor& cursor, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list); void render(); #undef __write_impl diff --git a/support/src/FontWriter/src/font_writer.cpp b/support/src/FontWriter/src/font_writer.cpp index abe020b8..06e9be77 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -67,7 +67,7 @@ namespace JabyEngine { this->last_primitive = &this->tex_page[GPU::update_id()]; } - void FontWriter :: write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list) { + void FontWriter :: write(Cursor& cursor, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list) { static const auto exchang_str = [](const char* str, const char* new_str) -> pair { return {str + 1, new_str}; }; @@ -78,13 +78,13 @@ namespace JabyEngine { const auto sprt_size = GPU::SizeI16::from(this->render_info.font_size); const auto row_count = 256/sprt_size.width; - const auto push_char = [&](State& state, char cur_char) -> bool { + const auto push_char = [&](Cursor& cursor, char cur_char) -> bool { auto& primitive = GlobalPrimitiveFactory.new_primitive(); - primitive->position = state.pos; + primitive->position = cursor.pos; primitive->size = sprt_size; if(wiggle) { - const auto [off_x, off_y] = (*wiggle)[(state.wiggle_count++)&0x7]; + const auto [off_x, off_y] = (*wiggle)[(cursor.wiggle_count++)&0x7]; primitive->position.move(off_x, off_y); } primitive->tex_offset = GPU::PageOffset::from_tile_id(cur_char - '!', row_count, sprt_size); @@ -93,10 +93,10 @@ namespace JabyEngine { this->last_primitive->concat(primitive); this->last_primitive = &primitive; - state.pos.move(this->render_info.kern_size.width, 0); + cursor.pos.move(this->render_info.kern_size.width, 0); return true; }; - const auto old_x = state.pos.x; + const auto old_x = cursor.pos.x; const char* prev_str = nullptr; char buffer[32]; @@ -112,12 +112,12 @@ namespace JabyEngine { return; case '\n': - state.pos.x = old_x; - state.pos.y += this->render_info.kern_size.height; + cursor.pos.x = old_x; + cursor.pos.y += this->render_info.kern_size.height; continue; case ' ': - state.pos.x += this->render_info.kern_size.width; + cursor.pos.x += this->render_info.kern_size.width; continue; case '%': @@ -140,7 +140,7 @@ namespace JabyEngine { } default: - if(!push_char(state, cur_char)) { + if(!push_char(cursor, cur_char)) { return; } }