git-svn-id: https://svn.eduke32.com/eduke32@220 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-07-14 07:28:32 +00:00
parent c8589f5b9a
commit f5e728ab22
3 changed files with 422 additions and 415 deletions

View file

@ -42,6 +42,7 @@ OURCXXFLAGS=-fno-exceptions -fno-rtti
LIBS=-lm LIBS=-lm
ifneq (0,$(JFAUD)) ifneq (0,$(JFAUD))
JFAUDLIBS=../jfaud/libjfaud.a ../jfaud/mpadec/libmpadec.a JFAUDLIBS=../jfaud/libjfaud.a ../jfaud/mpadec/libmpadec.a
OURCFLAGS+=-DJFAUD
endif endif
NASMFLAGS=-s #-g NASMFLAGS=-s #-g
@ -206,10 +207,15 @@ $(OBJ)%.$o: $(SRC)jmact/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(OBJ)%.$o: $(SRC)jaudiolib/%.c $(OBJ)%.$o: $(SRC)jaudiolib/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
ifeq (1,$(JFAUD))
$(OBJ)%.$o: $(SRC)misc/%.rc
windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC) -DJFAUD
else
$(OBJ)%.$o: $(SRC)misc/%.rc $(OBJ)%.$o: $(SRC)misc/%.rc
windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC) windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC)
endif
$(OBJ)%.$o: $(SRC)util/%.c $(OBJ)%.$o: $(SRC)util/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1

View file

@ -19,7 +19,6 @@ BEGIN
CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32 CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32
END END
WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168 WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog" CAPTION "Dialog"
@ -29,8 +28,13 @@ BEGIN
CONTROL "", IDCVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56 CONTROL "", IDCVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56
CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10 CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10
#ifdef JFAUD
CONTROL "S&ound driver:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 28, 50, 8
CONTROL "", IDCSOUNDDRV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 26, 110, 56
#else
CONTROL "S&ound driver:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_DISABLED | WS_VISIBLE, 5, 28, 50, 8 CONTROL "S&ound driver:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_DISABLED | WS_VISIBLE, 5, 28, 50, 8
CONTROL "", IDCSOUNDDRV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_DISABLED | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 26, 110, 56 CONTROL "", IDCSOUNDDRV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_DISABLED | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 26, 110, 56
#endif
CONTROL "&MIDI device:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_DISABLED | WS_VISIBLE, 5, 44, 50, 8 CONTROL "&MIDI device:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_DISABLED | WS_VISIBLE, 5, 44, 50, 8
CONTROL "", IDCMIDIDEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_DISABLED | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 42, 110, 56 CONTROL "", IDCMIDIDEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_DISABLED | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 42, 110, 56
@ -40,7 +44,6 @@ BEGIN
CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8 CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8
END END
WIN_STARTWINPAGE_GAME DIALOGEX DISCARDABLE 20, 40, 279, 168 WIN_STARTWINPAGE_GAME DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog" CAPTION "Dialog"

View file

@ -27,11 +27,11 @@
static struct audioenumdrv *wavedevs = NULL; static struct audioenumdrv *wavedevs = NULL;
static struct { static struct {
int fullscreen; int fullscreen;
int xdim, ydim, bpp; int xdim, ydim, bpp;
int forcesetup; int forcesetup;
int usemouse, usejoy; int usemouse, usejoy;
char selectedgrp[BMAX_PATH+1]; char selectedgrp[BMAX_PATH+1];
} settings; } settings;
static HWND startupdlg = NULL; static HWND startupdlg = NULL;
@ -44,514 +44,512 @@ static int done = -1, mode = TAB_CONFIG;
static void PopulateForm(int pgs) static void PopulateForm(int pgs)
{ {
HWND hwnd; HWND hwnd;
char buf[256]; char buf[256];
int i,j; int i,j;
if (pgs & POPULATE_VIDEO) { if (pgs & POPULATE_VIDEO) {
int mode; int mode;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1); mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
if (mode < 0) { if (mode < 0) {
int cd[] = { 32, 24, 16, 15, 8, 0 }; int cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; } for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; }
for ( ; cd[i]; i++) { for ( ; cd[i]; i++) {
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
if (mode < 0) continue; if (mode < 0) continue;
settings.bpp = cd[i]; settings.bpp = cd[i];
break; break;
} }
} }
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd); ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) { for (i=0; i<validmodecnt; i++) {
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
j = ComboBox_AddString(hwnd, buf); j = ComboBox_AddString(hwnd, buf);
ComboBox_SetItemData(hwnd, j, i); ComboBox_SetItemData(hwnd, j, i);
if (i == mode) ComboBox_SetCurSel(hwnd, j); if (i == mode) ComboBox_SetCurSel(hwnd, j);
} }
} }
if (pgs & POPULATE_CONFIG) { if (pgs & POPULATE_CONFIG) {
struct audioenumdev *d; struct audioenumdev *d;
char *n; char *n;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV); hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
ComboBox_ResetContent(hwnd); ComboBox_ResetContent(hwnd);
if (wavedevs) { if (wavedevs) {
d = wavedevs->devs; d = wavedevs->devs;
for (i=0; wavedevs->drvs[i]; i++) { for (i=0; wavedevs->drvs[i]; i++) {
strcpy(buf, wavedevs->drvs[i]); strcpy(buf, wavedevs->drvs[i]);
if (d->devs) { if (d->devs) {
strcat(buf, ":"); strcat(buf, ":");
n = buf + strlen(buf); n = buf + strlen(buf);
for (j=0; d->devs[j]; j++) { for (j=0; d->devs[j]; j++) {
strcpy(n, d->devs[j]); strcpy(n, d->devs[j]);
ComboBox_AddString(hwnd, buf); ComboBox_AddString(hwnd, buf);
} }
} else { } else {
ComboBox_AddString(hwnd, buf); ComboBox_AddString(hwnd, buf);
} }
d = d->next; d = d->next;
} }
} }
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
} }
if (pgs & POPULATE_GAME) { if (pgs & POPULATE_GAME) {
struct grpfile *fg; struct grpfile *fg;
int i, j; int i, j;
char buf[128+BMAX_PATH]; char buf[128+BMAX_PATH];
hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA); hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA);
for (fg = foundgrps; fg; fg=fg->next) { for (fg = foundgrps; fg; fg=fg->next) {
for (i = 0; i<numgrpfiles; i++) for (i = 0; i<numgrpfiles; i++)
if (fg->crcval == grpfiles[i].crcval) break; if (fg->crcval == grpfiles[i].crcval) break;
if (i == numgrpfiles) continue; // unrecognised grp file if (i == numgrpfiles) continue; // unrecognised grp file
Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name); Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name);
j = ListBox_AddString(hwnd, buf); j = ListBox_AddString(hwnd, buf);
ListBox_SetItemData(hwnd, j, (LPARAM)fg); ListBox_SetItemData(hwnd, j, (LPARAM)fg);
if (!Bstrcasecmp(fg->name, settings.selectedgrp)) ListBox_SetCurSel(hwnd, j); if (!Bstrcasecmp(fg->name, settings.selectedgrp)) ListBox_SetCurSel(hwnd, j);
} }
} }
} }
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg) {
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case IDCFULLSCREEN: case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen; settings.fullscreen = !settings.fullscreen;
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
return TRUE; return TRUE;
case IDCVMODE: case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) { if (HIWORD(wParam) == CBN_SELCHANGE) {
int i; int i;
i = ComboBox_GetCurSel((HWND)lParam); i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) { if (i != CB_ERR) {
settings.xdim = validmode[i].xdim; settings.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim; settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp; settings.bpp = validmode[i].bpp;
} }
} }
return TRUE; return TRUE;
case IDCALWAYSSHOW: case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE; return TRUE;
case IDCINPUTMOUSE: case IDCINPUTMOUSE:
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED; settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
return TRUE; return TRUE;
case IDCINPUTJOY: case IDCINPUTJOY:
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED; settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
return TRUE; return TRUE;
default: break; default: break;
} }
break; break;
default: break; default: break;
} }
return FALSE; return FALSE;
} }
static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg) {
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case IDGDATA: { case IDGDATA: {
int i; int i;
i = ListBox_GetCurSel((HWND)lParam); i = ListBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); if (i != CB_ERR) strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
return TRUE; return TRUE;
} }
default: break; default: break;
} }
break; break;
default: break; default: break;
} }
return FALSE; return FALSE;
} }
static void SetPage(int n) static void SetPage(int n)
{ {
HWND tab; HWND tab;
int cur; int cur;
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0); cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
ShowWindow(pages[cur],SW_HIDE); ShowWindow(pages[cur],SW_HIDE);
SendMessage(tab, TCM_SETCURSEL, n, 0); SendMessage(tab, TCM_SETCURSEL, n, 0);
ShowWindow(pages[n],SW_SHOW); ShowWindow(pages[n],SW_SHOW);
mode = n; mode = n;
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
} }
static void EnableConfig(int n) static void EnableConfig(int n)
{ {
//EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n);
EnableWindow(GetDlgItem(pages[TAB_GAME], IDGDATA), n); EnableWindow(GetDlgItem(pages[TAB_GAME], IDGDATA), n);
} }
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static HBITMAP hbmp = NULL; static HBITMAP hbmp = NULL;
HDC hdc; HDC hdc;
switch (uMsg) {
case WM_INITDIALOG: {
HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0;
switch (uMsg) { // Fetch the positions (in screen coordinates) of all the windows we need to tweak
case WM_INITDIALOG: { ZeroMemory(&chrome, sizeof(chrome));
HWND hwnd; AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
RECT r, rdlg, chrome, rtab, rcancel, rstart; GetWindowRect(hwndDlg, &rdlg);
int xoffset = 0, yoffset = 0; GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Fetch the positions (in screen coordinates) of all the windows we need to tweak // Knock off the non-client area of the main dialogue to give just the client area
ZeroMemory(&chrome, sizeof(chrome)); rdlg.left -= chrome.left; rdlg.top -= chrome.top;
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Knock off the non-client area of the main dialogue to give just the client area // Translate them to client-relative coordinates wrt the main dialogue window
rdlg.left -= chrome.left; rdlg.top -= chrome.top; rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom; rtab.left -= rdlg.left; rtab.top -= rdlg.top;
// Translate them to client-relative coordinates wrt the main dialogue window rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1; rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1; rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top; rstart.left -= rdlg.left; rstart.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1; // And then convert the main dialogue coordinates to just width/length
rstart.left -= rdlg.left; rstart.top -= rdlg.top; rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
// And then convert the main dialogue coordinates to just width/length // Load the bitmap into the bitmap control and fetch its dimensions
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1; hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
rdlg.left = 0; rdlg.top = 0; hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
GetClientRect(hwnd, &r);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
// Load the bitmap into the bitmap control and fetch its dimensions // Shift and resize the controls that require it
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); rtab.left += xoffset; rtab.bottom += yoffset;
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); rcancel.left += xoffset; rcancel.top += yoffset;
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); rstart.left += xoffset; rstart.top += yoffset;
GetClientRect(hwnd, &r); rdlg.right += xoffset;
xoffset = r.right; rdlg.bottom += yoffset;
yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it // Move the controls to their new positions
rtab.left += xoffset; rtab.bottom += yoffset; MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
rcancel.left += xoffset; rcancel.top += yoffset; MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
rstart.left += xoffset; rstart.top += yoffset; MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
rdlg.right += xoffset;
rdlg.bottom += yoffset;
// Move the controls to their new positions // Move the main dialogue to the centre of the screen
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); hdc = GetDC(NULL);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Move the main dialogue to the centre of the screen // Add tabs to the tab control
hdc = GetDC(NULL); {
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; TCITEM tab;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc); hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control ZeroMemory(&tab, sizeof(tab));
{ tab.mask = TCIF_TEXT;
TCITEM tab; tab.pszText = TEXT("Configuration");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Game");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); // Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r);
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
r.right -= r.left-1;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
ZeroMemory(&tab, sizeof(tab)); // Create the pages and position them in the tab control, but hide them
tab.mask = TCIF_TEXT; pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
tab.pszText = TEXT("Configuration"); MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(),
tab.mask = TCIF_TEXT; MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc);
tab.pszText = TEXT("Game"); pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
tab.mask = TCIF_TEXT; SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
tab.pszText = TEXT("Messages"); SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages // Tell the editfield acting as the console to exclude the width of the scrollbar
ZeroMemory(&r, sizeof(r)); GetClientRect(pages[TAB_MESSAGES],&r);
GetClientRect(hwnd, &r); r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); r.left = r.top = 0;
r.right -= r.left-1; SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// Create the pages and position them in the tab control, but hide them // Set a tab stop in the game data listbox
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), {
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); DWORD tabs[1] = { 150 };
pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); }
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
// Tell the editfield acting as the console to exclude the width of the scrollbar SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
GetClientRect(pages[TAB_MESSAGES],&r); SetWindowText(hwndDlg, apptitle);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; }
r.left = r.top = 0; return FALSE;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); }
// Set a tab stop in the game data listbox case WM_NOTIFY: {
{ LPNMHDR nmhdr = (LPNMHDR)lParam;
DWORD tabs[1] = { 150 }; int cur;
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs); if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
} cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) {
case TCN_SELCHANGING: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
}
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); case WM_CLOSE:
SetWindowText(hwndDlg, apptitle); if (mode == TAB_CONFIG) done = 0;
} else quitevent++;
return FALSE; return TRUE;
}
case WM_NOTIFY: { case WM_DESTROY:
LPNMHDR nmhdr = (LPNMHDR)lParam; if (hbmp) {
int cur; DeleteObject(hbmp);
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; hbmp = NULL;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); }
switch (nmhdr->code) {
case TCN_SELCHANGING: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
}
case WM_CLOSE: if (pages[TAB_GAME]) {
if (mode == TAB_CONFIG) done = 0; DestroyWindow(pages[TAB_GAME]);
else quitevent++; pages[TAB_GAME] = NULL;
return TRUE; }
case WM_DESTROY: if (pages[TAB_CONFIG]) {
if (hbmp) { DestroyWindow(pages[TAB_CONFIG]);
DeleteObject(hbmp); pages[TAB_CONFIG] = NULL;
hbmp = NULL; }
}
if (pages[TAB_GAME]) { startupdlg = NULL;
DestroyWindow(pages[TAB_GAME]); return TRUE;
pages[TAB_GAME] = NULL;
}
if (pages[TAB_CONFIG]) { case WM_COMMAND:
DestroyWindow(pages[TAB_CONFIG]); switch (LOWORD(wParam)) {
pages[TAB_CONFIG] = NULL; case WIN_STARTWIN_CANCEL:
} if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WIN_STARTWIN_START: done = 1; return TRUE;
}
return FALSE;
startupdlg = NULL; case WM_CTLCOLORSTATIC:
return TRUE; if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
break;
case WM_COMMAND: default: break;
switch (LOWORD(wParam)) { }
case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WIN_STARTWIN_START: done = 1; return TRUE;
}
return FALSE;
case WM_CTLCOLORSTATIC: return FALSE;
if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
break;
default: break;
}
return FALSE;
} }
int startwin_open(void) int startwin_open(void)
{ {
INITCOMMONCONTROLSEX icc; INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1; if (startupdlg) return 1;
icc.dwSize = sizeof(icc); icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TAB_CLASSES; icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc); InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) { if (startupdlg) {
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
return 0; return 0;
} }
return -1; return -1;
} }
int startwin_close(void) int startwin_close(void)
{ {
if (!startupdlg) return 1; if (!startupdlg) return 1;
DestroyWindow(startupdlg); DestroyWindow(startupdlg);
startupdlg = NULL; startupdlg = NULL;
return 0; return 0;
} }
int startwin_puts(const char *buf) int startwin_puts(const char *buf)
{ {
const char *p = NULL, *q = NULL; const char *p = NULL, *q = NULL;
char workbuf[1024]; char workbuf[1024];
static int newline = 0; static int newline = 0;
int curlen, linesbefore, linesafter; int curlen, linesbefore, linesafter;
HWND edctl; HWND edctl;
int vis; int vis;
if (!startupdlg) return 1; if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES];
if (!edctl) return -1;
edctl = pages[TAB_MESSAGES]; vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (!edctl) return -1;
vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES); if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); p = buf;
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); while (*p) {
p = buf; if (newline) {
while (*p) { SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
if (newline) { newline = 0;
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); }
newline = 0; q = p;
} while (*q && *q != '\n') q++;
q = p; memcpy(workbuf, p, q-p);
while (*q && *q != '\n') q++; if (*q == '\n') {
memcpy(workbuf, p, q-p); if (!q[1]) {
if (*q == '\n') { newline = 1;
if (!q[1]) { workbuf[q-p] = 0;
newline = 1; } else {
workbuf[q-p] = 0; workbuf[q-p] = '\r';
} else { workbuf[q-p+1] = '\n';
workbuf[q-p] = '\r'; workbuf[q-p+2] = 0;
workbuf[q-p+1] = '\n'; }
workbuf[q-p+2] = 0; p = q+1;
} } else {
p = q+1; workbuf[q-p] = 0;
} else { p = q;
workbuf[q-p] = 0; }
p = q; SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
} }
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
} SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); return 0;
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
return 0;
} }
int startwin_settitle(const char *str) int startwin_settitle(const char *str)
{ {
if (!startupdlg) return 1; if (!startupdlg) return 1;
SetWindowText(startupdlg, str); SetWindowText(startupdlg, str);
return 0; return 0;
} }
int startwin_idle(void *v) int startwin_idle(void *v)
{ {
if (!startupdlg || !IsWindow(startupdlg)) return 0; if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
return 0; return 0;
} }
extern char *duke3dgrp; extern char *duke3dgrp;
int startwin_run(void) int startwin_run(void)
{ {
MSG msg; MSG msg;
if (!startupdlg) return 1; if (!startupdlg) return 1;
done = -1; done = -1;
ScanGroups(); ScanGroups();
#ifdef JFAUD #ifdef JFAUD
EnumAudioDevs(&wavedevs, NULL, NULL); EnumAudioDevs(&wavedevs, NULL, NULL);
#endif #endif
SetPage(TAB_CONFIG); SetPage(TAB_CONFIG);
EnableConfig(1); EnableConfig(1);
settings.fullscreen = ScreenMode; settings.fullscreen = ScreenMode;
settings.xdim = ScreenWidth; settings.xdim = ScreenWidth;
settings.ydim = ScreenHeight; settings.ydim = ScreenHeight;
settings.bpp = ScreenBPP; settings.bpp = ScreenBPP;
settings.forcesetup = ForceSetup; settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse; settings.usemouse = UseMouse;
settings.usejoy = UseJoystick; settings.usejoy = UseJoystick;
strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
PopulateForm(-1); PopulateForm(-1);
while (done < 0) { while (done < 0) {
switch (GetMessage(&msg, NULL, 0,0)) { switch (GetMessage(&msg, NULL, 0,0)) {
case 0: done = 1; break; case 0: done = 1; break;
case -1: return -1; case -1: return -1;
default: default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
break; break;
} }
} }
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
if (done) { if (done) {
ScreenMode = settings.fullscreen; ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim; ScreenWidth = settings.xdim;
ScreenHeight = settings.ydim; ScreenHeight = settings.ydim;
ScreenBPP = settings.bpp; ScreenBPP = settings.bpp;
ForceSetup = settings.forcesetup; ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse; UseMouse = settings.usemouse;
UseJoystick = settings.usejoy; UseJoystick = settings.usejoy;
duke3dgrp = settings.selectedgrp; duke3dgrp = settings.selectedgrp;
} }
#ifdef JFAUD if (wavedevs) {
if (wavedevs) { struct audioenumdev *d, *e;
struct audioenumdev *d, *e; free(wavedevs->drvs);
free(wavedevs->drvs); for (e=wavedevs->devs; e; e=d) {
for (e=wavedevs->devs; e; e=d) { d = e->next;
d = e->next; if (e->devs) free(e->devs);
if (e->devs) free(e->devs); free(e);
free(e); }
} free(wavedevs);
free(wavedevs); }
}
#endif
return done; return done;
} }