diff --git a/.gitignore b/.gitignore index d402b63..0412bf5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.app *.elf *.3dsx +*.cia # ...and icons *.smdh diff --git a/libstarlight/source/starlight/ui/DebugConsole.cpp b/libstarlight/source/starlight/ui/DebugConsole.cpp index 2c9e9ed..dace710 100644 --- a/libstarlight/source/starlight/ui/DebugConsole.cpp +++ b/libstarlight/source/starlight/ui/DebugConsole.cpp @@ -17,7 +17,6 @@ namespace { //std::weak_ptr curDC = std::shared_ptr(nullptr); DebugConsole* cs = nullptr; - // TODO: figure out how the fuck to make this not svcBreak on hardware!? ssize_t consoleWrite(struct _reent* r, void* fd, const char* ptr, size_t len) { if (!ptr) return -1; @@ -25,8 +24,8 @@ namespace { //auto cs = curDC.lock(); if (cs == nullptr) return -1; // nullref but not expired??? - cs->text.append("buh");//(ptr, len); - cs->buffer.reset(); + cs->text.append(ptr, len); + cs->dirty = true; return len; } @@ -64,7 +63,6 @@ void DebugConsole::Start() { setvbuf(stderr, NULL , _IONBF, 0); } - text = "foop?\n"; } void DebugConsole::PreDrawOffscreen() { @@ -72,7 +70,9 @@ void DebugConsole::PreDrawOffscreen() { } void DebugConsole::PreDraw() { - if (!buffer) { + if (dirty || !buffer) { + dirty = false; + static TextConfig textConfig = ThemeManager::GetMetric("/textPresets/normal.12", TextConfig()); textConfig.font = ThemeManager::GetFont("mono.12"); textConfig.justification = Vector2(0, 1); @@ -85,7 +85,7 @@ void DebugConsole::PreDraw() { text = text.substr(cfp); } - buffer = std::make_unique(rect.size + Vector2(0, 8)); + if (!buffer) buffer = std::make_unique(rect.size + Vector2(0, 8)); buffer->Clear(); GFXManager::PushContext(buffer.get()); textConfig.Print(buffer->rect, text); diff --git a/libstarlight/source/starlight/ui/DebugConsole.h b/libstarlight/source/starlight/ui/DebugConsole.h index 96b97da..a88eeca 100644 --- a/libstarlight/source/starlight/ui/DebugConsole.h +++ b/libstarlight/source/starlight/ui/DebugConsole.h @@ -23,6 +23,7 @@ namespace starlight { std::string text = ""; std::unique_ptr buffer; + bool dirty = false; DebugConsole(VRect rect); ~DebugConsole() override; diff --git a/testbed/source/Core.cpp b/testbed/source/Core.cpp index 8b60f85..8bf6c1d 100644 --- a/testbed/source/Core.cpp +++ b/testbed/source/Core.cpp @@ -73,8 +73,8 @@ void Core::Init() { label->SetText("This is a form, coming in and nuking the non-form UI elements. Whoops."); form->touchScreen->Add(label);*/ - //auto console = form->topScreen->AddNew(VRect::topScreen); - //console->Start(); + auto console = form->topScreen->AddNew(VRect::topScreen); + console->Start(); auto xbtn = std::make_shared(VRect(320-96,28,32,24)); xbtn->eOnTap = [](auto& btn){ diff --git a/testbed/starlight-testbed.cia b/testbed/starlight-testbed.cia index 08b6412..309a252 100644 Binary files a/testbed/starlight-testbed.cia and b/testbed/starlight-testbed.cia differ