|
group2 0.1.0
CSE 125 Group 2
|
IScreen implementation for the main menu/join screen; hosts the server join form. More...
#include <MainMenu.hpp>
Public Member Functions | |
| bool | init (AppContext &ctx, ServerBrowserTab initialTab=ServerBrowserTab::LocalListing) |
| Bind renderer, window, and discovery configuration; 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< JoinRequest > | consumeJoinRequest () |
| Take the pending join request set when the user clicks "Join", clearing it. | |
| bool | consumeHostRequest () |
| Take the pending host request set when the user clicks "Host", clearing it. | |
| bool | consumeReturnToTitleScreenRequest () |
| Take the pending title-screen request set when the user clicks "Return to Title Screen", clearing it. | |
| bool | consumeExitRequest () |
| True if the user requested closing the application, then clear that request. | |
| void | setJoinError (const std::string &error) |
| Display an error string on the join form (e.g. from a failed connection attempt). | |
| void | setLaunchError (const std::string &error) |
| Display a launch or connection error on the host tab. | |
| void | setJoinInProgress (bool joining, const std::string &label={}) |
| Show or clear the in-progress connection indicator. | |
| void | setPopupMessage (const std::string &message) |
| Display a modal message on the next main menu screen frame. | |
| 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. | |
| HostConfigState | consumeDraftConfig () const |
| Current host-screen draft settings. | |
| 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. | |
| HostConfigState | draftConfig () const |
| Current host-screen draft settings, clamped and sanitized. | |
| 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. | |
| void | startGlobalRefresh (bool force=false) |
| Start an asynchronous global server-browser refresh when allowed by throttling. | |
| void | joinRefreshThreadIfFinished () |
| Join the global browser worker once it has finished. | |
Private Attributes | |
| NewRenderer * | renderer = nullptr |
| Renderer; not owned. | |
| SDL_Window * | window = nullptr |
| Application window; not owned. | |
| Client * | client = nullptr |
| Network client owned by App; not owned. | |
| HostedServer * | hostedServer = nullptr |
| Hosted server owned by App; not owned. | |
| HostConfigState * | draft = nullptr |
| Persistent draft state owned by App; not owned. | |
| NetworkConfig * | networkConfig = nullptr |
| Runtime network config owned by App; not owned. | |
| UserSettings * | settings = nullptr |
| Live user settings; not owned. | |
| std::string_view | settingsPath |
| Save path for user settings. | |
| SystemMenuOverlay | systemMenu_ |
| Shared Escape menu for front-end screens. | |
| GlobalDiscoveryConfig | discoveryConfig |
| JoinMenuState | joinMenuState |
| Mutable state backing the join form widgets. | |
| std::string | lastHostError |
| Error message shown on the host form; empty when no error. | |
| std::optional< MatchConfig > | lastSyncedMatchConfig |
| Last match config acknowledged locally as server state. | |
| std::optional< DiscoverySettings > | lastSyncedDiscoverySettings |
| Last discovery settings acknowledged locally. | |
| ConfirmModal | confirm_ |
| Reusable confirmation modal for host tab actions. | |
| PendingConfirmAction | pendingConfirmAction = PendingConfirmAction::None |
| Action to run after modal confirm. | |
| std::optional< JoinRequest > | pendingJoinRequest |
| Set when the user clicks "Join", cleared on App transition to Lobby. | |
| bool | pendingHostRequest = false |
| Set when the user clicks "Host", cleared on App transition. | |
| 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 | pendingReturnToTitleScreenRequest |
| Set when the user clicks "Return to Title Screen", cleared on transition. | |
| bool | pendingExitRequest = false |
| Set when the user confirms "Exit to Desktop", cleared by App. | |
| std::string | joinError |
| Error message shown on the join form; empty when no error. | |
| std::string | popupMessage |
| Modal message shown once after returning to the main menu. | |
| bool | openPopupMessage = false |
| True when the modal should be opened next frame. | |
| std::unique_ptr< DiscoveryClient > | localDiscoveryClient = std::make_unique<DiscoveryClient>() |
| std::vector< net::discovery::ServerInfo > | globalServers |
| Latest directory-server browser snapshot. | |
| std::vector< DiscoveryClient::DiscoveredServer > | localServers |
| Latest LAN browser snapshot. | |
| std::string | browserError |
| Last global browser error, empty when none. | |
| std::mutex | browserMutex |
| Guards global browser results from worker thread. | |
| std::thread | browserThread |
| Worker used for global server-browser requests. | |
| std::atomic< bool > | browserRefreshing {false} |
| True while browserThread is fetching. | |
| uint64_t | lastBrowserRefreshMs = 0 |
| SDL tick timestamp of the last global refresh. | |
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. | |
IScreen implementation for the main menu/join screen; hosts the server join form.
|
strongprivate |
|
private |
True if the client is connected and is the current lobby host.
| HostConfigState MainMenu::consumeDraftConfig | ( | ) | const |
Current host-screen draft settings.
| bool MainMenu::consumeExitRequest | ( | ) |
True if the user requested closing the application, then clear that request.
| bool MainMenu::consumeGoToLobbyRequest | ( | ) |
True if the user requested entering the hosted lobby, then clear that request.
| bool MainMenu::consumeHostRequest | ( | ) |
Take the pending host request set when the user clicks "Host", clearing it.
| std::optional< JoinRequest > MainMenu::consumeJoinRequest | ( | ) |
Take the pending join request set when the user clicks "Join", clearing it.
| bool MainMenu::consumeLaunchRequest | ( | ) |
True if the user requested server launch, then clear that request.
| bool MainMenu::consumeReturnToTitleScreenRequest | ( | ) |
Take the pending title-screen request set when the user clicks "Return to Title Screen", clearing it.
| bool MainMenu::consumeShutdownRequest | ( | ) |
True if the user requested hosted-server shutdown, then clear that request.
|
private |
Current host-screen draft settings, clamped and sanitized.
|
overridevirtual |
|
private |
True if the current draft differs from the last settings sent to or received from the server.
| bool MainMenu::init | ( | AppContext & | ctx, |
| ServerBrowserTab | initialTab = ServerBrowserTab::LocalListing ) |
Bind renderer, window, and discovery configuration; must be called before iterate().
|
overridevirtual |
Update the screen state and render the next frame.
Implements IScreen.
|
private |
Join the global browser worker once it has finished.
|
overridevirtual |
Perform any necessary cleanup before the screen is destroyed.
Implements IScreen.
|
private |
Ask the host whether to discard unsaved match setting changes before leaving this screen.
|
private |
Ask the host to confirm server shutdown.
| void MainMenu::setJoinError | ( | const std::string & | error | ) |
Display an error string on the join form (e.g. from a failed connection attempt).
| void MainMenu::setJoinInProgress | ( | bool | joining, |
| const std::string & | label = {} ) |
Show or clear the in-progress connection indicator.
| void MainMenu::setLaunchError | ( | const std::string & | error | ) |
Display a launch or connection error on the host tab.
| void MainMenu::setPopupMessage | ( | const std::string & | message | ) |
Display a modal message on the next main menu screen frame.
|
private |
Start an asynchronous global server-browser refresh when allowed by throttling.
|
private |
Send the current host-managed settings to the hosted server.
|
private |
Last global browser error, empty when none.
|
private |
Guards global browser results from worker thread.
|
private |
True while browserThread is fetching.
|
private |
Worker used for global server-browser requests.
|
private |
Reusable confirmation modal for host tab actions.
|
private |
|
private |
Persistent draft state owned by App; not owned.
|
private |
Latest directory-server browser snapshot.
|
private |
Hosted server owned by App; not owned.
|
private |
Error message shown on the join form; empty when no error.
|
private |
Mutable state backing the join form widgets.
|
private |
SDL tick timestamp of the last global refresh.
|
private |
Error message shown on the host form; empty when no error.
|
private |
Last discovery settings acknowledged locally.
|
private |
Last match config acknowledged locally as server state.
|
private |
|
private |
Latest LAN browser snapshot.
|
private |
Runtime network config owned by App; not owned.
|
private |
True when the modal should be opened next frame.
|
private |
Action to run after modal confirm.
|
private |
Set when the user confirms "Exit to Desktop", cleared by App.
|
private |
Set when the user clicks "Go to Lobby", cleared by App.
|
private |
Set when the user clicks "Host", cleared on App transition.
|
private |
|
private |
Set when the user clicks "Launch", cleared by App.
|
private |
Set when the user clicks "Return to Title Screen", cleared on transition.
|
private |
Set when the user clicks "Shutdown", cleared by App.
|
private |
Modal message shown once after returning to the main menu.
|
private |
Renderer; not owned.
|
private |
Live user settings; not owned.
|
private |
Save path for user settings.
|
private |
Shared Escape menu for front-end screens.
|
private |
Application window; not owned.