void UpdateXferProgress( unsigned long iBytesCurrent, unsigned long iBytesTotal ) { bool bInterrupt = false; FOREACH_EnabledPlayer(pn) { bInterrupt |= INPUTMAPPER->IsButtonDown( MenuInput(pn, MENU_BUTTON_SELECT) ); bInterrupt |= INPUTMAPPER->IsButtonDown(MenuInput(pn, MENU_BUTTON_LEFT)) && INPUTMAPPER->IsButtonDown(MenuInput(pn, MENU_BUTTON_RIGHT)); } if ( bInterrupt ) { InterruptCopy(); InputEventArray throwaway; INPUTFILTER->GetInputEvents( throwaway ); } // Draw() is very expensive: only do it on occasion. if( DrawTimer.Ago() < DRAW_UPDATE_TIME ) return; /* this truncates to int, but that's okay for our purposes */ float iTransferRate = iBytesCurrent / g_UpdateDuration.Ago(); float fPercent = iBytesCurrent / (iBytesTotal/100); const CString sRate = FormatByteValue( iTransferRate ) + "/sec"; CString sMessage = ssprintf( "\n\n%s\n%.2f%% %s\n\n%s", USER_PACK_WAIT_TEXT.GetValue().c_str(), fPercent, sRate.c_str(), USER_PACK_CANCEL_TEXT.GetValue().c_str() ); SCREENMAN->OverlayMessage( sMessage ); SCREENMAN->Draw(); DrawTimer.Touch(); }
void ScreenUserPacks::HandleScreenMessage( const ScreenMessage SM ) { #if 0 /* Not compatible with FileCopy callback system; was this ever used? -- vyhd */ if ( SM == SM_CancelTransfer ) { Dialog::OK("SM_CancelTransfer"); InterruptCopy(); InputEventArray throwaway; INPUTFILTER->GetInputEvents( throwaway ); LOG->Warn("Cancelled Transfer of user pack."); } #endif if ( SM == SM_LinkedMenuChange ) { m_pCurLOM = m_pCurLOM->SwitchToNextMenu(); return; } if ( SM == SM_ConfirmDeleteZip ) { SCREENMAN->Prompt( SM_AnswerConfirmDeleteZip, "Proceed to delete pack from machine?", PROMPT_YES_NO, ANSWER_NO ); } if ( SM == SM_AnswerConfirmDeleteZip ) { if (ScreenPrompt::s_LastAnswer == ANSWER_NO) return; CString sSelection = m_AddedZips.GetCurrentSelection(); g_CurSelection = sSelection; bool bSuccess = UPACKMAN->Remove( USER_PACK_SAVE_PATH + sSelection ); if (bSuccess) { m_SoundDelete.Play(); ReloadZips(); m_bRestart = true; } else { SCREENMAN->SystemMessage( "Failed to delete zip file from machine. Check your file permissions." ); } } if ( SM == SM_ConfirmAddZip ) { SCREENMAN->Prompt( SM_AnswerConfirmAddZip, "Proceed to add pack to machine?", PROMPT_YES_NO, ANSWER_NO ); } if ( SM == SM_AnswerConfirmAddZip ) { CString sError; m_bPrompt = false; if (ScreenPrompt::s_LastAnswer == ANSWER_NO) return; m_bStopThread = true; m_PlayerSongLoadThread.Wait(); MountMutex.Lock(); #if defined(LINUX) && defined(ITG_ARCADE) system( "mount -o remount,rw /itgdata" ); #endif MEMCARDMAN->LockCards(); MEMCARDMAN->MountCard(m_CurPlayer, 99999); CString sSelection = m_USBZips.GetCurrentSelection(); { //////////////////////// #define XFER_CLEANUP MEMCARDMAN->UnmountCard(m_CurPlayer); \ MEMCARDMAN->UnlockCards(); \ MountMutex.Unlock(); \ m_bStopThread = false; \ m_PlayerSongLoadThread.Create( InitSASSongThread, this ) //////////////////////// g_CurXferFile = MEM_CARD_MOUNT_POINT[m_CurPlayer] + "/" + USER_PACK_TRANSFER_PATH + sSelection; if ( !UPACKMAN->IsPackTransferable( sSelection, g_CurXferFile, sError ) || !UPACKMAN->IsPackMountable( g_CurXferFile, sError ) ) { SCREENMAN->SystemMessage( "Could not add pack to machine:\n" + sError ); XFER_CLEANUP; return; } sError = ""; // ?? RageTimer start; DrawTimer.Touch(); g_iLastCurrentBytes = 0; g_UpdateDuration.Touch(); if (!UPACKMAN->TransferPack( g_CurXferFile, sSelection, UpdateXferProgress, sError ) ) { SCREENMAN->SystemMessage( "Transfer error:\n" + sError ); XFER_CLEANUP; SCREENMAN->HideOverlayMessage(); SCREENMAN->ZeroNextUpdate(); return; } LOG->Debug( "Transferred %s in %f seconds.", g_CurXferFile.c_str(), start.Ago() ); } #if defined(LINUX) && defined(ITG_ARCADE) sync(); system( "mount -o remount,ro /itgdata" ); #endif SCREENMAN->HideOverlayMessage(); SCREENMAN->ZeroNextUpdate(); FILEMAN->FlushDirCache(USER_PACK_SAVE_PATH); m_bRestart = true; m_SoundTransferDone.Play(); ReloadZips(); XFER_CLEANUP; #undef XFER_CLEANUP } switch( SM ) { case SM_GoToNextScreen: case SM_GoToPrevScreen: SCREENMAN->SetNewScreen( PREV_SCREEN ); break; } }