fix: integrate multiplayer
This commit is contained in:
parent
3f3f4598f6
commit
82803ded36
10 changed files with 75 additions and 2308 deletions
|
|
@ -18,6 +18,8 @@ use super::scoring::ScoringPanel;
|
|||
pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
||||
let i18n = use_i18n();
|
||||
|
||||
let auth_username =
|
||||
use_context::<RwSignal<Option<String>>>().expect("auth_username not found in context");
|
||||
let vs = state.view_state.clone();
|
||||
let player_id = state.player_id;
|
||||
let is_my_turn = vs.active_mp_player == Some(player_id);
|
||||
|
|
@ -240,6 +242,11 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
|||
on:click=move |_| i18n.set_locale(Locale::fr)
|
||||
>"FR"</button>
|
||||
</div>
|
||||
|
||||
{move || auth_username.get().map(|u| view! {
|
||||
<p class="playing-as">"Playing as " <strong>{u}</strong></p>
|
||||
})}
|
||||
|
||||
<a class="quit-link" href="#" on:click=move |e| {
|
||||
e.prevent_default();
|
||||
cmd_tx_quit.unbounded_send(NetCommand::Disconnect).ok();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ use leptos::prelude::*;
|
|||
use crate::app::NetCommand;
|
||||
use crate::i18n::*;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
const PORTAL_URL: &str = "http://localhost:9092";
|
||||
#[cfg(not(debug_assertions))]
|
||||
const PORTAL_URL: &str = "/portal";
|
||||
|
||||
#[component]
|
||||
pub fn LoginScreen(error: Option<String>) -> impl IntoView {
|
||||
let i18n = use_i18n();
|
||||
|
|
@ -11,6 +16,8 @@ pub fn LoginScreen(error: Option<String>) -> impl IntoView {
|
|||
|
||||
let cmd_tx = use_context::<UnboundedSender<NetCommand>>()
|
||||
.expect("UnboundedSender<NetCommand> not found in context");
|
||||
let auth_username =
|
||||
use_context::<RwSignal<Option<String>>>().expect("auth_username not found in context");
|
||||
|
||||
let cmd_tx_create = cmd_tx.clone();
|
||||
let cmd_tx_join = cmd_tx.clone();
|
||||
|
|
@ -47,6 +54,19 @@ pub fn LoginScreen(error: Option<String>) -> impl IntoView {
|
|||
|
||||
{error.map(|err| view! { <p class="error-msg">{err}</p> })}
|
||||
|
||||
// Auth status badge
|
||||
{move || match auth_username.get() {
|
||||
Some(u) => view! {
|
||||
<p class="auth-badge auth-badge--in">"✓ Logged in as " <strong>{u}</strong></p>
|
||||
}.into_any(),
|
||||
None => view! {
|
||||
<p class="auth-badge auth-badge--out">
|
||||
"Not logged in — games won't be tracked. "
|
||||
<a href=PORTAL_URL target="_blank">"Create account"</a>
|
||||
</p>
|
||||
}.into_any(),
|
||||
}}
|
||||
|
||||
<input
|
||||
class="login-input"
|
||||
type="text"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue