From 6be2263f40e5301151cedc9ed8f72a97f6a5afc5 Mon Sep 17 00:00:00 2001 From: emilis Date: Sun, 16 Nov 2025 18:51:19 +0000 Subject: [PATCH] lobby/settings ui touchups --- werewolves-proto/src/game/settings.rs | 10 +----- werewolves/index.scss | 44 ++++++++++++++++++++------- werewolves/src/clients/host/host.rs | 19 ++---------- werewolves/src/components/lobby.rs | 17 +++++------ werewolves/src/components/settings.rs | 34 +++++++++++++++++++-- 5 files changed, 76 insertions(+), 48 deletions(-) diff --git a/werewolves-proto/src/game/settings.rs b/werewolves-proto/src/game/settings.rs index 78602a0..fef0b3d 100644 --- a/werewolves-proto/src/game/settings.rs +++ b/werewolves-proto/src/game/settings.rs @@ -231,15 +231,7 @@ impl GameSettings { } pub fn min_players_needed(&self) -> usize { - let (wolves, villagers) = (self.wolves_count(), self.village_roles_count()); - - if wolves > villagers { - wolves + 1 + wolves - } else if wolves < villagers { - wolves + villagers - } else { - wolves + villagers + 1 - } + (2 * self.wolves_count() + 1).max(3) } pub fn new_slot(&mut self, role: RoleTitle) -> SlotId { diff --git a/werewolves/index.scss b/werewolves/index.scss index e1b1deb..809f5ac 100644 --- a/werewolves/index.scss +++ b/werewolves/index.scss @@ -81,8 +81,8 @@ body { body { min-height: 100vh; max-width: 100vw; - top: 0; - left: 0; + top: 0px; + left: 0px; font-size: 1.5vh; user-select: none; @@ -174,7 +174,10 @@ nav.host-nav { } .lobby-player-list { + overflow: hidden; padding-bottom: 80px; + flex-shrink: 1; + display: flex; flex-direction: row; flex-wrap: wrap; @@ -334,23 +337,29 @@ button { &:disabled:hover::after { content: attr(reason); + overflow-y: hidden; position: absolute; - margin-top: 10px; - top: 90%; - // left: 0; + margin-top: 100px; + min-width: 20vw; font: 'Cute Font'; - // color: #000; - // background-color: #fff; color: rgba(255, 0, 0, 1); - background-color: rgba(255, 0, 0, 0.3); + background-color: black; border: 1px solid rgba(255, 0, 0, 0.3); - min-width: 50vw; - width: fit-content; padding: 3px; z-index: 4; + align-self: center; + justify-self: center; } } +.host-setup { + display: flex; + flex-direction: column; + flex-wrap: nowrap; + font-family: 'Cute Font'; + font-size: 1.5em; + overflow-y: hidden; +} .settings { list-style: none; @@ -369,6 +378,15 @@ button { padding: 0px; font-size: 0.7em; } + + .settings-info { + display: flex; + flex-direction: column; + flex-wrap: nowrap; + gap: 5px; + text-align: left; + width: fit-content; + } } .wolves-intro { @@ -822,7 +840,7 @@ clients { .client-nav { max-width: 100%; padding: 10px; - height: 37px; + height: 38px; display: flex; flex-direction: row; justify-content: baseline; @@ -2219,3 +2237,7 @@ li.choice { .has-confirm { cursor: pointer; } + +.dimmed { + filter: opacity(70%); +} diff --git a/werewolves/src/clients/host/host.rs b/werewolves/src/clients/host/host.rs index 71faad7..46f122f 100644 --- a/werewolves/src/clients/host/host.rs +++ b/werewolves/src/clients/host/host.rs @@ -467,7 +467,7 @@ impl Component for Host { let _ = loc.replace("/"); } }); - let screen = if self.big_screen { + let screen = self.big_screen.then_some({ let to_normal = Callback::from(|_| { if let Some(loc) = gloo::utils::document().location() { let _ = loc.replace("/host"); @@ -476,20 +476,7 @@ impl Component for Host { html! { } - } else { - // let to_big = Callback::from(|_| { - // if let Some(loc) = gloo::utils::document().location() { - // let _ = loc.replace("/host/big"); - // } - // }); - html! { - - - - } - }; + }); let story_on_click = if let HostState::Story { .. } = &self.state { crate::callback::send_message(HostMessage::GetState, self.send.clone()) } else { @@ -765,7 +752,7 @@ impl Host { }) }); html! { -
+
{settings}
diff --git a/werewolves/src/components/lobby.rs b/werewolves/src/components/lobby.rs index 0b5718c..3d9eea9 100644 --- a/werewolves/src/components/lobby.rs +++ b/werewolves/src/components/lobby.rs @@ -29,16 +29,13 @@ pub struct LobbyProps { #[function_component] pub fn Lobby(LobbyProps { players, on_action }: &LobbyProps) -> Html { html! { -
-

{format!("Players in lobby: {}", players.len())}

-
- { - players - .iter() - .map(|p| html! {}) - .collect::() - } -
+
+ { + players + .iter() + .map(|p| html! {}) + .collect::() + }
} } diff --git a/werewolves/src/components/settings.rs b/werewolves/src/components/settings.rs index 5395784..dae065d 100644 --- a/werewolves/src/components/settings.rs +++ b/werewolves/src/components/settings.rs @@ -285,6 +285,11 @@ pub fn Settings(
}; + let current_roles = settings.slots().len(); + let min_roles = settings.min_players_needed(); + let min_roles_class = (current_roles < min_roles).then_some("red"); + let player_count = players_in_lobby.len(); + let player_count_class = (player_count != current_roles).then_some("red"); html! {
@@ -301,11 +306,36 @@ pub fn Settings( > {"add player"} -

{format!("min roles for setup: {}", settings.min_players_needed())}

-

{format!("current role count: {}", settings.slots().len())}

+
{add_roles_buttons}
+
+ + {"current/minimum roles: "} + + + {current_roles} + + {"/"} + + {min_roles} + + + + + {"players/roles: "} + + + {player_count} + + {"/"} + + {current_roles} + + + +

{"roles in the game"}