Fixed UIText class for non-uniform scale

This commit is contained in:
2021-07-29 08:21:45 -04:00
parent 31e16585d1
commit 363f28cb9c
6 changed files with 35 additions and 9 deletions

View File

@ -31,7 +31,7 @@ UIText::~UIText()
{
}
void UIText::ParseString(std::string inputText, int x, int y, int scale, std::string tag)
void UIText::ParseString(std::string inputText, int x, int y, int letterScale, std::string tag)
{
//Parse input text into an array of char
int posX = x;
@ -64,18 +64,18 @@ void UIText::ParseString(std::string inputText, int x, int y, int scale, std::st
posX = x;
posY += letterHeight;
}
UIText::AddLetter(posX, posY, current, tag);
UIText::AddLetter(posX, posY, current, tag, letterScale);
current = inputText[i];
} while ((strcmp(&current,"\0"))!=0);
}
void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag)
void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale)
{
auto& letter(manager.addEntity());
letter.addComponent<TransformComponent>(xpos*scale, ypos*scale, letterWidth, letterHeight, 1);
letter.addComponent<TransformComponent>(xpos*lttrScale, ypos*lttrScale, letterWidth, letterHeight, 1);
// printf("Scale: %d\n",scale);
letter.addComponent<SpriteComponent>("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, scale);
letter.addComponent<SpriteComponent>("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, lttrScale);
letter.setTag(tag);
letter.addGroup(Game::groupUI_Layer1);
}