Add weapon and some other info to perround
In the events per round, it now dispalys the weapon used and headshot and noscope if applicable. Otherwise also cleaned up other code
This commit is contained in:
@@ -42,13 +42,6 @@ pub fn demo() -> impl leptos::IntoView {
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
let selected_tab = move || {
|
||||
let loc = leptos_router::use_location();
|
||||
let loc_path = loc.pathname.get();
|
||||
let trailing = loc_path.split('/').last();
|
||||
trailing.unwrap_or("/").to_owned()
|
||||
};
|
||||
|
||||
let style = stylers::style! {
|
||||
"Demo",
|
||||
.analysis_bar {
|
||||
@@ -87,13 +80,27 @@ pub fn demo() -> impl leptos::IntoView {
|
||||
}
|
||||
|
||||
#[leptos::component]
|
||||
pub fn tab_bar<P>(prefix: P, parts: &'static [(&'static str, &'static str)]) -> impl leptos::IntoView where P: Fn() -> String + Copy + 'static {
|
||||
pub fn tab_bar<P>(
|
||||
prefix: P,
|
||||
parts: &'static [(&'static str, &'static str)],
|
||||
) -> impl leptos::IntoView
|
||||
where
|
||||
P: Fn() -> String + Copy + 'static,
|
||||
{
|
||||
let selected_tab = move || {
|
||||
let prefix = prefix();
|
||||
let loc = leptos_router::use_location();
|
||||
let loc_path = loc.pathname.get();
|
||||
let trailing = loc_path.strip_prefix(&prefix).unwrap_or(&loc_path).split('/').filter(|l| !l.is_empty()).next();
|
||||
trailing.or(parts.first().map(|p| p.0)).unwrap_or("").to_owned()
|
||||
let trailing = loc_path
|
||||
.strip_prefix(&prefix)
|
||||
.unwrap_or(&loc_path)
|
||||
.split('/')
|
||||
.filter(|l| !l.is_empty())
|
||||
.next();
|
||||
trailing
|
||||
.or(parts.first().map(|p| p.0))
|
||||
.unwrap_or("")
|
||||
.to_owned()
|
||||
};
|
||||
|
||||
let style = stylers::style! {
|
||||
@@ -122,7 +129,8 @@ pub fn tab_bar<P>(prefix: P, parts: &'static [(&'static str, &'static str)]) ->
|
||||
}
|
||||
};
|
||||
|
||||
let tabs = move || parts.into_iter().map(|(routename, name)| {
|
||||
let tabs = move || {
|
||||
parts.into_iter().map(|(routename, name)| {
|
||||
view! {class=style,
|
||||
<div class="analysis_selector" class:current=move || selected_tab() == routename.to_string()>
|
||||
<A href=routename.to_string()>
|
||||
@@ -130,7 +138,8 @@ pub fn tab_bar<P>(prefix: P, parts: &'static [(&'static str, &'static str)]) ->
|
||||
</A>
|
||||
</div>
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
}).collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
view! {class = style,
|
||||
<div class="analysis_bar" style=format!("--rows: {}", parts.len())>
|
||||
|
||||
@@ -79,24 +79,33 @@ pub fn per_round() -> impl leptos::IntoView {
|
||||
|
||||
match (current_round, teams) {
|
||||
(Some(round), Some(teams)) => {
|
||||
round.events.iter().map(|event| {
|
||||
round.events.into_iter().map(|event| {
|
||||
match event {
|
||||
common::demo_analysis::RoundEvent::BombPlanted => view! { <li>Bomb has been planted</li> }.into_view(),
|
||||
common::demo_analysis::RoundEvent::BombDefused => view! { <li>Bomb has been defused</li> }.into_view(),
|
||||
common::demo_analysis::RoundEvent::Killed { attacker, died } => {
|
||||
let mut attacker_t = teams.iter().find(|t| t.players.contains(attacker)).map(|t| t.name == "TERRORIST").unwrap_or(false);
|
||||
let mut died_t = teams.iter().find(|t| t.players.contains(died)).map(|t| t.name == "TERRORIST").unwrap_or(false);
|
||||
common::demo_analysis::RoundEvent::Killed { attacker, died, weapon, headshot, noscope } => {
|
||||
let mut attacker_t = teams.iter().find(|t| t.players.contains(&attacker)).map(|t| t.name == "TERRORIST").unwrap_or(false);
|
||||
let mut died_t = teams.iter().find(|t| t.players.contains(&died)).map(|t| t.name == "TERRORIST").unwrap_or(false);
|
||||
|
||||
if (12..27).contains(&round_index) {
|
||||
attacker_t = !attacker_t;
|
||||
died_t = !died_t;
|
||||
}
|
||||
|
||||
let weapon_display = move || {
|
||||
let parts = weapon.as_ref().into_iter().map(|w| w.as_str())
|
||||
.chain(headshot.then_some("Headshot").into_iter())
|
||||
.chain(noscope.then_some("Noscope").into_iter());
|
||||
|
||||
format!("(using {})", parts.collect::<Vec<_>>().join(","))
|
||||
};
|
||||
|
||||
view! {
|
||||
class=style,
|
||||
<li>{"'"}
|
||||
<span class:t_player=move || attacker_t class:ct_player=move || !attacker_t>{ attacker }</span>{"'"} killed {"'"}
|
||||
<span class:t_player=move || died_t class:ct_player=move || !died_t>{ died }</span>{"'"}
|
||||
<li>
|
||||
{"'"}<span class:t_player=move || attacker_t class:ct_player=move || !attacker_t>{ attacker }</span>{"'"}
|
||||
killed { weapon_display }
|
||||
{"'"}<span class:t_player=move || died_t class:ct_player=move || !died_t>{ died }</span>{"'"}
|
||||
</li>
|
||||
}.into_view()
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ fn main() {
|
||||
<Route path="/demo/:id" view=Demo>
|
||||
<Route path="scoreboard" view=frontend::demo::scoreboard::Scoreboard>
|
||||
<Route path="general" view=frontend::demo::scoreboard::general::General />
|
||||
<Route path="utility" view=frontend::demo::scoreboard::utility::Utility />
|
||||
<Route path="utility" view=frontend::demo::scoreboard::utility::Utility />
|
||||
<Route path="" view=frontend::demo::scoreboard::general::General />
|
||||
</Route>
|
||||
<Route path="perround" view=frontend::demo::perround::PerRound />
|
||||
|
||||
@@ -31,9 +31,7 @@ fn steam_login(height: &'static str, width: &'static str) -> impl leptos::IntoVi
|
||||
}
|
||||
};
|
||||
|
||||
view! {
|
||||
{ tmp }
|
||||
}
|
||||
tmp
|
||||
}
|
||||
|
||||
#[leptos::component]
|
||||
|
||||
Reference in New Issue
Block a user