diff --git a/gui.cpp b/gui.cpp index ac67532..6116c06 100644 --- a/gui.cpp +++ b/gui.cpp @@ -190,7 +190,7 @@ Result Gui::reinit(CFG_Region fontRegion) { C2D_Font fnt: (Optional) The wanted C2D_Font. Is nullptr by default. int flags: (Optional) C2D text flags to use. */ -void Gui::DrawStringCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt, int flags) { +void Gui::DrawStringCentered(float x, float y, float size, u32 color, const std::string &Text, int maxWidth, int maxHeight, C2D_Font fnt, int flags) { Gui::DrawString(x +(currentScreen ? 200 : 160), y, size, color, Text, maxWidth, maxHeight, fnt, flags | C2D_AlignCenter); } @@ -207,7 +207,7 @@ void Gui::DrawStringCentered(float x, float y, float size, u32 color, std::strin C2D_Font fnt: (Optional) The wanted C2D_Font. Is nullptr by default. int flags: (Optional) C2D text flags to use. */ -void Gui::DrawString(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt, int flags) { +void Gui::DrawString(float x, float y, float size, u32 color, const std::string &Text, int maxWidth, int maxHeight, C2D_Font fnt, int flags) { C2D_Text c2d_text; if (fnt) C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); @@ -259,7 +259,7 @@ void Gui::DrawString(float x, float y, float size, u32 color, std::string Text, std::string Text: The Text. C2D_Font fnt: (Optional) The wanted C2D_Font. Is nullptr by default. */ -float Gui::GetStringWidth(float size, std::string Text, C2D_Font fnt) { +float Gui::GetStringWidth(float size, const std::string &Text, C2D_Font fnt) { float width = 0; if (fnt) GetStringSize(size, &width, NULL, Text, fnt); @@ -277,7 +277,7 @@ float Gui::GetStringWidth(float size, std::string Text, C2D_Font fnt) { std::string Text: The Text. C2D_Font fnt: (Optional) The wanted C2D_Font. Is nullptr by default. */ -void Gui::GetStringSize(float size, float *width, float *height, std::string Text, C2D_Font fnt) { +void Gui::GetStringSize(float size, float *width, float *height, const std::string &Text, C2D_Font fnt) { C2D_Text c2d_text; if (fnt) C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); @@ -294,11 +294,11 @@ void Gui::GetStringSize(float size, float *width, float *height, std::string Tex std::string Text: The Text. C2D_Font fnt: (Optional) The wanted C2D_Font. Is nullptr by default. */ -float Gui::GetStringHeight(float size, std::string Text, C2D_Font fnt) { +float Gui::GetStringHeight(float size, const std::string &Text, C2D_Font fnt) { float height = 0; - if (fnt) GetStringSize(size, NULL, &height, Text.c_str(), fnt); - else GetStringSize(size, NULL, &height, Text.c_str()); + if (fnt) GetStringSize(size, NULL, &height, Text, fnt); + else GetStringSize(size, NULL, &height, Text); return height; } diff --git a/gui.hpp b/gui.hpp index 020be54..b97d0e3 100644 --- a/gui.hpp +++ b/gui.hpp @@ -121,7 +121,7 @@ namespace Gui { fnt: The Font which should be used. Uses SystemFont by default. (Optional!) int flags: C2D text flags to use. (Optional!) */ - void DrawStringCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr, int flags = 0); + void DrawStringCentered(float x, float y, float size, u32 color, const std::string &Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr, int flags = 0); /* Draws a String. @@ -136,7 +136,7 @@ namespace Gui { fnt: The Font which should be used. Uses SystemFont by default. (Optional!) flags: C2D text flags to use. */ - void DrawString(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr, int flags = 0); + void DrawString(float x, float y, float size, u32 color, const std::string &Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr, int flags = 0); /* Get the width of a String. @@ -145,7 +145,7 @@ namespace Gui { Text: The Text where the width should be getted from. fnt: The Font which should be used. Uses SystemFont by default. (Optional!) */ - float GetStringWidth(float size, std::string Text, C2D_Font fnt = nullptr); + float GetStringWidth(float size, const std::string &Text, C2D_Font fnt = nullptr); /* Get the size of a String. @@ -156,7 +156,7 @@ namespace Gui { Text: The Text where the size should be getted from. fnt: The Font which should be used. Uses SystemFont by default. (Optional!) */ - void GetStringSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr); + void GetStringSize(float size, float *width, float *height, const std::string &Text, C2D_Font fnt = nullptr); /* Get the height of a String. @@ -165,7 +165,7 @@ namespace Gui { Text: The Text where the height should be getted from. fnt: The Font which should be used. Uses SystemFont by default. (Optional!) */ - float GetStringHeight(float size, std::string Text, C2D_Font fnt = nullptr); + float GetStringHeight(float size, const std::string &Text, C2D_Font fnt = nullptr); /* Draw a Rectangle.