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

IScreen implementation for local server launch settings. More...

#include <HostConfig.hpp>

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

Public Member Functions

bool init (AppContext &ctx)
 Bind App-owned renderer, client, hosted-server, and draft config state.
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
 No-op screen shutdown hook; App owns all borrowed services.
bool consumeLaunchRequest ()
 True if the user requested server launch, then clear that request.
bool consumeShutdownRequest ()
 True if the user requested hosted-server shutdown, then clear that request.
bool consumeGoToLobbyRequest ()
 True if the user requested entering the hosted lobby, then clear that request.
bool consumeBackToMainMenuRequest ()
 True if the user requested returning to the main menu, then clear that request.
bool consumeExitRequest ()
 True if the user requested closing the application, then clear that request.
HostConfigState draftConfig () const
 Current host-screen draft settings.
void setLaunchError (const std::string &error)
 Display a launch or connection error on the host form.
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 Types

enum class  PendingConfirmAction { None , DiscardMatchChanges , ShutdownServer }

Private Member Functions

bool canManageCurrentServer () const
 True if the client is connected and is the current lobby host.
bool hasUnsavedServerChanges () const
 True if the current draft differs from the last settings sent to or received from the server.
bool updateServerSettings ()
 Send the current host-managed settings to the hosted server.
void requestDiscardMatchChangesConfirm ()
 Ask the host whether to discard unsaved match setting changes before leaving this screen.
void requestShutdownConfirm ()
 Ask the host to confirm server shutdown.

Private Attributes

NewRendererrenderer = nullptr
 Renderer; not owned.
SDL_Window * window = nullptr
 Application window; not owned.
Clientclient = nullptr
 Network client owned by App; not owned.
HostedServerhostedServer = nullptr
 Hosted server owned by App; not owned.
HostConfigStatedraft = nullptr
 Persistent draft state owned by App; not owned.
UserSettingssettings = 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::string lastError
 Error message shown on the host form; empty when no error.
std::optional< MatchConfiglastSyncedMatchConfig
 Last match config acknowledged locally as server state.
std::optional< DiscoverySettingslastSyncedDiscoverySettings
 Last discovery settings acknowledged locally.
ConfirmModal confirm_
 Reusable confirmation modal for discarding unsaved changes.
PendingConfirmAction pendingConfirmAction = PendingConfirmAction::None
 Action to run after modal confirm.
bool pendingLaunch = false
 Set when the user clicks "Launch", cleared by App.
bool pendingShutdown = false
 Set when the user clicks "Shutdown", cleared by App.
bool pendingGoToLobby = false
 Set when the user clicks "Go to Lobby", cleared by App.
bool pendingBackToMainMenu = false
 Set when the user clicks "Back to Main Menu", cleared by App.
bool pendingExitRequest = false
 Set when the user confirms "Exit to Desktop", cleared by App.

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.

Detailed Description

IScreen implementation for local server launch settings.

Member Enumeration Documentation

◆ PendingConfirmAction

enum class HostConfig::PendingConfirmAction
strongprivate
Enumerator
None 
DiscardMatchChanges 
ShutdownServer 

Member Function Documentation

◆ canManageCurrentServer()

bool HostConfig::canManageCurrentServer ( ) const
private

True if the client is connected and is the current lobby host.

Here is the caller graph for this function:

◆ consumeBackToMainMenuRequest()

bool HostConfig::consumeBackToMainMenuRequest ( )

True if the user requested returning to the main menu, then clear that request.

◆ consumeExitRequest()

bool HostConfig::consumeExitRequest ( )

True if the user requested closing the application, then clear that request.

◆ consumeGoToLobbyRequest()

bool HostConfig::consumeGoToLobbyRequest ( )

True if the user requested entering the hosted lobby, then clear that request.

◆ consumeLaunchRequest()

bool HostConfig::consumeLaunchRequest ( )

True if the user requested server launch, then clear that request.

◆ consumeShutdownRequest()

bool HostConfig::consumeShutdownRequest ( )

True if the user requested hosted-server shutdown, then clear that request.

◆ draftConfig()

HostConfigState HostConfig::draftConfig ( ) const

Current host-screen draft settings.

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

◆ event()

SDL_AppResult HostConfig::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:

◆ hasUnsavedServerChanges()

bool HostConfig::hasUnsavedServerChanges ( ) const
private

True if the current draft differs from the last settings sent to or received from the server.

Here is the caller graph for this function:

◆ init()

bool HostConfig::init ( AppContext & ctx)

Bind App-owned renderer, client, hosted-server, and draft config state.

Returns
True when the required borrowed services are available.
Here is the call graph for this function:

◆ iterate()

SDL_AppResult HostConfig::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 HostConfig::quit ( )
overridevirtual

No-op screen shutdown hook; App owns all borrowed services.

Implements IScreen.

◆ requestDiscardMatchChangesConfirm()

void HostConfig::requestDiscardMatchChangesConfirm ( )
private

Ask the host whether to discard unsaved match setting changes before leaving this screen.

Here is the caller graph for this function:

◆ requestShutdownConfirm()

void HostConfig::requestShutdownConfirm ( )
private

Ask the host to confirm server shutdown.

Here is the caller graph for this function:

◆ setLaunchError()

void HostConfig::setLaunchError ( const std::string & error)

Display a launch or connection error on the host form.

◆ updateServerSettings()

bool HostConfig::updateServerSettings ( )
private

Send the current host-managed settings to the hosted server.

Here is the caller graph for this function:

Member Data Documentation

◆ client

Client* HostConfig::client = nullptr
private

Network client owned by App; not owned.

◆ confirm_

ConfirmModal HostConfig::confirm_
private

Reusable confirmation modal for discarding unsaved changes.

◆ draft

HostConfigState* HostConfig::draft = nullptr
private

Persistent draft state owned by App; not owned.

◆ hostedServer

HostedServer* HostConfig::hostedServer = nullptr
private

Hosted server owned by App; not owned.

◆ lastError

std::string HostConfig::lastError
private

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

◆ lastSyncedDiscoverySettings

std::optional<DiscoverySettings> HostConfig::lastSyncedDiscoverySettings
private

Last discovery settings acknowledged locally.

◆ lastSyncedMatchConfig

std::optional<MatchConfig> HostConfig::lastSyncedMatchConfig
private

Last match config acknowledged locally as server state.

◆ pendingBackToMainMenu

bool HostConfig::pendingBackToMainMenu = false
private

Set when the user clicks "Back to Main Menu", cleared by App.

◆ pendingConfirmAction

PendingConfirmAction HostConfig::pendingConfirmAction = PendingConfirmAction::None
private

Action to run after modal confirm.

◆ pendingExitRequest

bool HostConfig::pendingExitRequest = false
private

Set when the user confirms "Exit to Desktop", cleared by App.

◆ pendingGoToLobby

bool HostConfig::pendingGoToLobby = false
private

Set when the user clicks "Go to Lobby", cleared by App.

◆ pendingLaunch

bool HostConfig::pendingLaunch = false
private

Set when the user clicks "Launch", cleared by App.

◆ pendingShutdown

bool HostConfig::pendingShutdown = false
private

Set when the user clicks "Shutdown", cleared by App.

◆ renderer

NewRenderer* HostConfig::renderer = nullptr
private

Renderer; not owned.

◆ settings

UserSettings* HostConfig::settings = nullptr
private

Live user settings; not owned.

◆ settingsPath

std::string_view HostConfig::settingsPath
private

Save path for user settings.

◆ systemMenu_

SystemMenuOverlay HostConfig::systemMenu_
private

Shared Escape menu for front-end screens.

◆ window

SDL_Window* HostConfig::window = nullptr
private

Application window; not owned.


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