コード例 #1
0
ファイル: dlgFloppy.c プロジェクト: r-type/uae4arm-libretro
/**
 * Let user browse given disk, insert disk if one selected.
 */
static void DlgDisk_BrowseDisk(char *dlgname, int drive, int diskid)
{
	char *selname, *zip_path;
	const char *tmpname, *realname;

	assert(drive >= 0 && drive < MAX_FLOPPYDRIVES);
	if (szDiskFileName[drive][0])
		tmpname = szDiskFileName[drive];
	else
		tmpname = szDiskImageDirectory;

	selname = SDLGui_FileSelect(tmpname, &zip_path, false);
	if (!selname)
		return;
	printf("in)d%d:(%s)\n",drive,selname);	
	if (File_Exists(selname))
	{printf("----------Exist)\n");	
		realname = Floppy_SetDiskFileName(drive, selname, zip_path);
		if (realname)
			File_ShrinkName(dlgname, realname, floppydlg[diskid].w);
	}
	else
	{printf("---------not found\n");	
		Floppy_SetDiskFileNameNone(drive);
		dlgname[0] = '\0';
	}
	if (zip_path)
		free(zip_path);
	free(selname);
}
コード例 #2
0
ファイル: dlgNewDisk.c プロジェクト: r-type/hatari
/**
 * Show and process the "new blank disk image" dialog.
 * Return file name of last created diskimage or NULL if none created.
 * Caller needs to free the name.
 */
char *DlgNewDisk_Main(void)
{
	int but;
	char *szNewDiskName, *tmpname, *retname = NULL;
	sprintf(szTracks, "%i", nTracks);

 	SDLGui_CenterDlg(newdiskdlg);

	/* Initialize disk image name: */
	szNewDiskName = File_MakePath(ConfigureParams.DiskImage.szDiskImageDirectory, "new_disk.st", NULL);
	if (!szNewDiskName)
		return NULL;

	/* Draw and process the dialog */
	do
	{
		but = SDLGui_DoDialog(newdiskdlg, NULL, false);
		switch(but)
		{
		 case DLGNEWDISK_DECTRACK:
			if (nTracks > 40)
				nTracks -= 1;
			sprintf(szTracks, "%i", nTracks);
			break;
		 case DLGNEWDISK_INCTRACK:
			if (nTracks < 85)
				nTracks += 1;
			sprintf(szTracks, "%i", nTracks);
			break;
		 case DLGNEWDISK_SAVE:
			tmpname = SDLGui_FileSelect("New floppy image:", szNewDiskName, NULL, true);
			if (tmpname)
			{
				if (DlgNewDisk_CreateDisk(tmpname))
				{
					if (retname)
						free(retname);
					retname = tmpname;
				}
				else
					free(tmpname);
			}
			break;
		}
	}
	while (but != DLGNEWDISK_EXIT && but != SDLGUI_QUIT
	       && but != SDLGUI_ERROR && !bQuitProgram);

	free(szNewDiskName);
	return retname;
}
コード例 #3
0
ファイル: dlgFloppy.c プロジェクト: r-type/uae4arm-libretro
/**
 * Let user browse given directory, set directory if one selected.
 */
static void DlgDisk_BrowseDir(char *dlgname, char *confname, int maxlen)
{
	char *str, *selname;

	selname = SDLGui_FileSelect(confname, NULL, false);
	if (!selname)
		return;

	strcpy(confname, selname);
	free(selname);

	str = strrchr(confname, PATHSEP);
	if (str != NULL)
		str[1] = 0;
	File_CleanFileName(confname);
	File_ShrinkName(dlgname, confname, maxlen);
}
コード例 #4
0
ファイル: dlgHardDisk.c プロジェクト: hskinnemoen/hatari
/**
 * Let user browse given directory, set directory if one selected.
 * return FALSE if none selected, otherwise return TRUE.
 */
static bool DlgDisk_BrowseDir(char *dlgname, char *confname, int maxlen)
{
	char *str, *selname;

	selname = SDLGui_FileSelect(confname, NULL, FALSE);
	if (selname)
	{
		strcpy(confname, selname);
		free(selname);

		str = strrchr(confname, PATHSEP);
		if (str != NULL)
			str[1] = 0;
		File_CleanFileName(confname);
		File_ShrinkName(dlgname, confname, maxlen);
		return TRUE;
	}
	return FALSE;
}
コード例 #5
0
/**
 * Shorcut to load a disk image
 */
static void ShortCut_InsertDisk(int drive)
{
    char *selname, *zip_path = NULL;
    const char *tmpname;
    char FileNameB[ FILENAME_MAX ];
    char ZipPathB[ FILENAME_MAX ];

    if (SDLGui_SetScreen(sdlscrn))
        return;

    /* Save current names for drive 1 before checking autoinsert */
    strcpy ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] );
    strcpy ( ZipPathB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] );

    if (ConfigureParams.DiskImage.szDiskFileName[drive][0])
        tmpname = ConfigureParams.DiskImage.szDiskFileName[drive];
    else
        tmpname = ConfigureParams.DiskImage.szDiskImageDirectory;

    Main_PauseEmulation(true);
    selname = SDLGui_FileSelect("Floppy image:", tmpname, &zip_path, false);
    if (selname)
    {
        if (File_Exists(selname))
            Floppy_SetDiskFileName(drive, selname, zip_path);
        else
            Floppy_SetDiskFileNameNone(drive);

        if (zip_path)
            free(zip_path);
        free(selname);

        Floppy_InsertDiskIntoDrive(0);

        /* Check if inserting into drive 0 also changed drive 1 with autoinsert */
        if ( ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] ) != 0 )
                || ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] ) != 0 ) )
            Floppy_InsertDiskIntoDrive(1);

    }
    Main_UnPauseEmulation();
}
コード例 #6
0
/**
 * Let user browse for a file, confname is used as default.
 * If bAllowNew is true, user can select new files also.
 * 
 * If no file is selected, or there's some problem with the file,
 * return false and clear dlgname & confname.
 * Otherwise return true, set dlgname & confname to the new file name
 * (dlgname is shrinked & limited to maxlen and confname is assumed
 * to have FILENAME_MAX amount of space).
 */
bool SDLGui_FileConfSelect(char *dlgname, char *confname, int maxlen, bool bAllowNew)
{
	char *selname;
	
	selname = SDLGui_FileSelect(confname, NULL, bAllowNew);
	if (selname)
	{
		if (!File_DoesFileNameEndWithSlash(selname) &&
		    (bAllowNew || File_Exists(selname)))
		{
			strncpy(confname, selname, FILENAME_MAX);
			confname[FILENAME_MAX-1] = '\0';
			File_ShrinkName(dlgname, selname, maxlen);
		}
		else
		{
			dlgname[0] = confname[0] = 0;
		}
		free(selname);
		return true;
	}
	return false;
}
コード例 #7
0
ファイル: dlgMain.c プロジェクト: lordashram/hatari-libretro
/**
 * This functions sets up the actual font and then displays the main dialog.
 */
int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
{
	int retbut;
	bool bOldMouseVisibility;
	int nOldMouseX, nOldMouseY;
	char *psNewCfg;

	*bReset = false;
	*bLoadedSnapshot = false;

	if (SDLGui_SetScreen(sdlscrn))
		return false;

	SDL_GetMouseState(&nOldMouseX, &nOldMouseY);
	bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
	SDL_ShowCursor(SDL_ENABLE);

	SDLGui_CenterDlg(maindlg);

	maindlg[MAINDLG_NORESET].state |= SG_SELECTED;
	maindlg[MAINDLG_RESET].state &= ~SG_SELECTED;

	do
	{
		retbut = SDLGui_DoDialog(maindlg, NULL);
		switch (retbut)
		{
		 case MAINDLG_ABOUT:
			Dialog_AboutDlg();
			break;
		 case MAINDLG_FLOPPYS:
			DlgFloppy_Main();
			break;
		 case MAINDLG_HARDDISK:
			DlgHardDisk_Main();
			break;
		 case MAINDLG_ROM:
			DlgRom_Main();
			break;
		 case MAINDLG_MONITOR:
			Dialog_MonitorDlg();
			break;
		 case MAINDLG_WINDOW:
			Dialog_WindowDlg();
			break;
		 case MAINDLG_SYSTEM:
			Dialog_SystemDlg();
			break;
		 case MAINDLG_MEMORY:
			if (Dialog_MemDlg())
			{
				/* Memory snapshot has been loaded - leave GUI immediately */
				*bLoadedSnapshot = true;
				SDL_ShowCursor(bOldMouseVisibility);
				Main_WarpMouse(nOldMouseX, nOldMouseY);
				return true;
			}
			break;
		 case MAINDLG_JOY:
			Dialog_JoyDlg();
			break;
		 case MAINDLG_KEYBD:
			Dialog_KeyboardDlg();
			break;
		 case MAINDLG_DEVICES:
			Dialog_DeviceDlg();
			break;
		 case MAINDLG_SOUND:
			Dialog_SoundDlg();
			break;
		 case MAINDLG_LOADCFG:
			psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, false);
			if (psNewCfg)
			{
				strcpy(sConfigFileName, psNewCfg);
				Configuration_Load(NULL);
				free(psNewCfg);
			}
			break;
		 case MAINDLG_SAVECFG:
			psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, true);
			if (psNewCfg)
			{
				strcpy(sConfigFileName, psNewCfg);
				Configuration_Save();
				free(psNewCfg);
			}
			break;
		 case MAINDLG_QUIT:
			bQuitProgram = true;
			break;
		}
                gui_poll_events();

	}
	while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
	        && retbut != SDLGUI_ERROR && !bQuitProgram);


	if (maindlg[MAINDLG_RESET].state & SG_SELECTED)
		*bReset = true;

	SDL_ShowCursor(bOldMouseVisibility);
	Main_WarpMouse(nOldMouseX, nOldMouseY);

	return (retbut == MAINDLG_OK);
}
コード例 #8
0
ファイル: dlgMain.cpp プロジェクト: diablodiab/frodo-libretro
/**
 * This functions sets up the actual font and then displays the main dialog.
 */
int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
{
	int retbut=0;
	bool bOldMouseVisibility;
	int nOldMouseX, nOldMouseY;
	char *psNewCfg;

	*bReset = false;
	*bLoadedSnapshot = false;

	if (SDLGui_SetScreen())
		return false;

	SDLGui_CenterDlg(maindlg);

	maindlg[MAINDLG_NORESET].state |= SG_SELECTED;
	maindlg[MAINDLG_RESET].state &= ~SG_SELECTED;

	prefs = new Prefs(ThePrefs);

	do
	{       
		retbut = SDLGui_DoDialog(maindlg, NULL);
		switch (retbut)
		{
		 case MAINDLG_ABOUT:
			Dialog_AboutDlg();
			break;

		 case MAINDLG_FLOPPYS:
			DlgFloppy_Main();
			break;

		 case MAINDLG_VIDEO:
			Dialog_VideoDlg();
			break;

		 case MAINDLG_MISC:
			Dialog_MiscDlg();
			break;

		 case MAINDLG_JOYSTICK:
			Dialog_JoyDlg();
			break;

		 case MAINDLG_SOUND:
			Dialog_SoundDlg();
			break;

		 case MAINDLG_LOADCFG:

			strcpy(sConfigFileName, ".frodorc");
			psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, false);

			if (psNewCfg)
			{						
				prefs->Load(psNewCfg);
             	TheC64->NewPrefs(prefs);
             	ThePrefs = *prefs;

				strcpy(sConfigFileName, psNewCfg);
				free(psNewCfg);
			}
			break;

		case MAINDLG_SAVECFG:

			strcpy(sConfigFileName, ".frodorc");
			psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, true);

			if (psNewCfg)
			{
				strcpy(sConfigFileName, psNewCfg);
				prefs->Save(sConfigFileName);
				free(psNewCfg);
			}
			break;

 		case MAINDLG_SNAPSHOT:
			Dialog_SnapshotDlg();
			break;

		 case MAINDLG_QUIT:
			bQuitProgram = true;
			break;
		}

		if(ThePrefs!=*prefs){
			printf("pref change \n");
			TheC64->NewPrefs(prefs);
			ThePrefs = *prefs;
		}

                gui_poll_events();

	}
	while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
	        && retbut != SDLGUI_ERROR && !bQuitProgram);


	if (maindlg[MAINDLG_RESET].state & SG_SELECTED)
		*bReset = true;

	delete prefs;

	return (retbut == MAINDLG_OK);
}
コード例 #9
0
ファイル: dlgMain.c プロジェクト: engur/PUAE
/**
 * This functions sets up the actual font and then displays the main dialog.
 */
int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
{
	int retbut=0;
	bool bOldMouseVisibility;
	int nOldMouseX, nOldMouseY;
	char *psNewCfg;

	*bReset = false;
	*bLoadedSnapshot = false;

	if (SDLGui_SetScreen(/*sdlscrn*/))
		return false;

	SDLGui_CenterDlg(maindlg);

	maindlg[MAINDLG_NORESET].state |= SG_SELECTED;
	maindlg[MAINDLG_RESET].state &= ~SG_SELECTED;

	do
	{
		retbut = SDLGui_DoDialog(maindlg, NULL);
		switch (retbut)
		{
		 case MAINDLG_ABOUT:
			Dialog_AboutDlg();
			break;

		 case MAINDLG_FLOPPYS:
			DlgFloppy_Main();
			break;

		 case MAINDLG_HARDDISK:
			DlgHardDisk_Main();
			break;

		 case MAINDLG_ROM:
			DlgRom_Main();
			break;

		 case MAINDLG_VIDEO:
			Dialog_VideoDlg();
			break;

		 case MAINDLG_SYSTEM:
			Dialog_SystemDlg();
			break;

		 case MAINDLG_MEMORY:
			if (Dialog_MemDlg())
			{
				/* Memory snapshot has been loaded - leave GUI immediately */
				*bLoadedSnapshot = true;
				//Main_WarpMouse(nOldMouseX, nOldMouseY);
				return true;
			}
			break;

		 case MAINDLG_MISC:
			Dialog_MiscDlg();
			break;

		 case MAINDLG_JOYSTICK:
			Dialog_JoyDlg();
			break;

		 case MAINDLG_SOUND:
			Dialog_SoundDlg();
			break;

		 case MAINDLG_LOADCFG:
			strcpy(sConfigFileName, ".uaerc");
			psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, false);
			if (psNewCfg)
			{
					default_prefs(& changed_prefs, 0);
					changed_prefs.chipmem_size = 0;
					changed_prefs.bogomem_size = 0;
					unmount_all_hdfs();
					int ret = cfgfile_load (& changed_prefs, psNewCfg, NULL,1,0);
					if (ret) {

						check_prefs_changed_cpu();
						check_prefs_changed_audio();
						check_prefs_changed_custom();

						MUSTRESET_CFG=1;
					}


				strcpy(sConfigFileName, psNewCfg);

			}
			break;

		 case MAINDLG_QUIT:
			bQuitProgram = true;
			break;
		}
                gui_poll_events();
	}
	while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
	        && retbut != SDLGUI_ERROR && !bQuitProgram);


	if (maindlg[MAINDLG_RESET].state & SG_SELECTED)
		*bReset = true;

	return (retbut == MAINDLG_OK);
}