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