From ff27eafccffc7137dec13c9fa1f00d211725fa46 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 1 Oct 2015 13:09:27 +0200 Subject: [PATCH] WORKING number frame --- include/GUI/NumberFrame.h | 60 +++++++-------------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/include/GUI/NumberFrame.h b/include/GUI/NumberFrame.h index dae825d..d1717b1 100644 --- a/include/GUI/NumberFrame.h +++ b/include/GUI/NumberFrame.h @@ -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; }