|
|
1.1 root 1: /*
2: Hatari - dlgMain.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: The main dialog.
8: */
9: const char DlgMain_fileid[] = "Hatari dlgMain.c : " __DATE__ " " __TIME__;
10:
11: #include "main.h"
12: #include "configuration.h"
13: #include "dialog.h"
14: #include "sdlgui.h"
15: #include "screen.h"
1.1.1.3 root 16: #include "dimension.h"
1.1 root 17:
18:
1.1.1.3 root 19: #define MAINDLG_ABOUT 0
20: #define MAINDLG_SYSTEM 2
21: #define MAINDLG_ROM 3
22: #define MAINDLG_GRAPH 4
23: #define MAINDLG_ENET 5
1.1.1.2 root 24: #define MAINDLG_BOOT 6
1.1.1.3 root 25: #define MAINDLG_SCSI 7
26: #define MAINDLG_MO 8
27: #define MAINDLG_FLOPPY 9
28: #define MAINDLG_KEYBD 10
29: #define MAINDLG_MOUSE 11
30: #define MAINDLG_SOUND 12
31: #define MAINDLG_PRINTER 13
1.1 root 32: #define MAINDLG_LOADCFG 14
33: #define MAINDLG_SAVECFG 15
1.1.1.3 root 34: #define MAINDLG_RESET 16
35: #define MAINDLG_SHOW 17
36: #define MAINDLG_OK 18
37: #define MAINDLG_QUIT 19
38: #define MAINDLG_CANCEL 20
1.1 root 39:
40:
41: /* The main dialog: */
42: static SGOBJ maindlg[] =
43: {
44: { SGBOX, 0, 0, 0,0, 50,19, NULL },
1.1.1.3 root 45: { SGTEXT, 0, 0, 15,1, 20,1, "Previous - Main menu" },
46: { SGBUTTON, 0, 0, 2,4, 13,1, "System" },
47: { SGBUTTON, 0, 0, 2,6, 13,1, "ROM" },
48: { SGBUTTON, 0, 0, 2,8, 13,1, "Graphics" },
49: { SGBUTTON, 0, 0, 2,10, 13,1, "Ethernet" },
1.1.1.2 root 50: { SGBUTTON, 0, 0, 17,4, 16,1, "Boot options" },
51: { SGBUTTON, 0, 0, 17,6, 16,1, "SCSI disks" },
1.1.1.3 root 52: { SGBUTTON, 0, 0, 17,8, 16,1, "MO disks" },
53: { SGBUTTON, 0, 0, 17,10, 16,1, "Floppy disks" },
54: { SGBUTTON, 0, 0, 35,4, 13,1, "Keyboard" },
55: { SGBUTTON, 0, 0, 35,6, 13,1, "Mouse" },
56: { SGBUTTON, 0, 0, 35,8, 13,1, "Sound" },
57: { SGBUTTON, 0, 0, 35,10, 13,1, "Printer" },
1.1 root 58: { SGBUTTON, 0, 0, 7,13, 16,1, "Load config." },
59: { SGBUTTON, 0, 0, 27,13, 16,1, "Save config." },
1.1.1.3 root 60: { SGCHECKBOX, 0, 0, 3,15, 15,1, "Reset machine" },
1.1.1.2 root 61: { SGCHECKBOX, 0, 0, 3,17, 15,1, "Show at startup" },
1.1 root 62: { SGBUTTON, SG_DEFAULT, 0, 21,15, 8,3, "OK" },
63: { SGBUTTON, 0, 0, 36,15, 10,1, "Quit" },
64: { SGBUTTON, SG_CANCEL, 0, 36,17, 10,1, "Cancel" },
65: { -1, 0, 0, 0,0, 0,0, NULL }
66: };
67:
68:
69: /**
70: * This functions sets up the actual font and then displays the main dialog.
71: */
72: int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
73: {
74: int retbut;
75: bool bOldMouseVisibility;
76: int nOldMouseX, nOldMouseY;
77: char *psNewCfg;
78:
79: *bReset = false;
80: *bLoadedSnapshot = false;
81:
82: if (SDLGui_SetScreen(sdlscrn))
83: return false;
84:
85: SDL_GetMouseState(&nOldMouseX, &nOldMouseY);
86: bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
87: SDL_ShowCursor(SDL_ENABLE);
88:
89: SDLGui_CenterDlg(maindlg);
90:
91: maindlg[MAINDLG_RESET].state &= ~SG_SELECTED;
1.1.1.2 root 92:
93: if(ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup)
94: maindlg[MAINDLG_SHOW].state |= SG_SELECTED;
95: else
96: maindlg[MAINDLG_SHOW].state &= ~SG_SELECTED;
1.1 root 97:
98: do
99: {
100: retbut = SDLGui_DoDialog(maindlg, NULL);
101: switch (retbut)
102: {
103: case MAINDLG_ABOUT:
104: Dialog_AboutDlg();
105: break;
1.1.1.3 root 106: case MAINDLG_GRAPH:
107: Dialog_DimensionDlg();
1.1 root 108: break;
1.1.1.3 root 109: case MAINDLG_ENET:
110: DlgEthernet_Main();
111: break;
112: case MAINDLG_SCSI:
113: DlgSCSI_Main();
1.1 root 114: break;
115: case MAINDLG_ROM:
116: DlgRom_Main();
117: break;
1.1.1.3 root 118: case MAINDLG_MO:
119: DlgOptical_Main();
1.1 root 120: break;
1.1.1.3 root 121: case MAINDLG_FLOPPY:
122: DlgFloppy_Main();
1.1 root 123: break;
124: case MAINDLG_SYSTEM:
125: Dialog_SystemDlg();
126: break;
1.1.1.3 root 127: case MAINDLG_PRINTER:
128: DlgPrinter_Main();
1.1 root 129: break;
1.1.1.2 root 130: case MAINDLG_BOOT:
131: DlgBoot_Main();
1.1 root 132: break;
133: case MAINDLG_KEYBD:
1.1.1.2 root 134: Dialog_KeyboardDlg();
1.1 root 135: break;
1.1.1.3 root 136: case MAINDLG_MOUSE:
137: Dialog_MouseDlg();
1.1 root 138: break;
139: case MAINDLG_SOUND:
1.1.1.3 root 140: DlgSound_Main();
1.1 root 141: break;
142: case MAINDLG_LOADCFG:
143: psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, false);
144: if (psNewCfg)
145: {
146: strcpy(sConfigFileName, psNewCfg);
147: Configuration_Load(NULL);
148: free(psNewCfg);
149: }
150: break;
151: case MAINDLG_SAVECFG:
152: psNewCfg = SDLGui_FileSelect(sConfigFileName, NULL, true);
153: if (psNewCfg)
154: {
155: strcpy(sConfigFileName, psNewCfg);
156: Configuration_Save();
157: free(psNewCfg);
158: }
159: break;
1.1.1.2 root 160: case MAINDLG_SHOW:
161: if (maindlg[MAINDLG_SHOW].state & SG_SELECTED)
162: ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup = true;
163: else
164: ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup = false;
165: break;
1.1 root 166: case MAINDLG_QUIT:
167: bQuitProgram = true;
168: break;
169: }
170: }
171: while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
172: && retbut != SDLGUI_ERROR && !bQuitProgram);
173:
1.1.1.2 root 174:
1.1 root 175: if (maindlg[MAINDLG_RESET].state & SG_SELECTED)
176: *bReset = true;
177:
178: SDL_ShowCursor(bOldMouseVisibility);
179: Main_WarpMouse(nOldMouseX, nOldMouseY);
180:
181: return (retbut == MAINDLG_OK);
182: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.