This commit is contained in:
Robin Appelman 2024-11-22 22:17:21 +01:00
commit b08267a08c
10 changed files with 318 additions and 304 deletions

2
Cargo.lock generated
View file

@ -953,7 +953,7 @@ dependencies = [
[[package]] [[package]]
name = "demostf-frontend" name = "demostf-frontend"
version = "1.0.0" version = "1.0.1"
dependencies = [ dependencies = [
"async-session", "async-session",
"axum", "axum",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "demostf-frontend" name = "demostf-frontend"
version = "1.0.0" version = "1.0.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

30
flake.lock generated
View file

@ -22,17 +22,14 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1731933812, "lastModified": 1732198790,
"narHash": "sha256-PeuRDDq1DcHxbOmXWb3nWMp5PqWUn5PSKimNbUzWEaQ=", "narHash": "sha256-VNTFKcX52PRh3I88ofYTyBWCtqVQB3fVIMO64HHs3+0=",
"owner": "nix-community", "path": "/home/robin/Projects/flakelight",
"repo": "flakelight", "type": "path"
"rev": "f4b26f683be5c9ac1ec05f968dbbcb35f4bb6346",
"type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "path": "/home/robin/Projects/flakelight",
"repo": "flakelight", "type": "path"
"type": "github"
} }
}, },
"mill-scale": { "mill-scale": {
@ -44,17 +41,14 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1732197065, "lastModified": 1732212005,
"narHash": "sha256-Lyosd/rJHFp1xnWPNhukQkW1hFtIiIiVDxQ+fcVypgI=", "narHash": "sha256-t2+yKoxZe2JkvyHkJAAyyLS6N8yzyx0o95DuzHqv7JA=",
"owner": "icewind1991", "path": "/home/robin/Projects/mill-scale",
"repo": "mill-scale", "type": "path"
"rev": "8051d162308a80dde168b7efe012bfa1363be4ba",
"type": "github"
}, },
"original": { "original": {
"owner": "icewind1991", "path": "/home/robin/Projects/mill-scale",
"repo": "mill-scale", "type": "path"
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {

View file

@ -2,11 +2,13 @@
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05"; nixpkgs.url = "nixpkgs/nixos-24.05";
flakelight = { flakelight = {
url = "github:nix-community/flakelight"; # url = "github:nix-community/flakelight";
url = "path:/home/robin/Projects/flakelight";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
mill-scale = { mill-scale = {
url = "github:icewind1991/mill-scale"; # url = "github:icewind1991/mill-scale";
url = "path:/home/robin/Projects/mill-scale";
inputs.flakelight.follows = "flakelight"; inputs.flakelight.follows = "flakelight";
}; };
npmlock2nix = { npmlock2nix = {
@ -37,6 +39,8 @@
]; ];
toolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; toolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
tools = pkgs: with pkgs; [ tools = pkgs: with pkgs; [
bacon
cargo-edit
nodejs nodejs
nodePackages.svgo nodePackages.svgo
typescript typescript

View file

@ -5,18 +5,21 @@ export interface AnalyseMenuProps {
isShared: boolean; isShared: boolean;
} }
export function AnalyseMenu({sessionName, onShare, canShare, isShared}:AnalyseMenuProps) { export function AnalyseMenu(props: AnalyseMenuProps) {
const loc = () => window.location.toString().replace(/\#.*/, '') + '#' + props.sessionName;
const loc = window.location.toString().replace(/\#.+/, '') + '#' + sessionName; const shareText = () => (props.isShared) ?
const shareText = (isShared) ? <input class="share-text" value={loc()} readOnly={true}
<input class="share-text" value={loc} readOnly={true}
title="Use this link to join the current session" title="Use this link to join the current session"
style={{width: `${(loc.length*8)}px`}} style={{width: `${(loc().length * 8)}px`}}
onFocus={(event)=>{(event.target as HTMLInputElement).select()}}/> : ''; onFocus={(event) => {
(event.target as HTMLInputElement).select()
}}/> : '';
const shareButton = (canShare) ? <div class="analyse-menu"> const shareButton = () => (props.canShare) ? <div class="analyse-menu">
<button class="share-session" title="Start a shared session" <button class="share-session" title="Start a shared session"
onClick={()=>{onShare()}}/> onClick={() => {
props.onShare()
}}/>
{shareText} {shareText}
</div> : ''; </div> : '';

View file

@ -34,8 +34,12 @@ export const Analyser = (props: AnalyseProps) => {
if (update["tick"]) { if (update["tick"]) {
setTick(update["tick"]); setTick(update["tick"]);
} }
if (update.hasOwnProperty("playing")) {
if (update["playing"]) { if (update["playing"]) {
setPlaying(update["playing"]); play();
} else {
pause();
}
} }
} }
@ -46,7 +50,7 @@ export const Analyser = (props: AnalyseProps) => {
setTick(Math.floor(parsed)); setTick(Math.floor(parsed));
} else { } else {
const name = window.location.hash.substring(1); const name = window.location.hash.substring(1);
Session.join(name, onUpdate); session = Session.join(name, onUpdate);
setSessionName(name); setSessionName(name);
} }
} }
@ -86,7 +90,7 @@ export const Analyser = (props: AnalyseProps) => {
setPlaying(true); setPlaying(true);
requestAnimationFrame(animFrame); requestAnimationFrame(animFrame);
if (session) { if (session) {
session.update({playing: false}); session.update({playing: true});
} }
} }
@ -98,7 +102,7 @@ export const Analyser = (props: AnalyseProps) => {
} }
} }
const syncPlayTick = debounce(500, () => { const syncPlayTick = throttle(2500, () => {
if (session) { if (session) {
session.update({ session.update({
playing: playing(), playing: playing(),

View file

@ -14,6 +14,7 @@ export class Session {
this.sessionName = name; this.sessionName = name;
this.initialState = initialState; this.initialState = initialState;
this.onState = onState; this.onState = onState;
this.open();
} }
public static create(state: PlaybackState): Session { public static create(state: PlaybackState): Session {
@ -98,7 +99,7 @@ export class Session {
tick: update["tick"] tick: update["tick"]
})); }));
} }
if (update["playing"]) { if (update.hasOwnProperty("playing")) {
this.socket.send(JSON.stringify({ this.socket.send(JSON.stringify({
type: 'play', type: 'play',
session: this.sessionName, session: this.sessionName,

View file

@ -293,10 +293,10 @@ impl Render for DemoFormat {
MapMode::Ultiduo => "Ultiduo", MapMode::Ultiduo => "Ultiduo",
MapMode::Bball => "BBall", MapMode::Bball => "BBall",
MapMode::Other => match self.player_count { MapMode::Other => match self.player_count {
17 | 18 | 19 => "HL", 17..=19 => "HL",
15 | 14 => "Prolander", 14..=15 => "Prolander",
13 | 12 | 11 => "6v6", 11..=13 => "6v6",
7 | 8 | 9 => "4v4", 7..=9 => "4v4",
_ => "Other", _ => "Other",
}, },
}; };

View file

@ -19,7 +19,7 @@
margin: 10px; margin: 10px;
border: none; border: none;
cursor: pointer; cursor: pointer;
background-image: url("images/link_white.svg"); background-image: url("inline://images//link_white.svg");
background-size: contain; background-size: contain;
&:active, &:focus { &:active, &:focus {

View file

@ -19,6 +19,10 @@
bottom: 0; bottom: 0;
left: 64px; left: 64px;
width: calc(100% - 64px); width: calc(100% - 64px);
& .timeline-progress[disabled] {
opacity: 0.2;
}
} }
& .play-pause-button { & .play-pause-button {
@ -35,6 +39,10 @@
&:focus, &:active { &:focus, &:active {
outline: none; outline: none;
} }
&[disabled] {
opacity: 0.2;
}
} }
} }