Subversion Repositories eduke32

Compare Revisions

Regard whitespace Rev 334 → Rev 335

/polymer/eduke32/source/startwin.game.c
26,7 → 26,8
 
static struct audioenumdrv *wavedevs = NULL;
 
static struct {
static struct
{
int fullscreen;
int xdim, ydim, bpp;
int forcesetup;
33,10 → 34,14
int usemouse, usejoy;
char selectedgrp[BMAX_PATH+1];
int game;
} settings;
}
settings;
 
static HWND startupdlg = NULL;
static HWND pages[3] = { NULL, NULL, NULL };
static HWND pages[3] =
{
NULL, NULL, NULL
};
static int done = -1, mode = TAB_CONFIG;
 
#define POPULATE_VIDEO 1
49,16 → 54,23
char buf[256];
int i,j;
 
if (pgs & POPULATE_VIDEO) {
if (pgs & POPULATE_VIDEO)
{
int mode;
 
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
 
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 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp) i++; else break; }
for (; cd[i]; i++) {
for (i=0; cd[i];)
{
if (cd[i] >= settings.bpp) i++;
else break;
}
for (; cd[i]; i++)
{
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
if (mode < 0) continue;
settings.bpp = cd[i];
68,7 → 80,8
 
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) {
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
 
// all modes get added to the 3D mode list
79,24 → 92,31
}
}
 
if (pgs & POPULATE_CONFIG) {
if (pgs & POPULATE_CONFIG)
{
struct audioenumdev *d;
char *n;
 
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
ComboBox_ResetContent(hwnd);
if (wavedevs) {
if (wavedevs)
{
d = wavedevs->devs;
for (i=0; wavedevs->drvs[i]; i++) {
for (i=0; wavedevs->drvs[i]; i++)
{
strcpy(buf, wavedevs->drvs[i]);
if (d->devs) {
if (d->devs)
{
strcat(buf, ":");
n = buf + strlen(buf);
for (j=0; d->devs[j]; j++) {
for (j=0; d->devs[j]; j++)
{
strcpy(n, d->devs[j]);
ComboBox_AddString(hwnd, buf);
}
} else {
}
else
{
ComboBox_AddString(hwnd, buf);
}
d = d->next;
109,7 → 129,8
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
}
 
if (pgs & POPULATE_GAME) {
if (pgs & POPULATE_GAME)
{
struct grpfile *fg;
int i, j;
char buf[128+BMAX_PATH];
116,7 → 137,8
 
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++) if (fg->crcval == grpfiles[i].crcval) break;
if (i == numgrpfiles) continue; // unrecognised grp file
Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name);
129,19 → 151,23
 
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam)) {
switch (LOWORD(wParam))
{
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) {
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) {
if (i != CB_ERR)
{
settings.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp;
169,15 → 195,19
 
static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDGDATA: {
switch (LOWORD(wParam))
{
case IDGDATA:
{
int i;
if (HIWORD(wParam) != LBN_SELCHANGE) break;
i = ListBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) {
if (i != CB_ERR)
{
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
settings.game = ((struct grpfile*)i)->game;
}
226,8 → 256,10
static HBITMAP hbmp = NULL;
HDC hdc;
 
switch (uMsg) {
case WM_INITDIALOG: {
switch (uMsg)
{
case WM_INITDIALOG:
{
HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0;
241,22 → 273,32
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
 
// Knock off the non-client area of the main dialogue to give just the client area
rdlg.left -= chrome.left; rdlg.top -= chrome.top;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
rdlg.left -= chrome.left;
rdlg.top -= chrome.top;
rdlg.right -= chrome.right;
rdlg.bottom -= chrome.bottom;
 
// Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rtab.right -= rtab.left - 1;
rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left;
rtab.top -= rdlg.top;
 
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rcancel.right -= rcancel.left - 1;
rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left;
rcancel.top -= rdlg.top;
 
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
rstart.right -= rstart.left - 1;
rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left;
rstart.top -= rdlg.top;
 
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
rdlg.right -= rdlg.left - 1;
rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0;
rdlg.top = 0;
 
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
267,9 → 309,12
yoffset = r.bottom - rdlg.bottom;
 
// Shift and resize the controls that require it
rtab.left += xoffset; rtab.bottom += yoffset;
rcancel.left += xoffset; rcancel.top += yoffset;
rstart.left += xoffset; rstart.top += yoffset;
rtab.left += xoffset;
rtab.bottom += yoffset;
rcancel.left += xoffset;
rcancel.top += yoffset;
rstart.left += xoffset;
rstart.top += yoffset;
rdlg.right += xoffset;
rdlg.bottom += yoffset;
 
340,18 → 385,22
return FALSE;
}
 
case WM_NOTIFY: {
case WM_NOTIFY:
{
LPNMHDR nmhdr = (LPNMHDR)lParam;
int cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) {
case TCN_SELCHANGING: {
switch (nmhdr->code)
{
case TCN_SELCHANGING:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE: {
case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
366,17 → 415,20
return TRUE;
 
case WM_DESTROY:
if (hbmp) {
if (hbmp)
{
DeleteObject(hbmp);
hbmp = NULL;
}
 
if (pages[TAB_GAME]) {
if (pages[TAB_GAME])
{
DestroyWindow(pages[TAB_GAME]);
pages[TAB_GAME] = NULL;
}
 
if (pages[TAB_CONFIG]) {
if (pages[TAB_CONFIG])
{
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
385,13 → 437,15
return TRUE;
 
case WM_COMMAND:
switch (LOWORD(wParam)) {
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;
done = 1;
return TRUE;
}
return FALSE;
 
416,7 → 470,8
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
if (startupdlg)
{
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
453,8 → 508,10
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
while (*p) {
if (newline) {
while (*p)
{
if (newline)
{
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0;
}
461,17 → 518,23
q = p;
while (*q && *q != '\n') q++;
memcpy(workbuf, p, q-p);
if (*q == '\n') {
if (!q[1]) {
if (*q == '\n')
{
if (!q[1])
{
newline = 1;
workbuf[q-p] = 0;
} else {
}
else
{
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
}
else
{
workbuf[q-p] = 0;
p = q;
}
523,10 → 586,13
strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
PopulateForm(-1);
 
while (done < 0) {
switch (GetMessage(&msg, NULL, 0,0)) {
while (done < 0)
{
switch (GetMessage(&msg, NULL, 0,0))
{
case 0:
done = 1; break;
done = 1;
break;
case -1:
return -1;
default:
539,7 → 605,8
 
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
if (done)
{
ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim;
ScreenHeight = settings.ydim;
551,10 → 618,12
gametype = settings.game;
}
 
if (wavedevs) {
if (wavedevs)
{
struct audioenumdev *d, *e;
free(wavedevs->drvs);
for (e=wavedevs->devs; e; e=d) {
for (e=wavedevs->devs; e; e=d)
{
d = e->next;
if (e->devs) free(e->devs);
free(e);