WORKING number frame
This commit is contained in:
+10
-50
@@ -16,16 +16,16 @@ public:
|
||||
NumberFrame(Frame* parent, std::string name)
|
||||
: Frame(parent, name)
|
||||
{
|
||||
m_NumberTextures[0] = "Textures/GUI/Numbers/N0.png";
|
||||
m_NumberTextures[1] = "Textures/GUI/Numbers/N1.png";
|
||||
m_NumberTextures[2] = "Textures/GUI/Numbers/N2.png";
|
||||
m_NumberTextures[3] = "Textures/GUI/Numbers/N3.png";
|
||||
m_NumberTextures[4] = "Textures/GUI/Numbers/N4.png";
|
||||
m_NumberTextures[5] = "Textures/GUI/Numbers/N5.png";
|
||||
m_NumberTextures[6] = "Textures/GUI/Numbers/N6.png";
|
||||
m_NumberTextures[7] = "Textures/GUI/Numbers/N7.png";
|
||||
m_NumberTextures[8] = "Textures/GUI/Numbers/N8.png";
|
||||
m_NumberTextures[9] = "Textures/GUI/Numbers/N9.png";
|
||||
m_CharacterTextures['0'] = "Textures/GUI/Numbers/N0.png";
|
||||
m_CharacterTextures['1'] = "Textures/GUI/Numbers/N1.png";
|
||||
m_CharacterTextures['2'] = "Textures/GUI/Numbers/N2.png";
|
||||
m_CharacterTextures['3'] = "Textures/GUI/Numbers/N3.png";
|
||||
m_CharacterTextures['4'] = "Textures/GUI/Numbers/N4.png";
|
||||
m_CharacterTextures['5'] = "Textures/GUI/Numbers/N5.png";
|
||||
m_CharacterTextures['6'] = "Textures/GUI/Numbers/N6.png";
|
||||
m_CharacterTextures['7'] = "Textures/GUI/Numbers/N7.png";
|
||||
m_CharacterTextures['8'] = "Textures/GUI/Numbers/N8.png";
|
||||
m_CharacterTextures['9'] = "Textures/GUI/Numbers/N9.png";
|
||||
|
||||
// Create number frame if missing
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
@@ -61,12 +61,6 @@ public:
|
||||
|
||||
std::string digits = std::to_string(number);
|
||||
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
|
||||
std::string digits = std::to_string(number);
|
||||
|
||||
|
||||
int i = 0;
|
||||
for (char& c : digits) {
|
||||
// Create number frame if missing
|
||||
@@ -92,40 +86,6 @@ public:
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
do {
|
||||
// Create number frame if missing
|
||||
if (m_NumberFrames.size() <= n) {
|
||||
auto frame = new GUI::TextureFrame(this, "NumberFrameDigit");
|
||||
frame->DisableScissor();
|
||||
m_NumberFrames.push_back(frame);
|
||||
}
|
||||
|
||||
int digit = number % 10;
|
||||
|
||||
// Update value
|
||||
m_NumberFrames[n]->SetTexture(m_NumberTextures[digit]);
|
||||
Width += m_NumberFrames[n]->Width;
|
||||
if (Height < m_NumberFrames[n]->Height) {
|
||||
Height = m_NumberFrames[n]->Height;
|
||||
}
|
||||
// Position frame based on alignment
|
||||
if (n > 0) {
|
||||
if (m_LeftAligned) {
|
||||
m_NumberFrames[n]->SetLeft(m_NumberFrames[n - 1]->Right());
|
||||
} else {
|
||||
m_NumberFrames[n]->SetRight(m_NumberFrames[n - 1]->Left());
|
||||
}
|
||||
}
|
||||
|
||||
ss << digit;
|
||||
|
||||
number /= 10;
|
||||
n++;
|
||||
} while (number > 0);
|
||||
|
||||
LOG_DEBUG("Number: %s", ss.str().c_str());
|
||||
}
|
||||
|
||||
void SetLeftAlign() { m_LeftAligned = true; }
|
||||
|
||||
Reference in New Issue
Block a user