Beispiel #1
0
void MainWnd::OnCheatsSavecheatlist()
{
  CString buffer;
  CString filename;

  int index = theApp.filename.ReverseFind('\\');

  if(index != -1)
    buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    buffer = theApp.filename;

  CString saveDir = regQueryStringValue(_T("saveDir"), NULL);

  if(saveDir.IsEmpty())
    saveDir = getDirFromFile(theApp.filename);

  if(isDriveRoot(saveDir))
    filename.Format(_T("%s%s.clt"), saveDir, buffer);
  else
    filename.Format(_T("%s\\%s.clt"), saveDir, buffer);

  LPCTSTR exts[] = { _T(".clt") };
  CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
  CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);

  FileDlg dlg(this, filename, filter, 0, _T("CLT"), exts, saveDir, title, true);

  if(dlg.DoModal() == IDOK) {
    winSaveCheatList(dlg.GetPathName());
  }
}
void TileViewer::save()
{
    char captureBuffer[2048];

    if(captureFormat == 0)
        strcpy(captureBuffer, "tiles.png");
    else
        strcpy(captureBuffer, "tiles.bmp");

    char *exts[] = {".png", ".bmp" };

    FileDlg dlg(getHandle(),
                (char *)captureBuffer,
                (int)sizeof(captureBuffer),
                (char *)winLoadFilter(IDS_FILTER_PNG),
                captureFormat ? 2 : 1,
                captureFormat ? "BMP" : "PNG",
                exts,
                (char *)NULL,
                (char *)winResLoadString(IDS_SELECT_CAPTURE_NAME),
                TRUE);

    BOOL res = dlg.DoModal();
    if(res == FALSE) {
        DWORD res = CommDlgExtendedError();
        return;
    }

    if(captureFormat)
        saveBMP(captureBuffer);
    else
        savePNG(captureBuffer);
}
bool MainWnd::fileOpenSelect()
{
  theApp.dir = "";
  CString initialDir = regQueryStringValue("romdir",".");
  if(!initialDir.IsEmpty())
    theApp.dir = initialDir;

  int selectedFilter = regQueryDwordValue("selectedFilter", 0);
  if(selectedFilter < 0 || selectedFilter > 2)
    selectedFilter = 0;

  theApp.szFile = "";

  LPCTSTR exts[] = { "" };
  CString filter = winLoadFilter(IDS_FILTER_ROM);
  CString title = winResLoadString(IDS_SELECT_ROM);

  FileDlg dlg(this, "", filter, selectedFilter, "", exts, theApp.dir, title, false);

  if(dlg.DoModal() == IDOK) {
    regSetDwordValue("selectedFilter", dlg.m_ofn.nFilterIndex);
    theApp.szFile = dlg.GetPathName();
    theApp.dir = theApp.szFile.Left(dlg.m_ofn.nFileOffset);
    if(theApp.dir.GetLength() > 3 && theApp.dir[theApp.dir.GetLength()-1] == '\\')
      theApp.dir = theApp.dir.Left(theApp.dir.GetLength()-1);
    regSetStringValue("romdir", theApp.dir);
    return true;
  }
  return false;
}
Beispiel #4
0
bool MainWnd::fileOpenSelect( int system )
{
	theApp.dir = _T("");
	CString initialDir;
	int selectedFilter = 0;
	LPCTSTR exts[] = { _T(""), _T(""), _T(""), _T("") };
	CString filter;
	CString title;

	switch( system )
	{
	case 0:
		// GBA
		initialDir = regQueryStringValue( _T("romdir"), _T(".") );
		selectedFilter = regQueryDwordValue( _T("selectedFilter"), 0);
		if( (selectedFilter < 0) || (selectedFilter > 2) ) {
			selectedFilter = 0;
		}
		filter = winLoadFilter( IDS_FILTER_GBAROM );
		break;
	case 1:
		// GBC
		initialDir = regQueryStringValue( _T("gbcromdir"), _T(".") );
		// TODO: memorize selected filter for GBC as well
		filter = winLoadFilter( IDS_FILTER_GBCROM );
		break;
	case 2:
		// GB
		initialDir = regQueryStringValue( _T("gbromdir"), _T(".") );
		// TODO: memorize selected filter for GB as well
		filter = winLoadFilter( IDS_FILTER_GBROM );
		break;
	}

	title = winResLoadString( IDS_SELECT_ROM );

	if( !initialDir.IsEmpty() ) {
		theApp.dir = initialDir;
	}

	if( initialDir[0] == '.' ) {
		// handle as relative path
		char baseDir[MAX_PATH+1];
		GetModuleFileName( NULL, baseDir, MAX_PATH );
		baseDir[MAX_PATH] = '\0'; // for security reasons
		PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
		strcat( baseDir, "\\" );
		strcat( baseDir, initialDir );
		initialDir = baseDir;
	}

	theApp.szFile = _T("");


	FileDlg dlg( this, _T(""), filter, selectedFilter, _T(""), exts, theApp.dir, title, false);

	if( dlg.DoModal() == IDOK ) {
		if( system == 0 ) {
			regSetDwordValue( _T("selectedFilter"), dlg.m_ofn.nFilterIndex );
		}
		theApp.szFile = dlg.GetPathName();
		theApp.dir = theApp.szFile.Left( dlg.m_ofn.nFileOffset );
		if( (theApp.dir.GetLength() > 3) && (theApp.dir[theApp.dir.GetLength()-1] == _T('\\')) ) {
			theApp.dir = theApp.dir.Left( theApp.dir.GetLength() - 1 );
		}
		SetCurrentDirectory( theApp.dir );
		regSetStringValue( _T("lastDir"), theApp.dir );
		return true;
	}
	return false;
}