group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
HostConfig.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "IScreen.hpp"
7#include "app/AppContext.hpp"
14
15#include <optional>
16#include <string>
17#include <string_view>
18
20class HostConfig : public IScreen
21{
22public:
25 bool init(AppContext& ctx);
26
27 SDL_AppResult event(SDL_Event* event) override;
28 SDL_AppResult iterate() override;
29
31 void quit() override;
32
35
38
41
44
46 bool consumeExitRequest();
47
50
52 void setLaunchError(const std::string& error);
53
54private:
61
63 bool canManageCurrentServer() const;
64
66 bool hasUnsavedServerChanges() const;
67
70
73
76
77 NewRenderer* renderer = nullptr;
78 SDL_Window* window = nullptr;
79 Client* client = nullptr;
83 std::string_view settingsPath;
85 std::string lastError;
86 std::optional<MatchConfig> lastSyncedMatchConfig;
87 std::optional<DiscoverySettings> lastSyncedDiscoverySettings;
90 bool pendingLaunch = false;
91 bool pendingShutdown = false;
92 bool pendingGoToLobby = false;
93 bool pendingBackToMainMenu = false;
94 bool pendingExitRequest = false;
95};
Borrowed dependencies shared by client screens.
Runtime host-controlled discovery advertisement settings.
Client-side owner for a locally launched authoritative server process.
Abstract interface for top-level application screens (lobby, in-game).
Work-in-progress SDL3 GPU renderer.
TCP stream client — sends input to the server and receives state updates.
Definition Client.hpp:69
Definition ConfirmModal.hpp:22
IScreen implementation for local server launch settings.
Definition HostConfig.hpp:21
PendingConfirmAction
Definition HostConfig.hpp:56
@ ShutdownServer
Definition HostConfig.hpp:59
@ DiscardMatchChanges
Definition HostConfig.hpp:58
@ None
Definition HostConfig.hpp:57
void requestShutdownConfirm()
Ask the host to confirm server shutdown.
Definition HostConfig.cpp:293
Client * client
Network client owned by App; not owned.
Definition HostConfig.hpp:79
bool consumeShutdownRequest()
True if the user requested hosted-server shutdown, then clear that request.
Definition HostConfig.cpp:153
SDL_AppResult iterate() override
Update the screen state and render the next frame.
Definition HostConfig.cpp:63
bool pendingShutdown
Set when the user clicks "Shutdown", cleared by App.
Definition HostConfig.hpp:91
void setLaunchError(const std::string &error)
Display a launch or connection error on the host form.
Definition HostConfig.cpp:216
bool hasUnsavedServerChanges() const
True if the current draft differs from the last settings sent to or received from the server.
Definition HostConfig.cpp:236
HostConfigState * draft
Persistent draft state owned by App; not owned.
Definition HostConfig.hpp:81
bool consumeLaunchRequest()
True if the user requested server launch, then clear that request.
Definition HostConfig.cpp:144
bool updateServerSettings()
Send the current host-managed settings to the hosted server.
Definition HostConfig.cpp:251
NewRenderer * renderer
Renderer; not owned.
Definition HostConfig.hpp:77
PendingConfirmAction pendingConfirmAction
Action to run after modal confirm.
Definition HostConfig.hpp:89
HostedServer * hostedServer
Hosted server owned by App; not owned.
Definition HostConfig.hpp:80
bool init(AppContext &ctx)
Bind App-owned renderer, client, hosted-server, and draft config state.
Definition HostConfig.cpp:13
SDL_Window * window
Application window; not owned.
Definition HostConfig.hpp:78
std::string_view settingsPath
Save path for user settings.
Definition HostConfig.hpp:83
bool pendingGoToLobby
Set when the user clicks "Go to Lobby", cleared by App.
Definition HostConfig.hpp:92
bool pendingExitRequest
Set when the user confirms "Exit to Desktop", cleared by App.
Definition HostConfig.hpp:94
bool consumeGoToLobbyRequest()
True if the user requested entering the hosted lobby, then clear that request.
Definition HostConfig.cpp:162
bool canManageCurrentServer() const
True if the client is connected and is the current lobby host.
Definition HostConfig.cpp:221
SDL_AppResult event(SDL_Event *event) override
Handle an incoming SDL event.
Definition HostConfig.cpp:47
UserSettings * settings
Live user settings; not owned.
Definition HostConfig.hpp:82
SystemMenuOverlay systemMenu_
Shared Escape menu for front-end screens.
Definition HostConfig.hpp:84
std::optional< DiscoverySettings > lastSyncedDiscoverySettings
Last discovery settings acknowledged locally.
Definition HostConfig.hpp:87
std::optional< MatchConfig > lastSyncedMatchConfig
Last match config acknowledged locally as server state.
Definition HostConfig.hpp:86
bool pendingBackToMainMenu
Set when the user clicks "Back to Main Menu", cleared by App.
Definition HostConfig.hpp:93
ConfirmModal confirm_
Reusable confirmation modal for discarding unsaved changes.
Definition HostConfig.hpp:88
void quit() override
No-op screen shutdown hook; App owns all borrowed services.
Definition HostConfig.cpp:56
bool consumeExitRequest()
True if the user requested closing the application, then clear that request.
Definition HostConfig.cpp:180
std::string lastError
Error message shown on the host form; empty when no error.
Definition HostConfig.hpp:85
bool pendingLaunch
Set when the user clicks "Launch", cleared by App.
Definition HostConfig.hpp:90
HostConfigState draftConfig() const
Current host-screen draft settings.
Definition HostConfig.cpp:189
void requestDiscardMatchChangesConfirm()
Ask the host whether to discard unsaved match setting changes before leaving this screen.
Definition HostConfig.cpp:283
bool consumeBackToMainMenuRequest()
True if the user requested returning to the main menu, then clear that request.
Definition HostConfig.cpp:171
Starts, monitors, and shuts down a server process spawned by the client.
Definition HostedServer.hpp:37
Interface implemented by each full-screen mode (Lobby, Game).
Definition IScreen.hpp:16
Graphics-team's work-in-progress SDL3 GPU renderer.
Definition NewRenderer.hpp:83
Shared Escape menu for non-gameplay screens.
Definition SystemMenuOverlay.hpp:20
Non-owning view of App-owned services and configuration.
Definition AppContext.hpp:20
Persistent host-screen options used when launching a local server.
Definition HostedServer.hpp:17
Per-user gameplay settings loaded from SDL's pref-path TOML file.
Definition UserSettings.hpp:25