Example #1
0
void CommandLine::process_movieCommands()
{
	if(play_movie_file != "")
	{
		FCEUI_LoadMovie(play_movie_file.c_str(),true,false,-1);
	}
	else if(record_movie_file != "")
	{
		FCEUI_SaveMovie(record_movie_file.c_str(), L"", START_BLANK, NULL, FCEUI_MovieGetRTCDefault());
	}
}
Example #2
0
//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;
}