Subversion Repositories eduke32

Rev

Rev 214 | Rev 220 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
194 terminx 1
#ifndef RENDERTYPEWIN
2
#error Only for Windows
3
#endif
4
 
5
#include "duke3d.h"
219 terminx 6
#include "sounds.h"
194 terminx 7
 
8
#include "build.h"
9
#include "winlayer.h"
10
#include "compat.h"
11
 
214 terminx 12
#include "startdlg.h"
13
 
194 terminx 14
#define WIN32_LEAN_AND_MEAN
15
#include <windows.h>
16
#include <windowsx.h>
17
#define _WIN32_IE 0x0300
18
#include <commctrl.h>
19
#include <stdio.h>
20
 
21
#include "startwin.game.h"
22
 
23
#define TAB_CONFIG 0
214 terminx 24
#define TAB_GAME 1
25
#define TAB_MESSAGES 2
194 terminx 26
 
219 terminx 27
static struct audioenumdrv *wavedevs = NULL;
28
 
194 terminx 29
static struct {
30
    int fullscreen;
31
    int xdim, ydim, bpp;
32
    int forcesetup;
33
    int usemouse, usejoy;
214 terminx 34
    char selectedgrp[BMAX_PATH+1];
194 terminx 35
} settings;
36
 
37
static HWND startupdlg = NULL;
214 terminx 38
static HWND pages[3] = { NULL, NULL, NULL };
197 terminx 39
static int done = -1, mode = TAB_CONFIG;
194 terminx 40
 
219 terminx 41
#define POPULATE_VIDEO 1
42
#define POPULATE_CONFIG 2
43
#define POPULATE_GAME 4
44
 
214 terminx 45
static void PopulateForm(int pgs)
194 terminx 46
{
47
    HWND hwnd;
219 terminx 48
    char buf[256];
49
    int i,j;
50
 
51
    if (pgs & POPULATE_VIDEO) {
214 terminx 52
        int mode;
194 terminx 53
 
214 terminx 54
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
194 terminx 55
 
214 terminx 56
        mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
57
        if (mode < 0) {
58
            int cd[] = { 32, 24, 16, 15, 8, 0 };
59
            for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; }
60
            for ( ; cd[i]; i++) {
61
                mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
62
                if (mode < 0) continue;
63
                settings.bpp = cd[i];
64
                break;
65
            }
194 terminx 66
        }
214 terminx 67
 
68
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
69
        ComboBox_ResetContent(hwnd);
70
        for (i=0; i<validmodecnt; i++) {
71
            if (validmode[i].fs != settings.fullscreen) continue;
72
 
73
            // all modes get added to the 3D mode list
74
            Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
75
            j = ComboBox_AddString(hwnd, buf);
76
            ComboBox_SetItemData(hwnd, j, i);
77
            if (i == mode) ComboBox_SetCurSel(hwnd, j);
78
        }
219 terminx 79
    }
214 terminx 80
 
219 terminx 81
    if (pgs & POPULATE_CONFIG) {
82
        struct audioenumdev *d;
83
        char *n;
84
 
85
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
86
        ComboBox_ResetContent(hwnd);
87
        if (wavedevs) {
88
            d = wavedevs->devs;
89
            for (i=0; wavedevs->drvs[i]; i++) {
90
                strcpy(buf, wavedevs->drvs[i]);
91
                if (d->devs) {
92
                    strcat(buf, ":");
93
                    n = buf + strlen(buf);
94
                    for (j=0; d->devs[j]; j++) {
95
                        strcpy(n, d->devs[j]);
96
                        ComboBox_AddString(hwnd, buf);
97
                    }
98
                } else {
99
                    ComboBox_AddString(hwnd, buf);
100
                }
101
                d = d->next;
102
            }
103
        }
104
 
105
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
106
 
214 terminx 107
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED));
108
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
194 terminx 109
    }
110
 
219 terminx 111
    if (pgs & POPULATE_GAME) {
214 terminx 112
        struct grpfile *fg;
113
        int i, j;
114
        char buf[128+BMAX_PATH];
194 terminx 115
 
214 terminx 116
        hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA);
194 terminx 117
 
214 terminx 118
        for (fg = foundgrps; fg; fg=fg->next) {
119
            for (i = 0; i<numgrpfiles; i++)
120
                if (fg->crcval == grpfiles[i].crcval) break;
121
            if (i == numgrpfiles) continue;     // unrecognised grp file
122
 
123
            Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name);
124
            j = ListBox_AddString(hwnd, buf);
125
            ListBox_SetItemData(hwnd, j, (LPARAM)fg);
126
            if (!Bstrcasecmp(fg->name, settings.selectedgrp)) ListBox_SetCurSel(hwnd, j);
127
        }
194 terminx 128
    }
129
}
130
 
131
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
132
{
133
    switch (uMsg) {
134
    case WM_COMMAND:
135
        switch (LOWORD(wParam)) {
136
        case IDCFULLSCREEN:
137
            settings.fullscreen = !settings.fullscreen;
219 terminx 138
            PopulateForm(POPULATE_VIDEO);
194 terminx 139
            return TRUE;
140
        case IDCVMODE:
141
            if (HIWORD(wParam) == CBN_SELCHANGE) {
142
                int i;
143
                i = ComboBox_GetCurSel((HWND)lParam);
144
                if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
145
                if (i != CB_ERR) {
146
                    settings.xdim = validmode[i].xdim;
147
                    settings.ydim = validmode[i].ydim;
148
                    settings.bpp  = validmode[i].bpp;
149
                }
150
            }
151
            return TRUE;
152
        case IDCALWAYSSHOW:
153
            settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
154
            return TRUE;
155
        case IDCINPUTMOUSE:
156
            settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
157
            return TRUE;
158
        case IDCINPUTJOY:
159
            settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
160
            return TRUE;
161
        default: break;
162
        }
163
        break;
164
    default: break;
165
    }
166
    return FALSE;
167
}
168
 
214 terminx 169
static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
170
{
171
    switch (uMsg) {
172
    case WM_COMMAND:
173
        switch (LOWORD(wParam)) {
174
        case IDGDATA: {
175
                int i;
176
                i = ListBox_GetCurSel((HWND)lParam);
177
                if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
178
                if (i != CB_ERR) strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
179
                return TRUE;
180
            }
181
        default: break;
182
        }
183
        break;
184
    default: break;
185
    }
186
    return FALSE;
187
}
194 terminx 188
 
189
 
214 terminx 190
 
194 terminx 191
static void SetPage(int n)
192
{
193
    HWND tab;
194
    int cur;
195
    tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
196
    cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
197
    ShowWindow(pages[cur],SW_HIDE);
198
    SendMessage(tab, TCM_SETCURSEL, n, 0);
199
    ShowWindow(pages[n],SW_SHOW);
197 terminx 200
    mode = n;
196 terminx 201
 
202
    SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
194 terminx 203
}
204
 
205
static void EnableConfig(int n)
206
{
197 terminx 207
    //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
194 terminx 208
    EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
209
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
210
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
211
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n);
212
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n);
214 terminx 213
 
214
    EnableWindow(GetDlgItem(pages[TAB_GAME], IDGDATA), n);
194 terminx 215
}
216
 
217
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
218
{
219
    static HBITMAP hbmp = NULL;
220
    HDC hdc;
221
 
222
    switch (uMsg) {
223
    case WM_INITDIALOG: {
224
            HWND hwnd;
225
            RECT r, rdlg, chrome, rtab, rcancel, rstart;
226
            int xoffset = 0, yoffset = 0;
227
 
228
            // Fetch the positions (in screen coordinates) of all the windows we need to tweak
229
            ZeroMemory(&chrome, sizeof(chrome));
230
            AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
231
            GetWindowRect(hwndDlg, &rdlg);
232
            GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
233
            GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
234
            GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
235
 
236
            // Knock off the non-client area of the main dialogue to give just the client area
237
            rdlg.left -= chrome.left; rdlg.top -= chrome.top;
238
            rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
239
 
240
            // Translate them to client-relative coordinates wrt the main dialogue window
241
            rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
242
            rtab.left  -= rdlg.left; rtab.top -= rdlg.top;
243
 
244
            rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
245
            rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
246
 
247
            rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
248
            rstart.left -= rdlg.left; rstart.top -= rdlg.top;
249
 
250
            // And then convert the main dialogue coordinates to just width/length
251
            rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
252
            rdlg.left = 0; rdlg.top = 0;
253
 
254
            // Load the bitmap into the bitmap control and fetch its dimensions
255
            hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
256
            hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
257
            SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
258
            GetClientRect(hwnd, &r);
259
            xoffset = r.right;
260
            yoffset = r.bottom - rdlg.bottom;
261
 
262
            // Shift and resize the controls that require it
263
            rtab.left += xoffset; rtab.bottom += yoffset;
264
            rcancel.left += xoffset; rcancel.top += yoffset;
265
            rstart.left += xoffset; rstart.top += yoffset;
266
            rdlg.right += xoffset;
267
            rdlg.bottom += yoffset;
268
 
269
            // Move the controls to their new positions
270
            MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
271
            MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
272
            MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
273
 
274
            // Move the main dialogue to the centre of the screen
275
            hdc = GetDC(NULL);
276
            rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
277
            rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
278
            ReleaseDC(NULL, hdc);
279
            MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
280
                       rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
281
 
282
            // Add tabs to the tab control
283
            {
284
                TCITEM tab;
285
 
286
                hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
287
 
288
                ZeroMemory(&tab, sizeof(tab));
289
                tab.mask = TCIF_TEXT;
290
                tab.pszText = TEXT("Configuration");
214 terminx 291
                SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
194 terminx 292
                tab.mask = TCIF_TEXT;
214 terminx 293
                tab.pszText = TEXT("Game");
294
                SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
295
                tab.mask = TCIF_TEXT;
194 terminx 296
                tab.pszText = TEXT("Messages");
214 terminx 297
                SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
194 terminx 298
 
299
                // Work out the position and size of the area inside the tab control for the pages
300
                ZeroMemory(&r, sizeof(r));
301
                GetClientRect(hwnd, &r);
302
                SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
303
                r.right -= r.left-1;
304
                r.bottom -= r.top-1;
305
                r.top += rtab.top;
306
                r.left += rtab.left;
307
 
308
                // Create the pages and position them in the tab control, but hide them
309
                pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
310
                                                 MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
214 terminx 311
                pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(),
312
                                               MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc);
194 terminx 313
                pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
314
                SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
214 terminx 315
                SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
194 terminx 316
                SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
317
 
318
                // Tell the editfield acting as the console to exclude the width of the scrollbar
319
                GetClientRect(pages[TAB_MESSAGES],&r);
320
                r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
321
                r.left = r.top = 0;
322
                SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
323
 
214 terminx 324
                // Set a tab stop in the game data listbox
325
                {
326
                    DWORD tabs[1] = { 150 };
327
                    ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
328
                }
329
 
194 terminx 330
                SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
214 terminx 331
                SetWindowText(hwndDlg, apptitle);
194 terminx 332
            }
333
            return FALSE;
334
        }
335
 
336
    case WM_NOTIFY: {
337
            LPNMHDR nmhdr = (LPNMHDR)lParam;
338
            int cur;
339
            if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
340
            cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
341
            switch (nmhdr->code) {
342
            case TCN_SELCHANGING: {
343
                    if (cur < 0 || !pages[cur]) break;
344
                    ShowWindow(pages[cur],SW_HIDE);
345
                    return TRUE;
346
                }
347
            case TCN_SELCHANGE: {
348
                    if (cur < 0 || !pages[cur]) break;
349
                    ShowWindow(pages[cur],SW_SHOW);
350
                    return TRUE;
351
                }
352
            }
353
            break;
354
        }
355
 
356
    case WM_CLOSE:
214 terminx 357
        if (mode == TAB_CONFIG) done = 0;
358
        else quitevent++;
194 terminx 359
        return TRUE;
360
 
361
    case WM_DESTROY:
362
        if (hbmp) {
363
            DeleteObject(hbmp);
364
            hbmp = NULL;
365
        }
366
 
214 terminx 367
        if (pages[TAB_GAME]) {
368
            DestroyWindow(pages[TAB_GAME]);
369
            pages[TAB_GAME] = NULL;
370
        }
371
 
194 terminx 372
        if (pages[TAB_CONFIG]) {
373
            DestroyWindow(pages[TAB_CONFIG]);
374
            pages[TAB_CONFIG] = NULL;
375
        }
376
 
377
        startupdlg = NULL;
378
        return TRUE;
379
 
380
    case WM_COMMAND:
381
        switch (LOWORD(wParam)) {
214 terminx 382
        case WIN_STARTWIN_CANCEL:
383
            if (mode == TAB_CONFIG) done = 0;
384
            else quitevent++;
385
            return TRUE;
194 terminx 386
        case WIN_STARTWIN_START: done = 1; return TRUE;
387
        }
388
        return FALSE;
389
 
390
    case WM_CTLCOLORSTATIC:
391
        if ((HWND)lParam == pages[TAB_MESSAGES])
392
            return (BOOL)GetSysColorBrush(COLOR_WINDOW);
393
        break;
394
 
395
    default: break;
396
    }
397
 
398
    return FALSE;
399
}
400
 
401
 
402
int startwin_open(void)
403
{
404
    INITCOMMONCONTROLSEX icc;
405
    if (startupdlg) return 1;
406
    icc.dwSize = sizeof(icc);
407
    icc.dwICC = ICC_TAB_CLASSES;
408
    InitCommonControlsEx(&icc);
409
    startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
410
    if (startupdlg) {
411
        SetPage(TAB_MESSAGES);
412
        EnableConfig(0);
413
        return 0;
414
    }
415
    return -1;
416
}
417
 
418
int startwin_close(void)
419
{
420
    if (!startupdlg) return 1;
421
    DestroyWindow(startupdlg);
422
    startupdlg = NULL;
423
    return 0;
424
}
425
 
426
int startwin_puts(const char *buf)
427
{
428
    const char *p = NULL, *q = NULL;
429
    char workbuf[1024];
430
    static int newline = 0;
431
    int curlen, linesbefore, linesafter;
432
    HWND edctl;
433
    int vis;
434
 
435
    if (!startupdlg) return 1;
436
 
437
    edctl = pages[TAB_MESSAGES];
438
    if (!edctl) return -1;
439
 
440
    vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
441
 
442
    if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
443
    curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
444
    SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
445
    linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
446
    p = buf;
447
    while (*p) {
448
        if (newline) {
449
            SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
450
            newline = 0;
451
        }
452
        q = p;
453
        while (*q && *q != '\n') q++;
454
        memcpy(workbuf, p, q-p);
455
        if (*q == '\n') {
456
            if (!q[1]) {
457
                newline = 1;
458
                workbuf[q-p] = 0;
459
            } else {
460
                workbuf[q-p] = '\r';
461
                workbuf[q-p+1] = '\n';
462
                workbuf[q-p+2] = 0;
463
            }
464
            p = q+1;
465
        } else {
466
            workbuf[q-p] = 0;
467
            p = q;
468
        }
469
        SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
470
    }
471
    linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
472
    SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
473
    if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
474
    return 0;
475
}
476
 
477
int startwin_settitle(const char *str)
478
{
479
    if (!startupdlg) return 1;
480
    SetWindowText(startupdlg, str);
481
    return 0;
482
}
483
 
484
int startwin_idle(void *v)
485
{
486
    if (!startupdlg || !IsWindow(startupdlg)) return 0;
487
    if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
488
    return 0;
489
}
490
 
214 terminx 491
extern char *duke3dgrp;
492
 
194 terminx 493
int startwin_run(void)
494
{
495
    MSG msg;
496
    if (!startupdlg) return 1;
497
 
498
    done = -1;
499
 
214 terminx 500
    ScanGroups();
219 terminx 501
#ifdef JFAUD
502
    EnumAudioDevs(&wavedevs, NULL, NULL);
503
#endif
194 terminx 504
    SetPage(TAB_CONFIG);
505
    EnableConfig(1);
506
 
507
    settings.fullscreen = ScreenMode;
508
    settings.xdim = ScreenWidth;
509
    settings.ydim = ScreenHeight;
510
    settings.bpp = ScreenBPP;
511
    settings.forcesetup = ForceSetup;
512
    settings.usemouse = UseMouse;
513
    settings.usejoy = UseJoystick;
214 terminx 514
    strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
515
    PopulateForm(-1);
194 terminx 516
 
517
    while (done < 0) {
518
        switch (GetMessage(&msg, NULL, 0,0)) {
519
        case 0: done = 1; break;
520
        case -1: return -1;
521
        default:
522
            if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
523
            TranslateMessage(&msg);
524
            DispatchMessage(&msg);
525
            break;
526
        }
527
    }
528
 
529
    SetPage(TAB_MESSAGES);
530
    EnableConfig(0);
531
    if (done) {
532
        ScreenMode = settings.fullscreen;
533
        ScreenWidth = settings.xdim;
534
        ScreenHeight = settings.ydim;
535
        ScreenBPP = settings.bpp;
536
        ForceSetup = settings.forcesetup;
537
        UseMouse = settings.usemouse;
538
        UseJoystick = settings.usejoy;
214 terminx 539
        duke3dgrp = settings.selectedgrp;
194 terminx 540
    }
541
 
219 terminx 542
#ifdef JFAUD
543
    if (wavedevs) {
544
        struct audioenumdev *d, *e;
545
        free(wavedevs->drvs);
546
        for (e=wavedevs->devs; e; e=d) {
547
            d = e->next;
548
            if (e->devs) free(e->devs);
549
            free(e);
550
        }
551
        free(wavedevs);
552
    }
553
#endif
554
 
194 terminx 555
    return done;
556
}
557