mirror of
https://github.com/DarkStore-3DS/Universal-Core.git
synced 2026-07-02 16:59:05 +00:00
Fix non-buffered text
This commit is contained in:
+10
-11
@@ -30,11 +30,10 @@
|
|||||||
#include "tonccpy.h"
|
#include "tonccpy.h"
|
||||||
|
|
||||||
#ifdef UNIVCORE_TEXT_BUFFERED
|
#ifdef UNIVCORE_TEXT_BUFFERED
|
||||||
u8 Font::textBuf[2][256 * 192];
|
u8 Font::textBuf[2][256 * 192];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Font::Font(const std::vector<std::string> &paths) {
|
Font::Font(const std::vector<std::string> &paths) {
|
||||||
|
|
||||||
FILE *file = nullptr;
|
FILE *file = nullptr;
|
||||||
for(const auto &path : paths) {
|
for(const auto &path : paths) {
|
||||||
file = fopen(path.c_str(), "rb");
|
file = fopen(path.c_str(), "rb");
|
||||||
@@ -330,11 +329,11 @@ ITCM_CODE void Font::print(std::u16string_view text, int x, int y, Alignment ali
|
|||||||
} else {
|
} else {
|
||||||
width = 256;
|
width = 256;
|
||||||
height = 192;
|
height = 192;
|
||||||
#ifdef UNIVCORE_TEXT_BUFFERED
|
#ifdef UNIVCORE_TEXT_BUFFERED
|
||||||
dstBegin = textBuf[currentScreen];
|
dstBegin = textBuf[currentScreen];
|
||||||
#else
|
#else
|
||||||
dstBegin = (u8 *)bgGetGfxPtr(Gui::top ? 2 : 6);
|
dstBegin = (u8 *)bgGetGfxPtr(currentScreen ? 3 : 7);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
dstBegin += y * width + x + fontWidths[(index * 3)];
|
dstBegin += y * width + x + fontWidths[(index * 3)];
|
||||||
|
|
||||||
@@ -369,9 +368,9 @@ ITCM_CODE void Font::print(std::u16string_view text, int x, int y, Alignment ali
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNIVCORE_TEXT_BUFFERED
|
#ifdef UNIVCORE_TEXT_BUFFERED
|
||||||
void Font::clear(bool top) { dmaFillWords(0, Font::textBuf[top], 256 * 192); }
|
void Font::clear(bool top) { dmaFillWords(0, Font::textBuf[top], 256 * 192); }
|
||||||
|
|
||||||
void Font::update(bool top) {
|
void Font::update(bool top) {
|
||||||
tonccpy(bgGetGfxPtr(top ? 2 : 6), Font::textBuf[top], 256 * 192);
|
tonccpy(bgGetGfxPtr(top ? 2 : 6), Font::textBuf[top], 256 * 192);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+13
-4
@@ -86,11 +86,15 @@ void Gui::clearScreen(bool top) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::clearTextBufs(void) {
|
void Gui::clearTextBufs(void) {
|
||||||
Font::clear();
|
#ifdef UNIVCORE_TEXT_BUFFERED
|
||||||
|
Font::clear();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::updateTextBufs(bool top) {
|
void Gui::updateTextBufs(bool top) {
|
||||||
Font::update(top);
|
#ifdef UNIVCORE_TEXT_BUFFERED
|
||||||
|
Font::update(top);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::DrawSprite(Spritesheet &sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY) {
|
void Gui::DrawSprite(Spritesheet &sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY) {
|
||||||
@@ -121,8 +125,13 @@ void Gui::DrawStringCentered(int x, int y, u8 size, u8 color, const std::string
|
|||||||
void Gui::DrawString(int x, int y, u8 size, u8 color, const std::string &Text, float maxWidth, float maxHeight, Font *fnt, int flags) {
|
void Gui::DrawString(int x, int y, u8 size, u8 color, const std::string &Text, float maxWidth, float maxHeight, Font *fnt, int flags) {
|
||||||
if (!fnt && size >= DefaultFonts.size()) return;
|
if (!fnt && size >= DefaultFonts.size()) return;
|
||||||
|
|
||||||
float heightScale = maxHeight == 0 ? 1.0f : std::min(1.0f, maxHeight / Gui::GetStringHeight(size, Text, fnt));
|
#ifdef UNIVCORE_3DS_SIZE
|
||||||
float widthScale = maxWidth == 0 ? 1.0f : std::min(1.0f, maxWidth / Gui::GetStringWidth(size, Text, fnt));
|
float heightScale = maxHeight == 0 ? 1.0f : std::min(1.0f, (maxWidth * 4 / 5) / Gui::GetStringHeight(size, Text, fnt));
|
||||||
|
float widthScale = maxWidth == 0 ? 1.0f : std::min(1.0f, (maxWidth * 4 / 5) / Gui::GetStringWidth(size, Text, fnt));
|
||||||
|
#else
|
||||||
|
float heightScale = maxHeight == 0 ? 1.0f : std::min(1.0f, maxHeight / Gui::GetStringHeight(size, Text, fnt));
|
||||||
|
float widthScale = maxWidth == 0 ? 1.0f : std::min(1.0f, maxWidth / Gui::GetStringWidth(size, Text, fnt));
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Wrapping and such
|
// TODO: Wrapping and such
|
||||||
(fnt ? *fnt : *DefaultFonts[size]).print(x, y, Text, flags & C2D_AlignCenter ? Alignment::center : (flags & C2D_AlignRight ? Alignment::right : Alignment::left), color, maxWidth, widthScale, heightScale);
|
(fnt ? *fnt : *DefaultFonts[size]).print(x, y, Text, flags & C2D_AlignCenter ? Alignment::center : (flags & C2D_AlignRight ? Alignment::right : Alignment::left), color, maxWidth, widthScale, heightScale);
|
||||||
|
|||||||
Reference in New Issue
Block a user