diff --git a/include/gui.hpp b/include/gui.hpp index 55e1423..0e9f063 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -88,25 +88,25 @@ namespace Gui { Initialize the GUI. Call this when initializing. - FontPath: The font to use. + FontPaths: The locations to check for the font. */ - bool init(const char *FontPath = nullptr); + bool init(const std::vector &FontPaths); /* Load a Font. (NFTR) fnt: The Font variable which should be initialized. - Path: Path to the NFTR file. + Paths: The locations to check for the NFTR file. if you're unsure, just call 'Gui::init();' and it will load the default font. */ - bool loadFont(Font &fnt, const char *Path = nullptr); + bool loadFont(Font &fnt, const std::vector &Paths); /* Reinit the GUI. - FontPath: The font to use. + FontPaths: The locations to check for the font. */ - bool reinit(const char *FontPath = nullptr); + bool reinit(const std::vector &FontPaths); /* Draws a centered String. diff --git a/source/gui.cpp b/source/gui.cpp index 4d9bc86..71a848f 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -44,7 +44,7 @@ int fadecolor = 0; bool widescreen = false; int selectorTimer = 0; -bool Gui::init(const char *FontPath) { +bool Gui::init(const std::vector &FontPaths) { // Initialize video mode videoSetMode(MODE_5_2D); videoSetModeSub(MODE_5_2D); @@ -74,7 +74,7 @@ bool Gui::init(const char *FontPath) { REG_BLDCNT_SUB = 1 << 11; // Load the default font - DefaultFont = std::make_unique(std::vector({"sd:/_nds/Universal-Updater/font.nftr", "fat:/_nds/Universal-Updater/font.nftr", "nitro:/graphics/font/default.nftr"})); + DefaultFont = std::make_unique(FontPaths); return true; } @@ -91,9 +91,8 @@ void Gui::DrawSprite(Spritesheet &sheet, size_t imgindex, int x, int y, float Sc sheet[imgindex].draw(x, y, 0x20, ScaleX, ScaleY); } -bool Gui::loadFont(Font &fnt, const char *Path) { - if(Path && access(Path, F_OK) == 0) // Only load if found. - fnt = Font(Path); +bool Gui::loadFont(Font &fnt, const std::vector &Paths) { + fnt = Font(Paths); return true; } @@ -105,8 +104,8 @@ bool Gui::loadSheet(const char *Path, Spritesheet &sheet) { return true; } -bool Gui::reinit(const char *FontPath) { - return Gui::init(FontPath); +bool Gui::reinit(const std::vector &FontPaths) { + return Gui::init(FontPaths); } void Gui::DrawStringCentered(int x, int y, float size, u8 color, const std::string &Text, int maxWidth, int maxHeight, Font *fnt, int flags) {