Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions include/gui/GuiText.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class GuiText : public GuiElement {
//!\param t Text
//!\param s Font size
//!\param c Font color
GuiText(const char * t, int32_t s, const glm::vec4 & c);
GuiText(const char * t, int32_t s, const glm::vec4 & c, int32_t SSAA);
//!\overload
//!\param t Text
//!\param s Font size
//!\param c Font color
GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c);
GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c, int32_t SSAA);
//!\overload
//!\Assumes SetPresets() has been called to setup preferred text attributes
//!\param t Text
Expand All @@ -53,8 +53,11 @@ class GuiText : public GuiElement {
//!\param w Maximum width of texture image (for text wrapping)
//!\param wrap Wrapmode when w>0
//!\param a Text alignment
static void setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a);
static void setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a, int32_t SSAA);
static void setPresetFont(FreeTypeGX *font);
//!Sets Supersampling Anti-Aliasing
//!\param SSAA Valid values are: 1, 2, 4, 8, 16, 32
void setSSAA(int32_t SSAA);
//!Sets the font size
//!\param s Font size
void setFontSize(int32_t s);
Expand Down Expand Up @@ -118,7 +121,7 @@ class GuiText : public GuiElement {
static FreeTypeGX * presentFont;
static int32_t presetSize;
static int32_t presetMaxWidth;
static float presetInternalRenderingScale;
static int32_t presetSSAA;
static int32_t presetAlignment;
static GX2ColorF32 presetColor;

Expand Down Expand Up @@ -149,7 +152,7 @@ class GuiText : public GuiElement {
float blurGlowIntensity;
float blurAlpha;
glm::vec4 blurGlowColor;
float internalRenderingScale;
int32_t internalSSAA;
};

#endif
2 changes: 1 addition & 1 deletion source/gui/GuiSelectBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void GuiSelectBox::Init(std::map<std::string,std::string> values, int32_t valueI
valueButtons[i].valueButtonHighlightedImg = new GuiImage(valueHighlightedImageData);

valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale);
valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(),32,glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(),32,glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), 0);

valueButtons[i].valueButtonText->setMaxWidth(valueButtons[i].valueButtonImg->getWidth() * imgScale - 20.0f, GuiText::WRAP);
valueButtons[i].valueButtonText->setPosition(0, 0);
Expand Down
25 changes: 15 additions & 10 deletions source/gui/GuiText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

FreeTypeGX * GuiText::presentFont = NULL;
int32_t GuiText::presetSize = 28;
float GuiText::presetInternalRenderingScale = 2.0f; //Lets render the font at the doubled size. This make it even smoother!
int32_t GuiText::presetSSAA = 0;
int32_t GuiText::presetMaxWidth = 0xFFFF;
int32_t GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE;
GX2ColorF32 GuiText::presetColor = (GX2ColorF32) {
Expand Down Expand Up @@ -54,10 +54,10 @@ GuiText::GuiText() {
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
internalRenderingScale = presetInternalRenderingScale;
internalSSAA = presetSSAA;
}

GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c, int32_t SSAA) {
text = NULL;
size = s;
currentSize = size;
Expand All @@ -76,7 +76,7 @@ GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
internalRenderingScale = presetInternalRenderingScale;
internalSSAA = SSAA;

if(t) {
text = FreeTypeGX::charToWideChar(t);
Expand All @@ -87,7 +87,7 @@ GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
}
}

GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c) {
GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c, int32_t SSAA) {
text = NULL;
size = s;
currentSize = size;
Expand All @@ -106,7 +106,7 @@ GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c) {
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
internalRenderingScale = presetInternalRenderingScale;
internalSSAA = SSAA;

if(t) {
text = new (std::nothrow) wchar_t[wcslen(t)+1];
Expand Down Expand Up @@ -141,7 +141,7 @@ GuiText::GuiText(const char * t) {
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
internalRenderingScale = presetInternalRenderingScale;
internalSSAA = presetSSAA;

if(t) {
text = FreeTypeGX::charToWideChar(t);
Expand Down Expand Up @@ -233,19 +233,24 @@ void GuiText::clearDynamicText() {
textDynWidth.clear();
}

void GuiText::setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a) {
void GuiText::setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a, int32_t SSAA) {
presetSize = sz;
presetColor = (GX2ColorF32) {
(float)c.r / 255.0f, (float)c.g / 255.0f, (float)c.b / 255.0f, (float)c.a / 255.0f
};
presetMaxWidth = w;
presetAlignment = a;
presetSSAA = SSAA;
}

void GuiText::setPresetFont(FreeTypeGX *f) {
presentFont = f;
}

void GuiText::setSSAA(int32_t SSAA) {
internalSSAA = SSAA;
}

void GuiText::setFontSize(int32_t s) {
size = s;
}
Expand Down Expand Up @@ -491,10 +496,10 @@ void GuiText::draw(CVideo *pVideo) {
color[3] = getAlpha();
blurGlowColor[3] = blurAlpha * getAlpha();

float finalRenderingScale = 2.0f * internalRenderingScale;
int32_t finalRenderingScale = internalSSAA == 0 ? 1 : internalSSAA << 1;

int32_t newSize = size * getScale() * finalRenderingScale;
int32_t normal_size = size * getScale();
int32_t newSize = normalSize * finalRenderingScale;

if(newSize != currentSize) {
currentSize = normal_size;
Expand Down