fix: remove language switcher from game panel
This commit is contained in:
parent
04369ea28e
commit
c69891605e
3 changed files with 38 additions and 31 deletions
|
|
@ -12,17 +12,17 @@ use backbone_lib::session::{ConnectError, GameSession, RoomConfig, RoomRole, Ses
|
||||||
use backbone_lib::traits::ViewStateUpdate;
|
use backbone_lib::traits::ViewStateUpdate;
|
||||||
|
|
||||||
use crate::api;
|
use crate::api;
|
||||||
use crate::i18n::*;
|
|
||||||
use crate::game::components::{ConnectingScreen, GameScreen};
|
use crate::game::components::{ConnectingScreen, GameScreen};
|
||||||
use crate::game::session::{
|
use crate::game::session::{
|
||||||
compute_last_moves, patch_player_name, push_or_show, run_local_bot_game,
|
compute_last_moves, patch_player_name, push_or_show, run_local_bot_game,
|
||||||
};
|
};
|
||||||
use crate::game::trictrac::backend::TrictracBackend;
|
use crate::game::trictrac::backend::TrictracBackend;
|
||||||
use crate::game::trictrac::types::{
|
use crate::game::trictrac::types::{GameDelta, PlayerAction, ScoredEvent, SerStage, ViewState};
|
||||||
GameDelta, PlayerAction, ScoredEvent, SerStage, ViewState,
|
use crate::i18n::*;
|
||||||
};
|
|
||||||
use crate::nav::SiteNav;
|
use crate::nav::SiteNav;
|
||||||
use crate::portal::{account::AccountPage, game_detail::GameDetailPage, lobby::LobbyPage, profile::ProfilePage};
|
use crate::portal::{
|
||||||
|
account::AccountPage, game_detail::GameDetailPage, lobby::LobbyPage, profile::ProfilePage,
|
||||||
|
};
|
||||||
use trictrac_store::CheckerMove;
|
use trictrac_store::CheckerMove;
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
@ -65,8 +65,12 @@ pub enum Screen {
|
||||||
|
|
||||||
/// Commands sent from UI event handlers into the network task.
|
/// Commands sent from UI event handlers into the network task.
|
||||||
pub enum NetCommand {
|
pub enum NetCommand {
|
||||||
CreateRoom { room: String },
|
CreateRoom {
|
||||||
JoinRoom { room: String },
|
room: String,
|
||||||
|
},
|
||||||
|
JoinRoom {
|
||||||
|
room: String,
|
||||||
|
},
|
||||||
Reconnect {
|
Reconnect {
|
||||||
relay_url: String,
|
relay_url: String,
|
||||||
game_id: String,
|
game_id: String,
|
||||||
|
|
@ -227,10 +231,12 @@ pub fn App() -> impl IntoView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if remote_config.is_none() {
|
if remote_config.is_none() {
|
||||||
let player_name = auth_username.get_untracked()
|
let player_name = auth_username
|
||||||
.unwrap_or_else(|| t_string!(i18n, anonymous_name).to_string());
|
.get_untracked()
|
||||||
|
.unwrap_or_else(|| untrack(|| t_string!(i18n, anonymous_name).to_string()));
|
||||||
loop {
|
loop {
|
||||||
let restart = run_local_bot_game(screen, &mut cmd_rx, pending, player_name.clone()).await;
|
let restart =
|
||||||
|
run_local_bot_game(screen, &mut cmd_rx, pending, player_name.clone()).await;
|
||||||
if !restart {
|
if !restart {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -270,7 +276,8 @@ pub fn App() -> impl IntoView {
|
||||||
let is_host = session.is_host;
|
let is_host = session.is_host;
|
||||||
let player_id = session.player_id;
|
let player_id = session.player_id;
|
||||||
let reconnect_token = session.reconnect_token;
|
let reconnect_token = session.reconnect_token;
|
||||||
let my_name = auth_username.get_untracked()
|
let my_name = auth_username
|
||||||
|
.get_untracked()
|
||||||
.unwrap_or_else(|| t_string!(i18n, anonymous_name).to_string());
|
.unwrap_or_else(|| t_string!(i18n, anonymous_name).to_string());
|
||||||
let mut vs = ViewState::default_with_names("", "");
|
let mut vs = ViewState::default_with_names("", "");
|
||||||
let mut result_submitted = false;
|
let mut result_submitted = false;
|
||||||
|
|
@ -378,23 +385,26 @@ fn GameOverlay(
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
if location.pathname.get() != "/" {
|
if location.pathname.get() != "/" {
|
||||||
return view! { }.into_any();
|
return view! {}.into_any();
|
||||||
}
|
}
|
||||||
let q = pending.get();
|
let q = pending.get();
|
||||||
let front = q.front().cloned();
|
let front = q.front().cloned();
|
||||||
if let Some(state) = front {
|
if let Some(state) = front {
|
||||||
return view! {
|
return view! {
|
||||||
<div class="game-overlay"><GameScreen state /></div>
|
<div class="game-overlay"><GameScreen state /></div>
|
||||||
}.into_any();
|
}
|
||||||
|
.into_any();
|
||||||
}
|
}
|
||||||
match screen.get() {
|
match screen.get() {
|
||||||
Screen::Playing(state) => view! {
|
Screen::Playing(state) => view! {
|
||||||
<div class="game-overlay"><GameScreen state /></div>
|
<div class="game-overlay"><GameScreen state /></div>
|
||||||
}.into_any(),
|
}
|
||||||
|
.into_any(),
|
||||||
Screen::Connecting => view! {
|
Screen::Connecting => view! {
|
||||||
<div class="game-overlay"><ConnectingScreen /></div>
|
<div class="game-overlay"><ConnectingScreen /></div>
|
||||||
}.into_any(),
|
}
|
||||||
_ => view! { }.into_any(),
|
.into_any(),
|
||||||
|
_ => view! {}.into_any(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ use trictrac_store::{Board as StoreBoard, CheckerMove, Color, Dice as StoreDice,
|
||||||
|
|
||||||
use super::die::Die;
|
use super::die::Die;
|
||||||
use crate::app::{GameUiState, NetCommand, PauseReason};
|
use crate::app::{GameUiState, NetCommand, PauseReason};
|
||||||
|
use crate::game::trictrac::types::{PlayerAction, PreGameRollState, SerStage, SerTurnStage};
|
||||||
use crate::i18n::*;
|
use crate::i18n::*;
|
||||||
use crate::portal::lobby::{qr_svg, room_url};
|
use crate::portal::lobby::{qr_svg, room_url};
|
||||||
use crate::game::trictrac::types::{PlayerAction, PreGameRollState, SerStage, SerTurnStage};
|
|
||||||
|
|
||||||
use super::board::Board;
|
use super::board::Board;
|
||||||
use super::score_panel::PlayerScorePanel;
|
use super::score_panel::PlayerScorePanel;
|
||||||
|
|
@ -225,8 +225,16 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
||||||
let opp_holes_end = opp_score.holes;
|
let opp_holes_end = opp_score.holes;
|
||||||
|
|
||||||
let share_open = RwSignal::new(false);
|
let share_open = RwSignal::new(false);
|
||||||
let share_url = if !is_bot_game { room_url(&room_id) } else { String::new() };
|
let share_url = if !is_bot_game {
|
||||||
let share_svg = if !is_bot_game { qr_svg(&share_url) } else { String::new() };
|
room_url(&room_id)
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
let share_svg = if !is_bot_game {
|
||||||
|
qr_svg(&share_url)
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="game-container">
|
<div class="game-container">
|
||||||
|
|
@ -249,17 +257,6 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
||||||
</button>
|
</button>
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<div class="lang-switcher">
|
|
||||||
<button
|
|
||||||
class:lang-active=move || i18n.get_locale() == Locale::en
|
|
||||||
on:click=move |_| i18n.set_locale(Locale::en)
|
|
||||||
>"EN"</button>
|
|
||||||
<button
|
|
||||||
class:lang-active=move || i18n.get_locale() == Locale::fr
|
|
||||||
on:click=move |_| i18n.set_locale(Locale::fr)
|
|
||||||
>"FR"</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{move || auth_username.get().map(|u| view! {
|
{move || auth_username.get().map(|u| view! {
|
||||||
<span class="playing-as">"▶ " <strong>{u}</strong></span>
|
<span class="playing-as">"▶ " <strong>{u}</strong></span>
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ fn IdleCard(
|
||||||
<div style="margin-top:0.75rem;display:flex;gap:0.5rem">
|
<div style="margin-top:0.75rem;display:flex;gap:0.5rem">
|
||||||
<input
|
<input
|
||||||
class="login-input"
|
class="login-input"
|
||||||
style="flex:1;margin:0"
|
style="margin:0"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder=move || t_string!(i18n, join_code_placeholder)
|
placeholder=move || t_string!(i18n, join_code_placeholder)
|
||||||
prop:value=move || join_code.get()
|
prop:value=move || join_code.get()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue