Rename 'State' to 'Cursor'

This commit is contained in:
2024-01-05 12:33:14 -06:00
parent 3e6f5505c2
commit d37bff2f66
3 changed files with 18 additions and 27 deletions

View File

@@ -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<const char*, const char*> {
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;
}
}