diff options
Diffstat (limited to 'frontend/src/components/UploadRunDialog.tsx')
| -rw-r--r-- | frontend/src/components/UploadRunDialog.tsx | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/frontend/src/components/UploadRunDialog.tsx b/frontend/src/components/UploadRunDialog.tsx index dd609a1..445fe7c 100644 --- a/frontend/src/components/UploadRunDialog.tsx +++ b/frontend/src/components/UploadRunDialog.tsx | |||
| @@ -52,7 +52,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 52 | } else { | 52 | } else { |
| 53 | fileInputRefPartner.current?.click(); | 53 | fileInputRefPartner.current?.click(); |
| 54 | } | 54 | } |
| 55 | } | 55 | }; |
| 56 | 56 | ||
| 57 | const _handle_drag_over = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { | 57 | const _handle_drag_over = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { |
| 58 | e.preventDefault(); | 58 | e.preventDefault(); |
| @@ -62,7 +62,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 62 | } else { | 62 | } else { |
| 63 | setDragHighlightPartner(true); | 63 | setDragHighlightPartner(true); |
| 64 | } | 64 | } |
| 65 | } | 65 | }; |
| 66 | 66 | ||
| 67 | const _handle_drag_leave = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { | 67 | const _handle_drag_leave = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { |
| 68 | e.preventDefault(); | 68 | e.preventDefault(); |
| @@ -72,7 +72,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 72 | } else { | 72 | } else { |
| 73 | setDragHighlightPartner(false); | 73 | setDragHighlightPartner(false); |
| 74 | } | 74 | } |
| 75 | } | 75 | }; |
| 76 | 76 | ||
| 77 | const _handle_drop = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { | 77 | const _handle_drop = (e: React.DragEvent<HTMLDivElement>, host: boolean) => { |
| 78 | e.preventDefault(); | 78 | e.preventDefault(); |
| @@ -80,7 +80,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 80 | setDragHighlight(true); | 80 | setDragHighlight(true); |
| 81 | 81 | ||
| 82 | _handle_file_change(e.dataTransfer.files, host); | 82 | _handle_file_change(e.dataTransfer.files, host); |
| 83 | } | 83 | }; |
| 84 | 84 | ||
| 85 | const _handle_dropdowns = (dropdown: number) => { | 85 | const _handle_dropdowns = (dropdown: number) => { |
| 86 | setDropdown1Vis(false); | 86 | setDropdown1Vis(false); |
| @@ -91,7 +91,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 91 | setDropdown2Vis(!dropdown2Vis); | 91 | setDropdown2Vis(!dropdown2Vis); |
| 92 | document.querySelector("#dropdown2")?.scrollTo(0, 0); | 92 | document.querySelector("#dropdown2")?.scrollTo(0, 0); |
| 93 | } | 93 | } |
| 94 | } | 94 | }; |
| 95 | 95 | ||
| 96 | const _handle_game_select = async (game_id: string, game_name: string) => { | 96 | const _handle_game_select = async (game_id: string, game_name: string) => { |
| 97 | setLoading(true); | 97 | setLoading(true); |
| @@ -120,16 +120,16 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 120 | if (token) { | 120 | if (token) { |
| 121 | if (games[selectedGameID].is_coop) { | 121 | if (games[selectedGameID].is_coop) { |
| 122 | if (uploadRunContent.host_demo === null) { | 122 | if (uploadRunContent.host_demo === null) { |
| 123 | await message("Error", "You must select a host demo to upload.") | 123 | await message("Error", "You must select a host demo to upload."); |
| 124 | return | 124 | return; |
| 125 | } else if (uploadRunContent.partner_demo === null) { | 125 | } else if (uploadRunContent.partner_demo === null) { |
| 126 | await message("Error", "You must select a partner demo to upload.") | 126 | await message("Error", "You must select a partner demo to upload."); |
| 127 | return | 127 | return; |
| 128 | } | 128 | } |
| 129 | } else { | 129 | } else { |
| 130 | if (uploadRunContent.host_demo === null) { | 130 | if (uploadRunContent.host_demo === null) { |
| 131 | await message("Error", "You must select a demo to upload.") | 131 | await message("Error", "You must select a demo to upload."); |
| 132 | return | 132 | return; |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | const demo = SourceDemoParser.default() | 135 | const demo = SourceDemoParser.default() |
| @@ -137,24 +137,24 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 137 | .parse(await uploadRunContent.host_demo.arrayBuffer()); | 137 | .parse(await uploadRunContent.host_demo.arrayBuffer()); |
| 138 | const scoreboard = demo.findPacket<NetMessages.SvcUserMessage>((msg) => { | 138 | const scoreboard = demo.findPacket<NetMessages.SvcUserMessage>((msg) => { |
| 139 | return msg instanceof NetMessages.SvcUserMessage && msg.userMessage instanceof ScoreboardTempUpdate; | 139 | return msg instanceof NetMessages.SvcUserMessage && msg.userMessage instanceof ScoreboardTempUpdate; |
| 140 | }) | 140 | }); |
| 141 | 141 | ||
| 142 | if (!scoreboard) { | 142 | if (!scoreboard) { |
| 143 | await message("Error", "Error while processing demo: Unable to get scoreboard result. Either there is a demo that is corrupt or haven't been recorded in challenge mode.") | 143 | await message("Error", "Error while processing demo: Unable to get scoreboard result. Either there is a demo that is corrupt or haven't been recorded in challenge mode."); |
| 144 | return | 144 | return; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | if (!demo.mapName || !MapNames[demo.mapName]) { | 147 | if (!demo.mapName || !MapNames[demo.mapName]) { |
| 148 | await message("Error", "Error while processing demo: Invalid map name.") | 148 | await message("Error", "Error while processing demo: Invalid map name."); |
| 149 | return | 149 | return; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | if (selectedGameID === 0 && MapNames[demo.mapName] > 60) { | 152 | if (selectedGameID === 0 && MapNames[demo.mapName] > 60) { |
| 153 | await message("Error", "Error while processing demo: Invalid cooperative demo in singleplayer submission.") | 153 | await message("Error", "Error while processing demo: Invalid cooperative demo in singleplayer submission."); |
| 154 | return | 154 | return; |
| 155 | } else if (selectedGameID === 1 && MapNames[demo.mapName] <= 60) { | 155 | } else if (selectedGameID === 1 && MapNames[demo.mapName] <= 60) { |
| 156 | await message("Error", "Error while processing demo: Invalid singleplayer demo in cooperative submission.") | 156 | await message("Error", "Error while processing demo: Invalid singleplayer demo in cooperative submission."); |
| 157 | return | 157 | return; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | const { portalScore, timeScore } = scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; | 160 | const { portalScore, timeScore } = scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; |
| @@ -207,7 +207,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 207 | </div> | 207 | </div> |
| 208 | <div style={{ top: "110px" }} className={dropdown1Vis ? "upload-run-dropdown" : "upload-run-dropdown hidden"}> | 208 | <div style={{ top: "110px" }} className={dropdown1Vis ? "upload-run-dropdown" : "upload-run-dropdown hidden"}> |
| 209 | {games.map((game) => ( | 209 | {games.map((game) => ( |
| 210 | <div onClick={() => { _handle_game_select(game.id.toString(), game.name); _handle_dropdowns(1) }} key={game.id}>{game.name}</div> | 210 | <div onClick={() => { _handle_game_select(game.id.toString(), game.name); _handle_dropdowns(1); }} key={game.id}>{game.name}</div> |
| 211 | ))} | 211 | ))} |
| 212 | </div> | 212 | </div> |
| 213 | </div> | 213 | </div> |
| @@ -219,7 +219,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 219 | 219 | ||
| 220 | <div> | 220 | <div> |
| 221 | <h3 style={{ margin: "10px 0px" }}>Host Demo</h3> | 221 | <h3 style={{ margin: "10px 0px" }}>Host Demo</h3> |
| 222 | <div onClick={() => { _handle_file_click(true) }} onDragOver={(e) => { _handle_drag_over(e, true) }} onDrop={(e) => { _handle_drop(e, true) }} onDragLeave={(e) => { _handle_drag_leave(e, true) }} className={`upload-run-drag-area ${dragHightlight ? "upload-run-drag-area-highlight" : ""} ${uploadRunContent.host_demo ? "upload-run-drag-area-hidden" : ""}`}> | 222 | <div onClick={() => { _handle_file_click(true); }} onDragOver={(e) => { _handle_drag_over(e, true); }} onDrop={(e) => { _handle_drop(e, true); }} onDragLeave={(e) => { _handle_drag_leave(e, true); }} className={`upload-run-drag-area ${dragHightlight ? "upload-run-drag-area-highlight" : ""} ${uploadRunContent.host_demo ? "upload-run-drag-area-hidden" : ""}`}> |
| 223 | <input ref={fileInputRef} type="file" name="host_demo" id="host_demo" accept=".dem" onChange={(e) => _handle_file_change(e.target.files, true)} /> | 223 | <input ref={fileInputRef} type="file" name="host_demo" id="host_demo" accept=".dem" onChange={(e) => _handle_file_change(e.target.files, true)} /> |
| 224 | {!uploadRunContent.host_demo ? | 224 | {!uploadRunContent.host_demo ? |
| 225 | <div> | 225 | <div> |
| @@ -239,7 +239,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 239 | <> | 239 | <> |
| 240 | <div> | 240 | <div> |
| 241 | <h3 style={{ margin: "10px 0px" }}>Partner Demo</h3> | 241 | <h3 style={{ margin: "10px 0px" }}>Partner Demo</h3> |
| 242 | <div onClick={() => { _handle_file_click(false) }} onDragOver={(e) => { _handle_drag_over(e, false) }} onDrop={(e) => { _handle_drop(e, false) }} onDragLeave={(e) => { _handle_drag_leave(e, false) }} className={`upload-run-drag-area ${dragHightlightPartner ? "upload-run-drag-area-highlight-partner" : ""} ${uploadRunContent.partner_demo ? "upload-run-drag-area-hidden" : ""}`}> | 242 | <div onClick={() => { _handle_file_click(false); }} onDragOver={(e) => { _handle_drag_over(e, false); }} onDrop={(e) => { _handle_drop(e, false); }} onDragLeave={(e) => { _handle_drag_leave(e, false); }} className={`upload-run-drag-area ${dragHightlightPartner ? "upload-run-drag-area-highlight-partner" : ""} ${uploadRunContent.partner_demo ? "upload-run-drag-area-hidden" : ""}`}> |
| 243 | <input ref={fileInputRefPartner} type="file" name="partner_demo" id="partner_demo" accept=".dem" onChange={(e) => _handle_file_change(e.target.files, false)} /> {!uploadRunContent.partner_demo ? | 243 | <input ref={fileInputRefPartner} type="file" name="partner_demo" id="partner_demo" accept=".dem" onChange={(e) => _handle_file_change(e.target.files, false)} /> {!uploadRunContent.partner_demo ? |
| 244 | <div> | 244 | <div> |
| 245 | <span>Drag and drop</span> | 245 | <span>Drag and drop</span> |