Annotation of previous_trunk/src/gui-sdl/dlgMissingFile.c, revision 1.1

1.1     ! root        1: /*
        !             2:   Hatari - dlgMissingFile.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: const char DlgMissingFile_fileid[] = "Hatari dlgMissingFile.c : " __DATE__ " " __TIME__;
        !             8: 
        !             9: #include "main.h"
        !            10: #include "configuration.h"
        !            11: #include "dialog.h"
        !            12: #include "sdlgui.h"
        !            13: #include "file.h"
        !            14: #include "paths.h"
        !            15: 
        !            16: 
        !            17: /* Missing ROM dialog */
        !            18: #define DLGMISROM_ALERT     1
        !            19: 
        !            20: #define DLGMISROM_BROWSE    4
        !            21: #define DLGMISROM_DEFAULT   5
        !            22: #define DLGMISROM_NAME      6
        !            23: 
        !            24: #define DLGMISROM_SELECT    7
        !            25: #define DLGMISROM_REMOVE    8
        !            26: #define DLGMISROM_QUIT      9
        !            27: 
        !            28: 
        !            29: static SGOBJ missingromdlg[] =
        !            30: {
        !            31:     { SGBOX, 0, 0, 0,0, 52,15, NULL },
        !            32:     { SGTEXT, 0, 0, 2,1, 38,1, NULL },
        !            33:     { SGTEXT, 0, 0, 2,4, 43,1, "Please select a valid ROM file:" },
        !            34:     
        !            35:     { SGBOX, 0, 0, 1,6, 50,4, NULL },
        !            36:     { SGBUTTON, 0, 0, 2,7, 8,1, "Browse" },
        !            37:     { SGBUTTON, 0, 0, 11,7, 9,1, "Default" },
        !            38:     { SGTEXT, 0, 0, 2,8, 46,1, NULL },
        !            39:     
        !            40:     { SGBUTTON, SG_DEFAULT, 0, 4,12, 10,1, "Select" },
        !            41:     { SGBUTTON, 0, 0, 16,12, 10,1, "Remove" },
        !            42:     { SGBUTTON, 0, 0, 38,12, 10,1, "Quit" },
        !            43:     { -1, 0, 0, 0,0, 0,0, NULL }
        !            44: };
        !            45: 
        !            46: 
        !            47: /* Missing Disk dialog */
        !            48: #define DLGMISDSK_ALERT     1
        !            49: 
        !            50: #define DLGMISDSK_DRIVE     4
        !            51: #define DLGMISDSK_BROWSE    5
        !            52: #define DLGMISDSK_PROTECT   6
        !            53: #define DLGMISDSK_NAME      7
        !            54: 
        !            55: #define DLGMISDSK_SELECT    8
        !            56: #define DLGMISDSK_REMOVE    9
        !            57: #define DLGMISDSK_QUIT      10
        !            58: 
        !            59: 
        !            60: static SGOBJ missingdiskdlg[] =
        !            61: {
        !            62:     { SGBOX, 0, 0, 0,0, 52,15, NULL },
        !            63:     { SGTEXT, 0, 0, 6,1, 38,1, NULL },
        !            64:     { SGTEXT, 0, 0, 2,4, 43,1, "Please remove or select a valid disk image:" },
        !            65:     
        !            66:     { SGBOX, 0, 0, 1,6, 50,4, NULL },
        !            67:     { SGTEXT, 0, 0, 2,7, 15,1, NULL },
        !            68:     { SGBUTTON, 0, 0, 39,7, 10,1, "Browse" },
        !            69:     { SGTEXT, 0, 0, 15,7, 10,1, NULL },
        !            70:     { SGTEXT, 0, 0, 2,8, 46,1, NULL },
        !            71:     
        !            72:     { SGBUTTON, SG_DEFAULT, 0, 4,12, 10,1, "Select" },
        !            73:     { SGBUTTON, 0, 0, 16,12, 10,1, "Remove" },
        !            74:     { SGBUTTON, 0, 0, 38,12, 10,1, "Quit" },
        !            75:     { -1, 0, 0, 0,0, 0,0, NULL }
        !            76: };
        !            77: 
        !            78: 
        !            79: 
        !            80: 
        !            81: /*-----------------------------------------------------------------------*/
        !            82: /**
        !            83:  * Show and process the Missing ROM dialog.
        !            84:  */
        !            85: void DlgMissing_Rom(const char* type, char *imgname, const char *defname, bool *enabled) {
        !            86:     int but;
        !            87:     
        !            88:     char dlgname_missingrom[64];
        !            89:     char missingrom_alert[64];
        !            90:     
        !            91:     bool bOldMouseVisibility;
        !            92:     bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
        !            93:     SDL_ShowCursor(SDL_ENABLE);
        !            94:     
        !            95:     SDLGui_CenterDlg(missingromdlg);
        !            96:     
        !            97:     /* Set up dialog to actual values: */
        !            98:     sprintf(missingrom_alert, "%s: ROM file not found!", type);
        !            99:     missingromdlg[DLGMISROM_ALERT].txt = missingrom_alert;
        !           100:     
        !           101:     File_ShrinkName(dlgname_missingrom, imgname, missingromdlg[DLGMISROM_NAME].w);
        !           102:     
        !           103:     missingromdlg[DLGMISROM_NAME].txt = dlgname_missingrom;
        !           104:     
        !           105:     if (*enabled) {
        !           106:         missingromdlg[DLGMISROM_REMOVE].type = SGBUTTON;
        !           107:         missingromdlg[DLGMISROM_REMOVE].txt = "Remove";
        !           108:     } else {
        !           109:         missingromdlg[DLGMISROM_REMOVE].type = SGTEXT;
        !           110:         missingromdlg[DLGMISROM_REMOVE].txt = "";
        !           111:     }
        !           112:     
        !           113:     
        !           114:     /* Draw and process the dialog */
        !           115:     do
        !           116:     {
        !           117:         but = SDLGui_DoDialog(missingromdlg, NULL);
        !           118:         switch (but)
        !           119:         {
        !           120:                 
        !           121:             case DLGMISROM_BROWSE:
        !           122:                 SDLGui_FileConfSelect(dlgname_missingrom, imgname,
        !           123:                                       missingromdlg[DLGMISROM_NAME].w,
        !           124:                                       false);
        !           125:                 break;
        !           126:             case DLGMISROM_DEFAULT:
        !           127:                 sprintf(imgname, "%s",defname);
        !           128:                 File_ShrinkName(dlgname_missingrom, imgname, missingromdlg[DLGMISROM_NAME].w);
        !           129:                 break;
        !           130:             case DLGMISROM_REMOVE:
        !           131:                 *enabled = false;
        !           132:                 *imgname = '\0';
        !           133:                 break;
        !           134:             case DLGMISROM_QUIT:
        !           135:                 bQuitProgram = true;
        !           136:                 break;
        !           137:                 
        !           138:             default:
        !           139:                 break;
        !           140:         }
        !           141:     }
        !           142:     while (but != DLGMISROM_SELECT && but != DLGMISROM_REMOVE &&
        !           143:            but != SDLGUI_QUIT && but != SDLGUI_ERROR && !bQuitProgram);
        !           144:     
        !           145:     
        !           146:     SDL_ShowCursor(bOldMouseVisibility);
        !           147: }
        !           148: 
        !           149: 
        !           150: /*-----------------------------------------------------------------------*/
        !           151: /**
        !           152:  * Show and process the Missing Disk dialog.
        !           153:  */
        !           154: void DlgMissing_Disk(const char* type, int num, char *imgname, bool *inserted, bool *wp)
        !           155: {
        !           156:     int but;
        !           157:     
        !           158:     char dlgname_missingdisk[64];
        !           159:     char missingdisk_alert[64];
        !           160:     char missingdisk_disk[64];
        !           161:     
        !           162:     bool bOldMouseVisibility;
        !           163:     bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
        !           164:     SDL_ShowCursor(SDL_ENABLE);
        !           165: 
        !           166:     SDLGui_CenterDlg(missingdiskdlg);
        !           167:     
        !           168:     /* Set up dialog to actual values: */
        !           169:     sprintf(missingdisk_alert, "%s drive %i: disk image not found!", type, num);
        !           170:     missingdiskdlg[DLGMISDSK_ALERT].txt = missingdisk_alert;
        !           171:     
        !           172:     sprintf(missingdisk_disk, "%s %i:", type, num);
        !           173:     missingdiskdlg[DLGMISDSK_DRIVE].txt = missingdisk_disk;
        !           174:     
        !           175:     File_ShrinkName(dlgname_missingdisk, imgname, missingdiskdlg[DLGMISDSK_NAME].w);
        !           176:     
        !           177:     missingdiskdlg[DLGMISDSK_NAME].txt = dlgname_missingdisk;
        !           178:     
        !           179:     
        !           180:     /* Draw and process the dialog */
        !           181:     do
        !           182:     {
        !           183:         if (*wp)
        !           184:             missingdiskdlg[DLGMISDSK_PROTECT].txt = "read-only";
        !           185:         else
        !           186:             missingdiskdlg[DLGMISDSK_PROTECT].txt = "";
        !           187: 
        !           188:         but = SDLGui_DoDialog(missingdiskdlg, NULL);
        !           189:         switch (but)
        !           190:         {
        !           191:                 
        !           192:             case DLGMISDSK_BROWSE:
        !           193:                 SDLGui_DiskSelect(dlgname_missingdisk, imgname, missingdiskdlg[DLGMISDSK_NAME].w, wp);
        !           194:                 break;
        !           195:             case DLGMISDSK_REMOVE:
        !           196:                 *inserted = false;
        !           197:                 *wp = false;
        !           198:                 *imgname = '\0';
        !           199:                 break;
        !           200:             case DLGMISDSK_QUIT:
        !           201:                 bQuitProgram = true;
        !           202:                 break;
        !           203:                 
        !           204:             default:
        !           205:                 break;
        !           206:         }
        !           207:     }
        !           208:     while (but != DLGMISDSK_SELECT && but != DLGMISDSK_REMOVE &&
        !           209:            but != SDLGUI_QUIT && but != SDLGUI_ERROR && !bQuitProgram);
        !           210:     
        !           211:     SDL_ShowCursor(bOldMouseVisibility);
        !           212: }

unix.superglobalmegacorp.com

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