mirror of
				https://github.com/lov3b/Pong.git
				synced 2025-11-03 23:00:19 +01:00 
			
		
		
		
	Larger font on countdown
This commit is contained in:
		@@ -17,6 +17,12 @@ int_least64_t getCurrentEpochTimeMillis() {
 | 
				
			|||||||
OptionScreen::OptionScreen(const std::string &text, SDL_Point *screenSize, int seconds) : TextScreen(text, screenSize,
 | 
					OptionScreen::OptionScreen(const std::string &text, SDL_Point *screenSize, int seconds) : TextScreen(text, screenSize,
 | 
				
			||||||
                                                                                                     std::nullopt),
 | 
					                                                                                                     std::nullopt),
 | 
				
			||||||
                                                                                          stepsToDo(seconds) {
 | 
					                                                                                          stepsToDo(seconds) {
 | 
				
			||||||
 | 
					    secondaryFont = TTF_OpenFont(getDefaultFontPath(), 100);
 | 
				
			||||||
 | 
					    if (secondaryFont == nullptr) {
 | 
				
			||||||
 | 
					        std::cerr << "Failed to load secondary font: " << TTF_GetError() << std::endl;
 | 
				
			||||||
 | 
					        exit(-1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void OptionScreen::update() {
 | 
					void OptionScreen::update() {
 | 
				
			||||||
@@ -30,6 +36,7 @@ void OptionScreen::update() {
 | 
				
			|||||||
            stepsDone++;
 | 
					            stepsDone++;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            isDone_ = true;
 | 
					            isDone_ = true;
 | 
				
			||||||
 | 
					            std::swap(font, secondaryFont);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,4 +48,5 @@ void OptionScreen::startCountDown() {
 | 
				
			|||||||
    nextMsEpoch = epochMs;
 | 
					    nextMsEpoch = epochMs;
 | 
				
			||||||
    hasStartedCounting_ = true;
 | 
					    hasStartedCounting_ = true;
 | 
				
			||||||
    stepsDone = 0;
 | 
					    stepsDone = 0;
 | 
				
			||||||
 | 
					    std::swap(font, secondaryFont);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -13,6 +13,7 @@ private:
 | 
				
			|||||||
    int stepsToDo, stepsDone = 0;
 | 
					    int stepsToDo, stepsDone = 0;
 | 
				
			||||||
    bool isDone_ = false;
 | 
					    bool isDone_ = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TTF_Font *secondaryFont;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    [[nodiscard]] const bool &isDone() const {
 | 
					    [[nodiscard]] const bool &isDone() const {
 | 
				
			||||||
        return isDone_;
 | 
					        return isDone_;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,6 @@ class TextScreen {
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
    std::vector<SDL_Surface *> surfaces;
 | 
					    std::vector<SDL_Surface *> surfaces;
 | 
				
			||||||
    std::vector<SDL_Surface *> shadowSurfaces;
 | 
					    std::vector<SDL_Surface *> shadowSurfaces;
 | 
				
			||||||
    TTF_Font *font;
 | 
					 | 
				
			||||||
    SDL_Point *screenSize;
 | 
					    SDL_Point *screenSize;
 | 
				
			||||||
    std::optional<SDL_Point> basePosition;
 | 
					    std::optional<SDL_Point> basePosition;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,6 +31,7 @@ private:
 | 
				
			|||||||
    const int shadowOffset = 3;
 | 
					    const int shadowOffset = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
 | 
					    TTF_Font *font;
 | 
				
			||||||
    std::vector<std::string> lines;
 | 
					    std::vector<std::string> lines;
 | 
				
			||||||
    bool hasUpdated;
 | 
					    bool hasUpdated;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user