annotate src/win32/MovieOpen.cpp @ 8:08a8e09ca414

add files required by automake
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:54:39 -0600
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 // MovieOpen.cpp : implementation file
rlm@1 2 //
rlm@1 3
rlm@1 4 #include "stdafx.h"
rlm@1 5 #include "resource.h"
rlm@1 6 #include "MovieOpen.h"
rlm@1 7 #include "MainWnd.h"
rlm@1 8 #include "FileDlg.h"
rlm@1 9 #include "WinResUtil.h"
rlm@1 10 #include "WinMiscUtil.h"
rlm@1 11 #include "VBA.h"
rlm@1 12
rlm@1 13 #include "../gba/GBA.h"
rlm@1 14 #include "../gb/gbGlobals.h"
rlm@1 15 #include "../common/Util.h"
rlm@1 16 #include "7zip/OpenArchive.h"
rlm@1 17
rlm@1 18 // MovieOpen dialog
rlm@1 19
rlm@1 20 IMPLEMENT_DYNAMIC(MovieOpen, CDialog)
rlm@1 21 MovieOpen::MovieOpen(CWnd *pParent /*=NULL*/)
rlm@1 22 : CDialog(MovieOpen::IDD, pParent)
rlm@1 23 {}
rlm@1 24
rlm@1 25 MovieOpen::~MovieOpen()
rlm@1 26 {
rlm@1 27 SetArchiveParentHWND(NULL);
rlm@1 28 }
rlm@1 29
rlm@1 30 BOOL MovieOpen::OnInitDialog()
rlm@1 31 {
rlm@1 32 CDialog::OnInitDialog();
rlm@1 33
rlm@1 34 pauseFrame = 0;
rlm@1 35 ZeroMemory(&movieInfo, sizeof SMovie);
rlm@1 36
rlm@1 37 SetArchiveParentHWND(GetSafeHwnd());
rlm@1 38
rlm@1 39 GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(FALSE);
rlm@1 40 GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText("");
rlm@1 41 GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText("");
rlm@1 42 GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
rlm@1 43 GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
rlm@1 44 GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE);
rlm@1 45
rlm@1 46 CheckDlgButton(IDC_READONLY, TRUE);
rlm@1 47 m_editDescription.SetReadOnly(theApp.movieReadOnly);
rlm@1 48
rlm@1 49 m_editFilename.LimitText(_MAX_PATH);
rlm@1 50 m_editAuthor.LimitText(MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 51 m_editDescription.LimitText(MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 52 m_editPauseFrame.LimitText(8);
rlm@1 53
rlm@1 54 // convert the ROM filename into a default movie name
rlm@1 55 CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, ".vbm");
rlm@1 56
rlm@1 57 GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
rlm@1 58
rlm@1 59 // scroll to show the rightmost side of the movie filename
rlm@1 60 ((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
rlm@1 61
rlm@1 62 OnBnClickedMovieRefresh();
rlm@1 63
rlm@1 64 return TRUE; // return TRUE unless you set the focus to a control
rlm@1 65 // EXCEPTION: OCX Property Pages should return FALSE
rlm@1 66 }
rlm@1 67
rlm@1 68 void MovieOpen::DoDataExchange(CDataExchange *pDX)
rlm@1 69 {
rlm@1 70 CDialog::DoDataExchange(pDX);
rlm@1 71 //{{AFX_DATA_MAP(MovieCreate)
rlm@1 72 DDX_Control(pDX, IDC_EDIT_AUTHOR, m_editAuthor);
rlm@1 73 DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_editDescription);
rlm@1 74 DDX_Control(pDX, IDC_MOVIE_FILENAME, m_editFilename);
rlm@1 75 DDX_Control(pDX, IDC_EDIT_PAUSEFRAME, m_editPauseFrame);
rlm@1 76 //}}AFX_DATA_MAP
rlm@1 77 }
rlm@1 78
rlm@1 79 BEGIN_MESSAGE_MAP(MovieOpen, CDialog)
rlm@1 80 ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse)
rlm@1 81 ON_BN_CLICKED(IDOK, OnBnClickedOk)
rlm@1 82 ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
rlm@1 83 ON_BN_CLICKED(IDC_MOVIE_REFRESH, OnBnClickedMovieRefresh)
rlm@1 84 ON_BN_CLICKED(IDC_READONLY, OnBnClickedReadonly)
rlm@1 85 ON_BN_CLICKED(IDC_CHECK_PAUSEFRAME, OnBnClickedCheckPauseframe)
rlm@1 86 ON_BN_CLICKED(IDC_CHECK_HIDEBORDER, OnBnClickedHideborder)
rlm@1 87 ON_EN_CHANGE(IDC_MOVIE_FILENAME, OnEnChangeMovieFilename)
rlm@1 88 END_MESSAGE_MAP()
rlm@1 89
rlm@1 90 // MovieOpen message handlers
rlm@1 91
rlm@1 92 // FIXME: file-scope-global
rlm@1 93 static bool shouldReopenBrowse = false;
rlm@1 94
rlm@1 95 void MovieOpen::OnBnClickedBrowse()
rlm@1 96 {
rlm@1 97 theApp.winCheckFullscreen(); // FIXME: necessary or not?
rlm@1 98
rlm@1 99 LPCTSTR exts[] = { ".vbm", NULL };
rlm@1 100
rlm@1 101 CString filter = winResLoadFilter(IDS_FILTER_MOVIE);
rlm@1 102 CString title = winResLoadString(IDS_SELECT_MOVIE_NAME);
rlm@1 103
rlm@1 104 CString movieName = winGetDestFilename(theApp.gameFilename, IDS_MOVIE_DIR, exts[0]);
rlm@1 105 CString movieDir = winGetDestDir(IDS_MOVIE_DIR);
rlm@1 106
rlm@1 107 FileDlg dlg(this, movieName, filter, 1, "VBM", exts, movieDir, title, false, true);
rlm@1 108
rlm@1 109 do
rlm@1 110 {
rlm@1 111 shouldReopenBrowse = false;
rlm@1 112
rlm@1 113 if (dlg.DoModal() == IDCANCEL)
rlm@1 114 {
rlm@1 115 return;
rlm@1 116 }
rlm@1 117
rlm@1 118 movieName = dlg.GetPathName();
rlm@1 119
rlm@1 120 GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName);
rlm@1 121
rlm@1 122 // SetWindowText calls OnEnChangeMovieFilename which calls OnBnClickedMovieRefresh
rlm@1 123 // so this extra call to OnBnClickedMovieRefresh is bad
rlm@1 124 //OnBnClickedMovieRefresh();
rlm@1 125 }
rlm@1 126 while (shouldReopenBrowse);
rlm@1 127
rlm@1 128 // scroll to show the rightmost side of the movie filename
rlm@1 129 ((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel((DWORD)(movieName.GetLength() - 1), FALSE);
rlm@1 130 }
rlm@1 131
rlm@1 132 // some extensions that might commonly be near emulation-related files that we almost certainly can't open, or at least not
rlm@1 133 // directly.
rlm@1 134 // also includes definitely non-movie extensions we know about, since we only use this variable in a movie opening function.
rlm@1 135 // we do this by exclusion instead of inclusion because we don't want to exclude extensions used for any archive files, even
rlm@1 136 // extensionless or unusually-named archives.
rlm@1 137 static const char *s_movieIgnoreExtensions [] = {
rlm@1 138 "gba", "gbc", "gb", "sgb", "cgb", "bin", "agb", "bios", "mb", "elf", "sgm", "clt", "dat", "gbs", "gcf", "spc",
rlm@1 139 "xpc", "pal", "act", "dmp", "avi", "ini", "txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3",
rlm@1 140 "wav", "lnk", "exe", "bat", "sav", "luasav"
rlm@1 141 };
rlm@1 142
rlm@1 143 void MovieOpen::OnBnClickedMovieRefresh()
rlm@1 144 {
rlm@1 145 static int recursionDepth = 0;
rlm@1 146 if (recursionDepth > 0)
rlm@1 147 return;
rlm@1 148 struct Scope {Scope(){ ++ recursionDepth; } ~Scope(){ --recursionDepth; }} scope;
rlm@1 149
rlm@1 150 CString tempName;
rlm@1 151 GetDlgItem(IDC_MOVIE_FILENAME)->GetWindowText(tempName);
rlm@1 152
rlm@1 153 #if 1
rlm@1 154 // use ObtainFile to support opening files within archives (.7z, .rar, .zip, .zip.rar.7z, etc.)
rlm@1 155
rlm@1 156 if (movieLogicalName.GetLength() > 2048) movieLogicalName.Truncate(2048);
rlm@1 157
rlm@1 158 char LogicalName[2048], PhysicalName[2048];
rlm@1 159 if (ObtainFile(tempName, LogicalName, PhysicalName, "mov", s_movieIgnoreExtensions,
rlm@1 160 sizeof(s_movieIgnoreExtensions) / sizeof(*s_movieIgnoreExtensions)))
rlm@1 161 {
rlm@1 162 if (tempName != LogicalName)
rlm@1 163 {
rlm@1 164 int selStart = 0, selEnd = 0;
rlm@1 165 ((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->GetSel(selStart, selEnd);
rlm@1 166
rlm@1 167 GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(LogicalName);
rlm@1 168
rlm@1 169 ((CEdit *)GetDlgItem(IDC_MOVIE_FILENAME))->SetSel(selStart, selEnd, FALSE);
rlm@1 170 }
rlm@1 171 moviePhysicalName = PhysicalName;
rlm@1 172 movieLogicalName = LogicalName;
rlm@1 173 ReleaseTempFileCategory("mov", PhysicalName);
rlm@1 174 }
rlm@1 175 else
rlm@1 176 {
rlm@1 177 shouldReopenBrowse = true;
rlm@1 178 return;
rlm@1 179 }
rlm@1 180 #else
rlm@1 181 // old version that only supports uncompressed movies
rlm@1 182 moviePhysicalName = tempName;
rlm@1 183 movieLogicalName = tempName;
rlm@1 184 #endif
rlm@1 185
rlm@1 186 if (VBAMovieGetInfo(moviePhysicalName, &movieInfo) == MOVIE_SUCCESS)
rlm@1 187 {
rlm@1 188 if (movieInfo.readOnly)
rlm@1 189 {
rlm@1 190 CheckDlgButton(IDC_READONLY, TRUE);
rlm@1 191 m_editDescription.SetReadOnly(TRUE);
rlm@1 192 }
rlm@1 193
rlm@1 194 char buffer[MOVIE_METADATA_SIZE];
rlm@1 195
rlm@1 196 strncpy(buffer, movieInfo.authorInfo, MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 197 buffer[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
rlm@1 198 GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(buffer);
rlm@1 199
rlm@1 200 strncpy(buffer, movieInfo.authorInfo + MOVIE_METADATA_AUTHOR_SIZE, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 201 buffer[MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
rlm@1 202 GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(buffer);
rlm@1 203
rlm@1 204 int option = 2;
rlm@1 205 if (movieInfo.header.startFlags & MOVIE_START_FROM_SRAM)
rlm@1 206 option = 1;
rlm@1 207 if (movieInfo.header.startFlags & MOVIE_START_FROM_SNAPSHOT)
rlm@1 208 option = 0;
rlm@1 209 CheckRadioButton(IDC_RECNOW, IDC_RECSTART, IDC_RECNOW + option);
rlm@1 210
rlm@1 211 option = 3;
rlm@1 212 if (movieInfo.header.typeFlags & MOVIE_TYPE_SGB)
rlm@1 213 option = 2;
rlm@1 214 if (movieInfo.header.typeFlags & MOVIE_TYPE_GBC)
rlm@1 215 option = 1;
rlm@1 216 if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
rlm@1 217 option = 0;
rlm@1 218 CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, IDC_REC_GBA + option);
rlm@1 219
rlm@1 220 GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(option == 2 ? TRUE : FALSE);
rlm@1 221
rlm@1 222 if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
rlm@1 223 {
rlm@1 224 if (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE)
rlm@1 225 {
rlm@1 226 if (movieInfo.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE)
rlm@1 227 option = 2;
rlm@1 228 else
rlm@1 229 option = 3;
rlm@1 230 }
rlm@1 231 else
rlm@1 232 option = 1;
rlm@1 233 }
rlm@1 234 else
rlm@1 235 option = 0;
rlm@1 236
rlm@1 237 CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + option);
rlm@1 238
rlm@1 239 {
rlm@1 240 char * p;
rlm@1 241 time_t ttime = (time_t)movieInfo.header.uid;
rlm@1 242 strncpy(buffer, ctime(&ttime), 127);
rlm@1 243 buffer[127] = '\0';
rlm@1 244 if ((p = strrchr(buffer, '\n')))
rlm@1 245 *p = '\0';
rlm@1 246 GetDlgItem(IDC_LABEL_DATE)->SetWindowText(buffer);
rlm@1 247
rlm@1 248 uint32 div = 60;
rlm@1 249 uint32 l = (movieInfo.header.length_frames + (div >> 1)) / div;
rlm@1 250 uint32 seconds = l % 60;
rlm@1 251 l /= 60;
rlm@1 252 uint32 minutes = l % 60;
rlm@1 253 l /= 60;
rlm@1 254 uint32 hours = l % 60;
rlm@1 255 sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds);
rlm@1 256 GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(buffer);
rlm@1 257 sprintf(buffer, "%ld", movieInfo.header.length_frames);
rlm@1 258 GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(buffer);
rlm@1 259 sprintf(buffer, "%ld", movieInfo.header.rerecord_count);
rlm@1 260 GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(buffer);
rlm@1 261 }
rlm@1 262
rlm@1 263 {
rlm@1 264 char warning1 [1024], warning2 [1024], buffer [1024];
rlm@1 265
rlm@1 266 strcpy(warning1, "");
rlm@1 267 strcpy(warning2, "");
rlm@1 268
rlm@1 269 char romTitle [12];
rlm@1 270 uint32 romGameCode;
rlm@1 271 uint16 checksum;
rlm@1 272 uint8 crc;
rlm@1 273
rlm@1 274 VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
rlm@1 275
rlm@1 276 // rather than treat these as warnings, might as well always show the info in the dialog (it's probably more
rlm@1 277 // informative and reassuring)
rlm@1 278 /// if (strncmp(movieInfo.header.romTitle,romTitle,12) != 0)
rlm@1 279 {
rlm@1 280 char str [13];
rlm@1 281 strncpy(str, movieInfo.header.romTitle, 12);
rlm@1 282 str[12] = '\0';
rlm@1 283 sprintf(buffer, "title=%s ", str);
rlm@1 284 strcat(warning1, buffer);
rlm@1 285
rlm@1 286 strncpy(str, romTitle, 12);
rlm@1 287 str[12] = '\0';
rlm@1 288 sprintf(buffer, "title=%s ", str);
rlm@1 289 strcat(warning2, buffer);
rlm@1 290 }
rlm@1 291 /// if (((movieInfo.header.typeFlags & MOVIE_TYPE_GBA)!=0) != (systemCartridgeType == 0))
rlm@1 292 {
rlm@1 293 sprintf(buffer, "type=%s ",
rlm@1 294 (movieInfo.header.typeFlags & MOVIE_TYPE_GBA) ? "GBA" : (movieInfo.header.typeFlags &
rlm@1 295 MOVIE_TYPE_GBC) ? "GBC" : (movieInfo.header.
rlm@1 296 typeFlags &
rlm@1 297 MOVIE_TYPE_SGB) ? "SGB" : "GB");
rlm@1 298 strcat(warning1, buffer);
rlm@1 299
rlm@1 300 sprintf(buffer, "type=%s ", systemCartridgeType ==
rlm@1 301 0 ? "GBA" : (gbRom[0x143] & 0x80 ? "GBC" : (gbRom[0x146] == 0x03 ? "SGB" : "GB")));
rlm@1 302 strcat(warning2, buffer);
rlm@1 303 }
rlm@1 304 /// if (movieInfo.header.romCRC != crc)
rlm@1 305 {
rlm@1 306 sprintf(buffer, "crc=%02x ", movieInfo.header.romCRC);
rlm@1 307 strcat(warning1, buffer);
rlm@1 308
rlm@1 309 sprintf(buffer, "crc=%02x ", crc);
rlm@1 310 strcat(warning2, buffer);
rlm@1 311 }
rlm@1 312 /// if (movieInfo.header.romGameCode != romGameCode)
rlm@1 313 {
rlm@1 314 char code [5];
rlm@1 315 if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
rlm@1 316 {
rlm@1 317 memcpy(code, &movieInfo.header.romGameCode, 4);
rlm@1 318 code[4] = '\0';
rlm@1 319 sprintf(buffer, "code=%s ", code);
rlm@1 320 strcat(warning1, buffer);
rlm@1 321 }
rlm@1 322
rlm@1 323 if (systemCartridgeType == 0)
rlm@1 324 {
rlm@1 325 memcpy(code, &romGameCode, 4);
rlm@1 326 code[4] = '\0';
rlm@1 327 sprintf(buffer, "code=%s ", code);
rlm@1 328 strcat(warning2, buffer);
rlm@1 329 }
rlm@1 330 }
rlm@1 331 /// if (movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags &
rlm@1 332 // MOVIE_SETTING_USEBIOSFILE)==0
rlm@1 333 // && checksum==0))
rlm@1 334 {
rlm@1 335 sprintf(buffer,
rlm@1 336 movieInfo.header.typeFlags &
rlm@1 337 MOVIE_TYPE_GBA ? ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) ==
rlm@1 338 0 ? "(bios=none) " : "(bios=%04x) ") : "check=%04x ",
rlm@1 339 movieInfo.header.romOrBiosChecksum);
rlm@1 340 strcat(warning1, buffer);
rlm@1 341
rlm@1 342 sprintf(buffer,
rlm@1 343 checksum == 0 ? "(bios=none) " : systemCartridgeType == 0 ? "(bios=%04x) " : "check=%04x ",
rlm@1 344 checksum);
rlm@1 345 strcat(warning2, buffer);
rlm@1 346 }
rlm@1 347
rlm@1 348 if (strlen(warning1) > 0)
rlm@1 349 {
rlm@1 350 sprintf(buffer, "Movie ROM: %s", warning1);
rlm@1 351 GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(buffer);
rlm@1 352
rlm@1 353 sprintf(buffer, "Your ROM: %s", warning2);
rlm@1 354
rlm@1 355 //if(movieInfo.header.romCRC != crc
rlm@1 356 //|| strncmp(movieInfo.header.romTitle,romTitle,12) != 0
rlm@1 357 //|| movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags &
rlm@1 358 // MOVIE_SETTING_USEBIOSFILE)==0 && checksum==0))
rlm@1 359 // strcat(buffer, "<-- MISMATCH");
rlm@1 360
rlm@1 361 GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(buffer);
rlm@1 362 }
rlm@1 363 else
rlm@1 364 {
rlm@1 365 GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText("(No problems detected)");
rlm@1 366 GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" ");
rlm@1 367 }
rlm@1 368 }
rlm@1 369 GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(TRUE);
rlm@1 370 }
rlm@1 371 else
rlm@1 372 {
rlm@1 373 GetDlgItem(IDC_LABEL_DATE)->SetWindowText(" ");
rlm@1 374 GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(" ");
rlm@1 375 GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(" ");
rlm@1 376 GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(" ");
rlm@1 377 GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(" ");
rlm@1 378 GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(" ");
rlm@1 379 GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(" ");
rlm@1 380 GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" ");
rlm@1 381
rlm@1 382 GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
rlm@1 383 GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
rlm@1 384 GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE);
rlm@1 385 CheckDlgButton(IDC_CHECK_PAUSEFRAME, FALSE);
rlm@1 386 /*
rlm@1 387 /// FIXME: how to un-check all the radio buttons?
rlm@1 388 CheckRadioButton(IDC_RECNOW, IDC_RECSTART, -1);
rlm@1 389 CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, -1);
rlm@1 390 CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, -1);*/
rlm@1 391 }
rlm@1 392 }
rlm@1 393
rlm@1 394 BOOL MovieOpen::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *res)
rlm@1 395 {
rlm@1 396 switch (msg)
rlm@1 397 {
rlm@1 398 case WM_CTLCOLORSTATIC:
rlm@1 399 {
rlm@1 400 //HWND hwndDlg = GetSafeHwnd();
rlm@1 401 HWND warnDlg = NULL;
rlm@1 402 GetDlgItem(IDC_LABEL_WARNING2, &warnDlg);
rlm@1 403
rlm@1 404 if ((HWND)lParam == warnDlg)
rlm@1 405 {
rlm@1 406 char romTitle [12];
rlm@1 407 uint32 romGameCode;
rlm@1 408 uint16 checksum;
rlm@1 409 uint8 crc;
rlm@1 410
rlm@1 411 VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
rlm@1 412
rlm@1 413 if (movieInfo.header.romCRC != crc
rlm@1 414 || strncmp(movieInfo.header.romTitle, romTitle, 12) != 0
rlm@1 415 || movieInfo.header.romOrBiosChecksum != checksum
rlm@1 416 && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) == 0 && checksum == 0))
rlm@1 417 {
rlm@1 418 // draw the md5 sum in red if it's different from the md5 of the rom used in the replay
rlm@1 419 HDC hdcStatic = (HDC)wParam;
rlm@1 420 SetTextColor(hdcStatic, RGB(255, 0, 0)); // use red for a mismatch
rlm@1 421
rlm@1 422 // I'm not sure why this doesn't work to make the background transparent... it turns white anyway
rlm@1 423 SetBkMode(hdcStatic, TRANSPARENT);
rlm@1 424 return (LONG)GetStockObject(NULL_BRUSH);
rlm@1 425 }
rlm@1 426 }
rlm@1 427 return FALSE;
rlm@1 428 }
rlm@1 429 }
rlm@1 430 return CDialog::OnWndMsg(msg, wParam, lParam, res);
rlm@1 431 }
rlm@1 432
rlm@1 433 void MovieOpen::OnBnClickedOk()
rlm@1 434 {
rlm@1 435 bool useBIOSFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
rlm@1 436 if (useBIOSFile)
rlm@1 437 {
rlm@1 438 extern bool systemLoadBIOS(const char *biosFileName, bool useBiosFile);
rlm@1 439 if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
rlm@1 440 {
rlm@1 441 systemMessage(0, "This movie requires a valid GBA BIOS file to play.\nPlease locate a BIOS file.");
rlm@1 442 ((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
rlm@1 443 if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
rlm@1 444 {
rlm@1 445 systemMessage(0, "\"%s\" is not a valid BIOS file; cannot play movie without one.", theApp.biosFileName);
rlm@1 446 return;
rlm@1 447 }
rlm@1 448 }
rlm@1 449 }
rlm@1 450
rlm@1 451 int code = VBAMovieOpen(moviePhysicalName, IsDlgButtonChecked(IDC_READONLY) != FALSE);
rlm@1 452
rlm@1 453 if (code != MOVIE_SUCCESS)
rlm@1 454 {
rlm@1 455 if (code == MOVIE_FILE_NOT_FOUND)
rlm@1 456 systemMessage(0, "Could not find movie file \"%s\".", (const char *)movieLogicalName);
rlm@1 457 else if (code == MOVIE_WRONG_FORMAT)
rlm@1 458 systemMessage(0, "Movie file \"%s\" is not in proper VBM format.", (const char *)movieLogicalName);
rlm@1 459 else if (code == MOVIE_WRONG_VERSION)
rlm@1 460 systemMessage(0, "Movie file \"%s\" is not a supported version.", (const char *)movieLogicalName);
rlm@1 461 else
rlm@1 462 systemMessage(0, "Failed to open movie \"%s\".", (const char *)movieLogicalName);
rlm@1 463 return;
rlm@1 464 }
rlm@1 465 else
rlm@1 466 {
rlm@1 467 // get author and movie info from the edit fields (the description might change):
rlm@1 468 char info[MOVIE_METADATA_SIZE], buffer[MOVIE_METADATA_SIZE];
rlm@1 469
rlm@1 470 GetDlgItem(IDC_EDIT_AUTHOR)->GetWindowText(buffer, MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 471 strncpy(info, buffer, MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 472 info[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0';
rlm@1 473
rlm@1 474 GetDlgItem(IDC_EDIT_DESCRIPTION)->GetWindowText(buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 475 strncpy(info + MOVIE_METADATA_AUTHOR_SIZE, buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE);
rlm@1 476 info[MOVIE_METADATA_SIZE - 1] = '\0';
rlm@1 477
rlm@1 478 VBAMovieSetMetadata(info);
rlm@1 479 }
rlm@1 480
rlm@1 481 if (IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME))
rlm@1 482 {
rlm@1 483 char buffer [9];
rlm@1 484 GetDlgItem(IDC_EDIT_PAUSEFRAME)->GetWindowText(buffer, 8);
rlm@1 485 buffer[8] = '\0';
rlm@1 486
rlm@1 487 int pauseFrame = atoi(buffer);
rlm@1 488 if (pauseFrame >= 0)
rlm@1 489 VBAMovieSetPauseAt(pauseFrame);
rlm@1 490 }
rlm@1 491
rlm@1 492 OnOK();
rlm@1 493 }
rlm@1 494
rlm@1 495 void MovieOpen::OnBnClickedCancel()
rlm@1 496 {
rlm@1 497 OnCancel();
rlm@1 498 }
rlm@1 499
rlm@1 500 void MovieOpen::OnBnClickedReadonly()
rlm@1 501 {
rlm@1 502 theApp.movieReadOnly = IsDlgButtonChecked(IDC_READONLY) != 0;
rlm@1 503 m_editDescription.SetReadOnly(theApp.movieReadOnly);
rlm@1 504 OnBnClickedMovieRefresh();
rlm@1 505 }
rlm@1 506
rlm@1 507 void MovieOpen::OnBnClickedCheckPauseframe()
rlm@1 508 {
rlm@1 509 if (IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME))
rlm@1 510 {
rlm@1 511 char buffer [8];
rlm@1 512 _itoa(movieInfo.header.length_frames, buffer, 10);
rlm@1 513 GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(buffer);
rlm@1 514 GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(TRUE);
rlm@1 515 }
rlm@1 516 else
rlm@1 517 {
rlm@1 518 GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText("");
rlm@1 519 GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE);
rlm@1 520 }
rlm@1 521 }
rlm@1 522
rlm@1 523 void MovieOpen::OnBnClickedHideborder()
rlm@1 524 {
rlm@1 525 theApp.hideMovieBorder = IsDlgButtonChecked(IDC_CHECK_HIDEBORDER) != 0;
rlm@1 526 }
rlm@1 527
rlm@1 528 void MovieOpen::OnEnChangeMovieFilename()
rlm@1 529 {
rlm@1 530 OnBnClickedMovieRefresh();
rlm@1 531 }
rlm@1 532