|
group2 0.1.0
CSE 125 Group 2
|
IScreen implementation for the pre-match lobby. More...
#include <Lobby.hpp>
Public Member Functions | |
| bool | init (NewRenderer *rendererPtr, SDL_Window *windowPtr, Client *clientPtr) |
| Bind renderer, window, and network client; register lobby callbacks. | |
| SDL_AppResult | event (SDL_Event *event) override |
| Handle an incoming SDL event. | |
| SDL_AppResult | iterate () override |
| Update the screen state and render the next frame. | |
| void | quit () override |
| Deregister all Client callbacks. | |
| bool | shouldStartMatch () const |
| True when a non-lobby MatchStatePacket has been received and is ready for handoff. | |
| std::optional< MatchStatePacket > | consumeStartMatchState () |
| Take ownership of the pending MatchStatePacket and clear internal countdown state. | |
| bool | consumeReturnToMenu () |
| True if the user has requested to return to the main menu, then clear that request. | |
| Public Member Functions inherited from IScreen | |
| virtual | ~IScreen ()=default |
| virtual void | shutdownAfterRenderer () |
| Perform cleanup that must happen after the App-owned renderer shuts down. | |
Private Member Functions | |
| bool | canHostStartMatch () const |
| True if the local client is host and all non-host players are ready. | |
| void | updateStartCountdown () |
| Advance the local countdown timer using SDL_GetTicksNS delta. | |
Private Attributes | |
| NewRenderer * | renderer = nullptr |
| Shared renderer; not owned. | |
| SDL_Window * | window = nullptr |
| Application window; not owned. | |
| Client * | client = nullptr |
| Network client; not owned. | |
| std::vector< LobbyPlayer > | players |
| Latest snapshot of connected players. | |
| ClientId | localClientId {-1} |
| This client's own ID, set by the server on join. | |
| std::optional< MatchStatePacket > | startMatchState |
| Set when the server signals a match start. | |
| bool | startCountdownActive = false |
| True while the pre-match countdown is ticking. | |
| float | startCountdownRemaining = 0.0f |
| Seconds remaining in the countdown. | |
| Uint64 | lastStartCountdownTickNs = 0 |
| SDL tick timestamp of the last countdown update (ns). | |
| bool | returnToMenu = false |
| Set to true when the user wants to return to the main menu. | |
IScreen implementation for the pre-match lobby.
Subscribes to lobby-state and match-state callbacks from Client, renders the player list via LobbyUI, and signals App when a match transition is ready.
|
private |
True if the local client is host and all non-host players are ready.
| bool Lobby::consumeReturnToMenu | ( | ) |
True if the user has requested to return to the main menu, then clear that request.
| std::optional< MatchStatePacket > Lobby::consumeStartMatchState | ( | ) |
Take ownership of the pending MatchStatePacket and clear internal countdown state.
|
overridevirtual |
| bool Lobby::init | ( | NewRenderer * | rendererPtr, |
| SDL_Window * | windowPtr, | ||
| Client * | clientPtr ) |
Bind renderer, window, and network client; register lobby callbacks.
|
overridevirtual |
Update the screen state and render the next frame.
Implements IScreen.
| bool Lobby::shouldStartMatch | ( | ) | const |
True when a non-lobby MatchStatePacket has been received and is ready for handoff.
|
private |
Advance the local countdown timer using SDL_GetTicksNS delta.
|
private |
Network client; not owned.
|
private |
SDL tick timestamp of the last countdown update (ns).
|
private |
This client's own ID, set by the server on join.
|
private |
Latest snapshot of connected players.
|
private |
Shared renderer; not owned.
|
private |
Set to true when the user wants to return to the main menu.
|
private |
True while the pre-match countdown is ticking.
|
private |
Seconds remaining in the countdown.
|
private |
Set when the server signals a match start.
|
private |
Application window; not owned.