|
group2 0.1.0
CSE 125 Group 2
|
IScreen implementation for the pre-match lobby. More...
#include <Lobby.hpp>
Public Member Functions | |
| bool | init (AppContext &ctx) |
| 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 requested returning to the main menu, then clear that request. | |
| bool | consumeReturnToHostConfig () |
| True if the host requested HostConfig without shutting down the session, then clear that request. | |
| bool | consumeServerShutdownNotice () |
| True if returning home because the server connection closed, then clear that reason. | |
| bool | consumeExitRequest () |
| True if the user requested closing the application, 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 when at least one non-host is connected and all connected 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. | |
| UserSettings * | settings = nullptr |
| Live user settings; not owned. | |
| std::string_view | settingsPath |
| Save path for user settings. | |
| SystemMenuOverlay | systemMenu_ |
| Shared Escape menu for front-end screens. | |
| 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< MatchConfig > | matchConfig |
| Latest match settings received from the server. | |
| 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. | |
| bool | returnToHostConfig = false |
| Set when the host wants to return to HostConfig. | |
| bool | serverShutdownNotice = false |
| Set when the server connection closed while in the lobby. | |
| bool | isHosting = false |
| True if App owns a running hosted server. | |
| std::string | serverName |
| Display name for the connected server. | |
| std::string | hostLanIp = "127.0.0.1" |
| Address shown in the hosting banner. | |
| uint16_t | hostPort = 0 |
| Server port shown in the hosting banner. | |
| bool | exitRequested = false |
| Set when the user confirms "Exit to Desktop". | |
| bool | hostAddressesVisible = false |
| Local UI flag: show listen/local addresses while hosting. | |
Additional Inherited Members | |
| Static Protected Member Functions inherited from IScreen | |
| static SDL_AppResult | processCommonImguiEvent (SDL_Event *event) |
| Forward event to ImGui and detect SDL_EVENT_QUIT. | |
| static bool | handleSystemMenuEvent (SDL_Event *event, SystemMenuOverlay &menu, UserSettings *settings) |
| Handle Escape-toggle of a SystemMenuOverlay and forward consumed events. | |
| static void | beginMenuFrame (NewRenderer *renderer) |
| Start a new ImGui frame and paint the shared menu background. | |
| static void | presentMenuFrame (NewRenderer &renderer) |
| Render the ImGui draw data and present a default-camera frame. | |
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 when at least one non-host is connected and all connected non-host players are ready.
| bool Lobby::consumeExitRequest | ( | ) |
True if the user requested closing the application, then clear that request.
| bool Lobby::consumeReturnToHostConfig | ( | ) |
True if the host requested HostConfig without shutting down the session, then clear that request.
| bool Lobby::consumeReturnToMenu | ( | ) |
True if the user requested returning to the main menu, then clear that request.
| bool Lobby::consumeServerShutdownNotice | ( | ) |
True if returning home because the server connection closed, then clear that reason.
| std::optional< MatchStatePacket > Lobby::consumeStartMatchState | ( | ) |
Take ownership of the pending MatchStatePacket and clear internal countdown state.
|
overridevirtual |
| bool Lobby::init | ( | AppContext & | ctx | ) |
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 |
Set when the user confirms "Exit to Desktop".
|
private |
Local UI flag: show listen/local addresses while hosting.
|
private |
Address shown in the hosting banner.
|
private |
Server port shown in the hosting banner.
|
private |
True if App owns a running hosted server.
|
private |
SDL tick timestamp of the last countdown update (ns).
|
private |
This client's own ID, set by the server on join.
|
private |
Latest match settings received from the server.
|
private |
Latest snapshot of connected players.
|
private |
Shared renderer; not owned.
|
private |
Set when the host wants to return to HostConfig.
|
private |
Set to true when the user wants to return to the main menu.
|
private |
Display name for the connected server.
|
private |
Set when the server connection closed while in the lobby.
|
private |
Live user settings; not owned.
|
private |
Save path for user settings.
|
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 |
Shared Escape menu for front-end screens.
|
private |
Application window; not owned.