Subversion Repositories eduke32

Rev

Rev 1188 | Rev 1221 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1188 Rev 1205
Line 28... Line 28...
28
28
29
static struct audioenumdrv *wavedevs = NULL;
29
static struct audioenumdrv *wavedevs = NULL;
30
30
31
static struct
31
static struct
32
{
32
{
33
    int fullscreen;
33
    int32_t fullscreen;
34
    int xdim, ydim, bpp;
34
    int32_t xdim, ydim, bpp;
35
    int forcesetup;
35
    int32_t forcesetup;
36
    int usemouse, usejoy;
36
    int32_t usemouse, usejoy;
37
    char selectedgrp[BMAX_PATH+1];
37
    char selectedgrp[BMAX_PATH+1];
38
    int game;
38
    int32_t game;
39
    int crcval; // for finding the grp in the list again
39
    int32_t crcval; // for finding the grp in the list again
40
    char *gamedir;
40
    char *gamedir;
41
}
41
}
42
settings;
42
settings;
43
43
44
static HWND startupdlg = NULL;
44
static HWND startupdlg = NULL;
45
static HWND pages[3] =
45
static HWND pages[3] =
46
{
46
{
47
    NULL, NULL, NULL
47
    NULL, NULL, NULL
48
};
48
};
49
static int done = -1, mode = TAB_CONFIG;
49
static int32_t done = -1, mode = TAB_CONFIG;
50
50
51
static CACHE1D_FIND_REC *finddirs=NULL;
51
static CACHE1D_FIND_REC *finddirs=NULL;
52
static int numdirs=0;
52
static int32_t numdirs=0;
53
53
54
static void clearfilenames(void)
54
static void clearfilenames(void)
55
{
55
{
56
    klistfree(finddirs);
56
    klistfree(finddirs);
57
    finddirs = NULL;
57
    finddirs = NULL;
58
    numdirs = 0;
58
    numdirs = 0;
59
}
59
}
60
60
61
static int getfilenames(char *path)
61
static int32_t getfilenames(char *path)
62
{
62
{
63
    CACHE1D_FIND_REC *r;
63
    CACHE1D_FIND_REC *r;
64
64
65
    clearfilenames();
65
    clearfilenames();
66
    finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
66
    finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
Line 75... Line 75...
75
75
76
#if defined(POLYMOST)
76
#if defined(POLYMOST)
77
extern char TEXCACHEFILE[];
77
extern char TEXCACHEFILE[];
78
#endif
78
#endif
79
79
80
extern int g_noSetup;
80
extern int32_t g_noSetup;
81
81
82
static void PopulateForm(int pgs)
82
static void PopulateForm(int32_t pgs)
83
{
83
{
84
    HWND hwnd;
84
    HWND hwnd;
85
    char buf[256];
85
    char buf[256];
86
    int i,j;
86
    int32_t i,j;
87
87
88
    if (pgs & POPULATE_VIDEO)
88
    if (pgs & POPULATE_VIDEO)
89
    {
89
    {
90
        int mode;
90
        int32_t mode;
91
91
92
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
92
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
93
93
94
        mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
94
        mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
95
        if (mode < 0)
95
        if (mode < 0)
96
        {
96
        {
97
            int cd[] = { 32, 24, 16, 15, 8, 0 };
97
            int32_t cd[] = { 32, 24, 16, 15, 8, 0 };
98
            for (i=0; cd[i];)
98
            for (i=0; cd[i];)
99
            {
99
            {
100
                if (cd[i] >= settings.bpp) i++;
100
                if (cd[i] >= settings.bpp) i++;
101
                else break;
101
                else break;
102
            }
102
            }
Line 161... Line 161...
161
    }
161
    }
162
162
163
    if (pgs & POPULATE_GAME)
163
    if (pgs & POPULATE_GAME)
164
    {
164
    {
165
        struct grpfile *fg;
165
        struct grpfile *fg;
166
        int i, j;
166
        int32_t i, j;
167
        char buf[128+BMAX_PATH];
167
        char buf[128+BMAX_PATH];
168
168
169
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
169
        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
170
170
171
        for (fg = foundgrps; fg; fg=fg->next)
171
        for (fg = foundgrps; fg; fg=fg->next)
Line 215... Line 215...
215
            PopulateForm(POPULATE_VIDEO);
215
            PopulateForm(POPULATE_VIDEO);
216
            return TRUE;
216
            return TRUE;
217
        case IDCVMODE:
217
        case IDCVMODE:
218
            if (HIWORD(wParam) == CBN_SELCHANGE)
218
            if (HIWORD(wParam) == CBN_SELCHANGE)
219
            {
219
            {
220
                int i;
220
                int32_t i;
221
                i = ComboBox_GetCurSel((HWND)lParam);
221
                i = ComboBox_GetCurSel((HWND)lParam);
222
                if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
222
                if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
223
                if (i != CB_ERR)
223
                if (i != CB_ERR)
224
                {
224
                {
225
                    settings.xdim = validmode[i].xdim;
225
                    settings.xdim = validmode[i].xdim;
Line 238... Line 238...
238
            settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
238
            settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
239
            return TRUE;
239
            return TRUE;
240
        case IDCGAMEDIR:
240
        case IDCGAMEDIR:
241
            if (HIWORD(wParam) == CBN_SELCHANGE)
241
            if (HIWORD(wParam) == CBN_SELCHANGE)
242
            {
242
            {
243
                int i,j;
243
                int32_t i,j;
244
                CACHE1D_FIND_REC *dir = NULL;
244
                CACHE1D_FIND_REC *dir = NULL;
245
                i = ComboBox_GetCurSel((HWND)lParam);
245
                i = ComboBox_GetCurSel((HWND)lParam);
246
                if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
246
                if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
247
                if (i != CB_ERR)
247
                if (i != CB_ERR)
248
                {
248
                {
Line 260... Line 260...
260
                }
260
                }
261
            }
261
            }
262
            return TRUE;
262
            return TRUE;
263
        case IDCDATA:
263
        case IDCDATA:
264
        {
264
        {
265
            int i;
265
            int32_t i;
266
            if (HIWORD(wParam) != LBN_SELCHANGE) break;
266
            if (HIWORD(wParam) != LBN_SELCHANGE) break;
267
            i = ListBox_GetCurSel((HWND)lParam);
267
            i = ListBox_GetCurSel((HWND)lParam);
268
            if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
268
            if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
269
            if (i != CB_ERR)
269
            if (i != CB_ERR)
270
            {
270
            {
Line 283... Line 283...
283
    }
283
    }
284
    return FALSE;
284
    return FALSE;
285
}
285
}
286
286
287
287
288
static void SetPage(int n)
288
static void SetPage(int32_t n)
289
{
289
{
290
    HWND tab;
290
    HWND tab;
291
    int cur;
291
    int32_t cur;
292
    tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
292
    tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
293
    cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
293
    cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0);
294
    ShowWindow(pages[cur],SW_HIDE);
294
    ShowWindow(pages[cur],SW_HIDE);
295
    SendMessage(tab, TCM_SETCURSEL, n, 0);
295
    SendMessage(tab, TCM_SETCURSEL, n, 0);
296
    ShowWindow(pages[n],SW_SHOW);
296
    ShowWindow(pages[n],SW_SHOW);
297
    mode = n;
297
    mode = n;
298
298
299
    SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
299
    SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
300
}
300
}
301
301
302
static void EnableConfig(int n)
302
static void EnableConfig(int32_t n)
303
{
303
{
304
    //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
304
    //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
305
    EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
305
    EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
306
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
306
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
307
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
307
    EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
Line 321... Line 321...
321
    {
321
    {
322
    case WM_INITDIALOG:
322
    case WM_INITDIALOG:
323
    {
323
    {
324
        HWND hwnd;
324
        HWND hwnd;
325
        RECT r, rdlg, chrome, rtab, rcancel, rstart;
325
        RECT r, rdlg, chrome, rtab, rcancel, rstart;
326
        int xoffset = 0, yoffset = 0;
326
        int32_t xoffset = 0, yoffset = 0;
327
327
328
        // Fetch the positions (in screen coordinates) of all the windows we need to tweak
328
        // Fetch the positions (in screen coordinates) of all the windows we need to tweak
329
        ZeroMemory(&chrome, sizeof(chrome));
329
        ZeroMemory(&chrome, sizeof(chrome));
330
        AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
330
        AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
331
        GetWindowRect(hwndDlg, &rdlg);
331
        GetWindowRect(hwndDlg, &rdlg);
Line 441... Line 441...
441
    }
441
    }
442
442
443
    case WM_NOTIFY:
443
    case WM_NOTIFY:
444
    {
444
    {
445
        LPNMHDR nmhdr = (LPNMHDR)lParam;
445
        LPNMHDR nmhdr = (LPNMHDR)lParam;
446
        int cur;
446
        int32_t cur;
447
        if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
447
        if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
448
        cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
448
        cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
449
        switch (nmhdr->code)
449
        switch (nmhdr->code)
450
        {
450
        {
451
        case TCN_SELCHANGING:
451
        case TCN_SELCHANGING:
452
        {
452
        {
453
            if (cur < 0 || !pages[cur]) break;
453
            if (cur < 0 || !pages[cur]) break;
Line 509... Line 509...
509
509
510
    return FALSE;
510
    return FALSE;
511
}
511
}
512
512
513
513
514
int startwin_open(void)
514
int32_t startwin_open(void)
515
{
515
{
516
    INITCOMMONCONTROLSEX icc;
516
    INITCOMMONCONTROLSEX icc;
517
    if (startupdlg) return 1;
517
    if (startupdlg) return 1;
518
    icc.dwSize = sizeof(icc);
518
    icc.dwSize = sizeof(icc);
519
    icc.dwICC = ICC_TAB_CLASSES;
519
    icc.dwICC = ICC_TAB_CLASSES;
Line 526... Line 526...
526
        return 0;
526
        return 0;
527
    }
527
    }
528
    return -1;
528
    return -1;
529
}
529
}
530
530
531
int startwin_close(void)
531
int32_t startwin_close(void)
532
{
532
{
533
    if (!startupdlg) return 1;
533
    if (!startupdlg) return 1;
534
    DestroyWindow(startupdlg);
534
    DestroyWindow(startupdlg);
535
    startupdlg = NULL;
535
    startupdlg = NULL;
536
    return 0;
536
    return 0;
537
}
537
}
538
538
539
int startwin_puts(const char *buf)
539
int32_t startwin_puts(const char *buf)
540
{
540
{
541
    const char *p = NULL, *q = NULL;
541
    const char *p = NULL, *q = NULL;
542
    static char workbuf[1024];
542
    static char workbuf[1024];
543
    static int newline = 0;
543
    static int32_t newline = 0;
544
    int curlen, linesbefore, linesafter;
544
    int32_t curlen, linesbefore, linesafter;
545
    HWND edctl;
545
    HWND edctl;
546
    int vis;
546
    int32_t vis;
547
    static HWND dactrl = NULL;
547
    static HWND dactrl = NULL;
548
548
549
    if (!startupdlg) return 1;
549
    if (!startupdlg) return 1;
550
550
551
    edctl = pages[TAB_MESSAGES];
551
    edctl = pages[TAB_MESSAGES];
552
    if (!edctl) return -1;
552
    if (!edctl) return -1;
553
553
554
    if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
554
    if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
555
555
556
    vis = ((int)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
556
    vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
557
557
558
    if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
558
    if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
559
    curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
559
    curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
560
    SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
560
    SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
561
    linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
561
    linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
Line 596... Line 596...
596
    SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
596
    SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
597
    if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
597
    if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
598
    return 0;
598
    return 0;
599
}
599
}
600
600
601
int startwin_settitle(const char *str)
601
int32_t startwin_settitle(const char *str)
602
{
602
{
603
    if (!startupdlg) return 1;
603
    if (!startupdlg) return 1;
604
    SetWindowText(startupdlg, str);
604
    SetWindowText(startupdlg, str);
605
    return 0;
605
    return 0;
606
}
606
}
607
607
608
int startwin_idle(void *v)
608
int32_t startwin_idle(void *v)
609
{
609
{
610
    if (!startupdlg || !IsWindow(startupdlg)) return 0;
610
    if (!startupdlg || !IsWindow(startupdlg)) return 0;
611
    if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
611
    if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
612
    return 0;
612
    return 0;
613
}
613
}
614
614
615
int startwin_run(void)
615
int32_t startwin_run(void)
616
{
616
{
617
    MSG msg;
617
    MSG msg;
618
    if (!startupdlg) return 1;
618
    if (!startupdlg) return 1;
619
619
620
    done = -1;
620
    done = -1;
Line 657... Line 657...
657
657
658
    SetPage(TAB_MESSAGES);
658
    SetPage(TAB_MESSAGES);
659
    EnableConfig(0);
659
    EnableConfig(0);
660
    if (done)
660
    if (done)
661
    {
661
    {
662
        int i;
662
        int32_t i;
663
663
664
        ud.config.ScreenMode = settings.fullscreen;
664
        ud.config.ScreenMode = settings.fullscreen;
665
        ud.config.ScreenWidth = settings.xdim;
665
        ud.config.ScreenWidth = settings.xdim;
666
        ud.config.ScreenHeight = settings.ydim;
666
        ud.config.ScreenHeight = settings.ydim;
667
        ud.config.ScreenBPP = settings.bpp;
667
        ud.config.ScreenBPP = settings.bpp;