diff --git a/source/code/main.cpp b/source/code/main.cpp index b6b57b5..8ebba82 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -182,17 +182,12 @@ static int InitImages(sago::SagoSpriteHolder& holder) { globalData.mouse = holder.GetSprite("mouse"); backBoard = holder.GetSprite("back_board"); - SDL_Color nf_standard_blue_color, nf_standard_small_color; + SDL_Color nf_standard_blue_color; nf_standard_blue_color.b = 255; nf_standard_blue_color.g = 0; nf_standard_blue_color.r = 0; nf_standard_blue_color.a = 255; - nf_standard_small_color.b = 0; - nf_standard_small_color.g = 0; - nf_standard_small_color.r = 200; - nf_standard_small_color.a = 255; globalData.standard_blue_font.load(globalData.screen, holder.GetDataHolder().getFontPtr("freeserif", 30), nf_standard_blue_color); - nf_standard_small_font.load(globalData.screen, holder.GetDataHolder().getFontPtr("freeserif", 16), nf_standard_small_color); //Loads the sound if sound present if (!globalData.NoSound) { @@ -387,6 +382,24 @@ void OpenScoresDisplay() { RunGameState(d); } + +static sago::SagoTextField* getSmallInt(size_t number) { + static std::vector > smallFontCache; + if (smallFontCache.size() < number+1) { + smallFontCache.resize(number+1); + } + if (!smallFontCache[number]) { + std::shared_ptr newNumber = std::make_shared(); + newNumber->SetHolder(&globalData.spriteHolder->GetDataHolder()); + newNumber->SetFont("freeserif"); + newNumber->SetFontSize(16); + newNumber->SetColor({255,0,0,255}); + newNumber->SetText(std::to_string(number).c_str()); + smallFontCache[number] = newNumber; + } + return smallFontCache[number].get(); +} + //Draws the balls and explosions static void DrawBalls() { for (size_t i = 0; i< theBallManager.ballArray.size(); i++) { @@ -405,7 +418,8 @@ static void DrawBalls() { int y = globalData.theTextManager.textArray[i].getY()-12; DrawIMG(iChainFrame,globalData.screen,x,y); - nf_standard_small_font.draw(globalData.screen, x+12,y+7, NFont::CENTER, "%s", globalData.theTextManager.textArray[i].getText()); + getSmallInt(std::stoi(globalData.theTextManager.textArray[i].getText()))->Draw(globalData.screen, x+12, y+7, + sago::SagoTextField::Alignment::center); } } } //DrawBalls diff --git a/source/code/mainVars.inc b/source/code/mainVars.inc index 5f5e566..50fe9f9 100644 --- a/source/code/mainVars.inc +++ b/source/code/mainVars.inc @@ -95,8 +95,6 @@ static sago::SagoSprite bExit; const int bExitSize = 100; //height and width of the exit button const int bExitOffset = 140; //pixels from the buttom right corner to the top left of the exit button -static NFont nf_standard_small_font; - static sago::MusicHandler bgMusic; //backgroundMusic static sago::MusicHandler highbeatMusic; //Background music with higher beat static sago::SoundHandler boing; //boing sound when clearing