Support Version number and change font to BIOS for ControllerTest

This commit is contained in:
Jaby 2024-01-05 13:35:37 -06:00
parent 9c8edb04e0
commit d59e2d163e
3 changed files with 23 additions and 6 deletions

View File

@ -21,8 +21,8 @@ namespace ControllerTest {
return true; return true;
} }
controller_state0.update(&Periphery::get_primary_controller_as<JabyEngine::Periphery::AnalogeController>(), FontWriter::new_font_writer); controller_state0.update(&Periphery::get_primary_controller_as<JabyEngine::Periphery::AnalogeController>(), FontWriter::bios_font_writer);
controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as<JabyEngine::Periphery::AnalogeController>(1, 0) : nullptr, FontWriter::new_font_writer); controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as<JabyEngine::Periphery::AnalogeController>(1, 0) : nullptr, FontWriter::bios_font_writer);
return false; return false;
} }
@ -30,7 +30,7 @@ namespace ControllerTest {
GPU::render(Shared::background); GPU::render(Shared::background);
controller_state0.render(); controller_state0.render();
controller_state1.render(); controller_state1.render();
FontWriter::new_font_writer.render(); FontWriter::bios_font_writer.render();
Shared::back_menu.render(); Shared::back_menu.render();
} }

View File

@ -86,14 +86,17 @@ static void setup() {
namespace NormalScene { namespace NormalScene {
static void update() { static void update() {
static const char Title[] = "Pool Box"; static const char Title[] = "Pool Box";
static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.get_font_size().width; 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(); 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(); paco.update();
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(0xD0), &FontWriter::wiggle); 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)); menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
} }

View File

@ -30,6 +30,15 @@ namespace JabyEngine {
constexpr GPU::SizeU16 get_font_size() const { constexpr GPU::SizeU16 get_font_size() const {
return GPU::SizeU16::from(this->render_info.font_size); 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<size_t Size>
constexpr size_t estimate_str_render_length(const char (&str)[Size]) const {
return (Size - 1)*FontInfo::get_kern_size().width;
}
}; };
struct Cursor { struct Cursor {
@ -39,6 +48,11 @@ namespace JabyEngine {
static constexpr Cursor create(GPU::PositionI16 pos, uint8_t wiggle_count = 0) { static constexpr Cursor create(GPU::PositionI16 pos, uint8_t wiggle_count = 0) {
return Cursor{.pos = pos, .wiggle_count = wiggle_count}; 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]; using Wiggle = GPU::PositionI8[8];