Annotation of hatari/src/gui-sdl/dlgMain.c, revision 1.1.1.14

1.1       root        1: /*
                      2:   Hatari - dlgMain.c
                      3: 
1.1.1.12  root        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.
1.1       root        6: 
                      7:   The main dialog.
                      8: */
1.1.1.8   root        9: const char DlgMain_fileid[] = "Hatari dlgMain.c : " __DATE__ " " __TIME__;
1.1       root       10: 
                     11: #include "main.h"
                     12: #include "configuration.h"
                     13: #include "dialog.h"
                     14: #include "sdlgui.h"
                     15: #include "screen.h"
                     16: 
                     17: 
1.1.1.14! root       18: #define MAINDLG_SYSTEM   2
        !            19: #define MAINDLG_CPU      3
1.1.1.2   root       20: #define MAINDLG_ROM      4
1.1.1.9   root       21: #define MAINDLG_MEMORY   5
                     22: #define MAINDLG_FLOPPYS  6
                     23: #define MAINDLG_HARDDISK 7
1.1.1.10  root       24: #define MAINDLG_MONITOR  8
                     25: #define MAINDLG_WINDOW   9
1.1.1.9   root       26: #define MAINDLG_JOY      10
                     27: #define MAINDLG_KEYBD    11
                     28: #define MAINDLG_DEVICES  12
1.1.1.10  root       29: #define MAINDLG_SOUND    13
1.1.1.14! root       30: #define MAINDLG_ABOUT    14
        !            31: #define MAINDLG_LOADCFG  15
        !            32: #define MAINDLG_SAVECFG  16
        !            33: #define MAINDLG_NORESET  17
        !            34: #define MAINDLG_RESET    18
        !            35: #define MAINDLG_OK       19
        !            36: #define MAINDLG_QUIT     20
        !            37: #define MAINDLG_CANCEL   21
1.1       root       38: 
                     39: 
                     40: /* The main dialog: */
                     41: static SGOBJ maindlg[] =
                     42: {
1.1.1.9   root       43:        { SGBOX, 0, 0, 0,0, 50,19, NULL },
                     44:        { SGTEXT, 0, 0, 17,1, 16,1, "Hatari main menu" },
1.1.1.14! root       45:        { SGBUTTON, 0, 0,  2, 4, 13,1, "S_ystem" },
        !            46:        { SGBUTTON, 0, 0,  2, 6, 13,1, "CP_U" },
1.1.1.13  root       47:        { SGBUTTON, 0, 0,  2, 8, 13,1, "_ROM" },
                     48:        { SGBUTTON, 0, 0,  2,10, 13,1, "_Memory" },
                     49:        { SGBUTTON, 0, 0, 17, 4, 16,1, "_Floppy disks" },
                     50:        { SGBUTTON, 0, 0, 17, 6, 16,1, "Hard _disks" },
                     51:        { SGBUTTON, 0, 0, 17, 8, 16,1, "_Atari screen" },
                     52:        { SGBUTTON, 0, 0, 17,10, 16,1, "_Hatari screen" },
                     53:        { SGBUTTON, 0, 0, 35, 4, 13,1, "_Joysticks" },
                     54:        { SGBUTTON, 0, 0, 35, 6, 13,1, "_Keyboard" },
                     55:        { SGBUTTON, 0, 0, 35, 8, 13,1, "D_evices" },
                     56:        { SGBUTTON, 0, 0, 35,10, 13,1, "S_ound" },
1.1.1.14! root       57:        { SGBUTTON, 0, 0,  2,13, 13,1, "A_bout" },
        !            58:        { SGBUTTON, 0, 0, 17,13, 16,1, "_Load config" },
        !            59:        { SGBUTTON, 0, 0, 35,13, 13,1, "_Save config" },
1.1.1.13  root       60:        { SGRADIOBUT, 0, 0, 3,15, 10,1, "_No Reset" },
                     61:        { SGRADIOBUT, 0, 0, 3,17, 15,1, "Reset ma_chine" },
1.1.1.9   root       62:        { SGBUTTON, SG_DEFAULT, 0, 21,15, 8,3, "OK" },
1.1.1.13  root       63:        { SGBUTTON, 0, 0, 36,15, 10,1, "_Quit" },
1.1.1.9   root       64:        { SGBUTTON, SG_CANCEL, 0, 36,17, 10,1, "Cancel" },
1.1.1.14! root       65:        { SGSTOP, 0, 0, 0,0, 0,0, NULL }
1.1       root       66: };
                     67: 
                     68: 
1.1.1.9   root       69: /**
                     70:  * This functions sets up the actual font and then displays the main dialog.
                     71:  */
1.1.1.8   root       72: int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
1.1       root       73: {
1.1.1.6   root       74:        int retbut;
1.1.1.7   root       75:        bool bOldMouseVisibility;
1.1.1.6   root       76:        int nOldMouseX, nOldMouseY;
1.1.1.10  root       77:        char *psNewCfg;
1.1.1.6   root       78: 
1.1.1.8   root       79:        *bReset = false;
                     80:        *bLoadedSnapshot = false;
                     81: 
1.1.1.6   root       82:        if (SDLGui_SetScreen(sdlscrn))
1.1.1.8   root       83:                return false;
1.1.1.6   root       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_NORESET].state |= SG_SELECTED;
                     92:        maindlg[MAINDLG_RESET].state &= ~SG_SELECTED;
                     93: 
                     94:        do
                     95:        {
1.1.1.13  root       96:                retbut = SDLGui_DoDialog(maindlg, NULL, false);
1.1.1.6   root       97:                switch (retbut)
                     98:                {
                     99:                 case MAINDLG_ABOUT:
                    100:                        Dialog_AboutDlg();
                    101:                        break;
1.1.1.14! root      102:                 case MAINDLG_CPU:
        !           103:                        DlgCpu_Main();
        !           104:                        break;
1.1.1.9   root      105:                 case MAINDLG_FLOPPYS:
                    106:                        DlgFloppy_Main();
                    107:                        break;
                    108:                 case MAINDLG_HARDDISK:
                    109:                        DlgHardDisk_Main();
1.1.1.6   root      110:                        break;
                    111:                 case MAINDLG_ROM:
                    112:                        DlgRom_Main();
                    113:                        break;
1.1.1.10  root      114:                 case MAINDLG_MONITOR:
                    115:                        Dialog_MonitorDlg();
1.1.1.6   root      116:                        break;
1.1.1.10  root      117:                 case MAINDLG_WINDOW:
                    118:                        Dialog_WindowDlg();
1.1.1.6   root      119:                        break;
1.1.1.9   root      120:                 case MAINDLG_SYSTEM:
1.1.1.14! root      121:                        DlgSystem_Main();
1.1.1.6   root      122:                        break;
                    123:                 case MAINDLG_MEMORY:
1.1.1.8   root      124:                        if (Dialog_MemDlg())
                    125:                        {
                    126:                                /* Memory snapshot has been loaded - leave GUI immediately */
                    127:                                *bLoadedSnapshot = true;
1.1.1.11  root      128:                                SDL_ShowCursor(bOldMouseVisibility);
1.1.1.13  root      129:                                Main_WarpMouse(nOldMouseX, nOldMouseY, true);
1.1.1.8   root      130:                                return true;
                    131:                        }
1.1.1.6   root      132:                        break;
                    133:                 case MAINDLG_JOY:
                    134:                        Dialog_JoyDlg();
                    135:                        break;
                    136:                 case MAINDLG_KEYBD:
                    137:                        Dialog_KeyboardDlg();
                    138:                        break;
                    139:                 case MAINDLG_DEVICES:
                    140:                        Dialog_DeviceDlg();
                    141:                        break;
1.1.1.10  root      142:                 case MAINDLG_SOUND:
                    143:                        Dialog_SoundDlg();
                    144:                        break;
1.1.1.6   root      145:                 case MAINDLG_LOADCFG:
1.1.1.13  root      146:                        psNewCfg = SDLGui_FileSelect("Load configuration:", sConfigFileName, NULL, false);
1.1.1.10  root      147:                        if (psNewCfg)
                    148:                        {
                    149:                                strcpy(sConfigFileName, psNewCfg);
                    150:                                Configuration_Load(NULL);
                    151:                                free(psNewCfg);
                    152:                        }
1.1.1.6   root      153:                        break;
                    154:                 case MAINDLG_SAVECFG:
1.1.1.13  root      155:                        psNewCfg = SDLGui_FileSelect("Save configuration:", sConfigFileName, NULL, true);
1.1.1.10  root      156:                        if (psNewCfg)
                    157:                        {
                    158:                                strcpy(sConfigFileName, psNewCfg);
                    159:                                Configuration_Save();
                    160:                                free(psNewCfg);
                    161:                        }
1.1.1.6   root      162:                        break;
                    163:                 case MAINDLG_QUIT:
1.1.1.8   root      164:                        bQuitProgram = true;
1.1.1.6   root      165:                        break;
                    166:                }
                    167:        }
                    168:        while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
                    169:                && retbut != SDLGUI_ERROR && !bQuitProgram);
                    170: 
                    171: 
                    172:        if (maindlg[MAINDLG_RESET].state & SG_SELECTED)
1.1.1.8   root      173:                *bReset = true;
1.1       root      174: 
1.1.1.6   root      175:        SDL_ShowCursor(bOldMouseVisibility);
1.1.1.13  root      176:        Main_WarpMouse(nOldMouseX, nOldMouseY, true);
1.1.1.2   root      177: 
1.1.1.6   root      178:        return (retbut == MAINDLG_OK);
1.1       root      179: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.