1 /*
2   Hatari - dialog.c
3 
4   This file is distributed under the GNU General Public License, version 2
5   or at your option any later version. Read the file gpl.txt for details.
6 
7   Code to handle our options dialog.
8 */
9 const char Dialog_fileid[] = "Hatari dialog.c : " __DATE__ " " __TIME__;
10 
11 #include "main.h"
12 #include "configuration.h"
13 #include "change.h"
14 #include "dialog.h"
15 #include "log.h"
16 #include "sdlgui.h"
17 #include "screen.h"
18 
19 
20 /*-----------------------------------------------------------------------*/
21 /**
22  * Open Property sheet Options dialog.
23  *
24  * We keep all our configuration details in a structure called
25  * 'ConfigureParams'. When we open our dialog we make a backup
26  * of this structure. When the user finally clicks on 'OK',
27  * we can compare and makes the necessary changes.
28  *
29  * Return true if user chooses OK, or false if cancel!
30  */
Dialog_DoProperty(void)31 bool Dialog_DoProperty(void)
32 {
33 	bool bOKDialog;  /* Did user 'OK' dialog? */
34 	bool bForceReset;
35 	bool bLoadedSnapshot;
36 	CNF_PARAMS current;
37 
38 #if WITH_SDL2
39 	bool bOldMouseMode = SDL_GetRelativeMouseMode();
40 	SDL_SetRelativeMouseMode(SDL_FALSE);
41 #endif
42 
43 	Main_PauseEmulation(true);
44 	bForceReset = false;
45 
46 	/* Copy details (this is so can restore if 'Cancel' dialog) */
47 	current = ConfigureParams;
48 	ConfigureParams.Screen.bFullScreen = bInFullScreen;
49 	bOKDialog = Dialog_MainDlg(&bForceReset, &bLoadedSnapshot);
50 
51 #if WITH_SDL2
52 	SDL_SetRelativeMouseMode(bOldMouseMode);
53 #endif
54 
55 	/* If a memory snapshot has been loaded, no further changes are required */
56 	if (bLoadedSnapshot)
57 	{
58 		Main_UnPauseEmulation();
59 		return true;
60 	}
61 
62 	/* Check if reset is required and ask user if he really wants to continue then */
63 	if (bOKDialog && !bForceReset
64 	    && Change_DoNeedReset(&current, &ConfigureParams)
65 	    && ConfigureParams.Log.nAlertDlgLogLevel > LOG_FATAL) {
66 		bOKDialog = DlgAlert_Query("The emulated system must be "
67 		                           "reset to apply these changes. "
68 		                           "Apply changes now and reset "
69 		                           "the emulator?");
70 	}
71 
72 	/* Copy details to configuration */
73 	if (bOKDialog) {
74 		Change_CopyChangedParamsToConfiguration(&current, &ConfigureParams, bForceReset);
75 	} else {
76 		ConfigureParams = current;
77 	}
78 
79 	Main_UnPauseEmulation();
80 
81 	if (bQuitProgram)
82 		Main_RequestQuit(0);
83 
84 	return bOKDialog;
85 }
86