From c8fa68815b5a4f85566b3f3d651de54c854c968a Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 18 Nov 2024 13:29:22 -0500 Subject: [PATCH] A bit more cleanup of render but kind of stuck on what to do further. --- render.cpp | 45 ++++++++++++++++++++++++--------------------- status.txt | 1 - 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/render.cpp b/render.cpp index b67d9f8..8788ca0 100644 --- a/render.cpp +++ b/render.cpp @@ -122,29 +122,32 @@ void SFMLRender::render_grid(const std::wstring &text, float x, float y) { }, [&](wchar_t tile) { - if(tile == '\n') { - // don't bother processing newlines, just skip - y += $line_spacing; - x = start_x; - } else if(tile == L'\r') { - return; // skip these, just windows junk - } else { - $bg_sprite.setPosition({x, y}); - - // only get a new sprite if the tile changed - if(last_tile != tile) { - last_tile = tile; // update last tile seen - sprite = get_text_sprite(tile); - configure_tile(sprite, sp_bounds, $bg_bounds, width_delta, height_delta); - } + switch(tile) { + case '\r': break; // ignore it + case '\n': { + // don't bother processing newlines, just skip + y += $line_spacing; + x = start_x; + } + break; + default: { + $bg_sprite.setPosition({x, y}); + + // only get a new sprite if the tile changed + if(last_tile != tile) { + last_tile = tile; // update last tile seen + sprite = get_text_sprite(tile); + configure_tile(sprite, sp_bounds, $bg_bounds, width_delta, height_delta); + } - sprite.setPosition({x+width_delta, y+height_delta}); - sprite.setColor(cur_fg); + sprite.setPosition({x+width_delta, y+height_delta}); + sprite.setColor(cur_fg); - $window.draw($bg_sprite); - $window.draw(sprite); - // next cell - x += $base_glyph.advance; + $window.draw($bg_sprite); + $window.draw(sprite); + // next cell + x += $base_glyph.advance; + } } }); } diff --git a/status.txt b/status.txt index 1dfdcf3..8de28f8 100644 --- a/status.txt +++ b/status.txt @@ -1,6 +1,5 @@ TODAY'S GOAL: -* Clean up renderer. * panels and everything except renderer should use character coodinates * Image -> Text converter.