diff options
| author | srdusr <[email protected]> | 2025-12-05 22:56:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-12-05 22:56:00 +0200 |
| commit | 076f29369e51dfb5798f70099a330ebeb1b66a4e (patch) | |
| tree | 202d355c47f1b698f8c96d688b2e268c0d53281d /crates/tui | |
| parent | f48fa830b10d4122d145e9822522d9b71e3f00fa (diff) | |
| download | typerpunk-076f29369e51dfb5798f70099a330ebeb1b66a4e.tar.gz typerpunk-076f29369e51dfb5798f70099a330ebeb1b66a4e.zip | |
Show the passage during the countdown, and fix navigation across screens
Countdown
- Five seconds instead of three, and shown over the passage on the race
screen rather than in an empty lobby. New ServerMessage::RaceText carries
the text (and its attribution) just before the countdown starts, so every
client can put it on screen and let players read the opening words while
the numbers run - what TypeRacer and 10FastFingers both do. Typing is
locked until Start lifts the gate.
- Two subscriptions had to move with it. Building the race view tears the
lobby down, and the lobby owned the only handlers for Countdown and Start,
so the count stopped arriving exactly when it was needed and the gate would
never have lifted.
- The TUI and Steam clients match ServerMessage exhaustively, so both gained
an arm for the new variant; whole workspace checks clean.
Multiplayer attribution
- Race passages now carry who wrote them, so a race shows its source the way
single player always has. Previously the server sent bare strings and both
the race and its end screen showed nothing.
Navigation
- Every screen's full-width "Back" button becomes a close control at the top
of the content. The wordmark and Escape already went back, so it was a
third way to do the same thing and the least reachable of them.
- The multiplayer screen had a Back button on top of that; gone.
Fixes
- The end screen graph is drawn into a canvas, so it cannot inherit a theme
change the way the rest of the page does. It now redraws on one - switching
theme used to leave the chart in the old palette.
- .stats-empty was align-self:flex-start inside a centred column, so "Sign in
to add friends" sat on a different axis from its own Sign In button.
- The store showed a sign-in prompt instead of its catalogue, so nobody could
see what signing in would get them. The catalogue now renders signed out,
with prices, behind a sign-in note.
- The room code field is sized for the five characters a code actually is,
and Join carries the same weight as the field it belongs to.
Diffstat (limited to 'crates/tui')
| -rw-r--r-- | crates/tui/src/main.rs | 1 | ||||
| -rw-r--r-- | crates/tui/src/multiplayer_net.rs | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/tui/src/main.rs b/crates/tui/src/main.rs index f5c4a68..27ea983 100644 --- a/crates/tui/src/main.rs +++ b/crates/tui/src/main.rs @@ -104,6 +104,7 @@ fn merge_player_list(existing: &[MpPlayer], incoming: Vec<typerpunk_core::multip fn apply_mp_event(app: &mut App, event: MpNetEvent) { match event { + MpNetEvent::Ignored => {} MpNetEvent::RoomCreated { code } => app.set_mp_room_created(code), MpNetEvent::Joined { player_id } => app.set_mp_joined(player_id), MpNetEvent::PlayerList(players) => { diff --git a/crates/tui/src/multiplayer_net.rs b/crates/tui/src/multiplayer_net.rs index 8c6c6b0..5d1b772 100644 --- a/crates/tui/src/multiplayer_net.rs +++ b/crates/tui/src/multiplayer_net.rs @@ -11,6 +11,10 @@ use typerpunk_core::multiplayer::{ClientMessage, PlayerInfo, ServerMessage}; #[derive(Debug, Clone)] pub enum NetEvent { + /// A protocol message this client has no use for. Delivered rather than + /// dropped so the match on ServerMessage stays exhaustive and adding a + /// variant is a compile-time prompt rather than a silent parse failure. + Ignored, RoomCreated { code: String }, Joined { player_id: String }, PlayerList(Vec<PlayerInfo>), @@ -81,6 +85,11 @@ fn to_event(msg: ServerMessage) -> NetEvent { match msg { ServerMessage::Joined { player_id } => NetEvent::Joined { player_id }, ServerMessage::PlayerList { players } => NetEvent::PlayerList(players), + // The passage ahead of the countdown, so a client can show it while + // players wait. This one does not yet, and Start still carries the + // text, so it is accepted and ignored rather than dropped as an + // unparseable message. + ServerMessage::RaceText { .. } => NetEvent::Ignored, ServerMessage::Countdown { seconds } => NetEvent::Countdown(seconds), ServerMessage::Start { text } => NetEvent::Start(text), ServerMessage::PlayerProgress { player_id, percent, wpm } => NetEvent::PlayerProgress { player_id, percent, wpm }, |