diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-19 20:53:09 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-19 20:53:09 +0300 |
| commit | d8daaebb4c5bf89250a7d35c97676dbb23ccbe3c (patch) | |
| tree | a17a43bd2e84222d6dd4d2958204cb2e0a87c362 /frontend | |
| parent | frontend: rename all chapters (diff) | |
| download | lphub-d8daaebb4c5bf89250a7d35c97676dbb23ccbe3c.tar.gz lphub-d8daaebb4c5bf89250a7d35c97676dbb23ccbe3c.tar.bz2 lphub-d8daaebb4c5bf89250a7d35c97676dbb23ccbe3c.zip | |
refactor: update readme and rules. use sdp for early demo confirmation
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/src/components/UploadRunDialog.tsx | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/frontend/src/components/UploadRunDialog.tsx b/frontend/src/components/UploadRunDialog.tsx index b241ed1..b26bbe6 100644 --- a/frontend/src/components/UploadRunDialog.tsx +++ b/frontend/src/components/UploadRunDialog.tsx | |||
| @@ -1,16 +1,12 @@ | |||
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import { UploadRunContent } from '../types/Content'; | 2 | import { UploadRunContent } from '../types/Content'; |
| 3 | import { DemoMessages, ScoreboardTempUpdate, SourceDemoParser, UserMessage } from '@nekz/sdp'; | 3 | import { ScoreboardTempUpdate, SourceDemoParser, NetMessages } from '@nekz/sdp'; |
| 4 | import fs from 'fs'; | ||
| 5 | |||
| 6 | |||
| 7 | 4 | ||
| 8 | import '../css/UploadRunDialog.css'; | 5 | import '../css/UploadRunDialog.css'; |
| 9 | import { Game } from '../types/Game'; | 6 | import { Game } from '../types/Game'; |
| 10 | import { Map } from '../types/Map'; | 7 | import { Map } from '../types/Map'; |
| 11 | import { API } from '../api/Api'; | 8 | import { API } from '../api/Api'; |
| 12 | import { useNavigate } from 'react-router-dom'; | 9 | import { useNavigate } from 'react-router-dom'; |
| 13 | import { SvcUserMessage } from '@nekz/sdp/script/src/types/NetMessages'; | ||
| 14 | 10 | ||
| 15 | interface UploadRunDialogProps { | 11 | interface UploadRunDialogProps { |
| 16 | token?: string; | 12 | token?: string; |
| @@ -108,16 +104,19 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 108 | return | 104 | return |
| 109 | } | 105 | } |
| 110 | } | 106 | } |
| 111 | // const demo = SourceDemoParser.default() | 107 | const demo = SourceDemoParser.default() |
| 112 | // .setOptions({ packets: true }) | 108 | .setOptions({ packets: true }) |
| 113 | // .parse(await uploadRunContent.host_demo.arrayBuffer()); | 109 | .parse(await uploadRunContent.host_demo.arrayBuffer()); |
| 114 | 110 | const scoreboard = demo.findPacket<NetMessages.SvcUserMessage>((message) => { | |
| 115 | // const scoreboardPacket = demo.findPacket(ScoreboardTempUpdate) | 111 | return message instanceof NetMessages.SvcUserMessage && message.userMessage instanceof ScoreboardTempUpdate; |
| 116 | // if (scoreboardPacket) { | 112 | }) |
| 117 | // console.log(scoreboardPacket) | 113 | |
| 118 | // } else { | 114 | if (!scoreboard) { |
| 119 | // console.log("couldnt find scoreboard packet") | 115 | alert("Error while processing demo: Unable to get scoreboard result. Is this not a CM demo?") |
| 120 | // } | 116 | return |
| 117 | } | ||
| 118 | const { portalScore, timeScore } = scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; | ||
| 119 | console.log(`Portal count: ${portalScore}. Ticks: ${timeScore}.`); | ||
| 121 | if (window.confirm("Are you sure you want to submit this run to LPHUB?")) { | 120 | if (window.confirm("Are you sure you want to submit this run to LPHUB?")) { |
| 122 | const message = await API.post_record(token, uploadRunContent); | 121 | const message = await API.post_record(token, uploadRunContent); |
| 123 | alert(message); | 122 | alert(message); |