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