fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
cbf5f06
main
1import { MemoryRouter as Router , Routes , Route } from 'react-router-dom' ; 2import { 3createRef , 4RefObject , 5useCallback , 6useEffect , 7useMemo , 8useRef , 9useState , 10} from 'react' ; 11import { 12Alert , 13AppBar , 14Avatar , 15Backdrop , 16Box , 17Button , 18Checkbox , 19CircularProgress , 20Dialog , 21DialogActions , 22DialogContent , 23DialogTitle , 24Divider , 25FormControl , 26IconButton , 27InputBase , 28InputLabel , 29List , 30ListItem , 31ListItemButton , 32ListItemText , 33MenuItem , 34Paper , 35Select , 36Stack , 37Toolbar , 38Tooltip , 39Typography , 40} from '@mui/material' ; 41import { 42ArrowDownward , 43ArrowUpward , 44Backup , 45Close , 46DeleteForever , 47DeleteForeverOutlined , 48Edit , 49Eject , 50FolderOpen , 51HourglassTop , 52NotificationsActive , 53Refresh , 54Search , 55} from '@mui/icons-material' ; 56import styled from '@emotion/styled' ; 57import { format } from 'date-fns' ; 58import { GlobalHotKeys } from 'react-hotkeys' ; 59import { 60SlugType , 61Tournament as ParryggTournament , 62MatchResult , 63} from '@parry-gg/client' ; 64import { 65AdminedTournament , 66ChallongeMatchItem , 67ChallongeTournament , 68Context , 69ContextPlayers , 70ContextScore , 71ContextSlot , 72CopyHostFormat , 73CopyHostOrClient , 74CopySettings , 75EnforcerSetting , 76GuideState , 77Id , 78InvalidReplay , 79Mode , 80OfflineModeStatus , 81Output , 82ParryggGame , 83PlayerOverrides , 84RendererOfflineModeTournament , 85Replay , 86ReportSettings , 87SelectedSetChain , 88Set , 89SlpDownloadStatus , 90StartggSet , 91State , 92Stream , 93Tournament , 94} from '../common/types' ; 95import { DraggableChip , DroppableChip } from './DragAndDrop' ; 96import ReplayList , { SkewReplay } from './ReplayList' ; 97import CopyControls from './CopyControls' ; 98import SetControls from './SetControls' ; 99import ErrorDialog from './ErrorDialog' ; 100import Settings from './Settings' ; 101import ManualReport from './ManualReport' ; 102import { 103calledColor , 104characterColorIndexLength , 105characterNames , 106frameMsDivisor , 107stageNames , 108startedColor , 109} from '../common/constants' ; 110import ManualBar from './ManualBar' ; 111import GuidedDialog from './GuidedDialog' ; 112import StartggTournamentForm from './StartggTournamentForm' ; 113import ChallongeTournamentForm from './ChallongeTournamentForm' ; 114import ParryggTournamentForm from './ParryggTournamentForm' ; 115import ResetSet from './ResetSet' ; 116import AssignStream from './AssignStream' ; 117import getCharacterIcon from './getCharacterIcon' ; 118import RightColumn from './RightColumn' ; 119import { WindowEvent } from './setWindowEventListener' ; 120import SlpDownloadModal from './SlpDownloadModal' ; 121import { assertInteger , assertString } from '../common/asserts' ; 122import OfflineModeConnection from './OfflineModeConnection' ; 123 124const ENFORCER_VERSION = '2.3.3' ; 125 126const Bottom = styled ( Paper ) ` 127height: 147px; 128` ; 129 130const BottomColumns = styled ( Stack ) ` 131box-sizing: border-box; 132height: 100%; 133padding: 8px; 134` ; 135 136const TopColumns = styled ( Stack ) ` 137flex-grow: 1; 138max-height: calc(100% - 147px); 139padding: 0 8px; 140` ; 141 142const TopColumn = styled ( Stack ) ` 143flex-shrink: 1; 144overflow-y: scroll; 145padding: 64px 0 8px; 146scroll-padding-top: 64px; 147` ; 148 149const AppBarSection = styled ( Stack ) ` 150flex-shrink: 1; 151padding: 8px; 152` ; 153 154const EMPTY_SET :Set = { 155id :0 , 156sggId :null , 157state :State . PENDING , 158round :0 , 159fullRoundText :'' , 160winnerId :null , 161entrant1Id :0 , 162entrant1Participants :[ 163{ 164id :0 , 165displayName :'' , 166prefix :'' , 167pronouns :'' , 168}, 169], 170entrant1Score :null , 171entrant2Id :0 , 172entrant2Participants :[ 173{ 174id :0 , 175displayName :'' , 176prefix :'' , 177pronouns :'' , 178}, 179], 180entrant2Score :null , 181gameScores :[], 182stream :null , 183station :null , 184ordinal :null , 185wasReported :false , 186updatedAtMs :0 , 187completedAtMs :0 , 188}; 189 190const EMPTY_SELECTED_SET_CHAIN :SelectedSetChain = { 191event :undefined , 192phase :undefined , 193phaseGroup :undefined , 194}; 195 196function hasTimeSkew ( replays :Replay []) { 197if ( replays . length < 2 ) { 198return false ; 199} 200 201for ( let i = 0 ; i < replays . length - 1 ; i += 1 ) { 202const firstMs = replays [ i ]. startAt . getTime (); 203const secondMs = replays [ i + 1 ]. startAt . getTime (); 204if ( secondMs - firstMs > 3600000 ) { 205return true ; 206} 207} 208return false ; 209} 210 211function applyAllReplaysSelected ( allReplays :Replay [], selected :boolean ) { 212allReplays 213. filter (( replay ) => replay . invalidReasons . length === 0 ) 214. forEach (( replay ) => { 215replay . selected = selected ; 216}); 217} 218 219function Hello () { 220const [ slpDownloadStatus , setSlpDownloadStatus ] = useState < SlpDownloadStatus >( 221{ status :'idle' }, 222); 223 224useEffect (() => { 225const handler = ( _event :any , status :SlpDownloadStatus ) => { 226setSlpDownloadStatus ( status ); 227}; 228window . electron . onSlpDownloadStatus ( handler ); 229}, []); 230 231const [ errors , setErrors ] = useState < string []>([]); 232const [ errorDialogOpen , setErrorDialogOpen ] = useState ( false ); 233const showErrorDialog = ( messages :string []) => { 234setErrors ( messages ); 235setErrorDialogOpen ( true ); 236}; 237 238// settings 239const [ mode , setMode ] = useState < Mode >( Mode . STARTGG ); 240const [ enforcerSetting , setEnforcerSetting ] = useState ( EnforcerSetting . NONE ); 241const [ vlerkMode , setVlerkMode ] = useState ( false ); 242const [ vlerkModeExternalId , setVlerkModeExternalId ] = useState ( - 1 ); 243const [ vlerkModeColorIndex , setVlerkModeColorIndex ] = useState ( - 1 ); 244const [ vlerkModeFilterLastIndex , setVlerkModeFilterLastIndex ] = useState ( 0 ); 245const [ vlerkModeFilterNotFound , setVlerkModeFilterNotFound ] = useState ( false ); 246const [ guidedMode , setGuidedMode ] = useState ( false ); 247const [ fileNameFormat , setFileNameFormat ] = useState ( '' ); 248const [ folderNameFormat , setFolderNameFormat ] = useState ( '' ); 249const [ smuggleCostumeIndex , setSmuggleCostumeIndex ] = useState ( false ); 250const [ appVersion , setAppVersion ] = useState ( '' ); 251const [ latestAppVersion , setLatestAppVersion ] = useState ( '' ); 252const [ hideCopyButton , setHideCopyButton ] = useState ( false ); 253const [ copySettings , setCopySettings ] = useState < CopySettings >({ 254output :Output . FILES , 255writeContext :false , 256writeDisplayNames :false , 257writeFileNames :false , 258writeStartTimes :false , 259}); 260const [ reportSettings , setReportSettings ] = useState < ReportSettings >({ 261alsoCopy :false , 262alsoDelete :false , 263}); 264const [ adminedTournaments , setAdminedTournaments ] = useState < 265AdminedTournament [] 266>([]); 267const [ gettingAdminedTournaments , setGettingAdminedTournaments ] = 268useState ( true ); 269 270// initial state 271const [ dir , setDir ] = useState ( '' ); 272const [ dirInit , setDirInit ] = useState ( false ); 273const [ isUsb , setIsUsb ] = useState ( false ); 274const [ copyDir , setCopyDir ] = useState ( '' ); 275const [ host , setHost ] = useState < CopyHostOrClient >({ 276name :'' , 277address :'' , 278}); 279const [ hostFormat , setHostFormat ] = useState < CopyHostFormat >({ 280fileNameFormat :'' , 281folderNameFormat :'' , 282}); 283const [ useLAN , setUseLAN ] = useState ( false ); 284const [ selectedSet , setSelectedSet ] = useState < Set >( EMPTY_SET ); 285const [ selectedSetChain , setSelectedSetChain ] = useState ( 286EMPTY_SELECTED_SET_CHAIN , 287); 288const [ startggTournament , setStartggTournament ] = useState < Tournament >({ 289slug :'' , 290name :'' , 291location :'' , 292events :[], 293stations :[], 294streams :[], 295}); 296const [ challongeTournaments , setChallongeTournaments ] = useState ( 297new Map < string , ChallongeTournament >(), 298); 299const [ selectedChallongeTournament , setSelectedChallongeTournament ] = 300useState ({ name :'' , slug :'' , tournamentType :'' }); 301const [ parryggTournament , setParryggTournament ] = 302useState < ParryggTournament . AsObject >(); 303const parryggSlug = useMemo ( 304() => 305parryggTournament ?. slugsList . find ( 306( slug ) => slug . type === SlugType . SLUG_TYPE_PRIMARY , 307)?. slug || '' , 308[ parryggTournament ], 309); 310const [ offlineModeStatus , setOfflineModeStatus ] = useState < OfflineModeStatus >( 311{ 312addressOrHost :'' , 313error :'' , 314}, 315); 316const [ offlineModeTournament , setOfflineModeTournament ] = 317useState < RendererOfflineModeTournament >({ 318id :0 , 319name :'' , 320slug :'' , 321location :'' , 322events :[], 323participants :[], 324stations :[], 325streams :[], 326}); 327const [ manualNames , setManualNames ] = useState < string []>([]); 328const [ undoSubdir , setUndoSubdir ] = useState ( '' ); 329const tournamentSet = useMemo ( 330() => 331( mode === Mode . STARTGG && startggTournament . slug . length > 0 ) || 332( mode === Mode . CHALLONGE && challongeTournaments . size > 0 ) || 333( mode === Mode . PARRYGG && parryggSlug . length > 0 ) || 334( mode === Mode . OFFLINE_MODE && 335offlineModeStatus . addressOrHost . length > 0 && 336offlineModeStatus . error . length === 0 ) || 337( mode === Mode . MANUAL && manualNames . length > 0 ), 338[ 339challongeTournaments , 340manualNames . length , 341mode , 342offlineModeStatus , 343parryggSlug , 344startggTournament , 345], 346); 347const copyDirSet = useMemo (() => copyDir . length > 0 , [ copyDir ]); 348const guidedDialogOpen = useMemo ( 349() => guidedMode && ( ! tournamentSet || ! copyDirSet ), 350[ copyDirSet , guidedMode , tournamentSet ], 351); 352useEffect (() => { 353const inner = async () => { 354const appVersionPromise = window . electron . getVersion (); 355const modePromise = window . electron . getMode (); 356const useLANPromise = window . electron . getUseLAN (); 357const enforcerSettingPromise = window . electron . getEnforcerSetting (); 358const vlerkModePromise = window . electron . getVlerkMode (); 359const guidedModePromise = window . electron . getGuidedMode (); 360const fileNameFormatPromise = window . electron . getFileNameFormat (); 361const folderNameFormatPromise = window . electron . getFolderNameFormat (); 362const smuggleCostumeIndexPromise = 363window . electron . getSmuggleCostumeIndex (); 364const hideCopyButtonPromise = window . electron . getHideCopyButton (); 365const copySettingsPromise = window . electron . getCopySettings (); 366const reportSettingsPromise = window . electron . getReportSettings (); 367 368// initial state 369const replaysDirPromise = window . electron . getReplaysDir (); 370const copyDirPromise = window . electron . getCopyDir (); 371const hostPromise = window . electron . getCopyHost (); 372const hostFormatPromise = window . electron . getCopyHostFormat (); 373const tournamentPromise = window . electron . getCurrentTournament (); 374const selectedSetPromise = window . electron . getSelectedSet (); 375const selectedSetChainPromise = window . electron . getSelectedSetChain (); 376const challongeTournamentsPromise = 377window . electron . getCurrentChallongeTournaments (); 378const selectedChallongeTournamentPromise = 379window . electron . getSelectedChallongeTournament (); 380const selectedParryggTournamentPromise = 381window . electron . getCurrentParryggTournament (); 382const offlineModeStatusPromise = window . electron . getOfflineModeStatus (); 383const offlineModeTournamentPromise = 384window . electron . getCurrentOfflineModeTournament (); 385const manualNamesPromise = window . electron . getManualNames (); 386const undoSubdirPromise = window . electron . getUndoSubdir (); 387 388// req network 389const latestAppVersionPromise = window . electron . getLatestVersion (); 390const tournamentsPromise = window . electron . getTournaments (); 391 392setAppVersion ( await appVersionPromise ); 393setMode ( await modePromise ); 394setUseLAN ( await useLANPromise ); 395setEnforcerSetting ( await enforcerSettingPromise ); 396setFileNameFormat ( await fileNameFormatPromise ); 397setFolderNameFormat ( await folderNameFormatPromise ); 398setVlerkMode ( await vlerkModePromise ); 399setGuidedMode ( await guidedModePromise ); 400setSmuggleCostumeIndex ( await smuggleCostumeIndexPromise ); 401setHideCopyButton ( await hideCopyButtonPromise ); 402setCopySettings ( await copySettingsPromise ); 403setReportSettings ( await reportSettingsPromise ); 404 405// initial state 406const replaysDir = await replaysDirPromise ; 407setDir ( replaysDir ); 408setDirInit ( replaysDir . length > 0 ); 409setCopyDir ( await copyDirPromise ); 410setHost ( await hostPromise ); 411setHostFormat ( await hostFormatPromise ); 412const currentTournament = await tournamentPromise ; 413if ( currentTournament ) { 414setStartggTournament ( currentTournament ); 415} 416const initSelectedSet = await selectedSetPromise ; 417if ( initSelectedSet ) { 418setSelectedSet ( initSelectedSet ); 419} 420const initSelectedSetChain = await selectedSetChainPromise ; 421const { event, phase, phaseGroup} = initSelectedSetChain ; 422setSelectedSetChain ({ 423 event, 424 phase, 425 phaseGroup, 426}); 427setChallongeTournaments ( await challongeTournamentsPromise ); 428const initSelectedChallongeTournament = 429await selectedChallongeTournamentPromise ; 430if ( initSelectedChallongeTournament ) { 431setSelectedChallongeTournament ( initSelectedChallongeTournament ); 432} 433const initSelectedParryggTournament = 434await selectedParryggTournamentPromise ; 435if ( initSelectedParryggTournament ) { 436setParryggTournament ( initSelectedParryggTournament ); 437} 438setOfflineModeStatus ( await offlineModeStatusPromise ); 439setOfflineModeTournament ( await offlineModeTournamentPromise ); 440setManualNames ( await manualNamesPromise ); 441setUndoSubdir ( await undoSubdirPromise ); 442 443// req network 444const errorMessages :string [] = []; 445try { 446setLatestAppVersion ( await latestAppVersionPromise ); 447} catch ( e :any ) { 448errorMessages . push ( 449`Unable to check for updates: ${ e instanceof Error ? e . message : e } ` , 450); 451} 452try { 453setAdminedTournaments ( await tournamentsPromise ); 454} catch ( e :any ) { 455errorMessages . push ( 456`Unable to fetch admined tournaments: ${ 457e instanceof Error ? e . message : e 458} ` , 459); 460} 461setGettingAdminedTournaments ( false ); 462if ( errorMessages . length > 0 ) { 463showErrorDialog ( errorMessages ); 464} 465}; 466inner (); 467}, []); 468 469const stations = useMemo (() => { 470if ( mode === Mode . STARTGG ) { 471return startggTournament . stations ; 472} 473if ( mode === Mode . OFFLINE_MODE ) { 474return offlineModeTournament . stations ; 475} 476return []; 477}, [ mode , offlineModeTournament . stations , startggTournament . stations ]); 478const streams = useMemo (() => { 479if ( mode === Mode . STARTGG ) { 480return startggTournament . streams ; 481} 482if ( mode === Mode . OFFLINE_MODE ) { 483return offlineModeTournament . streams ; 484} 485return []; 486}, [ mode , offlineModeTournament . streams , startggTournament . streams ]); 487 488useEffect (() => { 489window . electron . onCopyHost ( async ( event , newHost ) => { 490if ( ! newHost . address ) { 491const fileNameFormatPromise = window . electron . getFileNameFormat (); 492const folderNameFormatPromise = window . electron . getFolderNameFormat (); 493const copySettingsPromise = window . electron . getCopySettings (); 494const enforcerSettingPromise = window . electron . getEnforcerSetting (); 495const smuggleCostumeIndexPromise = 496window . electron . getSmuggleCostumeIndex (); 497setFileNameFormat ( await fileNameFormatPromise ); 498setFolderNameFormat ( await folderNameFormatPromise ); 499setCopySettings ( await copySettingsPromise ); 500setEnforcerSetting ( await enforcerSettingPromise ); 501setSmuggleCostumeIndex ( await smuggleCostumeIndexPromise ); 502setHostFormat ({ fileNameFormat :'' , folderNameFormat :'' }); 503} 504setHost ( newHost ); 505}); 506window . electron . onCopyHostFormat (( event , newHostFormat ) => { 507if ( newHostFormat . fileNameFormat ) { 508setFileNameFormat ( newHostFormat . fileNameFormat ); 509} 510if ( newHostFormat . folderNameFormat ) { 511setFolderNameFormat ( newHostFormat . folderNameFormat ); 512} 513if ( newHostFormat . copySettings !== undefined ) { 514setCopySettings ({ ...newHostFormat . copySettings , output :Output . ZIP }); 515} 516if ( newHostFormat . enforcerSetting !== undefined ) { 517setEnforcerSetting ( newHostFormat . enforcerSetting ); 518} 519if ( newHostFormat . smuggleCostumeIndex !== undefined ) { 520setSmuggleCostumeIndex ( newHostFormat . smuggleCostumeIndex ); 521} 522setHostFormat ( newHostFormat ); 523}); 524window . electron . onOfflineModeStatus (( event , newOfflineModeStatus ) => { 525setOfflineModeStatus ( newOfflineModeStatus ); 526}); 527}, []); 528 529const [ batchActives , setBatchActives ] = useState < 530[ 531{ active :boolean ; teamI :number }, 532{ active :boolean ; teamI :number }, 533{ active :boolean ; teamI :number }, 534{ active :boolean ; teamI :number }, 535] 536>([ 537{ active :false , teamI :- 1 }, 538{ active :false , teamI :- 1 }, 539{ active :false , teamI :- 1 }, 540{ active :false , teamI :- 1 }, 541]); 542const numBatchActive = batchActives . filter ( 543( batchActive ) => batchActive . active , 544). length ; 545const [ overrides , setOverrides ] = useState < 546[ PlayerOverrides , PlayerOverrides , PlayerOverrides , PlayerOverrides ] 547>([ 548{ 549displayName :'' , 550entrantId :0 , 551participantId :0 , 552prefix :'' , 553pronouns :'' , 554}, 555{ 556displayName :'' , 557entrantId :0 , 558participantId :0 , 559prefix :'' , 560pronouns :'' , 561}, 562{ 563displayName :'' , 564entrantId :0 , 565participantId :0 , 566prefix :'' , 567pronouns :'' , 568}, 569{ 570displayName :'' , 571entrantId :0 , 572participantId :0 , 573prefix :'' , 574pronouns :'' , 575}, 576]); 577const resetOverrides = () => { 578setOverrides ([ 579{ 580displayName :'' , 581entrantId :0 , 582participantId :0 , 583prefix :'' , 584pronouns :'' , 585}, 586{ 587displayName :'' , 588entrantId :0 , 589participantId :0 , 590prefix :'' , 591pronouns :'' , 592}, 593{ 594displayName :'' , 595entrantId :0 , 596participantId :0 , 597prefix :'' , 598pronouns :'' , 599}, 600{ 601displayName :'' , 602entrantId :0 , 603participantId :0 , 604prefix :'' , 605pronouns :'' , 606}, 607]); 608}; 609const [ dq , setDq ] = useState ({ displayName :'' , entrantId :0 }); 610const resetDq = useCallback (() => { 611setDq ({ displayName :'' , entrantId :0 }); 612}, []); 613 614// Replay list 615const [ allReplaysSelected , setAllReplaysSelected ] = useState ( true ); 616const [ dirDeleteDialogOpen , setDirDeleteDialogOpen ] = useState ( false ); 617const [ dirDeleting , setDirDeleting ] = useState ( false ); 618const [ dirExists , setDirExists ] = useState ( true ); 619const [ replays , setReplays ] = useState < Replay []>([]); 620const [ replayRefs , setReplayRefs ] = useState < RefObject < HTMLDivElement >[]>([]); 621const [ invalidReplays , setInvalidReplays ] = useState < InvalidReplay []>([]); 622const [ gettingReplays , setGettingReplays ] = useState ( false ); 623let hasRemainingReplays = false ; 624const selectedReplays :Replay [] = []; 625replays . forEach (( replay ) => { 626if ( replay . selected ) { 627selectedReplays . push ( replay ); 628hasRemainingReplays = false ; 629} else { 630hasRemainingReplays = true ; 631} 632}); 633const getNewBatchActives = ( newReplays :Replay []) => { 634const isPlayerArr :[ boolean , boolean , boolean , boolean ] = 635newReplays . length > 0 636 ?newReplays 637. map ( 638( replay ) => 639replay . players . map ( 640( player ) => 641player . playerType === 0 || player . playerType === 1 , 642) as [ boolean , boolean , boolean , boolean ], 643) 644. reduce ( 645( accArr , curArr ) => [ 646accArr [ 0 ] && curArr [ 0 ], 647accArr [ 1 ] && curArr [ 1 ], 648accArr [ 2 ] && curArr [ 2 ], 649accArr [ 3 ] && curArr [ 3 ], 650], 651[ true , true , true , true ], 652) 653 :[ false , false , false , false ]; 654const teamIndiciesArr = [ 655new Map < number , boolean >(), 656new Map < number , boolean >(), 657new Map < number , boolean >(), 658new Map < number , boolean >(), 659]; 660newReplays . forEach (( replay ) => { 661const teamIdsSeen :number [] = []; 662for ( let i = 0 ; i < 4 ; i += 1 ) { 663const { teamId} = replay . players [ i ]; 664if ( teamId === 0 || teamId === 1 || teamId === 2 ) { 665const teamI = teamIdsSeen . indexOf ( teamId ); 666if ( teamI === - 1 ) { 667teamIndiciesArr [ i ]. set ( teamIdsSeen . length , true ); 668teamIdsSeen . push ( teamId ); 669} else { 670teamIndiciesArr [ i ]. set ( teamI , true ); 671} 672} else { 673teamIndiciesArr [ i ]. set ( - 1 , true ); 674} 675} 676}); 677const teamsConsistent = teamIndiciesArr . every ( 678( teamIndicies ) => teamIndicies . size === 1 , 679); 680return isPlayerArr . map (( isPlayer , i ) => ({ 681active :teamsConsistent && isPlayer , 682teamI :teamsConsistent ?Array . from ( teamIndiciesArr [ i ]. keys ())[ 0 ] :- 1 , 683})) as [ 684{ active :boolean ; teamI :number }, 685{ active :boolean ; teamI :number }, 686{ active :boolean ; teamI :number }, 687{ active :boolean ; teamI :number }, 688]; 689}; 690const [ replayLoadCount , setReplayLoadCount ] = useState ( 0 ); 691const copyControlsRef = useRef < HTMLDivElement | null >( null ); 692useEffect (() => { 693if ( copyControlsRef . current ) { 694copyControlsRef . current . scrollIntoView ( false ); 695} 696}, [ replayLoadCount ]); 697const [ skewDetected , setSkewDetected ] = useState ( false ); 698const [ skewDialogOpen , setSkewDialogOpen ] = useState ( false ); 699const [ wasDeleted , setWasDeleted ] = useState ( false ); 700const chooseDir = async () => { 701setGettingReplays ( true ); 702const newDir = await window . electron . chooseReplaysDir (); 703if ( newDir && newDir !== dir ) { 704const { 705replays :newReplays , 706invalidReplays :newInvalidReplays , 707replayLoadCount :newReplayLoadCount , 708} = await window . electron . getReplaysInDir (); 709setAllReplaysSelected ( true ); 710applyAllReplaysSelected ( newReplays , true ); 711setBatchActives ( 712getNewBatchActives ( newReplays . filter (( replay ) => replay . selected )), 713); 714setDir ( newDir ); 715setIsUsb ( false ); 716setDirExists ( true ); 717setDirInit ( false ); 718resetOverrides (); 719const skew = hasTimeSkew ( newReplays ); 720setSkewDetected ( skew ); 721if ( skew && ! vlerkMode ) { 722setSkewDialogOpen ( true ); 723} 724setReplays ( newReplays ); 725setReplayLoadCount ( newReplayLoadCount ); 726setInvalidReplays ( newInvalidReplays ); 727if ( newInvalidReplays . length > 0 ) { 728showErrorDialog ( 729newInvalidReplays . map ( 730( invalidReplay ) => 731` ${ invalidReplay . fileName } : ${ invalidReplay . invalidReason } ` , 732), 733); 734} 735setReplayRefs ( vlerkMode ?newReplays . map (() => createRef ()) :[]); 736setWasDeleted ( false ); 737} 738setGettingReplays ( false ); 739}; 740 741const setManualNamesOuter = async ( names :string []) => { 742setManualNames ( names ); 743await window . electron . setManualNames ( names ); 744}; 745const [ manualDialogOpen , setManualDialogOpen ] = useState ( false ); 746 747const [ guideState , setGuideState ] = useState ( GuideState . NONE ); 748const [ guideBackdropOpen , setGuideBackdropOpen ] = useState ( false ); 749const [ confirmedCopySettings , setConfirmedCopySettings ] = useState ( false ); 750const guideActive = 751guidedMode && tournamentSet && copyDirSet && confirmedCopySettings ; 752const refreshReplays = useCallback ( 753async ( triggerGuide ?:boolean ) => { 754let newReplays :Replay [] = []; 755let newInvalidReplays :InvalidReplay [] = []; 756setGettingReplays ( true ); 757try { 758const res = await window . electron . getReplaysInDir (); 759newReplays = res . replays ; 760newInvalidReplays = res . invalidReplays ; 761setReplayLoadCount ( res . replayLoadCount ); 762setDirExists ( true ); 763if ( triggerGuide && newReplays . length > 0 ) { 764setGuideState ( 765mode === Mode . MANUAL ?GuideState . PLAYERS :GuideState . SET , 766); 767if ( guideActive ) { 768setGuideBackdropOpen ( true ); 769} 770} 771} catch ( e :any ) { 772setDirExists ( false ); 773setGuideBackdropOpen ( false ); 774setGuideState ( GuideState . NONE ); 775} 776setAllReplaysSelected ( true ); 777applyAllReplaysSelected ( newReplays , true ); 778setBatchActives ( 779getNewBatchActives ( newReplays . filter (( replay ) => replay . selected )), 780); 781setDirInit ( false ); 782resetOverrides (); 783const skew = hasTimeSkew ( newReplays ); 784setSkewDetected ( skew ); 785if ( skew && ! vlerkMode ) { 786setSkewDialogOpen ( true ); 787} 788setReplays ( newReplays ); 789setInvalidReplays ( newInvalidReplays ); 790if ( newInvalidReplays . length > 0 ) { 791showErrorDialog ( 792newInvalidReplays . map ( 793( invalidReplay ) => 794` ${ invalidReplay . fileName } : ${ invalidReplay . invalidReason } ` , 795), 796); 797} 798setReplayRefs ( vlerkMode ?newReplays . map (() => createRef ()) :[]); 799setGettingReplays ( false ); 800}, 801[ guideActive , mode , vlerkMode ], 802); 803 804const wouldDeleteCopyDir = 805dir . length > 0 && copyDir . length > 0 && dir === copyDir ; 806const [ ejecting , setEjecting ] = useState ( false ); 807const [ ejected , setEjected ] = useState ( false ); 808const deleteDir = async ( usedFilenames :string []) => { 809if ( ! dir || wouldDeleteCopyDir ) { 810return ; 811} 812 813setDirDeleting ( true ); 814setEjecting ( true ); 815try { 816setEjected ( await window . electron . deleteReplaysDir ( usedFilenames )); 817setWasDeleted ( true ); 818await refreshReplays (); 819} finally { 820setDirDeleting ( false ); 821setEjecting ( false ); 822} 823}; 824const deleteSelected = async ( used :boolean ) => { 825if ( ! dir || wouldDeleteCopyDir ) { 826return ; 827} 828 829setDirDeleting ( true ); 830try { 831await window . electron . deleteSelectedReplays ( 832selectedReplays . map (( selectedReplay ) => selectedReplay . filePath ), 833used , 834); 835await refreshReplays (); 836} finally { 837setDirDeleting ( false ); 838} 839}; 840const deleteUndo = async () => { 841if ( ! dir || ! undoSubdir || wouldDeleteCopyDir ) { 842return ; 843} 844 845setDirDeleting ( true ); 846try { 847setDir ( await window . electron . deleteUndoSrcDst ()); 848setUndoSubdir ( '' ); 849refreshReplays ( true ); 850} finally { 851setDirDeleting ( false ); 852} 853}; 854const onPlayerOverride = () => { 855setReplays ( Array . from ( replays )); 856}; 857const onReplayClick = ( index :number ) => { 858const newReplays = Array . from ( replays ); 859newReplays [ index ]. selected = ! newReplays [ index ]. selected ; 860const newBatchActives = getNewBatchActives ( 861newReplays . filter (( replay ) => replay . selected ), 862); 863 864const newOverrides = Array . from ( overrides ) as [ 865PlayerOverrides , 866PlayerOverrides , 867PlayerOverrides , 868PlayerOverrides , 869]; 870for ( let i = 0 ; i < 4 ; i += 1 ) { 871if ( batchActives [ i ]. active && ! newBatchActives [ i ]. active ) { 872newOverrides [ i ] = { 873displayName :'' , 874entrantId :0 , 875participantId :0 , 876prefix :'' , 877pronouns :'' , 878}; 879} 880} 881 882if ( newReplays [ index ]. selected ) { 883newReplays [ index ]. players . forEach (( player , i ) => { 884player . playerOverrides = { ...newOverrides [ i ] }; 885}); 886} else { 887newReplays [ index ]. players . forEach (( player ) => { 888player . playerOverrides = { 889displayName :'' , 890entrantId :0 , 891participantId :0 , 892prefix :'' , 893pronouns :'' , 894}; 895}); 896} 897 898setBatchActives ( newBatchActives ); 899setOverrides ( newOverrides ); 900setReplays ( newReplays ); 901resetDq (); 902}; 903useEffect (() => { 904window . electron . onTournament ( 905( 906e , 907{ 908selectedSet :newSelectedSet , 909startggTournament :newTournament , 910challongeTournaments :newChallongeTournaments , 911parryggTournament :newParryggTournament , 912offlineModeTournament :newOfflineModeTournament , 913}, 914) => { 915if ( newSelectedSet ) { 916setSelectedSet ( newSelectedSet ); 917} 918if ( newTournament ) { 919if ( tournamentSet && copyDirSet && confirmedCopySettings ) { 920setGuideBackdropOpen ( false ); 921} 922setStartggTournament ( newTournament ); 923} 924if ( newChallongeTournaments ) { 925if ( tournamentSet && copyDirSet && confirmedCopySettings ) { 926setGuideBackdropOpen ( false ); 927} 928setChallongeTournaments ( newChallongeTournaments ); 929} 930if ( newParryggTournament ) { 931if ( tournamentSet && copyDirSet && confirmedCopySettings ) { 932setGuideBackdropOpen ( false ); 933} 934setParryggTournament ( newParryggTournament ); 935} 936if ( newOfflineModeTournament ) { 937if ( tournamentSet && copyDirSet && confirmedCopySettings ) { 938setGuideBackdropOpen ( false ); 939} 940setOfflineModeTournament ( newOfflineModeTournament ); 941} 942}, 943selectedSet . id , 944); 945}, [ confirmedCopySettings , copyDirSet , selectedSet , tournamentSet ]); 946 947useEffect (() => { 948window . electron . onUsb (( e , newDir , newIsUsb ) => { 949if ( ! undoSubdir ) { 950setDir ( newDir ); 951setIsUsb ( newIsUsb ); 952setWasDeleted ( false ); 953refreshReplays ( true ); 954setEjected ( false ); 955} 956}); 957}, [ refreshReplays , undoSubdir ]); 958 959const availablePlayers :PlayerOverrides [] = []; 960selectedSet . entrant1Participants . forEach (( participant ) => { 961availablePlayers . push ({ 962displayName :participant . displayName , 963entrantId :selectedSet . entrant1Id , 964participantId :participant . id , 965prefix :participant . prefix , 966pronouns :participant . pronouns , 967}); 968}); 969selectedSet . entrant2Participants . forEach (( participant ) => { 970availablePlayers . push ({ 971displayName :participant . displayName , 972entrantId :selectedSet . entrant1Id , 973participantId :participant . id , 974prefix :participant . prefix , 975pronouns :participant . pronouns , 976}); 977}); 978 979const [ slugDialogOpen , setSlugDialogOpen ] = useState ( false ); 980const [ parryggSlugDialogOpen , setParryggSlugDialogOpen ] = useState ( false ); 981const [ gettingTournament , setGettingTournament ] = useState ( false ); 982 983// Challonge tournament view 984const getChallongeTournament = async ( maybeSlug :string ) => { 985if ( ! maybeSlug ) { 986return ; 987} 988 989setGettingTournament ( true ); 990try { 991await window . electron . getChallongeTournament ( maybeSlug ); 992} catch ( e :any ) { 993showErrorDialog ([ e . toString ()]); 994} finally { 995setGettingTournament ( false ); 996} 997}; 998 999const getParryggTournament = async ( 1000maybeSlug :string , 1001initial :boolean = false , 1002) => { 1003if ( ! maybeSlug ) { 1004return ; 1005} 1006 1007setGettingTournament ( true ); 1008try { 1009await window . electron . getParryggTournament ( 1010maybeSlug , 1011initial && vlerkMode , 1012); 1013if ( parryggSlug !== maybeSlug ) { 1014setSelectedSet ( EMPTY_SET ); 1015setSelectedSetChain ( EMPTY_SELECTED_SET_CHAIN ); 1016await window . electron . setSelectedSetChain ( '' , '' , '' ); 1017} 1018} catch ( e :any ) { 1019showErrorDialog ([ e . toString ()]); 1020} finally { 1021setGettingTournament ( false ); 1022} 1023}; 1024 1025const findOtherPlayer = ( 1026entrantId :Id , 1027participantId :Id , 1028) :PlayerOverrides => { 1029const isEntrant1 = entrantId === selectedSet . entrant1Id ; 1030const isTeams = selectedSet . entrant1Participants . length > 1 ; 1031if ( isEntrant1 && isTeams ) { 1032const participantToCheck = selectedSet . entrant1Participants . find ( 1033( participant ) => participant . id !== participantId , 1034); 1035if ( participantToCheck ) { 1036return { 1037displayName :participantToCheck . displayName , 1038entrantId :selectedSet . entrant1Id , 1039participantId :participantToCheck . id , 1040prefix :participantToCheck . prefix , 1041pronouns :participantToCheck . pronouns , 1042}; 1043} 1044} else if ( ! isEntrant1 && isTeams ) { 1045const participantToCheck = selectedSet . entrant2Participants . find ( 1046( participant ) => participant . id !== participantId , 1047); 1048if ( participantToCheck ) { 1049return { 1050displayName :participantToCheck . displayName , 1051entrantId :selectedSet . entrant2Id , 1052participantId :participantToCheck . id , 1053prefix :participantToCheck . prefix , 1054pronouns :participantToCheck . pronouns , 1055}; 1056} 1057} else if ( isEntrant1 && ! isTeams ) { 1058return { 1059displayName :selectedSet . entrant2Participants [ 0 ]. displayName , 1060entrantId :selectedSet . entrant2Id , 1061participantId :selectedSet . entrant2Participants [ 0 ]. id , 1062prefix :selectedSet . entrant2Participants [ 0 ]. prefix , 1063pronouns :selectedSet . entrant2Participants [ 0 ]. pronouns , 1064}; 1065} else if ( ! isEntrant1 && ! isTeams ) { 1066return { 1067displayName :selectedSet . entrant1Participants [ 0 ]. displayName , 1068entrantId :selectedSet . entrant1Id , 1069participantId :selectedSet . entrant1Participants [ 0 ]. id , 1070prefix :selectedSet . entrant1Participants [ 0 ]. prefix , 1071pronouns :selectedSet . entrant1Participants [ 0 ]. pronouns , 1072}; 1073} 1074return { 1075displayName :'' , 1076entrantId :0 , 1077participantId :0 , 1078prefix :'' , 1079pronouns :'' , 1080}; 1081}; 1082 1083// for click-assigning set participants 1084const [ selectedChipData , setSelectedChipData ] = useState < PlayerOverrides >({ 1085displayName :'' , 1086entrantId :0 , 1087participantId :0 , 1088prefix :'' , 1089pronouns :'' , 1090}); 1091const resetSelectedChipData = () => { 1092setSelectedChipData ({ 1093displayName :'' , 1094entrantId :0 , 1095participantId :0 , 1096prefix :'' , 1097pronouns :'' , 1098}); 1099}; 1100 1101// batch chips 1102const onClickOrDrop = ( 1103displayName :string , 1104entrantId :Id , 1105participantId :Id , 1106prefix :string , 1107pronouns :string , 1108index :number , 1109) => { 1110const newOverrides = Array . from ( overrides ) as [ 1111PlayerOverrides , 1112PlayerOverrides , 1113PlayerOverrides , 1114PlayerOverrides , 1115]; 1116newOverrides [ index ] = { 1117 displayName, 1118 entrantId, 1119 participantId, 1120 prefix, 1121 pronouns, 1122}; 1123newOverrides . forEach (( override , i ) => { 1124if ( 1125i !== index && 1126override . entrantId === entrantId && 1127override . participantId === participantId 1128) { 1129override . displayName = '' ; 1130override . entrantId = 0 ; 1131override . participantId = 0 ; 1132override . prefix = '' ; 1133override . pronouns = '' ; 1134} 1135}); 1136 1137// pigeonhole remaining player if possible 1138if ( numBatchActive === availablePlayers . length ) { 1139const { teamI} = batchActives [ index ]; 1140const isTeams = availablePlayers . length === 4 && teamI !== - 1 ; 1141 1142// find if there's exactly one hole to pigeon 1143const elligibleIndicies :number [] = []; 1144for ( let i = 0 ; i < 4 ; i += 1 ) { 1145if ( 1146batchActives [ i ]. active && 1147( ! isTeams || batchActives [ i ]. teamI === teamI ) && 1148newOverrides [ i ]. participantId !== participantId 1149) { 1150elligibleIndicies . push ( i ); 1151} 1152} 1153if ( elligibleIndicies . length === 1 ) { 1154const otherPlayer = findOtherPlayer ( entrantId , participantId ); 1155if ( otherPlayer . entrantId && otherPlayer . participantId ) { 1156newOverrides [ elligibleIndicies [ 0 ]] = otherPlayer ; 1157newOverrides . forEach (( override , i ) => { 1158if ( 1159i !== elligibleIndicies [ 0 ] && 1160override . entrantId === otherPlayer . entrantId && 1161override . participantId === otherPlayer . participantId 1162) { 1163override . displayName = '' ; 1164override . entrantId = 0 ; 1165override . participantId = 0 ; 1166override . prefix = '' ; 1167override . pronouns = '' ; 1168} 1169}); 1170} 1171} 1172} 1173 1174selectedReplays . forEach (( replay ) => { 1175replay . players [ index ]. playerOverrides = { ...newOverrides [ index ] }; 1176replay . players . forEach (( otherPlayer ) => { 1177if ( 1178otherPlayer . port === replay . players [ index ]. port || 1179( otherPlayer . playerType !== 0 && otherPlayer . playerType !== 1 ) 1180) { 1181return ; 1182} 1183if ( 1184otherPlayer . playerOverrides . displayName === displayName && 1185otherPlayer . playerOverrides . entrantId 1186) { 1187otherPlayer . playerOverrides . displayName = '' ; 1188otherPlayer . playerOverrides . entrantId = 0 ; 1189otherPlayer . playerOverrides . participantId = 0 ; 1190otherPlayer . playerOverrides . prefix = '' ; 1191otherPlayer . playerOverrides . pronouns = '' ; 1192} 1193}); 1194for ( let i = 0 ; i < 4 ; i += 1 ) { 1195replay . players [ i ]. playerOverrides = { ...newOverrides [ i ] }; 1196} 1197}); 1198setOverrides ( newOverrides ); 1199resetDq (); 1200resetSelectedChipData (); 1201}; 1202const batchChip = ( index :number ) => { 1203const { active} = batchActives [ index ]; 1204return ( 1205< DroppableChip 1206active = { active } 1207label = { overrides [ index ]. displayName || `P ${ index + 1 } (all games)` } 1208outlined = { active } 1209selectedChipData = { selectedChipData } 1210style = {{ width :'25%' }} 1211onClickOrDrop = {( 1212displayName :string , 1213entrantId :Id , 1214participantId :Id , 1215prefix :string , 1216pronouns :string , 1217) => 1218onClickOrDrop ( 1219displayName , 1220entrantId , 1221participantId , 1222prefix , 1223pronouns , 1224index , 1225) 1226} 1227/> 1228); 1229}; 1230 1231const getStartggTournament = async ( 1232maybeSlug :string , 1233initial :boolean = false , 1234) => { 1235if ( ! maybeSlug ) { 1236return ; 1237} 1238 1239setGettingTournament ( true ); 1240try { 1241await window . electron . getStartggTournament ( 1242maybeSlug , 1243initial && vlerkMode , 1244); 1245if ( startggTournament . slug !== maybeSlug ) { 1246setSelectedSet ( EMPTY_SET ); 1247setSelectedSetChain ( EMPTY_SELECTED_SET_CHAIN ); 1248await window . electron . setSelectedSetChain ( 0 , 0 , 0 ); 1249} 1250} catch ( e :any ) { 1251showErrorDialog ([ e . toString ()]); 1252} finally { 1253setGettingTournament ( false ); 1254} 1255}; 1256 1257// set controls 1258const selectSet = ( set :Set ) => { 1259const newOverrides :[ 1260PlayerOverrides , 1261PlayerOverrides , 1262PlayerOverrides , 1263PlayerOverrides , 1264] = [ 1265{ 1266displayName :'' , 1267entrantId :0 , 1268participantId :0 , 1269prefix :'' , 1270pronouns :'' , 1271}, 1272{ 1273displayName :'' , 1274entrantId :0 , 1275participantId :0 , 1276prefix :'' , 1277pronouns :'' , 1278}, 1279{ 1280displayName :'' , 1281entrantId :0 , 1282participantId :0 , 1283prefix :'' , 1284pronouns :'' , 1285}, 1286{ 1287displayName :'' , 1288entrantId :0 , 1289participantId :0 , 1290prefix :'' , 1291pronouns :'' , 1292}, 1293]; 1294selectedReplays . forEach (( replay ) => { 1295replay . players . forEach (( player , i ) => { 1296player . playerOverrides = { ...newOverrides [ i ] }; 1297}); 1298}); 1299const newReplays = Array . from ( replays ); 1300setSelectedSet ( set ); 1301setOverrides ( newOverrides ); 1302setReplays ( newReplays ); 1303}; 1304 1305const [ callingSet , setCallingSet ] = useState ( false ); 1306const callSet = async ( originalSet :Set ) => { 1307setCallingSet ( true ); 1308try { 1309if ( mode === Mode . STARTGG ) { 1310await window . electron . callSet ( originalSet ); 1311} else if ( mode === Mode . OFFLINE_MODE ) { 1312await window . electron . callOfflineModeSet ( assertInteger ( originalSet . id )); 1313} 1314} catch ( e :any ) { 1315showErrorDialog ([ e . toString ()]); 1316} finally { 1317setCallingSet ( false ); 1318} 1319}; 1320 1321const [ startingSet , setStartingSet ] = useState ( false ); 1322const startSet = async ( originalSet :Set ) => { 1323setStartingSet ( true ); 1324try { 1325if ( mode === Mode . STARTGG ) { 1326await window . electron . startSet ( originalSet ); 1327} else if ( mode === Mode . CHALLONGE ) { 1328await window . electron . startChallongeSet ( 1329selectedChallongeTournament . slug , 1330assertString ( originalSet . id ), 1331); 1332} else if ( mode === Mode . PARRYGG ) { 1333await window . electron . startParryggSet ( assertString ( originalSet . id )); 1334} else if ( mode === Mode . OFFLINE_MODE ) { 1335await window . electron . startOfflineModeSet ( 1336assertInteger ( originalSet . id ), 1337); 1338} 1339} catch ( e :any ) { 1340showErrorDialog ([ e . toString ()]); 1341} finally { 1342setStartingSet ( false ); 1343} 1344}; 1345 1346const reportStartggSet = useCallback ( 1347async ( set :StartggSet , originalSet :Set ) => { 1348const updatedSet = 1349originalSet . state === State . COMPLETED 1350 ?await window . electron . updateSet ( set ) 1351 :await window . electron . reportSet ( set , originalSet ); 1352resetDq (); 1353return updatedSet ; 1354}, 1355[ resetDq ], 1356); 1357const reportChallongeSet = useCallback ( 1358async ( matchId :string , items :ChallongeMatchItem []) => { 1359const updatedSet = await window . electron . reportChallongeSet ( 1360matchId , 1361items , 1362); 1363resetDq (); 1364return updatedSet ; 1365}, 1366[ resetDq ], 1367); 1368const reportParryggSet = useCallback ( 1369async ( 1370result :MatchResult . AsObject , 1371originalSet :Set , 1372games ?:ParryggGame [], 1373) => { 1374const updatedSet = await window . electron . reportParryggSet ( 1375assertString ( originalSet . id ), 1376result , 1377games , 1378); 1379resetDq (); 1380return updatedSet ; 1381}, 1382[ resetDq ], 1383); 1384const reportOfflineModeSet = useCallback ( 1385async ( set :StartggSet ) => { 1386const updatedSet = await window . electron . reportOfflineModeSet ( 1387assertInteger ( set . setId ), 1388assertInteger ( set . winnerId ), 1389set . isDQ , 1390set . gameData , 1391); 1392resetDq (); 1393return updatedSet ; 1394}, 1395[ resetDq ], 1396); 1397 1398// copy 1399type NameObj = { 1400characterName :string ; 1401displayName :string ; 1402entrantId :Id ; 1403participantId :Id ; 1404nametag :string ; 1405}; 1406type NamesObj = { 1407characterNames :Map < string , number >; 1408displayName :string ; 1409entrantId :Id ; 1410participantId :Id ; 1411nametags :Map < string , number >; 1412}; 1413type CombinedNameObj = { 1414characterNames :string []; 1415displayName :string ; 1416entrantId :Id ; 1417participantId :Id ; 1418nametags :string []; 1419}; 1420 1421const [ isCopying , setIsCopying ] = useState ( false ); 1422const [ copyError , setCopyError ] = useState ( '' ); 1423const [ copyErrorDialogOpen , setCopyErrorDialogOpen ] = useState ( false ); 1424const [ copySuccess , setCopySuccess ] = useState ( '' ); 1425 1426const onCopy = async ( 1427updatedSetFields ?:{ 1428id :Id ; 1429sggId :number | null ; 1430completedAtMs :number ; 1431stream :Stream | null ; 1432}, 1433violators ?:{ 1434checkNames :Map < string , boolean >; 1435displayName :string ; 1436entrantId :Id ; 1437}[], 1438) => { 1439setIsCopying ( true ); 1440 1441let offsetMs = 0 ; 1442let startDate = selectedReplays [ 0 ]. startAt ; 1443if ( copySettings . writeStartTimes && undoSubdir . length === 0 ) { 1444const lastReplay = selectedReplays [ selectedReplays . length - 1 ]; 1445const lastStartMs = lastReplay . startAt . getTime (); 1446const completedMs = 1447( updatedSetFields 1448 ?updatedSetFields . completedAtMs 1449 :selectedSet . completedAtMs ) || Date . now (); 1450offsetMs = 1451completedMs - 1452lastStartMs - 1453Math . round (( lastReplay . lastFrame + 124 ) / frameMsDivisor ); 1454startDate = new Date ( selectedReplays [ 0 ]. startAt . getTime () + offsetMs ); 1455} 1456 1457let fileNames = selectedReplays . map (( replay ) => replay . fileName ); 1458let subdir = '' ; 1459let context :Context | undefined ; 1460if ( 1461copySettings . writeFileNames || 1462copySettings . output === Output . FOLDER || 1463copySettings . output === Output . ZIP 1464) { 1465let allEntrantIdsSet = true ; 1466const nameObjs = selectedReplays . map (( replay ) => 1467replay . players . map (( player ) :NameObj => { 1468if ( player . playerType === 0 || player . playerType === 1 ) { 1469if ( ! player . playerOverrides . entrantId ) { 1470allEntrantIdsSet = false ; 1471} 1472return { 1473characterName :characterNames . get ( player . externalCharacterId ) ! , 1474displayName : 1475player . playerOverrides . displayName || player . displayName , 1476entrantId :player . playerOverrides . entrantId , 1477participantId :player . playerOverrides . participantId , 1478nametag :player . nametag , 1479}; 1480} 1481return { 1482characterName :'' , 1483displayName :'' , 1484entrantId :0 , 1485participantId :0 , 1486nametag :'' , 1487}; 1488}), 1489); 1490 1491const nameObjToPlayerOnly = ( nameObj :NameObj ) => { 1492if ( nameObj . displayName ) { 1493return nameObj . displayName ; 1494} 1495if ( nameObj . nametag ) { 1496return nameObj . nametag ; 1497} 1498return nameObj . characterName ; 1499}; 1500const combinedNameObjToPlayerOnly = ( 1501combinedNameObj :CombinedNameObj , 1502) => { 1503if ( combinedNameObj . displayName ) { 1504return combinedNameObj . displayName ; 1505} 1506if ( combinedNameObj . nametags . length > 0 ) { 1507return combinedNameObj . nametags . join ( ', ' ); 1508} 1509return combinedNameObj . characterNames . join ( ', ' ); 1510}; 1511const nameObjToPlayerChar = ( nameObj :NameObj ) => { 1512if ( nameObj . displayName ) { 1513return ` ${ nameObj . displayName } ( ${ nameObj . characterName } )` ; 1514} 1515if ( nameObj . nametag ) { 1516return ` ${ nameObj . characterName } ( ${ nameObj . nametag } )` ; 1517} 1518return nameObj . characterName ; 1519}; 1520const combinedNameObjToPlayerChar = ( 1521combinedNameObj :CombinedNameObj , 1522) => { 1523if ( combinedNameObj . displayName ) { 1524return ` ${ 1525combinedNameObj . displayName 1526} ( ${ combinedNameObj . characterNames . join ( ', ' )} )` ; 1527} 1528if ( combinedNameObj . nametags . length > 0 ) { 1529return ` ${ combinedNameObj . characterNames . join ( 1530', ' , 1531)} ( ${ combinedNameObj . nametags . join ( ', ' )} )` ; 1532} 1533return combinedNameObj . characterNames . join ( ', ' ); 1534}; 1535const entrant1CombinedNameObjs :CombinedNameObj [] = []; 1536const entrant2CombinedNameObjs :CombinedNameObj [] = []; 1537 1538let roundShort = '' ; 1539const regex = / ([A-Z]|[0-9]) / g ; 1540let regexRes = regex . exec ( selectedSet . fullRoundText ); 1541while ( regexRes ) { 1542roundShort += regexRes [ 0 ]; 1543regexRes = regex . exec ( selectedSet . fullRoundText ); 1544} 1545const roundLong = String ( selectedSet . fullRoundText ); 1546if ( 1547copySettings . output === Output . FOLDER || 1548copySettings . output === Output . ZIP 1549) { 1550const namesObjs :NamesObj [] = nameObjs [ 0 ]. map (( nameObj ) => ({ 1551characterNames :new Map ([[ nameObj . characterName , 0 ]]), 1552displayName :nameObj . displayName , 1553entrantId :nameObj . entrantId , 1554participantId :nameObj . participantId , 1555nametags :new Map ([[ nameObj . nametag , 0 ]]), 1556})); 1557if ( allEntrantIdsSet ) { 1558for ( let i = 1 ; i < nameObjs . length ; i += 1 ) { 1559for ( let j = 0 ; j < nameObjs [ i ]. length ; j += 1 ) { 1560const nameObj = nameObjs [ i ][ j ]; 1561const existingNamesObj = namesObjs . find ( 1562( namesObj ) => 1563namesObj . entrantId === nameObj . entrantId && 1564namesObj . participantId === nameObj . participantId , 1565) ! ; 1566if ( 1567nameObj . characterName && 1568! existingNamesObj . characterNames . has ( nameObj . characterName ) 1569) { 1570existingNamesObj . characterNames . set ( nameObj . characterName , i ); 1571} 1572if ( 1573nameObj . nametag && 1574! existingNamesObj . nametags . has ( nameObj . nametag ) 1575) { 1576existingNamesObj . nametags . set ( nameObj . nametag , i ); 1577} 1578} 1579} 1580} else { 1581for ( let i = 1 ; i < nameObjs . length ; i += 1 ) { 1582for ( let j = 0 ; j < nameObjs [ i ]. length ; j += 1 ) { 1583const nameObj = nameObjs [ i ][ j ]; 1584if ( nameObj . characterName ) { 1585namesObjs [ j ]. displayName = nameObj . displayName ; 1586namesObjs [ j ]. entrantId = nameObj . entrantId ; 1587if ( ! namesObjs [ j ]. characterNames . has ( nameObj . characterName )) { 1588namesObjs [ j ]. characterNames . set ( nameObj . characterName , i ); 1589} 1590} 1591if ( 1592nameObj . nametag && 1593! namesObjs [ i ]. nametags . has ( nameObj . nametag ) 1594) { 1595namesObjs [ i ]. nametags . set ( nameObj . nametag , j ); 1596} 1597} 1598} 1599} 1600const combinedNameObjs :CombinedNameObj [] = namesObjs 1601. map (( namesObj ) => ({ 1602displayName :namesObj . displayName , 1603entrantId :namesObj . entrantId , 1604participantId :namesObj . participantId , 1605characterNames :[ ...namesObj . characterNames . entries ()] 1606. sort (([, a ], [, b ]) => a - b ) 1607. map (( entry ) => entry [ 0 ]), 1608nametags :[ ...namesObj . nametags . entries ()] 1609. sort (([, a ], [, b ]) => a - b ) 1610. map (( entry ) => entry [ 0 ]), 1611})) 1612. filter (( nameObj ) => 1613nameObj . characterNames . some (( characterName ) => characterName ), 1614); 1615 1616selectedSet . entrant1Participants . forEach (( participant ) => { 1617const combinedNameObj = combinedNameObjs . find ( 1618( cbn ) => cbn . participantId === participant . id , 1619); 1620if ( combinedNameObj ) { 1621entrant1CombinedNameObjs . push ( combinedNameObj ); 1622} 1623}); 1624selectedSet . entrant2Participants . forEach (( participant ) => { 1625const combinedNameObj = combinedNameObjs . find ( 1626( cbn ) => cbn . participantId === participant . id , 1627); 1628if ( combinedNameObj ) { 1629entrant2CombinedNameObjs . push ( combinedNameObj ); 1630} 1631}); 1632 1633const playersOnly = ` ${ entrant1CombinedNameObjs 1634. map ( combinedNameObjToPlayerOnly ) 1635. join ( ' + ' )} vs ${ entrant2CombinedNameObjs 1636. map ( combinedNameObjToPlayerOnly ) 1637. join ( ' + ' )} ` ; 1638const playersChars = ` ${ entrant1CombinedNameObjs 1639. map ( combinedNameObjToPlayerChar ) 1640. join ( ' + ' )} vs ${ entrant2CombinedNameObjs 1641. map ( combinedNameObjToPlayerChar ) 1642. join ( ' + ' )} ` ; 1643const singlesChars = 1644combinedNameObjs . length === 4 ?playersOnly :playersChars ; 1645subdir = String ( folderNameFormat ); 1646subdir = subdir . replace ( '{date}' , format ( startDate , 'yyyyMMdd' )); 1647subdir = subdir . replace ( '{time}' , format ( startDate , 'HHmm' )); 1648subdir = subdir . replace ( '{roundShort}' , roundShort ); 1649subdir = subdir . replace ( '{roundLong}' , roundLong ); 1650subdir = subdir . replace ( '{games}' , selectedReplays . length . toString ( 10 )); 1651 1652// do last in case tournament/event/phase/phase group names contain template strings LOL 1653let tournamentName = '' ; 1654let tournamentSlug = '' ; 1655if ( mode === Mode . STARTGG ) { 1656tournamentName = startggTournament . name ; 1657tournamentSlug = startggTournament . slug ; 1658} else if ( mode === Mode . CHALLONGE ) { 1659tournamentName = selectedChallongeTournament . name ; 1660tournamentSlug = selectedChallongeTournament . slug ; 1661} else if ( mode === Mode . PARRYGG ) { 1662tournamentName = parryggTournament ?. name ?? '' ; 1663tournamentSlug = parryggSlug ; 1664} else if ( mode === Mode . OFFLINE_MODE ) { 1665tournamentName = offlineModeTournament . name ; 1666tournamentSlug = offlineModeTournament . slug ; 1667} 1668subdir = subdir . replace ( '{tournamentName}' , tournamentName ); 1669subdir = subdir . replace ( '{tournamentSlug}' , tournamentSlug ); 1670 1671let eventName = '' ; 1672let phaseName = '' ; 1673let phaseGroupName = '' ; 1674let phaseOrEvent = '' ; 1675if ( 1676mode === Mode . STARTGG || 1677mode === Mode . PARRYGG || 1678mode === Mode . OFFLINE_MODE 1679) { 1680eventName = selectedSetChain . event ?. name ?? '' ; 1681phaseName = selectedSetChain . phase ?. name ?? '' ; 1682phaseGroupName = selectedSetChain . phaseGroup ?. name ?? '' ; 1683if ( selectedSetChain . phase ?. hasSiblings ) { 1684phaseOrEvent = selectedSetChain . phase . name ; 1685} else if ( selectedSetChain . event ) { 1686phaseOrEvent = selectedSetChain . event . name ; 1687} 1688} 1689subdir = subdir . replace ( '{event}' , eventName ); 1690subdir = subdir . replace ( '{phase}' , phaseName ); 1691subdir = subdir . replace ( '{phaseGroup}' , phaseGroupName ); 1692subdir = subdir . replace ( '{phaseOrEvent}' , phaseOrEvent ); 1693 1694// do last in case player names contain template strings LOL 1695subdir = subdir . replace ( '{playersOnly}' , playersOnly ); 1696subdir = subdir . replace ( '{playersChars}' , playersChars ); 1697subdir = subdir . replace ( '{singlesChars}' , singlesChars ); 1698} 1699 1700if ( copySettings . writeFileNames ) { 1701fileNames = nameObjs . map (( game , i ) => { 1702const { stageId, startAt} = selectedReplays [ i ]; 1703const writeStartDate = 1704copySettings . writeStartTimes && undoSubdir . length === 0 1705 ?new Date ( startAt . getTime () + offsetMs ) 1706 :startAt ; 1707const time = format ( writeStartDate , 'HHmmss' ); 1708const names = game . filter (( nameObj ) => nameObj . characterName ); 1709const playersOnly = names . map ( nameObjToPlayerOnly ). join ( ', ' ); 1710const playersChars = names . map ( nameObjToPlayerChar ). join ( ', ' ); 1711const singlesChars = 1712nameObjs . length === 4 ?playersOnly :playersChars ; 1713 1714let fileName = `{ordinal} ${ fileNameFormat } ` ; 1715fileName = fileName . replace ( 1716'{date}' , 1717format ( writeStartDate , 'yyyyMMdd' ), 1718); 1719fileName = fileName . replace ( '{time}' , time ); 1720fileName = fileName . replace ( '{roundShort}' , roundShort ); 1721fileName = fileName . replace ( '{roundLong}' , roundLong ); 1722fileName = fileName . replace ( '{stage}' , stageNames . get ( stageId ) || '' ); 1723fileName = fileName . replace ( 1724'{ordinal}' , 1725copySettings . output === Output . FILES ?time :( i + 1 ). toString ( 10 ), 1726); 1727// do last in case player names contain template strings LOL 1728fileName = fileName . replace ( '{playersOnly}' , playersOnly ); 1729fileName = fileName . replace ( '{playersChars}' , playersChars ); 1730fileName = fileName . replace ( '{singlesChars}' , singlesChars ); 1731return ` ${ fileName } .slp` ; 1732}); 1733} 1734 1735if ( 1736copySettings . writeContext && 1737( copySettings . output === Output . FOLDER || 1738copySettings . output === Output . ZIP ) 1739) { 1740let canWriteContext = true ; 1741const scores :ContextScore [] = []; 1742const gameScores = [ 0 , 0 ]; 1743selectedReplays . forEach (( replay ) => { 1744const slots :ContextSlot [] = []; 1745const usedK = new Map < number , boolean >(); 1746for ( let j = 0 ; j < 2 ; j += 1 ) { 1747slots [ j ] = { 1748displayNames :[], 1749ports :[], 1750prefixes :[], 1751pronouns :[], 1752score :gameScores [ j ], 1753}; 1754let teamId :number | undefined ; 1755for ( let k = 0 ; k < replay . players . length ; k += 1 ) { 1756const player = replay . players [ k ]; 1757if ( 1758( player . playerType === 0 || player . playerType === 1 ) && 1759! usedK . has ( k ) && 1760( teamId === undefined || teamId === player . teamId ) 1761) { 1762const displayName = 1763player . playerOverrides . displayName || player . displayName ; 1764if ( ! displayName ) { 1765canWriteContext = false ; 1766} 1767slots [ j ]. displayNames . push ( displayName ); 1768slots [ j ]. ports . push ( player . port ); 1769slots [ j ]. prefixes . push ( player . playerOverrides . prefix ); 1770slots [ j ]. pronouns . push ( player . playerOverrides . pronouns ); 1771if ( player . isWinner ) { 1772gameScores [ j ] += 1 ; 1773} 1774usedK . set ( k , true ); 1775if ( replay . isTeams ) { 1776if ( teamId === undefined ) { 1777teamId = player . teamId ; 1778} 1779} else { 1780break ; 1781} 1782} 1783} 1784} 1785scores . push ({ slots :[ slots [ 0 ], slots [ 1 ]] }); 1786}); 1787const lastScore = scores [ scores . length - 1 ]; 1788const finalScore :ContextScore = { 1789slots :[ 1790{ 1791displayNames :lastScore . slots [ 0 ]. displayNames , 1792ports :lastScore . slots [ 0 ]. ports , 1793prefixes :lastScore . slots [ 0 ]. prefixes , 1794pronouns :lastScore . slots [ 0 ]. pronouns , 1795score :gameScores [ 0 ], 1796}, 1797{ 1798displayNames :lastScore . slots [ 1 ]. displayNames , 1799ports :lastScore . slots [ 1 ]. ports , 1800prefixes :lastScore . slots [ 1 ]. prefixes , 1801pronouns :lastScore . slots [ 1 ]. pronouns , 1802score :gameScores [ 1 ], 1803}, 1804], 1805}; 1806if ( canWriteContext ) { 1807const contextPlayers :ContextPlayers = { 1808entrant1 :entrant1CombinedNameObjs . map (( cbn ) => ({ 1809name :cbn . displayName , 1810characters :cbn . characterNames , 1811})), 1812entrant2 :entrant2CombinedNameObjs . map (( cbn ) => ({ 1813name :cbn . displayName , 1814characters :cbn . characterNames , 1815})), 1816}; 1817context = { 1818bestOf :Math . max ( gameScores [ 0 ], gameScores [ 1 ]) * 2 - 1 , 1819durationMs :selectedReplays 1820. map (( replay ) => 1821Math . ceil (( replay . lastFrame + 124 ) / frameMsDivisor ), 1822) 1823. reduce (( prev , curr ) => prev + curr , 0 ), 1824 scores, 1825 finalScore, 1826players :contextPlayers , 1827startMs :startDate . getTime (), 1828}; 1829 1830const setId = updatedSetFields ?updatedSetFields . id :selectedSet . id ; 1831const sggId = updatedSetFields 1832 ?updatedSetFields . sggId 1833 :selectedSet . sggId ; 1834if ( setId ) { 1835if ( mode === Mode . STARTGG ) { 1836context . startgg = { 1837tournament :{ 1838name :startggTournament . name , 1839location :startggTournament . location , 1840}, 1841event :selectedSetChain . event ! , 1842phase :selectedSetChain . phase ! , 1843phaseGroup :selectedSetChain . phaseGroup ! , 1844set :{ 1845id :sggId , 1846internalId :setId , 1847fullRoundText :selectedSet . fullRoundText , 1848ordinal :selectedSet . ordinal , 1849round :selectedSet . round , 1850stream :updatedSetFields 1851 ?updatedSetFields . stream 1852 :selectedSet . stream , 1853}, 1854}; 1855} else if ( mode === Mode . CHALLONGE ) { 1856context . challonge = { 1857tournament :{ 1858name :selectedChallongeTournament . name , 1859slug :selectedChallongeTournament . slug , 1860tournamentType :selectedChallongeTournament . tournamentType , 1861}, 1862set :{ 1863id :typeof setId === 'string' ?setId :undefined , 1864fullRoundText :selectedSet . fullRoundText , 1865ordinal :selectedSet . ordinal , 1866round :selectedSet . round , 1867stream :updatedSetFields 1868 ?updatedSetFields . stream 1869 :selectedSet . stream , 1870}, 1871}; 1872} else if ( mode === Mode . PARRYGG ) { 1873context . startgg = { 1874tournament :{ 1875name :parryggTournament ?. name || '' , 1876location :parryggTournament ?. venueAddress || '' , 1877}, 1878event :selectedSetChain . event ! , 1879phase :selectedSetChain . phase ! , 1880phaseGroup :selectedSetChain . phaseGroup ! , 1881set :{ 1882id :sggId , 1883internalId :setId , 1884fullRoundText :selectedSet . fullRoundText , 1885ordinal :selectedSet . ordinal , 1886round :selectedSet . round , 1887stream :updatedSetFields 1888 ?updatedSetFields . stream 1889 :selectedSet . stream , 1890}, 1891}; 1892} else if ( mode === Mode . OFFLINE_MODE ) { 1893context . startgg = { 1894tournament :{ 1895name :offlineModeTournament . name , 1896location :offlineModeTournament . location , 1897}, 1898event :selectedSetChain . event ! , 1899phase :selectedSetChain . phase ! , 1900phaseGroup :selectedSetChain . phaseGroup ! , 1901set :{ 1902id :sggId , 1903internalId :setId , 1904fullRoundText :selectedSet . fullRoundText , 1905ordinal :selectedSet . ordinal , 1906round :selectedSet . round , 1907stream :updatedSetFields 1908 ?updatedSetFields . stream 1909 :selectedSet . stream , 1910}, 1911}; 1912} 1913} 1914} 1915} 1916} 1917 1918let startTimes :string [] = []; 1919if ( copySettings . writeStartTimes && undoSubdir . length === 0 ) { 1920startTimes = selectedReplays . map (( replay ) => 1921new Date ( replay . startAt . getTime () + offsetMs ). toISOString (), 1922); 1923} 1924try { 1925await window . electron . writeReplays ( 1926fileNames , 1927copySettings . output , 1928selectedReplays , 1929startTimes , 1930subdir , 1931copySettings . writeDisplayNames , 1932context , 1933); 1934if ( violators && violators . length > 0 ) { 1935const vsStr = ` ${ selectedSet . entrant1Participants 1936. map (( participant ) => participant . displayName ) 1937. join ( '/' )} vs ${ selectedSet . entrant2Participants 1938. map (( participant ) => participant . displayName ) 1939. join ( '/' )} ` ; 1940let poolName = '' ; 1941if ( 1942mode === Mode . STARTGG || 1943mode === Mode . PARRYGG || 1944mode === Mode . OFFLINE_MODE 1945) { 1946poolName = selectedSetChain . phaseGroup ?. name ?? '' ; 1947} else if ( mode === Mode . CHALLONGE ) { 1948poolName = selectedChallongeTournament . name ; 1949} 1950await window . electron . appendEnforcerResult ( 1951violators 1952. map ( 1953({ checkNames, displayName, entrantId}) => 1954` ${ entrantId } , ${ displayName } , ${ Array . from ( checkNames . keys ()) 1955. sort () 1956. join ( '|' )} , ${ poolName } , ${ 1957selectedSet . fullRoundText 1958} , ${ vsStr } ` , 1959) 1960. join ( '\n' ) 1961. concat ( '\n' ), 1962); 1963} 1964setCopySuccess ( 'Success!' ); 1965setTimeout (() => setCopySuccess ( '' ), 5000 ); 1966} finally { 1967setIsCopying ( false ); 1968} 1969}; 1970 1971const [ undoDialogOpen , setUndoDialogOpen ] = useState ( false ); 1972const [ gettingReportedSubdirs , setGettingReportedSubdirs ] = useState ( false ); 1973const [ reportedSubdirs , setReportedSubdirs ] = useState < string []>([]); 1974 1975const superKey = window . electron . isMac ?'CMD' :'CTRL' ; 1976 1977return ( 1978<> 1979< SlpDownloadModal 1980status = { slpDownloadStatus } 1981onClose = { async () => { 1982setSlpDownloadStatus ({ status :'idle' }); 1983}} 1984/> 1985< AppBar position = "fixed" color = "inherit" > 1986< Toolbar disableGutters variant = "dense" > 1987< AppBarSection flexGrow = { 1 } minWidth = { 600 }> 1988< Stack alignItems = "center" direction = "row" > 1989< Tooltip 1990arrow 1991title = { 1992allReplaysSelected 1993 ?'Deselect all replays' 1994 :'Select all replays' 1995} 1996> 1997< Checkbox 1998checked = { allReplaysSelected } 1999onClick = {() => { 2000const newAllReplaysSelected = ! allReplaysSelected ; 2001setAllReplaysSelected ( newAllReplaysSelected ); 2002applyAllReplaysSelected ( replays , newAllReplaysSelected ); 2003replays . forEach (( replay ) => { 2004replay . players . forEach (( player ) => { 2005player . playerOverrides = { 2006displayName :'' , 2007entrantId :0 , 2008participantId :0 , 2009prefix :'' , 2010pronouns :'' , 2011}; 2012}); 2013}); 2014resetOverrides (); 2015setBatchActives ( 2016getNewBatchActives ( 2017replays . filter (( replay ) => replay . selected ), 2018), 2019); 2020setReplays ( Array . from ( replays )); 2021}} 2022/> 2023</ Tooltip > 2024< InputBase 2025disabled 2026size = "small" 2027value = { 2028undoSubdir 2029 ?`Fixing ${ undoSubdir } ` 2030 :dir || 'Set replays folder...' 2031} 2032style = {{ flexGrow :1 }} 2033/> 2034{ ejected && < Typography variant = "body2" > Ejected! </ Typography >} 2035{ undoSubdir && 2036( gettingReplays ?( 2037< CircularProgress size = "24px" style = {{ margin :'9px' }} /> 2038) :( 2039< Tooltip arrow title = "Cancel" > 2040< IconButton 2041onClick = { async () => { 2042setDir ( await window . electron . setUndoSubdir ( '' )); 2043setUndoSubdir ( '' ); 2044refreshReplays ( true ); 2045}} 2046> 2047< Close /> 2048</ IconButton > 2049</ Tooltip > 2050))} 2051{ ! undoSubdir && ( 2052<> 2053{ dir && ( 2054< Tooltip arrow title = "Eject (if USB)" > 2055< IconButton 2056disabled = { ejecting } 2057onClick = { async () => { 2058setEjecting ( true ); 2059try { 2060setEjected ( await window . electron . maybeEject ()); 2061} finally { 2062setEjecting ( false ); 2063} 2064}} 2065> 2066< Eject /> 2067</ IconButton > 2068</ Tooltip > 2069)} 2070{ dir && 2071dirExists && 2072! gettingReplays && 2073( replays . length > 0 || invalidReplays . length > 0 ) && 2074( isUsb ?( 2075<> 2076< Tooltip 2077arrow 2078title = { 2079wouldDeleteCopyDir 2080 ?'Would delete copy folder' 2081 :'Delete replays folder and eject' 2082} 2083> 2084< div > 2085< IconButton 2086disabled = { wouldDeleteCopyDir } 2087onClick = {() => setDirDeleteDialogOpen ( true )} 2088> 2089< DeleteForeverOutlined /> 2090</ IconButton > 2091</ div > 2092</ Tooltip > 2093< Dialog 2094open = { dirDeleteDialogOpen } 2095onClose = {() => { 2096setDirDeleteDialogOpen ( false ); 2097}} 2098> 2099< DialogTitle > Delete Replays Folder? </ DialogTitle > 2100< DialogContent > 2101< Alert severity = "warning" > 2102{ replays . length } replays { ' ' } 2103{ invalidReplays . length > 0 2104 ?`(and ${ invalidReplays . length } invalid replays) ` 2105 :'' } 2106will be deleted! (And the drive will be ejected if 2107applicable) 2108</ Alert > 2109</ DialogContent > 2110< DialogActions > 2111< Button 2112disabled = { dirDeleting } 2113endIcon = { 2114dirDeleting ?( 2115< CircularProgress size = "24px" /> 2116) :( 2117< DeleteForever /> 2118) 2119} 2120onClick = { async () => { 2121try { 2122await deleteDir ([]); 2123setGuideState ( GuideState . NONE ); 2124} catch ( e :any ) { 2125showErrorDialog ([ 2126e instanceof Error ?e . message :e , 2127]); 2128} finally { 2129setDirDeleteDialogOpen ( false ); 2130} 2131}} 2132variant = "contained" 2133> 2134Delete 2135</ Button > 2136</ DialogActions > 2137</ Dialog > 2138</> 2139) :( 2140< Tooltip 2141arrow 2142title = { 2143wouldDeleteCopyDir 2144 ?'Would delete copy folder' 2145 :'Delete selected replays' 2146} 2147> 2148< div > 2149< IconButton 2150disabled = { 2151selectedReplays . length === 0 || 2152wouldDeleteCopyDir || 2153dirDeleting 2154} 2155onClick = {() => deleteSelected ( false )} 2156> 2157< DeleteForeverOutlined /> 2158</ IconButton > 2159</ div > 2160</ Tooltip > 2161))} 2162{ dir && ! gettingReplays && ( 2163< Tooltip arrow title = "Refresh replays" > 2164< IconButton onClick = {() => refreshReplays ()}> 2165< Refresh /> 2166</ IconButton > 2167</ Tooltip > 2168)} 2169{ gettingReplays ?( 2170< CircularProgress size = "24px" style = {{ margin :'9px' }} /> 2171) :( 2172< Tooltip arrow title = "Set replays folder" > 2173< IconButton onClick = { chooseDir }> 2174< FolderOpen /> 2175</ IconButton > 2176</ Tooltip > 2177)} 2178</> 2179)} 2180</ Stack > 2181</ AppBarSection > 2182< Divider 2183flexItem 2184orientation = "vertical" 2185style = {{ marginTop :8 , marginBottom :8 }} 2186/> 2187< AppBarSection width = { 300 }> 2188{ mode === Mode . STARTGG && ( 2189< Stack direction = "row" > 2190< InputBase 2191disabled 2192size = "small" 2193value = { startggTournament . slug || 'Set start.gg tournament...' } 2194style = {{ flexGrow :1 }} 2195/> 2196< Tooltip arrow title = "Refresh tournament and all descendants" > 2197< div > 2198< IconButton 2199disabled = { gettingTournament } 2200onClick = {() => 2201getStartggTournament ( startggTournament . slug ) 2202} 2203> 2204{ gettingTournament ?( 2205< CircularProgress size = "24px" /> 2206) :( 2207< Refresh /> 2208)} 2209</ IconButton > 2210</ div > 2211</ Tooltip > 2212< Tooltip arrow title = "Set start.gg tournament" > 2213< IconButton 2214aria-label = "Set start.gg tournament" 2215onClick = {() => setSlugDialogOpen ( true )} 2216> 2217< Edit /> 2218</ IconButton > 2219</ Tooltip > 2220< Dialog 2221open = { slugDialogOpen } 2222onClose = {() => { 2223setSlugDialogOpen ( false ); 2224}} 2225> 2226< StartggTournamentForm 2227gettingAdminedTournaments = { gettingAdminedTournaments } 2228adminedTournaments = { adminedTournaments } 2229gettingTournament = { gettingTournament } 2230getAdminedTournaments = { async () => { 2231setGettingAdminedTournaments ( true ); 2232try { 2233setAdminedTournaments ( 2234await window . electron . getTournaments (), 2235); 2236} catch ( e :unknown ) { 2237showErrorDialog ([ 2238`Unable to fetch admined tournaments: ${ 2239e instanceof Error ? e . message : e 2240} ` , 2241]); 2242} 2243setGettingAdminedTournaments ( false ); 2244}} 2245getTournament = { getStartggTournament } 2246close = {() => { 2247setSlugDialogOpen ( false ); 2248}} 2249/> 2250</ Dialog > 2251</ Stack > 2252)} 2253{ mode === Mode . CHALLONGE && ( 2254< Stack direction = "row" > 2255< InputBase 2256disabled 2257size = "small" 2258value = "Add Challonge tournament..." 2259style = {{ flexGrow :1 }} 2260/> 2261< Tooltip arrow title = "Add Challonge tournament" > 2262< IconButton 2263aria-label = "Add Challonge tournament" 2264onClick = {() => setSlugDialogOpen ( true )} 2265> 2266< Edit /> 2267</ IconButton > 2268</ Tooltip > 2269< Dialog 2270open = { slugDialogOpen } 2271onClose = {() => { 2272setSlugDialogOpen ( false ); 2273}} 2274> 2275< ChallongeTournamentForm 2276gettingAdminedTournaments = { gettingAdminedTournaments } 2277adminedTournaments = { adminedTournaments } 2278gettingTournament = { gettingTournament } 2279getAdminedTournaments = { async () => { 2280setGettingAdminedTournaments ( true ); 2281try { 2282setAdminedTournaments ( 2283await window . electron . getTournaments (), 2284); 2285} catch ( e :unknown ) { 2286showErrorDialog ([ 2287`Unable to fetch admined tournaments: ${ 2288e instanceof Error ? e . message : e 2289} ` , 2290]); 2291} 2292setGettingAdminedTournaments ( false ); 2293}} 2294getTournament = { getChallongeTournament } 2295close = {() => { 2296setSlugDialogOpen ( false ); 2297}} 2298/> 2299</ Dialog > 2300</ Stack > 2301)} 2302{ mode === Mode . PARRYGG && ( 2303< Stack direction = "row" > 2304< InputBase 2305disabled 2306size = "small" 2307value = { parryggSlug || 'Set parry.gg tournament...' } 2308style = {{ flexGrow :1 }} 2309/> 2310< Tooltip arrow title = "Refresh tournament and all descendants" > 2311< div > 2312< IconButton 2313disabled = { gettingTournament } 2314onClick = {() => getParryggTournament ( parryggSlug )} 2315> 2316{ gettingTournament ?( 2317< CircularProgress size = "24px" /> 2318) :( 2319< Refresh /> 2320)} 2321</ IconButton > 2322</ div > 2323</ Tooltip > 2324< Tooltip arrow title = "Set parry.gg tournament" > 2325< IconButton 2326aria-label = "Set parry.gg tournament" 2327onClick = {() => setParryggSlugDialogOpen ( true )} 2328> 2329< Edit /> 2330</ IconButton > 2331</ Tooltip > 2332< Dialog 2333open = { parryggSlugDialogOpen } 2334onClose = {() => { 2335setParryggSlugDialogOpen ( false ); 2336}} 2337> 2338< ParryggTournamentForm 2339gettingAdminedTournaments = { gettingAdminedTournaments } 2340adminedTournaments = { adminedTournaments } 2341gettingTournament = { gettingTournament } 2342getAdminedTournaments = { async () => { 2343setGettingAdminedTournaments ( true ); 2344try { 2345setAdminedTournaments ( 2346await window . electron . getTournaments (), 2347); 2348} catch ( e :unknown ) { 2349showErrorDialog ([ 2350`Unable to fetch admined tournaments: ${ 2351e instanceof Error ? e . message : e 2352} ` , 2353]); 2354} 2355setGettingAdminedTournaments ( false ); 2356}} 2357getTournament = { getParryggTournament } 2358close = {() => { 2359setParryggSlugDialogOpen ( false ); 2360}} 2361/> 2362</ Dialog > 2363</ Stack > 2364)} 2365{ mode === Mode . OFFLINE_MODE && ( 2366< OfflineModeConnection 2367offlineModeStatus = { offlineModeStatus } 2368offlineModeTournament = { offlineModeTournament } 2369/> 2370)} 2371{ mode === Mode . MANUAL && ( 2372< ManualBar 2373manualDialogOpen = { manualDialogOpen } 2374setManualDialogOpen = { setManualDialogOpen } 2375manualNames = { manualNames } 2376setManualNames = { setManualNamesOuter } 2377/> 2378)} 2379</ AppBarSection > 2380</ Toolbar > 2381</ AppBar > 2382< TopColumns 2383direction = "row" 2384divider = {< Divider flexItem orientation = "vertical" />} 2385spacing = "8px" 2386> 2387< TopColumn flexGrow = { 1 } minWidth = "600px" > 2388{ dir && 2389! gettingReplays && 2390( dirExists ?( 2391<> 2392< ReplayList 2393dirInit = { dirInit } 2394numAvailablePlayers = { availablePlayers . length } 2395replays = { replays } 2396replayRefs = { replayRefs } 2397selectedChipData = { selectedChipData } 2398findOtherPlayer = { findOtherPlayer } 2399onClick = { onReplayClick } 2400onOverride = { onPlayerOverride } 2401resetSelectedChipData = { resetSelectedChipData } 2402elevate = { 2403guideActive && 2404guideBackdropOpen && 2405guideState === GuideState . REPLAYS 2406} 2407elevateChips = { 2408guideActive && 2409guideBackdropOpen && 2410guideState === GuideState . PLAYERS && 2411numBatchActive !== 2 && 2412numBatchActive !== 4 2413} 2414elevateNames = { 2415guideActive && 2416guideBackdropOpen && 2417guideState === GuideState . PLAYERS 2418} 2419/> 2420< Dialog 2421open = { skewDialogOpen } 2422onClose = {() => { 2423setSkewDialogOpen ( false ); 2424}} 2425> 2426< DialogTitle > 2427{ skewDetected 2428 ?'Large time gap detected!' 2429 :'Re-order replays' } 2430</ DialogTitle > 2431< DialogContent > 2432{ replays . map (( replay , i ) => ( 2433< ListItem key = { replay . fileName } disableGutters > 2434< Stack alignItems = "center" direction = "row" gap = "8px" > 2435< SkewReplay replay = { replay } /> 2436{ i === 0 ?( 2437< Tooltip arrow placement = "left" title = "First" > 2438< div style = {{ height :'40px' , width :'40px' }} /> 2439</ Tooltip > 2440) :( 2441< Tooltip arrow placement = "left" title = "Move up" > 2442< IconButton 2443onClick = {() => { 2444const arr = [ ...replays ]; 2445[ arr [ i - 1 ], arr [ i ]] = [ arr [ i ], arr [ i - 1 ]]; 2446setReplays ( arr ); 2447}} 2448> 2449< ArrowUpward /> 2450</ IconButton > 2451</ Tooltip > 2452)} 2453{ i === replays . length - 1 ?( 2454< Tooltip arrow placement = "right" title = "Last" > 2455< div style = {{ height :'40px' , width :'40px' }} /> 2456</ Tooltip > 2457) :( 2458< Tooltip arrow placement = "right" title = "Move down" > 2459< IconButton 2460onClick = {() => { 2461const arr = [ ...replays ]; 2462[ arr [ i ], arr [ i + 1 ]] = [ arr [ i + 1 ], arr [ i ]]; 2463setReplays ( arr ); 2464}} 2465> 2466< ArrowDownward /> 2467</ IconButton > 2468</ Tooltip > 2469)} 2470</ Stack > 2471</ ListItem > 2472))} 2473</ DialogContent > 2474< DialogActions > 2475< Button 2476variant = "contained" 2477onClick = {() => { 2478for ( let i = replays . length - 1 ; i > 0 ; i -= 1 ) { 2479const firstMs = replays [ i - 1 ]. startAt . getTime (); 2480const secondMs = replays [ i ]. startAt . getTime (); 2481if ( 2482firstMs > secondMs || 2483secondMs - firstMs > 3600000 2484) { 2485const durationMs = Math . ceil ( 2486( replays [ i - 1 ]. lastFrame + 124 ) / frameMsDivisor , 2487); 2488replays [ i - 1 ]. startAt = new Date ( 2489secondMs - durationMs , 2490); 2491} 2492} 2493setReplays ([ ...replays ]); 2494setSkewDialogOpen ( false ); 2495}} 2496> 2497Fix! 2498</ Button > 2499</ DialogActions > 2500</ Dialog > 2501</> 2502) :( 2503< Alert 2504severity = { wasDeleted ?'warning' :'error' } 2505sx = {{ mb :'8px' , mt :'8px' , pl :'10px' }} 2506> 2507{ wasDeleted 2508 ?'Replays folder deleted.' 2509 :'Replays folder not found.' } 2510</ Alert > 2511))} 2512{ dir && gettingReplays && ( 2513< CircularProgress 2514size = "24px" 2515style = {{ 2516marginTop :'8px' , 2517marginBottom :'8px' , 2518marginLeft :'10px' , 2519}} 2520/> 2521)} 2522< div ref = { copyControlsRef } /> 2523< CopyControls 2524dir = { copyDir } 2525setDir = { setCopyDir } 2526useLAN = { useLAN } 2527host = { host } 2528hostFormat = { hostFormat } 2529error = { copyError } 2530setError = { setCopyError } 2531errorDialogOpen = { copyErrorDialogOpen } 2532setErrorDialogOpen = { setCopyErrorDialogOpen } 2533hasSelectedReplays = { selectedReplays . length > 0 } 2534isCopying = { isCopying } 2535onCopy = { onCopy } 2536success = { copySuccess } 2537copySettings = { copySettings } 2538setCopySettings = { setCopySettings } 2539elevateSettings = { 2540guidedMode && 2541tournamentSet && 2542copyDirSet && 2543! confirmedCopySettings 2544} 2545vlerkMode = { vlerkMode } 2546undoSubdir = { undoSubdir } 2547hideCopyButton = { hideCopyButton } 2548setConfirmedCopySettings = { setConfirmedCopySettings } 2549guideState = { guideState } 2550setGuideBackdropOpen = { setGuideBackdropOpen } 2551/> 2552</ TopColumn > 2553< TopColumn 2554width = "300px" 2555sx = {{ 2556zIndex :( theme ) => 2557guideActive && 2558guideBackdropOpen && 2559( guideState === GuideState . SET || 2560( mode === Mode . MANUAL && guideState === GuideState . PLAYERS )) 2561 ?theme . zIndex . drawer + 2 2562 :undefined , 2563}} 2564> 2565< RightColumn 2566mode = { mode } 2567guideState = { guideState } 2568selectSet = { selectSet } 2569setGuideState = { setGuideState } 2570vlerkMode = { vlerkMode } 2571selectedSetChain = { selectedSetChain } 2572setSelectedSetChain = { setSelectedSetChain } 2573startggTournament = { startggTournament } 2574challongeTournaments = { challongeTournaments } 2575getChallongeTournament = { getChallongeTournament } 2576setSelectedChallongeTournament = { setSelectedChallongeTournament } 2577parryggTournament = { parryggTournament } 2578offlineModeTournament = { offlineModeTournament } 2579manualNames = { manualNames } 2580selectedChipData = { selectedChipData } 2581setSelectedChipData = { setSelectedChipData } 2582/> 2583</ TopColumn > 2584</ TopColumns > 2585< Bottom elevation = { 3 }> 2586< BottomColumns 2587direction = "row" 2588divider = {< Divider flexItem orientation = "vertical" />} 2589spacing = "8px" 2590> 2591< Stack 2592boxSizing = "border-box" 2593flexGrow = { 1 } 2594minWidth = "600px" 2595padding = "20px 0 0 42px" 2596> 2597< Stack direction = "row" > 2598{ batchChip ( 0 )} 2599{ batchChip ( 1 )} 2600{ batchChip ( 2 )} 2601{ batchChip ( 3 )} 2602</ Stack > 2603{ guidedMode ?( 2604< Stack 2605alignItems = "start" 2606direction = "row" 2607flexGrow = { 1 } 2608justifyContent = "right" 2609marginTop = "8px" 2610spacing = "8px" 2611> 2612< GuidedDialog 2613open = { guidedDialogOpen } 2614mode = { mode } 2615gettingAdminedTournaments = { gettingAdminedTournaments } 2616adminedTournaments = { adminedTournaments } 2617getAdminedTournaments = { async () => { 2618setGettingAdminedTournaments ( true ); 2619try { 2620setAdminedTournaments ( 2621await window . electron . getTournaments (), 2622); 2623} catch ( e :unknown ) { 2624showErrorDialog ([ 2625`Unable to fetch admined tournaments: ${ 2626e instanceof Error ? e . message : e 2627} ` , 2628]); 2629} 2630setGettingAdminedTournaments ( false ); 2631}} 2632gettingTournament = { gettingTournament } 2633tournamentSet = { tournamentSet } 2634copyDirSet = { copyDirSet } 2635getStartggTournament = { getStartggTournament } 2636getChallongeTournament = { getChallongeTournament } 2637getParryggTournament = { getParryggTournament } 2638offlineModeStatus = { offlineModeStatus } 2639manualNames = { manualNames } 2640setManualNames = { setManualNamesOuter } 2641setCopyDir = { setCopyDir } 2642confirmedCopySettings = { confirmedCopySettings } 2643state = { guideState } 2644setState = { setGuideState } 2645backdropOpen = { guideBackdropOpen } 2646setBackdropOpen = { setGuideBackdropOpen } 2647/> 2648< Stack > 2649< Typography 2650variant = "caption" 2651style = {{ cursor :'pointer' }} 2652onClick = {() => { 2653setGuidedMode (( old ) => { 2654window . electron . setGuidedMode ( ! old ); 2655return ! old ; 2656}); 2657}} 2658> 2659F1: Walkthrough Mode Off 2660</ Typography > 2661{( mode === Mode . STARTGG || mode === Mode . OFFLINE_MODE ) && ( 2662< Typography 2663variant = "caption" 2664style = {{ cursor :'pointer' }} 2665onClick = {() => { 2666window . electron . openEntrantsWindow (); 2667}} 2668> 2669{ superKey } + E: Pool Entrants 2670</ Typography > 2671)} 2672< Typography 2673variant = "caption" 2674style = {{ cursor :'pointer' }} 2675onClick = {() => { 2676window . dispatchEvent ( new Event ( WindowEvent . CTRLF )); 2677}} 2678> 2679{ superKey } + F: Search players 2680</ Typography > 2681< Typography 2682variant = "caption" 2683style = {{ cursor :'pointer' }} 2684onClick = { async () => { 2685setUndoDialogOpen ( true ); 2686try { 2687setGettingReportedSubdirs ( true ); 2688setReportedSubdirs ( 2689await window . electron . getReportedSubdirs (), 2690); 2691} catch ( e :any ) { 2692showErrorDialog ([ e instanceof Error ?e . message :e ]); 2693} finally { 2694setGettingReportedSubdirs ( false ); 2695} 2696}} 2697> 2698{ superKey } + Z: Fix reported set 2699</ Typography > 2700</ Stack > 2701</ Stack > 2702) :( 2703< Stack 2704alignItems = "start" 2705direction = "row" 2706flexGrow = { 1 } 2707justifyContent = "right" 2708marginTop = "8px" 2709spacing = "8px" 2710> 2711{ vlerkMode && ( 2712< Stack alignItems = "end" > 2713< Stack direction = "row" alignItems = "center" gap = "8px" > 2714< FormControl > 2715< InputLabel 2716size = "small" 2717id = "vlerk-mode-character-select-label" 2718> 2719Character 2720</ InputLabel > 2721< Select 2722label = "Character" 2723labelId = "vlerk-mode-character-select-label" 2724size = "small" 2725style = {{ width :'106px' }} 2726value = { vlerkModeExternalId } 2727onChange = {( event ) => { 2728if ( Number . isInteger ( event . target . value )) { 2729setVlerkModeExternalId ( 2730event . target . value as number , 2731); 2732setVlerkModeColorIndex ( - 1 ); 2733} 2734}} 2735> 2736< MenuItem value = { - 1 }> Any </ MenuItem > 2737{ Array . from ( characterNames . entries ()) 2738. sort (( a , b ) => a [ 1 ]. localeCompare ( b [ 1 ])) 2739. map (([ externalId , characterName ]) => ( 2740< MenuItem key = { externalId } value = { externalId }> 2741{ characterName } 2742</ MenuItem > 2743))} 2744</ Select > 2745</ FormControl > 2746< FormControl > 2747< InputLabel 2748size = "small" 2749id = "vlerk-mode-color-select-label" 2750> 2751Color 2752</ InputLabel > 2753< Select 2754label = "Color" 2755labelId = "vlerk-mode-color-select-label" 2756size = "small" 2757value = { vlerkModeColorIndex } 2758onChange = {( event ) => { 2759if ( Number . isInteger ( event . target . value )) { 2760setVlerkModeColorIndex ( 2761event . target . value as number , 2762); 2763} 2764}} 2765> 2766< MenuItem value = { - 1 }> Any </ MenuItem > 2767{ vlerkModeExternalId !== - 1 && 2768Array ( 2769characterColorIndexLength . get ( 2770vlerkModeExternalId , 2771) ! , 2772) 2773. fill ( 0 ) 2774. map (( _ , i ) => i ) 2775. map (( i ) => ( 2776< MenuItem key = { i } value = { i }> 2777< Avatar 2778src = { getCharacterIcon ( 2779vlerkModeExternalId , 2780i , 2781)} 2782style = {{ height :'24px' , width :'24px' }} 2783variant = "square" 2784/> 2785</ MenuItem > 2786))} 2787</ Select > 2788</ FormControl > 2789< IconButton 2790disabled = { 2791replays . length === 0 || 2792( vlerkModeExternalId === - 1 && 2793vlerkModeColorIndex === - 1 ) 2794} 2795onClick = {() => { 2796for ( 2797let i = vlerkModeFilterLastIndex + 1 ; 2798i < replays . length ; 2799i += 1 2800) { 2801const replay = replays [ i ]; 2802if ( 2803replay . players . some ( 2804( player ) => 2805player . playerType === 0 && 2806( vlerkModeExternalId === - 1 || 2807vlerkModeExternalId === 2808player . externalCharacterId ) && 2809( vlerkModeColorIndex === - 1 || 2810vlerkModeColorIndex === 2811player . costumeIndex ), 2812) 2813) { 2814replayRefs [ i ]. current ! . scrollIntoView ({ 2815behavior :'smooth' , 2816}); 2817setVlerkModeFilterLastIndex ( i ); 2818setVlerkModeFilterNotFound ( false ); 2819return ; 2820} 2821} 2822if ( vlerkModeFilterLastIndex === 0 ) { 2823setVlerkModeFilterNotFound ( true ); 2824return ; 2825} 2826// return to top and continue 2827for ( 2828let i = 0 ; 2829i < vlerkModeFilterLastIndex ; 2830i += 1 2831) { 2832const replay = replays [ i ]; 2833if ( 2834replay . players . some ( 2835( player ) => 2836player . playerType === 0 && 2837( vlerkModeExternalId === - 1 || 2838vlerkModeExternalId === 2839player . externalCharacterId ) && 2840( vlerkModeColorIndex === - 1 || 2841vlerkModeColorIndex === 2842player . costumeIndex ), 2843) 2844) { 2845replayRefs [ i ]. current ! . scrollIntoView ({ 2846behavior :'smooth' , 2847}); 2848setVlerkModeFilterLastIndex ( i ); 2849setVlerkModeFilterNotFound ( false ); 2850return ; 2851} 2852} 2853setVlerkModeFilterLastIndex ( 0 ); 2854setVlerkModeFilterNotFound ( true ); 2855}} 2856> 2857< Search /> 2858</ IconButton > 2859</ Stack > 2860{ vlerkModeFilterNotFound && ( 2861< Typography variant = "body2" color = "error" > 2862Not found 2863</ Typography > 2864)} 2865</ Stack > 2866)} 2867< Stack > 2868{( mode === Mode . STARTGG || mode === Mode . OFFLINE_MODE ) && ( 2869< Typography 2870variant = "caption" 2871style = {{ cursor :'pointer' }} 2872onClick = {() => { 2873window . electron . openEntrantsWindow (); 2874}} 2875> 2876{ superKey } + E: Pool Entrants 2877</ Typography > 2878)} 2879< Typography 2880variant = "caption" 2881style = {{ cursor :'pointer' }} 2882onClick = {() => { 2883window . dispatchEvent ( new Event ( WindowEvent . CTRLF )); 2884}} 2885> 2886{ superKey } + F: Search players 2887</ Typography > 2888{ vlerkMode && ( 2889< Typography 2890variant = "caption" 2891style = {{ cursor :'pointer' }} 2892onClick = {() => { 2893window . dispatchEvent ( new Event ( WindowEvent . CTRLS )); 2894}} 2895> 2896{ superKey } + S: Copy replays 2897</ Typography > 2898)} 2899</ Stack > 2900< Stack > 2901< Typography 2902variant = "caption" 2903style = {{ cursor :'pointer' }} 2904onClick = {() => { 2905setSkewDialogOpen ( true ); 2906}} 2907> 2908{ superKey } + T: Re-order replays 2909</ Typography > 2910< Typography 2911variant = "caption" 2912style = {{ cursor :'pointer' }} 2913onClick = { async () => { 2914setUndoDialogOpen ( true ); 2915try { 2916setGettingReportedSubdirs ( true ); 2917setReportedSubdirs ( 2918await window . electron . getReportedSubdirs (), 2919); 2920} catch ( e :any ) { 2921showErrorDialog ([ e instanceof Error ?e . message :e ]); 2922} finally { 2923setGettingReportedSubdirs ( false ); 2924} 2925}} 2926> 2927{ superKey } + Z: Fix reported set 2928</ Typography > 2929< Typography 2930variant = "caption" 2931style = {{ cursor :'pointer' }} 2932onClick = {() => { 2933setGuidedMode (( old ) => { 2934window . electron . setGuidedMode ( ! old ); 2935return ! old ; 2936}); 2937}} 2938> 2939F1: Walkthrough Mode 2940</ Typography > 2941</ Stack > 2942</ Stack > 2943)} 2944</ Stack > 2945< Stack justifyContent = "space-between" width = "300px" > 2946< Stack > 2947{ selectedSet . id !== 0 && ( 2948<> 2949< Stack 2950alignItems = "center" 2951justifyContent = "center" 2952direction = "row" 2953gap = "8px" 2954> 2955< Box width = "16px" /> 2956< Typography noWrap lineHeight = "20px" variant = "caption" > 2957{ selectedSet . fullRoundText } 2958{( typeof selectedSet . id === 'string' || 2959( Number . isInteger ( selectedSet . id ) && 2960selectedSet . id > 0 )) && 2961` ( ${ selectedSet . id } )` } 2962</ Typography > 2963{ selectedSet . state === State . CALLED && ( 2964< Tooltip arrow placement = "top" title = "Called" > 2965< NotificationsActive 2966fontSize = "inherit" 2967style = {{ color :calledColor }} 2968/> 2969</ Tooltip > 2970)} 2971{ selectedSet . state === State . STARTED && ( 2972< Tooltip arrow placement = "top" title = "Started" > 2973< HourglassTop 2974fontSize = "inherit" 2975style = {{ color :startedColor }} 2976/> 2977</ Tooltip > 2978)} 2979{ selectedSet . state === State . COMPLETED && ( 2980< Tooltip arrow placement = "top" title = "Completed" > 2981< Backup fontSize = "inherit" /> 2982</ Tooltip > 2983)} 2984</ Stack > 2985< Tooltip arrow placement = "top" title = "Click or drag!" > 2986< Stack direction = "row" gap = "8px" > 2987< Stack gap = "8px" width = "50%" > 2988< DraggableChip 2989entrantId = { selectedSet . entrant1Id } 2990nameWithHighlight = {{ 2991name :selectedSet . entrant1Participants [ 0 ] 2992. displayName , 2993}} 2994participantId = { selectedSet . entrant1Participants [ 0 ]. id } 2995prefix = { selectedSet . entrant1Participants [ 0 ]. prefix } 2996pronouns = { 2997selectedSet . entrant1Participants [ 0 ]. pronouns 2998} 2999selectedChipData = { selectedChipData } 3000setSelectedChipData = { setSelectedChipData } 3001elevate = { 3002guideActive && 3003guideBackdropOpen && 3004guideState === GuideState . PLAYERS 3005} 3006/> 3007{ selectedSet . entrant1Participants . length > 1 && ( 3008< DraggableChip 3009entrantId = { selectedSet . entrant1Id } 3010nameWithHighlight = {{ 3011name :selectedSet . entrant1Participants [ 1 ] 3012. displayName , 3013}} 3014participantId = { 3015selectedSet . entrant1Participants [ 1 ]. id 3016} 3017prefix = { selectedSet . entrant1Participants [ 1 ]. prefix } 3018pronouns = { 3019selectedSet . entrant1Participants [ 1 ]. pronouns 3020} 3021selectedChipData = { selectedChipData } 3022setSelectedChipData = { setSelectedChipData } 3023elevate = { 3024guideActive && 3025guideBackdropOpen && 3026guideState === GuideState . PLAYERS 3027} 3028/> 3029)} 3030</ Stack > 3031< Stack gap = "8px" width = "50%" > 3032< DraggableChip 3033entrantId = { selectedSet . entrant2Id } 3034nameWithHighlight = {{ 3035name :selectedSet . entrant2Participants [ 0 ] 3036. displayName , 3037}} 3038participantId = { selectedSet . entrant2Participants [ 0 ]. id } 3039prefix = { selectedSet . entrant2Participants [ 0 ]. prefix } 3040pronouns = { 3041selectedSet . entrant2Participants [ 0 ]. pronouns 3042} 3043selectedChipData = { selectedChipData } 3044setSelectedChipData = { setSelectedChipData } 3045elevate = { 3046guideActive && 3047guideBackdropOpen && 3048guideState === GuideState . PLAYERS 3049} 3050/> 3051{ selectedSet . entrant2Participants . length > 1 && ( 3052< DraggableChip 3053entrantId = { selectedSet . entrant2Id } 3054nameWithHighlight = {{ 3055name :selectedSet . entrant2Participants [ 1 ] 3056. displayName , 3057}} 3058participantId = { 3059selectedSet . entrant2Participants [ 1 ]. id 3060} 3061prefix = { selectedSet . entrant2Participants [ 1 ]. prefix } 3062pronouns = { 3063selectedSet . entrant2Participants [ 1 ]. pronouns 3064} 3065selectedChipData = { selectedChipData } 3066setSelectedChipData = { setSelectedChipData } 3067elevate = { 3068guideActive && 3069guideBackdropOpen && 3070guideState === GuideState . PLAYERS 3071} 3072/> 3073)} 3074</ Stack > 3075</ Stack > 3076</ Tooltip > 3077</> 3078)} 3079</ Stack > 3080< Stack direction = "row" justifyContent = "flex-end" paddingTop = "8px" > 3081< AssignStream 3082mode = { mode } 3083selectedSet = { selectedSet } 3084stations = { stations } 3085streams = { streams } 3086refreshStartggTournament = {() => 3087getStartggTournament ( startggTournament . slug ) 3088} 3089/> 3090< ResetSet mode = { mode } selectedSet = { selectedSet } /> 3091{( mode === Mode . STARTGG || mode === Mode . OFFLINE_MODE ) && ( 3092< Tooltip arrow title = "Mark set called" > 3093< div > 3094< IconButton 3095color = "primary" 3096disabled = { 3097! ( 3098( typeof selectedSet . id === 'string' || 3099( Number . isInteger ( selectedSet . id ) && 3100selectedSet . id > 0 )) && 3101( selectedSet . state === State . PENDING || 3102selectedSet . state === State . STARTED ) 3103) || callingSet 3104} 3105size = "small" 3106onClick = {() => callSet ( selectedSet )} 3107> 3108{ callingSet ?( 3109< CircularProgress size = "24px" /> 3110) :( 3111< NotificationsActive /> 3112)} 3113</ IconButton > 3114</ div > 3115</ Tooltip > 3116)} 3117< Tooltip arrow title = "Mark set started" > 3118< div > 3119< IconButton 3120color = "primary" 3121disabled = { 3122! ( 3123( typeof selectedSet . id === 'string' || 3124( Number . isInteger ( selectedSet . id ) && 3125selectedSet . id > 0 )) && 3126( selectedSet . state === State . PENDING || 3127selectedSet . state === State . CALLED ) 3128) || startingSet 3129} 3130size = "small" 3131onClick = {() => startSet ( selectedSet )} 3132> 3133{ startingSet ?( 3134< CircularProgress size = "24px" /> 3135) :( 3136< HourglassTop /> 3137)} 3138</ IconButton > 3139</ div > 3140</ Tooltip > 3141< ManualReport 3142mode = { mode } 3143reportChallongeSet = { reportChallongeSet } 3144reportStartggSet = { reportStartggSet } 3145reportParryggSet = { reportParryggSet } 3146reportOfflineModeSet = { reportOfflineModeSet } 3147selectedSet = { selectedSet } 3148/> 3149< SetControls 3150mode = { mode } 3151copyReplays = { onCopy } 3152deleteReplays = { 3153// eslint-disable-next-line no-nested-ternary 3154undoSubdir 3155 ?deleteUndo 3156 :isUsb 3157 ?() => { 3158return deleteDir ( 3159selectedReplays . map (( replay ) => replay . fileName ), 3160); 3161} 3162 :() => { 3163return deleteSelected ( true ); 3164} 3165} 3166reportChallongeSet = { reportChallongeSet } 3167reportStartggSet = { reportStartggSet } 3168reportParryggSet = { reportParryggSet } 3169reportOfflineModeSet = { reportOfflineModeSet } 3170setReportSettings = { async ( 3171newReportSettings :ReportSettings , 3172) => { 3173await window . electron . setReportSettings ( newReportSettings ); 3174setReportSettings ( newReportSettings ); 3175}} 3176resetGuide = {() => { 3177setGuideState ( GuideState . NONE ); 3178setGuideBackdropOpen ( false ); 3179}} 3180isCopying = { isCopying } 3181copyDisabled = { 3182( ! copyDir && ! host . address ) || selectedReplays . length === 0 3183} 3184isDeleting = { dirDeleting } 3185dqId = { dq . entrantId } 3186hasRemainingReplays = { hasRemainingReplays } 3187reportSettings = { reportSettings } 3188selectedReplays = { selectedReplays } 3189set = { selectedSet } 3190elevate = { 3191guideActive && 3192guideBackdropOpen && 3193guideState === GuideState . PLAYERS 3194} 3195enforcerVersion = { ENFORCER_VERSION } 3196enforcerSetting = { enforcerSetting } 3197smuggleCostumeIndex = { smuggleCostumeIndex } 3198wouldDeleteCopyDir = { wouldDeleteCopyDir } 3199replayLoadCount = { replayLoadCount } 3200undoSubdir = { undoSubdir } 3201/> 3202</ Stack > 3203</ Stack > 3204</ BottomColumns > 3205</ Bottom > 3206< Dialog 3207open = { undoDialogOpen } 3208onClose = {() => { 3209setUndoDialogOpen ( false ); 3210}} 3211> 3212< DialogTitle > Fix Reported Set </ DialogTitle > 3213< DialogContent > 3214{ gettingReportedSubdirs ?( 3215< CircularProgress /> 3216) :( 3217< List disablePadding > 3218{ reportedSubdirs . map (( reportedSubdir ) => ( 3219< ListItem disablePadding key = { reportedSubdir }> 3220< ListItemButton 3221disableGutters 3222onClick = { async () => { 3223try { 3224setDir ( 3225await window . electron . setUndoSubdir ( reportedSubdir ), 3226); 3227setUndoSubdir ( reportedSubdir ); 3228setUndoDialogOpen ( false ); 3229setIsUsb ( false ); 3230setWasDeleted ( false ); 3231refreshReplays ( true ); 3232setEjected ( false ); 3233} catch ( e :any ) { 3234showErrorDialog ([ e instanceof Error ?e . message :e ]); 3235} 3236}} 3237> 3238< ListItemText >{ reportedSubdir }</ ListItemText > 3239</ ListItemButton > 3240</ ListItem > 3241))} 3242</ List > 3243)} 3244</ DialogContent > 3245</ Dialog > 3246< Backdrop 3247onClick = { resetSelectedChipData } 3248open = { Boolean ( 3249selectedChipData . entrantId && selectedChipData . participantId , 3250)} 3251sx = {{ zIndex :( theme ) => theme . zIndex . drawer + 3 }} 3252/> 3253< Backdrop 3254onClick = {() => setGuideBackdropOpen ( false )} 3255open = { guidedMode && guideBackdropOpen } 3256sx = {{ zIndex :( theme ) => theme . zIndex . drawer + 1 }} 3257/> 3258< ErrorDialog 3259messages = { errors } 3260onClose = {() => { 3261setErrors ([]); 3262setErrorDialogOpen ( false ); 3263}} 3264open = { errorDialogOpen } 3265/> 3266< Settings 3267appVersion = { appVersion } 3268latestAppVersion = { latestAppVersion } 3269mode = { mode } 3270setMode = { async ( newMode :Mode ) => { 3271setMode ( newMode ); 3272setSelectedSet ( EMPTY_SET ); 3273setSelectedSetChain ( EMPTY_SELECTED_SET_CHAIN ); 3274setSelectedChallongeTournament ({ 3275name :'' , 3276slug :'' , 3277tournamentType :'' , 3278}); 3279await window . electron . setSelectedSetChain ( 0 , 0 , 0 ); 3280await window . electron . setSelectedChallongeTournament ( '' ); 3281}} 3282useLAN = { useLAN } 3283setUseLAN = { setUseLAN } 3284enforcerSetting = { enforcerSetting } 3285setEnforcerSetting = { setEnforcerSetting } 3286vlerkMode = { vlerkMode } 3287setVlerkMode = { setVlerkMode } 3288guidedMode = { guidedMode } 3289setGuidedMode = { setGuidedMode } 3290smuggleCostumeIndex = { smuggleCostumeIndex } 3291setSmuggleCostumeIndex = { setSmuggleCostumeIndex } 3292fileNameFormat = { fileNameFormat } 3293setFileNameFormat = { setFileNameFormat } 3294folderNameFormat = { folderNameFormat } 3295setFolderNameFormat = { setFolderNameFormat } 3296hideCopyButton = { hideCopyButton } 3297setHideCopyButton = { setHideCopyButton } 3298setAdminedTournaments = { setAdminedTournaments } 3299setGettingAdminedTournaments = { setGettingAdminedTournaments } 3300showErrorDialog = { showErrorDialog } 3301enforcerVersion = { ENFORCER_VERSION } 3302hostFormat = { hostFormat } 3303/> 3304< GlobalHotKeys 3305keyMap = {{ 3306COPY :window . electron . isMac 3307 ?[ 'command+s' , 'command+S' ] 3308 :[ 'ctrl+s' , 'ctrl+S' ], 3309ENTRANTS :window . electron . isMac 3310 ?[ 'command+e' , 'command+E' ] 3311 :[ 'ctrl+e' , 'ctrl+E' ], 3312ESC :'escape' , 3313FIND :window . electron . isMac 3314 ?[ 'command+f' , 'command+F' ] 3315 :[ 'ctrl+f' , 'ctrl+F' ], 3316SKEW :window . electron . isMac 3317 ?[ 'command+t' , 'command+T' ] 3318 :[ 'ctrl+t' , 'ctrl+T' ], 3319UNDO :window . electron . isMac 3320 ?[ 'command+z' , 'command+Z' ] 3321 :[ 'ctrl+z' , 'ctrl+Z' ], 3322WALKTHROUGH :'F1' , 3323}} 3324handlers = {{ 3325COPY :() => { 3326window . dispatchEvent ( new Event ( WindowEvent . CTRLS )); 3327}, 3328ENTRANTS :() => { 3329window . electron . openEntrantsWindow (); 3330}, 3331ESC :() => { 3332window . dispatchEvent ( new Event ( WindowEvent . ESCAPE )); 3333}, 3334FIND :() => { 3335window . dispatchEvent ( new Event ( WindowEvent . CTRLF )); 3336}, 3337SKEW :() => { 3338setSkewDialogOpen ( true ); 3339}, 3340UNDO :async () => { 3341setUndoDialogOpen ( true ); 3342try { 3343setGettingReportedSubdirs ( true ); 3344setReportedSubdirs ( await window . electron . getReportedSubdirs ()); 3345} catch ( e :any ) { 3346showErrorDialog ([ e instanceof Error ?e . message :e ]); 3347} finally { 3348setGettingReportedSubdirs ( false ); 3349} 3350}, 3351WALKTHROUGH :() => { 3352setGuidedMode (( old ) => { 3353window . electron . setGuidedMode ( ! old ); 3354return ! old ; 3355}); 3356}, 3357}} 3358/> 3359</> 3360); 3361} 3362 3363export default function App () { 3364return ( 3365< Router > 3366< Routes > 3367< Route path = "/" element = {< Hello />} /> 3368</ Routes > 3369</ Router > 3370); 3371}