group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Home Class Reference

IScreen implementation for the main menu; hosts the server join form. More...

#include <Home.hpp>

Inheritance diagram for Home:
[legend]
Collaboration diagram for Home:
[legend]

Public Member Functions

bool init (NewRenderer *rendererPtr, SDL_Window *windowPtr)
 Bind renderer and window; must be called before iterate().
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
 Perform any necessary cleanup before the screen is destroyed.
std::optional< JoinRequestconsumeJoinRequest ()
 Take the pending join request set when the user clicks "Join", clearing it.
void setJoinError (const std::string &error)
 Display an error string on the join form (e.g. from a failed connection attempt).
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 Attributes

NewRendererrenderer = nullptr
 Renderer; not owned.
SDL_Window * window = nullptr
 Application window; not owned.
JoinMenuState joinMenuState
 Mutable state backing the join form widgets.
std::optional< JoinRequestpendingJoinRequest
 Set when the user clicks "Join", cleared on App transition to Lobby.
std::string joinError
 Error message shown on the join form; empty when no error.

Detailed Description

IScreen implementation for the main menu; hosts the server join form.

Member Function Documentation

◆ consumeJoinRequest()

std::optional< JoinRequest > Home::consumeJoinRequest ( )

Take the pending join request set when the user clicks "Join", clearing it.

Returns
The request, or nullopt if none is pending.

◆ event()

SDL_AppResult Home::event ( SDL_Event * event)
overridevirtual

Handle an incoming SDL event.

Parameters
eventThe SDL event to process.
Returns
SDL_APP_CONTINUE to keep running, SDL_APP_FAILURE to exit.

Implements IScreen.

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

◆ init()

bool Home::init ( NewRenderer * rendererPtr,
SDL_Window * windowPtr )

Bind renderer and window; must be called before iterate().

Returns
False if either pointer is null.

◆ iterate()

SDL_AppResult Home::iterate ( )
overridevirtual

Update the screen state and render the next frame.

Returns
SDL_APP_CONTINUE to keep running, SDL_APP_FAILURE to exit.

Implements IScreen.

Here is the call graph for this function:

◆ quit()

void Home::quit ( )
overridevirtual

Perform any necessary cleanup before the screen is destroyed.

Implements IScreen.

◆ setJoinError()

void Home::setJoinError ( const std::string & error)

Display an error string on the join form (e.g. from a failed connection attempt).

Member Data Documentation

◆ joinError

std::string Home::joinError
private

Error message shown on the join form; empty when no error.

◆ joinMenuState

JoinMenuState Home::joinMenuState
private

Mutable state backing the join form widgets.

◆ pendingJoinRequest

std::optional<JoinRequest> Home::pendingJoinRequest
private

Set when the user clicks "Join", cleared on App transition to Lobby.

◆ renderer

NewRenderer* Home::renderer = nullptr
private

Renderer; not owned.

◆ window

SDL_Window* Home::window = nullptr
private

Application window; not owned.


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