//Replay movie dialog INT_PTR CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; char filename[MAX_PATH] = ""; switch(uMsg) { case WM_INITDIALOG: { SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayreadonly?BST_CHECKED:BST_UNCHECKED, 0); //Clear fields SetWindowText(GetDlgItem(hwndDlg, IDC_MLENGTH), ""); SetWindowText(GetDlgItem(hwndDlg, IDC_MFRAMES), ""); SetWindowText(GetDlgItem(hwndDlg, IDC_MRERECORDCOUNT), ""); SetWindowText(GetDlgItem(hwndDlg, IDC_MROM), ""); extern char curMovieFilename[512]; strncpy(playfilename, curMovieFilename, MAX_PATH); playfilename[MAX_PATH-1] = '\0'; SetWindowText(GetDlgItem(hwndDlg, PM_FILENAME), playfilename); SetFocus(GetDlgItem(hwndDlg, PM_FILENAME)); SendMessage(GetDlgItem(hwndDlg, PM_FILENAME), EM_SETSEL, 0, -1); // select all } return FALSE; case WM_COMMAND: int wID = LOWORD(wParam); switch(wID) { case ID_BROWSE: ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; ofn.nFilterIndex = 1; ofn.lpstrFile = filename; ofn.lpstrTitle = "Replay Movie from File"; ofn.nMaxFile = MAX_PATH; ofn.lpstrDefExt = "dsm"; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn)) SetDlgItemText(hwndDlg, PM_FILENAME, filename); return true; case IDC_CHECK_READONLY: replayreadonly = IsDlgButtonChecked(hwndDlg, IDC_CHECK_READONLY) != 0; return true; case IDOK: FCEUI_LoadMovie(playfilename, replayreadonly, false, 80000); ZeroMemory(&playfilename, sizeof(playfilename)); EndDialog(hwndDlg, 0); return true; case IDCANCEL: ZeroMemory(&playfilename, sizeof(playfilename)); EndDialog(hwndDlg, 0); return true; case PM_FILENAME: switch(HIWORD(wParam)) { case EN_CHANGE: { FixRelativeMovieFilename(hwndDlg, PM_FILENAME); // disable the OK button if we can't read the file char filename [MAX_PATH]; GetDlgItemText(hwndDlg,PM_FILENAME,filename,MAX_PATH); EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileReadable(filename)); strcpy(playfilename, filename); Describe(hwndDlg); // force read-only to be checked if we can't write the file if(!IsFileWritable(filename)) { CheckDlgButton(hwndDlg, IDC_CHECK_READONLY, BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_READONLY), FALSE); } else { EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_READONLY), TRUE); } } break; } break; } } return false; }
//Record movie dialog static INT_PTR CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static struct CreateMovieParameters* p = NULL; std::wstring author = L""; std::string fname; switch(uMsg) { case WM_INITDIALOG: CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED)); SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_FILENAME)); return false; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: { author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR); fname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_FILENAME); std::string sramfname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_SRAMFILENAME); if (fname.length()) { FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname); EndDialog(hwndDlg, 0); } return true; } case IDCANCEL: EndDialog(hwndDlg, 0); return true; case IDC_BUTTON_BROWSEFILE: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,szChoice,MAX_PATH); // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Record a new movie"; ofn.lpstrDefExt = "dsm"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; if(GetSaveFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsm for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsm"); */ SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_BUTTON_BROWSESRAM: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Choose SRAM"; ofn.lpstrDefExt = "dsv"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetOpenFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsv for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsv"); */ SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_EDIT_FILENAME: switch(HIWORD(wParam)) { case EN_CHANGE: { FixRelativeMovieFilename(hwndDlg, IDC_EDIT_FILENAME); // disable the OK button if we can't write to the file char filename [MAX_PATH]; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,filename,MAX_PATH); EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileWritable(filename)); } break; } break; } } HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0; IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); return false; }
//Record movie dialog static INT_PTR CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static struct CreateMovieParameters* p = NULL; std::wstring author = L""; std::string fname; SYSTEMTIME systime; switch(uMsg) { case WM_INITDIALOG: { CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED)); SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_FILENAME)); DateTime t = FCEUI_MovieGetRTCDefault(); ZeroMemory(&systime, sizeof(SYSTEMTIME)); systime.wYear = t.get_Year(); systime.wMonth = t.get_Month(); systime.wDay = t.get_Day(); systime.wDayOfWeek = t.get_DayOfWeek(); systime.wHour = t.get_Hour(); systime.wMinute = t.get_Minute(); systime.wSecond = t.get_Second(); systime.wMilliseconds = t.get_Millisecond(); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDT_VALID, &systime); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), GDT_VALID, &systime); union { struct { SYSTEMTIME rtcMin, rtcMax; }; SYSTEMTIME rtcMinMax[2]; }; ZeroMemory(&rtcMin, sizeof(SYSTEMTIME)); ZeroMemory(&rtcMax, sizeof(SYSTEMTIME)); rtcMin.wYear = 2000; rtcMin.wMonth = 1; rtcMin.wDay = 1; rtcMin.wDayOfWeek = 6; rtcMax.wYear = 2099; rtcMax.wMonth = 12; rtcMax.wDay = 31; rtcMax.wDayOfWeek = 4; DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MIN, &rtcMinMax); DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MAX, &rtcMinMax); return false; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: { author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR); fname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_FILENAME); std::string sramfname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_SRAMFILENAME); if (fname.length()) { struct tm t; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), &systime); t.tm_year = systime.wYear; t.tm_mon = systime.wMonth; t.tm_mday = systime.wDay; t.tm_wday = systime.wDayOfWeek; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), &systime); t.tm_hour = systime.wHour; t.tm_min = systime.wMinute; t.tm_sec = systime.wSecond; DateTime rtcstart(t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec); FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname, rtcstart); EndDialog(hwndDlg, 0); } return true; } case IDCANCEL: EndDialog(hwndDlg, 0); return true; case IDC_BUTTON_BROWSEFILE: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,szChoice,MAX_PATH); // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Record a new movie"; ofn.lpstrDefExt = "dsm"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; if(GetSaveFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsm for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsm"); */ SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_BUTTON_BROWSESRAM: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Choose SRAM"; ofn.lpstrDefExt = "dsv"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetOpenFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsv for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsv"); */ SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_EDIT_FILENAME: switch(HIWORD(wParam)) { case EN_CHANGE: { FixRelativeMovieFilename(hwndDlg, IDC_EDIT_FILENAME); // disable the OK button if we can't write to the file char filename [MAX_PATH]; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,filename,MAX_PATH); EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileWritable(filename)); } break; } break; } } HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0; IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); return false; }