Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
WinScreen Class Reference

Semi-transparent overlay shown when a team wins. More...

#include <WinScreen.hpp>

+ Inheritance diagram for WinScreen:
+ Collaboration diagram for WinScreen:

Public Member Functions

 WinScreen ()
 
 ~WinScreen () override=default
 
void reset ()
 
void setWinner (const std::string &team, Color color)
 Sets the winning team name and highlight color.
 
void setDuration (int seconds, int64_t ticks)
 Sets the win duration (server-authoritative, from gwt).
 
void draw (int scaledFontSize) const override
 Draws the widget.
 
bool handleInput () override
 Handles button input. Always returns true (overlay blocks all input).
 
bool quitRequested () const
 Returns true once the Quit button has been clicked (latched — stays true).
 
- Public Member Functions inherited from IWidget
virtual ~IWidget ()=default
 

Private Member Functions

void _rebuildPanel (int scaledFontSize) const
 

Static Private Member Functions

static std::string _formatDuration (unsigned int seconds)
 

Private Attributes

std::string _winnerTeam
 
Color _winnerColor = WHITE
 
int _durationSeconds = -1
 
int64_t _durationTicks = -1
 
bool _quitRequested = false
 
TooltipWidget _panel
 
ButtonWidget _quitBtn
 

Detailed Description

Semi-transparent overlay shown when a team wins.

Composed of a TooltipWidget (title + team name + duration) and a ButtonWidget (Quit). Both components are owned and driven internally. Call draw() every frame once the game has ended; poll quitRequested() to know when the player clicked Quit.

Usage: winScreen.setWinner(teamName, teamColor); winScreen.setDuration(durationSeconds, durationTicks); if (winScreen.handleInput()) { ... } // optional: blocks sibling input winScreen.draw(fontSize); if (winScreen.quitRequested()) closeWindow();

Definition at line 27 of file WinScreen.hpp.

Constructor & Destructor Documentation

◆ WinScreen()

◆ ~WinScreen()

WinScreen::~WinScreen ( )
overridedefault

Member Function Documentation

◆ _formatDuration()

std::string WinScreen::_formatDuration ( unsigned int  seconds)
staticprivate

Definition at line 50 of file WinScreen.cpp.

Referenced by _rebuildPanel().

+ Here is the caller graph for this function:

◆ _rebuildPanel()

void WinScreen::_rebuildPanel ( int  scaledFontSize) const
private

Definition at line 62 of file WinScreen.cpp.

References _durationSeconds, _durationTicks, _formatDuration(), _panel, _winnerColor, _winnerTeam, ACCENT, TooltipWidget::addColoredLine(), TooltipWidget::addLine(), TooltipWidget::clearLines(), I18n::get(), TITLE_COLOR, I18n::WIN_DURATION, I18n::WIN_DURATION_UNKNOWN, I18n::WIN_GAME_OVER, I18n::WIN_TEAM_WON, and I18n::WIN_TICKS.

Referenced by draw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ draw()

void WinScreen::draw ( int  scaledFontSize) const
overridevirtual

Draws the widget.

Parameters
scaledFontSizeBase font size for UI scaling.

Implements IWidget.

Definition at line 93 of file WinScreen.cpp.

References _panel, _quitBtn, _rebuildPanel(), BTN_H, BTN_MARGIN, BTN_W, ButtonWidget::draw(), TooltipWidget::draw(), I18n::get(), TooltipWidget::getLastBounds(), OVERLAY_COLOR, ButtonWidget::setLabel(), ButtonWidget::setPosition(), ButtonWidget::setSize(), and I18n::WIN_QUIT.

Referenced by RaylibRenderer::_render2D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleInput()

bool WinScreen::handleInput ( )
overridevirtual

Handles button input. Always returns true (overlay blocks all input).

Implements IWidget.

Definition at line 86 of file WinScreen.cpp.

References _quitBtn, _quitRequested, ButtonWidget::handleInput(), and ButtonWidget::wasClicked().

Referenced by RaylibRenderer::_render2D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quitRequested()

bool WinScreen::quitRequested ( ) const
inline

Returns true once the Quit button has been clicked (latched — stays true).

Definition at line 52 of file WinScreen.hpp.

References _quitRequested.

Referenced by RaylibRenderer::shouldClose().

+ Here is the caller graph for this function:

◆ reset()

void WinScreen::reset ( )
inline

Definition at line 33 of file WinScreen.hpp.

References _quitRequested.

Referenced by RaylibRenderer::init().

+ Here is the caller graph for this function:

◆ setDuration()

void WinScreen::setDuration ( int  seconds,
int64_t  ticks 
)

Sets the win duration (server-authoritative, from gwt).

Parameters
secondsTime the winner took to win, in seconds (-1 = not yet received).
ticksSame in game-time ticks.

Definition at line 44 of file WinScreen.cpp.

References _durationSeconds, and _durationTicks.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setWinner()

void WinScreen::setWinner ( const std::string &  team,
Color  color 
)

Sets the winning team name and highlight color.

Definition at line 38 of file WinScreen.cpp.

References _winnerColor, and _winnerTeam.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _durationSeconds

int WinScreen::_durationSeconds = -1
private

Definition at line 57 of file WinScreen.hpp.

Referenced by _rebuildPanel(), and setDuration().

◆ _durationTicks

int64_t WinScreen::_durationTicks = -1
private

Definition at line 58 of file WinScreen.hpp.

Referenced by _rebuildPanel(), and setDuration().

◆ _panel

TooltipWidget WinScreen::_panel
mutableprivate

Definition at line 62 of file WinScreen.hpp.

Referenced by _rebuildPanel(), draw(), and WinScreen().

◆ _quitBtn

ButtonWidget WinScreen::_quitBtn
mutableprivate

Definition at line 63 of file WinScreen.hpp.

Referenced by draw(), handleInput(), and WinScreen().

◆ _quitRequested

bool WinScreen::_quitRequested = false
private

Definition at line 60 of file WinScreen.hpp.

Referenced by handleInput(), quitRequested(), and reset().

◆ _winnerColor

Color WinScreen::_winnerColor = WHITE
private

Definition at line 56 of file WinScreen.hpp.

Referenced by _rebuildPanel(), and setWinner().

◆ _winnerTeam

std::string WinScreen::_winnerTeam
private

Definition at line 55 of file WinScreen.hpp.

Referenced by _rebuildPanel(), and setWinner().


The documentation for this class was generated from the following files: