group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Lobby.hpp
Go to the documentation of this file.
1
3
4#pragma once
5#include "IScreen.hpp"
6#include "network/Client.hpp"
9
10#include <optional>
11#include <vector>
12
17class Lobby : public IScreen
18{
19public:
22 bool init(NewRenderer* rendererPtr, SDL_Window* windowPtr, Client* clientPtr);
23
24 SDL_AppResult event(SDL_Event* event) override;
25 SDL_AppResult iterate() override;
26
28 void quit() override;
29
31 bool shouldStartMatch() const;
32
35 std::optional<MatchStatePacket> consumeStartMatchState();
36
37 bool consumeReturnToMenu();
38
39private:
41 bool canHostStartMatch() const;
42
45
46 NewRenderer* renderer = nullptr;
47 SDL_Window* window = nullptr;
48 Client* client = nullptr;
49 std::vector<LobbyPlayer> players;
51 std::optional<MatchStatePacket> startMatchState;
52 bool startCountdownActive = false;
55 bool returnToMenu = false;
56};
TCP client for connecting to the game server.
Abstract interface for top-level application screens (lobby, in-game).
Shared lobby data types exchanged between server and clients.
Work-in-progress SDL3 GPU renderer.
TCP stream client — sends input to the server and receives state updates.
Definition Client.hpp:60
Interface implemented by each full-screen mode (Lobby, Game).
Definition IScreen.hpp:12
IScreen implementation for the pre-match lobby.
Definition Lobby.hpp:18
std::optional< MatchStatePacket > startMatchState
Set when the server signals a match start.
Definition Lobby.hpp:51
bool canHostStartMatch() const
True if the local client is host and all non-host players are ready.
Definition Lobby.cpp:176
bool startCountdownActive
True while the pre-match countdown is ticking.
Definition Lobby.hpp:52
void updateStartCountdown()
Advance the local countdown timer using SDL_GetTicksNS delta.
Definition Lobby.cpp:191
float startCountdownRemaining
Seconds remaining in the countdown.
Definition Lobby.hpp:53
void quit() override
Deregister all Client callbacks.
Definition Lobby.cpp:152
bool init(NewRenderer *rendererPtr, SDL_Window *windowPtr, Client *clientPtr)
Bind renderer, window, and network client; register lobby callbacks.
Definition Lobby.cpp:15
SDL_Window * window
Application window; not owned.
Definition Lobby.hpp:47
bool returnToMenu
Set to true when the user wants to return to the main menu.
Definition Lobby.hpp:55
std::optional< MatchStatePacket > consumeStartMatchState()
Take ownership of the pending MatchStatePacket and clear internal countdown state.
Definition Lobby.cpp:166
SDL_AppResult iterate() override
Update the screen state and render the next frame.
Definition Lobby.cpp:110
bool consumeReturnToMenu()
True if the user has requested to return to the main menu, then clear that request.
Definition Lobby.cpp:211
Client * client
Network client; not owned.
Definition Lobby.hpp:48
SDL_AppResult event(SDL_Event *event) override
Handle an incoming SDL event.
Definition Lobby.cpp:102
std::vector< LobbyPlayer > players
Latest snapshot of connected players.
Definition Lobby.hpp:49
NewRenderer * renderer
Shared renderer; not owned.
Definition Lobby.hpp:46
ClientId localClientId
This client's own ID, set by the server on join.
Definition Lobby.hpp:50
Uint64 lastStartCountdownTickNs
SDL tick timestamp of the last countdown update (ns).
Definition Lobby.hpp:54
bool shouldStartMatch() const
True when a non-lobby MatchStatePacket has been received and is ready for handoff.
Definition Lobby.cpp:161
Graphics-team's work-in-progress SDL3 GPU renderer.
Definition NewRenderer.hpp:27
Associates an entity with a connected network client.
Definition ClientId.hpp:10