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]]
name = "demostf-frontend"
version = "1.0.0"
version = "1.0.1"
dependencies = [
"async-session",
"axum",

View file

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

30
flake.lock generated
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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