changed display write method
This commit is contained in:
@@ -31,10 +31,6 @@ template<int DigitCount>
|
|||||||
void Display<DigitCount>::write_score(int score)
|
void Display<DigitCount>::write_score(int score)
|
||||||
{
|
{
|
||||||
auto score_string = std::to_string(score);
|
auto score_string = std::to_string(score);
|
||||||
if (score_string.length() > DigitCount)
|
|
||||||
{
|
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto score_c_string = this->fit_string(score_string).c_str();
|
auto score_c_string = this->fit_string(score_string).c_str();
|
||||||
|
|
||||||
@@ -44,15 +40,16 @@ void Display<DigitCount>::write_score(int score)
|
|||||||
template<int DigitCount>
|
template<int DigitCount>
|
||||||
std::string Display<DigitCount>::fit_string(std::string& score_string)
|
std::string Display<DigitCount>::fit_string(std::string& score_string)
|
||||||
{
|
{
|
||||||
auto score_length = score_string.length();
|
auto score_length = score_string.length();
|
||||||
for (int i = 0; i < DigitCount; i++)
|
|
||||||
{
|
|
||||||
score_string = " " + score_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
score_length = score_string.length();
|
|
||||||
|
|
||||||
|
if (score_length > DigitCount)
|
||||||
|
{
|
||||||
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
|
||||||
return score_string.substr(score_length-DigitCount, score_length);
|
return score_string.substr(score_length-DigitCount, score_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
score_string.insert(0, DigitCount-score_length, ' ');
|
||||||
|
return score_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int DigitCount>
|
template<int DigitCount>
|
||||||
|
|||||||
Reference in New Issue
Block a user