From 111a42a7e12319a04b2830c60b266588753d717b Mon Sep 17 00:00:00 2001 From: jaby Date: Fri, 5 Jan 2024 13:35:37 -0600 Subject: [PATCH] Support Version number and change font to BIOS for ControllerTest --- .../src/Overlay/ControllerTest/controller_test.cpp | 6 +++--- examples/PoolBox/application/src/application.cpp | 9 ++++++--- support/include/FontWriter/Type/types.hpp | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp index ba609865..7f8a4a13 100644 --- a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp @@ -21,8 +21,8 @@ namespace ControllerTest { return true; } - controller_state0.update(&Periphery::get_primary_controller_as(), FontWriter::new_font_writer); - controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as(1, 0) : nullptr, FontWriter::new_font_writer); + controller_state0.update(&Periphery::get_primary_controller_as(), FontWriter::bios_font_writer); + controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as(1, 0) : nullptr, FontWriter::bios_font_writer); return false; } @@ -30,7 +30,7 @@ namespace ControllerTest { GPU::render(Shared::background); controller_state0.render(); controller_state1.render(); - FontWriter::new_font_writer.render(); + FontWriter::bios_font_writer.render(); Shared::back_menu.render(); } diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index 6b0a74c0..3c23641e 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -86,14 +86,17 @@ static void setup() { namespace NormalScene { static void update() { - static const char Title[] = "Pool Box"; - static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.get_font_size().width; + static const char Title[] = "Pool Box"; + static const char Version[] = "Ver. 0.8"; + static constexpr auto TitleLength = DefaultFont::Info.estimate_str_render_length(Title); + static constexpr auto VersionLength = DefaultFont::Info.estimate_str_render_length(Version); Periphery::query_controller(); - auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16)); + auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16)); paco.update(); FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(0xD0), &FontWriter::wiggle); + FontWriter::new_font_writer.write(cursor.change_position(Make::PositionI16((GPU::Display::Width-VersionLength)/2, 16 + DefaultFont::Info.get_kern_size().height)), Version, GPU::Color24::Green(0xD0), &FontWriter::wiggle); menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64)); } diff --git a/support/include/FontWriter/Type/types.hpp b/support/include/FontWriter/Type/types.hpp index bfff7a7d..c1fb91f7 100644 --- a/support/include/FontWriter/Type/types.hpp +++ b/support/include/FontWriter/Type/types.hpp @@ -30,6 +30,15 @@ namespace JabyEngine { constexpr GPU::SizeU16 get_font_size() const { return GPU::SizeU16::from(this->render_info.font_size); } + + constexpr GPU::SizeU16 get_kern_size() const { + return GPU::SizeU16::from(this->render_info.kern_size); + } + + template + constexpr size_t estimate_str_render_length(const char (&str)[Size]) const { + return (Size - 1)*FontInfo::get_kern_size().width; + } }; struct Cursor { @@ -39,6 +48,11 @@ namespace JabyEngine { static constexpr Cursor create(GPU::PositionI16 pos, uint8_t wiggle_count = 0) { return Cursor{.pos = pos, .wiggle_count = wiggle_count}; } + + constexpr Cursor& change_position(GPU::PositionI16 pos) { + this->pos = pos; + return *this; + } }; using Wiggle = GPU::PositionI8[8];