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

Root application class; owns shared resources and manages screen transitions. More...

#include <App.hpp>

Collaboration diagram for App:
[legend]

Classes

struct  JoinAttemptResult

Public Types

enum class  Screen {
  TitleScreen , Settings , MainMenu , HostConfig ,
  Lobby , Loading , PostMatch , InGame
}
 Named screens the application can display. More...

Public Member Functions

bool init ()
 Initialize SDL, the GPU renderer, ImGui, and the network client.
SDL_AppResult event (SDL_Event *event)
 Forward an SDL event to the active screen.
SDL_AppResult iterate ()
 Tick the active screen and check for pending screen transitions.
void quit ()
 Shut down all subsystems and release resources.
void transitionTo (Screen next)
 Destroy the current screen and activate the requested one.

Private Member Functions

void cleanup ()
 Destroy all subsystems without asserting on partial-init state.
AppContext screenContext ()
 Build a borrowed context for screen initialisation.
void applyAudioSettings ()
 Push saved volume settings into the shared audio system.
void updateBackgroundMusic ()
 Start the correct looping background music for the active screen.
void showMainMenuPopupMessage (const std::string &message)
 Show a modal message on the active main menu screen, if it is active.
void startJoinAttempt (const JoinRequest &request)
 Start the non-blocking join worker for a main-menu join request.
void pollJoinAttempt ()
 Apply a completed join worker result, if one is ready.
void waitForJoinAttempt ()
 Wait for any active join worker before shutdown.
bool shutdownHostedServerGracefully ()
 Ask a locally hosted server to shut down before falling back to process termination.

Private Attributes

SDL_Window * window = nullptr
 Main application window.
NewRenderer renderer
 SDL_GPU PBR renderer, shared across screens.
NetworkConfig networkConfig
 Host/port/transport loaded from config.toml.
DeveloperConfig developerConfig
 Developer toggles loaded from config.toml.
UserSettings userSettings
 User-specific input and gameplay settings.
std::string userSettingsPath
 Path used to load and save user settings.
std::string currentServerName
 Display name for the connected server, if known.
std::string currentServerIp
 Address used for the current server connection, if known.
uint16_t currentServerPort = 0
 Port used for the current server connection, if known.
SfxSystem sfxSystem
 Shared audio system for menus, music, and gameplay sounds.
Client client
 Network client connected to the authoritative server when in a session.
HostedServer hostedServer
 Optional local server process launched by the host screen.
HostConfigState hostConfigState
 Persistent host screen draft state.
Screen current = Screen::TitleScreen
 Which screen is currently active.
Screen settingsReturnScreen_ = Screen::TitleScreen
 Front-end screen to restore after Settings closes.
ServerBrowserTab nextMainMenuTab_ = ServerBrowserTab::LocalListing
 Initial tab for the next MainMenu open.
std::unique_ptr< IScreenscreen_
 Active screen instance.
bool imguiContextOwned = false
 True once App has created the ImGui context.
std::optional< PostMatchResultpendingPostMatchResult_
 Result data used to open the post-match screen.
std::future< JoinAttemptResultjoinAttempt_
 Background direct/global join attempt, if active.
std::string joinAttemptLabel_
 Target label displayed by the main menu while joining.
Uint64 previousAudioCounter_ = 0
 Performance counter used to tick menu audio.

Detailed Description

Root application class; owns shared resources and manages screen transitions.

Implements the SDL3 app-callback contract (init/event/iterate/quit). Exactly one IScreen is active at a time; App drives transitions among TitleScreen, MainMenu, host configuration, Lobby, and InGame screens.

Member Enumeration Documentation

◆ Screen

enum class App::Screen
strong

Named screens the application can display.

Enumerator
TitleScreen 

Top-level landing/title screen.

Settings 

Dedicated front-end settings screen.

MainMenu 

Join/server-browser main menu screen.

HostConfig 

Deprecated alias for opening the server browser host tab.

Lobby 

Pre-match lobby waiting room.

Loading 

Match-loading screen shown before synchronous game init.

PostMatch 

Dedicated scoreboard shown after a completed match.

InGame 

Active match session.

Member Function Documentation

◆ applyAudioSettings()

void App::applyAudioSettings ( )
private

Push saved volume settings into the shared audio system.

Here is the caller graph for this function:

◆ cleanup()

void App::cleanup ( )
private

Destroy all subsystems without asserting on partial-init state.

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

◆ event()

SDL_AppResult App::event ( SDL_Event * event)

Forward an SDL event to the active screen.

Returns
SDL_APP_CONTINUE or SDL_APP_FAILURE.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool App::init ( )

Initialize SDL, the GPU renderer, ImGui, and the network client.

Returns
True on success; false if any subsystem fails to initialize.
Here is the call graph for this function:

◆ iterate()

SDL_AppResult App::iterate ( )

Tick the active screen and check for pending screen transitions.

Returns
SDL_APP_CONTINUE or SDL_APP_FAILURE.
Here is the call graph for this function:

◆ pollJoinAttempt()

void App::pollJoinAttempt ( )
private

Apply a completed join worker result, if one is ready.

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

◆ quit()

void App::quit ( )

Shut down all subsystems and release resources.

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

◆ screenContext()

AppContext App::screenContext ( )
private

Build a borrowed context for screen initialisation.

Here is the caller graph for this function:

◆ showMainMenuPopupMessage()

void App::showMainMenuPopupMessage ( const std::string & message)
private

Show a modal message on the active main menu screen, if it is active.

Here is the caller graph for this function:

◆ shutdownHostedServerGracefully()

bool App::shutdownHostedServerGracefully ( )
private

Ask a locally hosted server to shut down before falling back to process termination.

Here is the caller graph for this function:

◆ startJoinAttempt()

void App::startJoinAttempt ( const JoinRequest & request)
private

Start the non-blocking join worker for a main-menu join request.

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

◆ transitionTo()

void App::transitionTo ( Screen next)

Destroy the current screen and activate the requested one.

Parameters
nextThe screen to transition to.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateBackgroundMusic()

void App::updateBackgroundMusic ( )
private

Start the correct looping background music for the active screen.

Here is the caller graph for this function:

◆ waitForJoinAttempt()

void App::waitForJoinAttempt ( )
private

Wait for any active join worker before shutdown.

Here is the caller graph for this function:

Member Data Documentation

◆ client

Client App::client
private

Network client connected to the authoritative server when in a session.

◆ current

Screen App::current = Screen::TitleScreen
private

Which screen is currently active.

◆ currentServerIp

std::string App::currentServerIp
private

Address used for the current server connection, if known.

◆ currentServerName

std::string App::currentServerName
private

Display name for the connected server, if known.

◆ currentServerPort

uint16_t App::currentServerPort = 0
private

Port used for the current server connection, if known.

◆ developerConfig

DeveloperConfig App::developerConfig
private

Developer toggles loaded from config.toml.

◆ hostConfigState

HostConfigState App::hostConfigState
private
Initial value:
{
.port = 9999,
.useSpecificPort = false,
.useLegacyTcp = false,
.persistAfterClientExit = false,
.advertiseGlobal = true,
.advertiseLan = true,
.serverName = "Server",
.killsToWin = 25,
.maxPlayers = 8,
.powerupInitialSpawnDelaySeconds = 60.0f,
.powerupRespawnCooldownSeconds = 30.0f,
}

Persistent host screen draft state.

◆ hostedServer

HostedServer App::hostedServer
private

Optional local server process launched by the host screen.

◆ imguiContextOwned

bool App::imguiContextOwned = false
private

True once App has created the ImGui context.

◆ joinAttempt_

std::future<JoinAttemptResult> App::joinAttempt_
private

Background direct/global join attempt, if active.

◆ joinAttemptLabel_

std::string App::joinAttemptLabel_
private

Target label displayed by the main menu while joining.

◆ networkConfig

NetworkConfig App::networkConfig
private

Host/port/transport loaded from config.toml.

◆ nextMainMenuTab_

ServerBrowserTab App::nextMainMenuTab_ = ServerBrowserTab::LocalListing
private

Initial tab for the next MainMenu open.

◆ pendingPostMatchResult_

std::optional<PostMatchResult> App::pendingPostMatchResult_
private

Result data used to open the post-match screen.

◆ previousAudioCounter_

Uint64 App::previousAudioCounter_ = 0
private

Performance counter used to tick menu audio.

◆ renderer

NewRenderer App::renderer
private

SDL_GPU PBR renderer, shared across screens.

◆ screen_

std::unique_ptr<IScreen> App::screen_
private

Active screen instance.

◆ settingsReturnScreen_

Screen App::settingsReturnScreen_ = Screen::TitleScreen
private

Front-end screen to restore after Settings closes.

◆ sfxSystem

SfxSystem App::sfxSystem
private

Shared audio system for menus, music, and gameplay sounds.

◆ userSettings

UserSettings App::userSettings
private

User-specific input and gameplay settings.

◆ userSettingsPath

std::string App::userSettingsPath
private

Path used to load and save user settings.

◆ window

SDL_Window* App::window = nullptr
private

Main application window.


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