Annotation of previous/src/gui-sdl/dlgMain.c, revision 1.1.1.5

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

unix.superglobalmegacorp.com

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