void CMainWindow::OnFileOpen() { Framework::Win32::CFileDialog dialog; const TCHAR* filter = _T("All Supported Files\0*.zip; *.rar; *.psf; *.minipsf; *.psf2; *.minipsf2; *.psfp; *.minipsfp;*") PLAYLIST_EXTENSION _T("\0") PLAYLIST_FILTER ARCHIVE_FILTER PSF_FILTER PSF2_FILTER PSFP_FILTER; dialog.m_OFN.lpstrFilter = filter; if(dialog.SummonOpen(m_hWnd)) { boost::filesystem::path filePath(dialog.GetPath()); std::wstring fileExtension = filePath.extension().wstring(); if(!wcsicmp(fileExtension.c_str(), PLAYLIST_EXTENSION)) { LoadPlaylist(filePath); } else if(!wcsicmp(fileExtension.c_str(), L".rar") || !wcsicmp(fileExtension.c_str(), L".zip")) { LoadArchive(filePath); } else { LoadSingleFile(filePath); } } }
void CPixelBufferView::OnSaveBitmap() { auto pixelBuffer = GetSelectedPixelBuffer(); if(!pixelBuffer) return; auto pixelBufferBitmap = pixelBuffer->second; auto bpp = pixelBufferBitmap.GetBitsPerPixel(); if((bpp == 24) || (bpp == 32)) { pixelBufferBitmap = ConvertBGRToRGB(std::move(pixelBufferBitmap)); } Framework::Win32::CFileDialog openFileDialog; openFileDialog.m_OFN.lpstrFilter = _T("Windows Bitmap Files (*.bmp)\0*.bmp"); int result = openFileDialog.SummonSave(m_hWnd); if(result == IDOK) { try { auto outputStream = Framework::CreateOutputStdStream(std::tstring(openFileDialog.m_OFN.lpstrFile)); Framework::CBMP::WriteBitmap(pixelBufferBitmap, outputStream); } catch(const std::exception& exception) { auto message = string_format("Failed to save buffer to file:\r\n\r\n%s", exception.what()); MessageBoxA(m_hWnd, message.c_str(), nullptr, MB_ICONHAND); } } }
void CMainWindow::RecordAvi() { if(m_recordingAvi) { m_recordingAvi = false; while(1) { DWORD result = MsgWaitForMultipleObjects(1, &m_recordAviMutex, FALSE, INFINITE, QS_ALLINPUT); if(result == WAIT_OBJECT_0) break; MSG msg; GetMessage(&msg, NULL, 0, 0); TranslateMessage(&msg); DispatchMessage(&msg); } { m_aviStream.Close(); delete [] m_recordBuffer; m_recordBuffer = NULL; m_recordBufferWidth = 0; m_recordBufferHeight = 0; } ReleaseMutex(m_recordAviMutex); UpdateUI(); } else { CScopedVmPauser vmPauser(m_virtualMachine); Framework::Win32::CFileDialog d; d.m_OFN.lpstrFilter = _T("AVI Movie Files (*.avi)\0*.avi\0All files (*.*)\0*.*\0"); if(!d.SummonSave(m_hWnd)) { return; } RECT rc = m_outputWnd->GetWindowRect(); unsigned int nViewW = rc.right - rc.left; unsigned int nViewH = rc.bottom - rc.top; m_aviStream.SetSize(nViewW, nViewH); if(!m_aviStream.Open(m_hWnd, d.GetPath())) { MessageBox(m_hWnd, _T("Failed to start AVI recording."), APP_NAME, 16); return; } m_recordBufferWidth = nViewW; m_recordBufferHeight = nViewH; m_recordBuffer = new uint8[m_recordBufferWidth * m_recordBufferHeight * 4]; m_recordingAvi = true; UpdateUI(); } }
void CCdromSelectionWnd::SelectImage() { Framework::Win32::CFileDialog Dialog; Dialog.m_OFN.lpstrFilter = DISKIMAGE_FILTER; if(Dialog.SummonOpen(m_hWnd) != IDOK) { return; } std::string sPath(string_cast<std::string>(Dialog.GetPath())); m_sImagePath = sPath.c_str(); }
void CMainWindow::OpenELF() { Framework::Win32::CFileDialog d; d.m_OFN.lpstrFilter = _T("ELF Executable Files (*.elf)\0*.elf\0All files (*.*)\0*.*\0"); Enable(FALSE); int nRet = d.SummonOpen(m_hWnd); Enable(TRUE); SetFocus(); if(nRet == 0) return; LoadELF(string_cast<std::string>(d.GetPath()).c_str()); }
void CMainWindow::BootDiskImage() { Framework::Win32::CFileDialog d; d.m_OFN.lpstrFilter = DISKIMAGE_FILTER; Enable(FALSE); int nRet = d.SummonOpen(m_hWnd); Enable(TRUE); SetFocus(); if(nRet == 0) return; CAppConfig::GetInstance().SetPreferenceString(PS2VM_CDROM0PATH, string_cast<std::string>(d.GetPath()).c_str()); BootCDROM(); }
void CMainWindow::OnPlaylistSaveClick() { Framework::Win32::CFileDialog dialog; const TCHAR* filter = PLAYLIST_FILTER; dialog.m_OFN.lpstrFilter = filter; dialog.m_OFN.lpstrDefExt = PLAYLIST_EXTENSION + 1; if(dialog.SummonSave(m_hWnd)) { try { m_playlist.Write(dialog.GetPath()); } catch(const std::exception& except) { std::tstring errorString = _T("Couldn't save playlist: \r\n\r\n"); errorString += string_cast<std::tstring>(except.what()); MessageBox(m_hWnd, errorString.c_str(), NULL, 16); } } }
void CPixelBufferView::OnSaveBitmap() { if(!m_pixelBufferBitmap.IsEmpty()) { Framework::Win32::CFileDialog openFileDialog; openFileDialog.m_OFN.lpstrFilter = _T("Windows Bitmap Files (*.bmp)\0*.bmp"); int result = openFileDialog.SummonSave(m_hWnd); if(result == IDOK) { try { auto outputStream = Framework::CreateOutputStdStream(std::tstring(openFileDialog.m_OFN.lpstrFile)); Framework::CBMP::WriteBitmap(m_pixelBufferBitmap, outputStream); } catch(const std::exception& exception) { auto message = string_format("Failed to save buffer to file:\r\n\r\n%s", exception.what()); MessageBoxA(m_hWnd, message.c_str(), nullptr, MB_ICONHAND); } } } }