diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc index 8b05c64..827816c 100644 --- a/source/code/BlockGameSdl.inc +++ b/source/code/BlockGameSdl.inc @@ -71,10 +71,6 @@ public: sago::SagoTextField::Alignment::center, sago::SagoTextField::VerticalAlignment::center); } - void PrintIntRightAlignedBoard(int x, int y, int number) { - globalData.button_font.drawRight(globalData.screen, x+topx+60, y+topy+10, std::to_string(number)); - } - void SetTopXY(int tx, int ty) { topx = tx; topy = ty; diff --git a/source/code/DialogBox.cpp b/source/code/DialogBox.cpp index 4cc997d..fac7312 100644 --- a/source/code/DialogBox.cpp +++ b/source/code/DialogBox.cpp @@ -26,6 +26,15 @@ http://www.blockattack.net #include "common.h" #include "ReadKeyboard.h" +static void setButtonFont(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text){ + field.SetHolder(holder); + field.SetFont("freeserif"); + field.SetColor({255,255,255,255}); + field.SetFontSize(24); + field.SetOutline(1, {0,0,0,255}); + field.SetText(text); +} + static void NFont_Write(SDL_Renderer* target, int x, int y, const std::string& text) { globalData.standard_blue_font.draw(target, x, y, text); } @@ -83,6 +92,9 @@ DialogBox::DialogBox(int x, int y, const std::string& name, const std::string& h this->x = x; this->y = y; SetName(name); + setButtonFont(&globalData.spriteHolder->GetDataHolder(), headerLabel, header.c_str()); + setButtonFont(&globalData.spriteHolder->GetDataHolder(), enterLabel, _("Enter to accept")); + setButtonFont(&globalData.spriteHolder->GetDataHolder(), cancelLabel, _("Esc to cancel")); } @@ -99,9 +111,9 @@ void DialogBox::Draw(SDL_Renderer* target) { this->x = globalData.xsize/2-300; this->y = globalData.ysize/2-100; DrawRectYellow(target, x, y, 200, 600); - globalData.button_font.drawCenter(target, x+300, y+20, header); - globalData.button_font.drawCenter(target, x+150, y+140, _("Enter to accept")); - globalData.button_font.drawCenter(target, x+450, y+140, _("Esc to cancel")); + headerLabel.Draw(target, x+300, y+20, sago::SagoTextField::Alignment::center); + enterLabel.Draw(target, x+150, y+140, sago::SagoTextField::Alignment::center); + cancelLabel.Draw(target, x+450, y+140, sago::SagoTextField::Alignment::center); DrawRectWhite(target, x+26, y+64, 54, 600-2*26); NFont_Write(target, x+40, y+76,rk->GetString()); std::string strHolder = rk->GetString(); diff --git a/source/code/DialogBox.hpp b/source/code/DialogBox.hpp index 7f838b6..562f8ef 100644 --- a/source/code/DialogBox.hpp +++ b/source/code/DialogBox.hpp @@ -52,6 +52,9 @@ private: std::string header; bool updated = false; SDL_TextInput textInputScope; + sago::SagoTextField headerLabel; + sago::SagoTextField enterLabel; + sago::SagoTextField cancelLabel; }; #endif /* DIALOGBOX_HPP */ diff --git a/source/code/global.hpp b/source/code/global.hpp index 17f746a..f2128c5 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp @@ -58,7 +58,6 @@ struct GlobalData { sago::SagoSprite iLevelCheckBoxMarked; sago::SagoSprite iCheckBoxArea; FontWrapper standard_blue_font; - FontWrapper button_font; bool MusicEnabled; //true if background music is enabled bool SoundEnabled; //true if sound effects is enabled bool bFullscreen; //true if game is running fullscreen diff --git a/source/code/main.cpp b/source/code/main.cpp index 3119362..f0e1f62 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -182,12 +182,7 @@ static int InitImages(sago::SagoSpriteHolder& holder) { globalData.mouse = holder.GetSprite("mouse"); backBoard = holder.GetSprite("back_board"); - SDL_Color nf_button_color, nf_standard_blue_color, nf_standard_small_color; - memset(&nf_button_color,0,sizeof(SDL_Color)); - nf_button_color.b = 255; - nf_button_color.g = 255; - nf_button_color.r = 255; - nf_button_color.a = 255; + SDL_Color nf_standard_blue_color, nf_standard_small_color; nf_standard_blue_color.b = 255; nf_standard_blue_color.g = 0; nf_standard_blue_color.r = 0; @@ -196,7 +191,6 @@ static int InitImages(sago::SagoSpriteHolder& holder) { nf_standard_small_color.g = 0; nf_standard_small_color.r = 200; nf_standard_small_color.a = 255; - globalData.button_font.load(globalData.screen, holder.GetDataHolder().getFontPtr("freeserif", 24), nf_button_color); 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);