|
|
1.1 root 1: /*
2: Hatari - dlgNewDisc.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: */
1.1.1.2 ! root 7: char DlgNewDisc_rcsid[] = "Hatari $Id: dlgNewDisc.c,v 1.3 2005/02/13 16:18:52 thothy Exp $";
1.1 root 8:
9: #include "main.h"
10: #include "configuration.h"
11: #include "createBlankImage.h"
12: #include "dialog.h"
13: #include "sdlgui.h"
14: #include "file.h"
15:
16:
17: #define DLGNEWDISC_DECTRACK 3
18: #define DLGNEWDISC_TRACKSTR 4
19: #define DLGNEWDISC_INCTRACK 5
20: #define DLGNEWDISC_SECTORS9 7
21: #define DLGNEWDISC_SECTORS10 8
22: #define DLGNEWDISC_SECTORS11 9
23: #define DLGNEWDISC_SIDES1 11
24: #define DLGNEWDISC_SIDES2 12
25: #define DLGNEWDISC_SAVE 13
26: #define DLGNEWDISC_EXIT 14
27:
28: static char szTracks[3];
29: static int nTracks = 80;
30:
31: /* The new disc image dialog: */
32: static SGOBJ newdiscdlg[] =
33: {
34: { SGBOX, 0, 0, 0,0, 28,12, NULL },
35: { SGTEXT, 0, 0, 6,1, 16,1, "New floppy image" },
36: { SGTEXT, 0, 0, 2,3, 7,1, "Tracks:" },
37: { SGBUTTON, 0, 0, 12,3, 1,1, "\x04" }, /* Left-arrow button */
38: { SGTEXT, 0, 0, 14,3, 2,1, szTracks },
39: { SGBUTTON, 0, 0, 17,3, 1,1, "\x03" }, /* Right-arrow button */
40: { SGTEXT, 0, 0, 2,5, 8,1, "Sectors:" },
41: { SGRADIOBUT, 0, SG_SELECTED, 12,5, 4,1, "9" },
42: { SGRADIOBUT, 0, 0, 17,5, 4,1, "10" },
43: { SGRADIOBUT, 0, 0, 22,5, 4,1, "11" },
44: { SGTEXT, 0, 0, 2,7, 6,1, "Sides:" },
45: { SGRADIOBUT, 0, 0, 12,7, 4,1, "1" },
46: { SGRADIOBUT, 0, SG_SELECTED, 17,7, 4,1, "2" },
47: { SGBUTTON, 0, 0, 4,10, 8,1, "Create" },
48: { SGBUTTON, 0, 0, 18,10, 6,1, "Back" },
49: { -1, 0, 0, 0,0, 0,0, NULL }
50: };
51:
52:
53: /*-----------------------------------------------------------------------*/
54: /*
55: Show and process the "new blank disc image" dialog.
56: */
57: void DlgNewDisc_Main(void)
58: {
59: int but;
60: char *szNewDiscName;
61:
62: sprintf(szTracks, "%i", nTracks);
63:
64: SDLGui_CenterDlg(newdiscdlg);
65:
66: /* Initialize disc image name: */
1.1.1.2 ! root 67: szNewDiscName = malloc(FILENAME_MAX);
! 68: if (!szNewDiscName)
! 69: {
! 70: perror("DlgNewDisc_Main");
! 71: return;
! 72: }
1.1 root 73: strcpy(szNewDiscName, DialogParams.DiscImage.szDiscImageDirectory);
74: if (strlen(szNewDiscName) < FILENAME_MAX-12)
75: strcat(szNewDiscName, "new_disc.st");
76:
77: /* Draw and process the dialog */
78: do
79: {
1.1.1.2 ! root 80: but = SDLGui_DoDialog(newdiscdlg, NULL);
1.1 root 81: switch(but)
82: {
83: case DLGNEWDISC_DECTRACK:
84: if (nTracks > 40)
85: nTracks -= 1;
86: sprintf(szTracks, "%i", nTracks);
87: break;
88: case DLGNEWDISC_INCTRACK:
89: if (nTracks < 85)
90: nTracks += 1;
91: sprintf(szTracks, "%i", nTracks);
92: break;
93: case DLGNEWDISC_SAVE:
94: if (SDLGui_FileSelect(szNewDiscName, NULL, TRUE))
95: {
96: if (!File_DoesFileNameEndWithSlash(szNewDiscName))
97: {
98: int nSectors, nSides;
99:
100: /* Get number of sectors */
101: if (newdiscdlg[DLGNEWDISC_SECTORS11].state & SG_SELECTED)
102: nSectors = 11;
103: else if (newdiscdlg[DLGNEWDISC_SECTORS10].state & SG_SELECTED)
104: nSectors = 10;
105: else
106: nSectors = 9;
107:
108: /* Get number of sides */
109: if (newdiscdlg[DLGNEWDISC_SIDES1].state & SG_SELECTED)
110: nSides = 1;
111: else
112: nSides = 2;
113:
114: CreateBlankImage_CreateFile(szNewDiscName, nTracks, nSectors, nSides);
115: }
116: }
117: break;
118: }
119: }
1.1.1.2 ! root 120: while (but != DLGNEWDISC_EXIT && but != SDLGUI_QUIT && !bQuitProgram);
1.1 root 121:
1.1.1.2 ! root 122: free(szNewDiscName);
1.1 root 123: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.