2010-05-25 10:56:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2012-11-24 09:13:29 +00:00
|
|
|
#ifndef _WIN32
|
2006-07-01 01:40:18 +00:00
|
|
|
#error Only for Windows
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "duke3d.h"
|
2006-07-13 23:13:06 +00:00
|
|
|
#include "sounds.h"
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "winlayer.h"
|
|
|
|
#include "compat.h"
|
|
|
|
|
2006-07-22 05:20:25 +00:00
|
|
|
#include "grpscan.h"
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
2008-11-05 11:49:13 +00:00
|
|
|
#ifndef _WIN32_IE
|
2006-07-01 01:40:18 +00:00
|
|
|
#define _WIN32_IE 0x0300
|
2008-11-05 11:49:13 +00:00
|
|
|
#endif
|
2006-07-01 01:40:18 +00:00
|
|
|
#include <commctrl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "startwin.game.h"
|
|
|
|
|
2012-03-28 19:44:33 +00:00
|
|
|
#include "game.h"
|
|
|
|
#include "common.h"
|
2012-06-03 16:09:33 +00:00
|
|
|
#include "common_game.h"
|
2012-03-28 19:44:33 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#define TAB_CONFIG 0
|
2008-08-19 13:26:56 +00:00
|
|
|
// #define TAB_GAME 1
|
|
|
|
#define TAB_MESSAGES 1
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2006-07-13 23:13:06 +00:00
|
|
|
static struct audioenumdrv *wavedevs = NULL;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
static struct
|
|
|
|
{
|
2009-04-14 22:55:32 +00:00
|
|
|
int32_t flags; // bitfield
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t xdim, ydim, bpp;
|
|
|
|
int32_t forcesetup;
|
|
|
|
int32_t usemouse, usejoy;
|
|
|
|
int32_t game;
|
|
|
|
int32_t crcval; // for finding the grp in the list again
|
2008-08-17 09:01:31 +00:00
|
|
|
char *gamedir;
|
2009-07-12 01:55:34 +00:00
|
|
|
char selectedgrp[BMAX_PATH];
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
settings;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
static HWND startupdlg = NULL;
|
2006-11-15 01:16:55 +00:00
|
|
|
static HWND pages[3] =
|
2007-08-25 01:05:00 +00:00
|
|
|
{
|
|
|
|
NULL, NULL, NULL
|
|
|
|
};
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t done = -1, mode = TAB_CONFIG;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2008-08-17 09:01:31 +00:00
|
|
|
static CACHE1D_FIND_REC *finddirs=NULL;
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t numdirs=0;
|
2008-08-17 09:01:31 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
static inline void clearfilenames(void)
|
2008-08-17 09:01:31 +00:00
|
|
|
{
|
|
|
|
klistfree(finddirs);
|
|
|
|
finddirs = NULL;
|
|
|
|
numdirs = 0;
|
|
|
|
}
|
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
static inline int32_t getfilenames(char *path)
|
2008-08-17 09:01:31 +00:00
|
|
|
{
|
|
|
|
CACHE1D_FIND_REC *r;
|
|
|
|
|
|
|
|
clearfilenames();
|
|
|
|
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
|
|
|
|
for (r = finddirs; r; r=r->next) numdirs++;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2006-07-13 23:13:06 +00:00
|
|
|
#define POPULATE_VIDEO 1
|
|
|
|
#define POPULATE_CONFIG 2
|
|
|
|
#define POPULATE_GAME 4
|
2008-08-17 09:25:52 +00:00
|
|
|
#define POPULATE_GAMEDIRS 8
|
2006-07-13 23:13:06 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2008-11-26 22:51:56 +00:00
|
|
|
extern char TEXCACHEFILE[];
|
2008-09-12 02:07:44 +00:00
|
|
|
#endif
|
2008-08-17 11:40:27 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t g_noSetup;
|
2008-10-11 11:50:02 +00:00
|
|
|
|
2009-06-05 20:09:13 +00:00
|
|
|
#ifdef INPUT_MOUSE
|
|
|
|
#undef INPUT_MOUSE
|
|
|
|
#endif
|
|
|
|
|
2009-04-15 05:58:38 +00:00
|
|
|
#define INPUT_KB 0
|
|
|
|
#define INPUT_MOUSE 1
|
|
|
|
#define INPUT_JOYSTICK 2
|
|
|
|
#define INPUT_ALL 3
|
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboard and joystick", "All supported devices" };
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void PopulateForm(int32_t pgs)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
HWND hwnd;
|
2009-07-12 01:55:34 +00:00
|
|
|
char buf[512];
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,j;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
if (pgs & POPULATE_GAMEDIRS)
|
|
|
|
{
|
|
|
|
CACHE1D_FIND_REC *dirs = NULL;
|
|
|
|
|
|
|
|
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR);
|
|
|
|
|
|
|
|
getfilenames("/");
|
|
|
|
(void)ComboBox_ResetContent(hwnd);
|
|
|
|
j = ComboBox_AddString(hwnd, "None");
|
|
|
|
(void)ComboBox_SetItemData(hwnd, j, 0);
|
|
|
|
(void)ComboBox_SetCurSel(hwnd, j);
|
|
|
|
for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++)
|
|
|
|
{
|
|
|
|
(void)ComboBox_AddString(hwnd, dirs->name);
|
|
|
|
(void)ComboBox_SetItemData(hwnd, i, i);
|
|
|
|
if (Bstrcasecmp(dirs->name,settings.gamedir) == 0)
|
|
|
|
(void)ComboBox_SetCurSel(hwnd, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (pgs & POPULATE_VIDEO)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mode;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
|
|
|
|
|
2009-04-14 22:55:32 +00:00
|
|
|
mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.flags&1, 1);
|
|
|
|
if (mode < 0 || (settings.bpp < 15 && (settings.flags & 2)))
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t cd[] = { 32, 24, 16, 15, 8, 0 };
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; cd[i];)
|
|
|
|
{
|
|
|
|
if (cd[i] >= settings.bpp) i++;
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
for (; cd[i]; i++)
|
|
|
|
{
|
2009-04-14 22:55:32 +00:00
|
|
|
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.flags&1, 1);
|
2006-07-18 21:08:38 +00:00
|
|
|
if (mode < 0) continue;
|
|
|
|
settings.bpp = cd[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-14 22:55:32 +00:00
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.flags&1) ? BST_CHECKED : BST_UNCHECKED));
|
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.flags&2) ? BST_CHECKED : BST_UNCHECKED));
|
2009-07-12 01:55:34 +00:00
|
|
|
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ComboBox_ResetContent(hwnd);
|
2009-07-12 01:55:34 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; i<validmodecnt; i++)
|
|
|
|
{
|
2009-04-14 22:55:32 +00:00
|
|
|
if (validmode[i].fs != (settings.flags & 1)) continue;
|
|
|
|
if ((validmode[i].bpp < 15) && (settings.flags & 2)) continue;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
// all modes get added to the 3D mode list
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
|
2006-07-18 21:08:38 +00:00
|
|
|
j = ComboBox_AddString(hwnd, buf);
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ComboBox_SetItemData(hwnd, j, i);
|
2008-05-10 01:29:37 +00:00
|
|
|
if (i == mode)(void)ComboBox_SetCurSel(hwnd, j);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (pgs & POPULATE_CONFIG)
|
|
|
|
{
|
2009-07-12 01:55:34 +00:00
|
|
|
#if 0
|
2006-07-18 21:08:38 +00:00
|
|
|
struct audioenumdev *d;
|
|
|
|
char *n;
|
|
|
|
|
|
|
|
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ComboBox_ResetContent(hwnd);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (wavedevs)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
d = wavedevs->devs;
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; wavedevs->drvs[i]; i++)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
strcpy(buf, wavedevs->drvs[i]);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (d->devs)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
strcat(buf, ":");
|
|
|
|
n = buf + strlen(buf);
|
2006-11-15 01:16:55 +00:00
|
|
|
for (j=0; d->devs[j]; j++)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
strcpy(n, d->devs[j]);
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ComboBox_AddString(hwnd, buf);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ComboBox_AddString(hwnd, buf);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
d = d->next;
|
|
|
|
}
|
|
|
|
}
|
2009-07-12 01:55:34 +00:00
|
|
|
#endif
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
|
2009-04-14 22:55:32 +00:00
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.flags & 4) ? BST_CHECKED : BST_UNCHECKED));
|
2009-04-15 05:58:38 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT);
|
|
|
|
|
|
|
|
(void)ComboBox_ResetContent(hwnd);
|
|
|
|
(void)ComboBox_SetCurSel(hwnd, 0);
|
2009-04-15 05:58:38 +00:00
|
|
|
|
2012-11-24 09:13:29 +00:00
|
|
|
j = 4;
|
|
|
|
|
|
|
|
#ifdef RENDERTYPEWIN
|
2010-11-23 22:30:27 +00:00
|
|
|
if (di_disabled) j = 2;
|
2012-11-24 09:13:29 +00:00
|
|
|
#endif
|
2010-11-23 22:30:27 +00:00
|
|
|
|
|
|
|
for (i=0; i<j; i++)
|
2009-07-12 01:55:34 +00:00
|
|
|
{
|
|
|
|
(void)ComboBox_InsertString(hwnd, i, controlstrings[i]);
|
|
|
|
(void)ComboBox_SetItemData(hwnd, i, i);
|
2009-04-15 05:58:38 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
switch (i)
|
2009-04-15 05:58:38 +00:00
|
|
|
{
|
2009-07-12 01:55:34 +00:00
|
|
|
case INPUT_MOUSE:
|
|
|
|
if (settings.usemouse && !settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
|
|
|
|
break;
|
|
|
|
case INPUT_JOYSTICK:
|
|
|
|
if (!settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
|
|
|
|
break;
|
|
|
|
case INPUT_ALL:
|
|
|
|
if (settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
|
|
|
|
break;
|
2009-04-15 05:58:38 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (pgs & POPULATE_GAME)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
struct grpfile *fg;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j;
|
2009-07-09 02:29:48 +00:00
|
|
|
char buf[1024];
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2008-08-19 13:26:56 +00:00
|
|
|
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
for (fg = foundgrps; fg; fg=fg->next)
|
|
|
|
{
|
2012-03-26 22:03:40 +00:00
|
|
|
for (i = 0; i<NUMGRPFILES; i++) if (fg->crcval == grpfiles[i].crcval) break;
|
|
|
|
if (i == NUMGRPFILES) continue; // unrecognised grp file
|
2006-07-18 21:08:38 +00:00
|
|
|
Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name);
|
|
|
|
j = ListBox_AddString(hwnd, buf);
|
2008-03-21 04:01:38 +00:00
|
|
|
(void)ListBox_SetItemData(hwnd, j, (LPARAM)fg);
|
2013-03-28 09:04:54 +00:00
|
|
|
if (!Bstrcasecmp(fg->name, settings.selectedgrp))
|
|
|
|
{
|
|
|
|
(void)ListBox_SetCurSel(hwnd, j);
|
|
|
|
settings.game = fg->game;
|
|
|
|
settings.crcval = fg->crcval;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-11-15 01:16:55 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDCFULLSCREEN:
|
2009-04-14 22:55:32 +00:00
|
|
|
if (settings.flags & 1) settings.flags &= ~1;
|
|
|
|
else settings.flags |= 1;
|
|
|
|
PopulateForm(POPULATE_VIDEO);
|
|
|
|
return TRUE;
|
|
|
|
case IDCPOLYMER:
|
|
|
|
if (settings.flags & 2) settings.flags &= ~2;
|
|
|
|
else settings.flags |= 2;
|
|
|
|
if (settings.bpp == 8) settings.bpp = 32;
|
2006-11-16 03:02:42 +00:00
|
|
|
PopulateForm(POPULATE_VIDEO);
|
|
|
|
return TRUE;
|
|
|
|
case IDCVMODE:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-11-16 03:02:42 +00:00
|
|
|
i = ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
|
|
|
settings.xdim = validmode[i].xdim;
|
|
|
|
settings.ydim = validmode[i].ydim;
|
|
|
|
settings.bpp = validmode[i].bpp;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2006-11-16 03:02:42 +00:00
|
|
|
return TRUE;
|
|
|
|
case IDCALWAYSSHOW:
|
|
|
|
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
|
|
|
|
return TRUE;
|
2009-04-14 22:55:32 +00:00
|
|
|
case IDCAUTOLOAD:
|
2009-04-14 23:34:48 +00:00
|
|
|
if (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) == BST_CHECKED)
|
2009-04-14 22:55:32 +00:00
|
|
|
settings.flags &= ~4;
|
|
|
|
else settings.flags |= 4;
|
|
|
|
return TRUE;
|
2009-04-15 05:58:38 +00:00
|
|
|
case IDCINPUT:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
i = ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
settings.usemouse = settings.usejoy = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
settings.usemouse = 1;
|
|
|
|
settings.usejoy = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
settings.usemouse = 0;
|
|
|
|
settings.usejoy = 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
settings.usemouse = settings.usejoy = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
2008-08-19 13:26:56 +00:00
|
|
|
case IDCGAMEDIR:
|
2008-08-17 09:01:31 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,j;
|
2008-08-17 09:01:31 +00:00
|
|
|
CACHE1D_FIND_REC *dir = NULL;
|
|
|
|
i = ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
2008-09-11 09:24:45 +00:00
|
|
|
if (i==0)
|
|
|
|
settings.gamedir = NULL;
|
|
|
|
else
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=1,dir=finddirs; dir != NULL; dir=dir->next,j++)
|
2008-09-11 09:24:45 +00:00
|
|
|
if (j == i)
|
|
|
|
{
|
|
|
|
settings.gamedir = dir->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-08-17 09:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
2008-08-19 13:26:56 +00:00
|
|
|
case IDCDATA:
|
|
|
|
{
|
Win64 support! (Meaning it works, not that we recommend it for everyday use.)
This includes a complete Windows header and library refresh, including the addition of 64-bit compiled libs:
*libogg 1.3.0
*libvorbis 1.3.3
*zlib 1.2.7
*libpng 1.5.13
*libvpx 9a3de881c0e681ba1a79a166a86308bbc84b4acd
*SDL_mixer 1.2.12 (for RENDERTYPE=SDL)
*DirectX import libraries: dsound and dxguid (now included)
To build in 64-bit, you essentially need MinGW's MSYS (but not MinGW itself) and MinGW-w64 at the top of your PATH. The target is automatically detected using `$(CC) -dumpmachine`. The EDukeWiki will get detailed instrucitons.
All compiler and linker warnings when building in 64-bit mode have been fixed.
Remaining 64-bit to-do:
- The ebacktrace dll does not build under 64-bit. It uses code specific to the format of 32-bit executables and will have to be ported to work with 64-bit executables. A future 64-bit version will be named ebacktrace1-64.dll.
- RENDERTYPE=SDL crashes in SDL_mixer's Mix_Linked_Version().
- DirectInput gives an error and does not function. This only affects joysticks, and the error never happens without any plugged in.
- Port the classic renderer ASM to 64-bit. (Just kidding, this is way out of my league.)
This commit includes a fair bit of Makefile development spanning all platforms, including simplifying the SDLCONFIG code, fixing build on Mac OS X (thanks rhoenie!), globally factoring Apple brew/port inclusion, enforcing that all -L come before all -l, and ensuring that $(shell ) is always :='d.
In addition, I have resurrected the old GCC_MAJOR and GCC_MINOR detection using `$(CC) -dumpversion`, but I have made it failsafe in case the command fails or the version is manually specified. I have applied this new fine-grained detection where applicable, including allowing LTO, and restraining -W's to versions that support them.
git-svn-id: https://svn.eduke32.com/eduke32@3278 1a8010ca-5511-0410-912e-c29ae57300e0
2012-12-13 02:37:20 +00:00
|
|
|
intptr_t i;
|
2008-08-19 13:26:56 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-08-02 08:13:51 +00:00
|
|
|
strcpy(settings.selectedgrp, ((struct grpfile *)i)->name);
|
|
|
|
settings.game = ((struct grpfile *)i)->game;
|
|
|
|
settings.crcval = ((struct grpfile *)i)->crcval;
|
2008-08-19 13:26:56 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2006-07-07 18:41:05 +00:00
|
|
|
}
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void SetPage(int32_t n)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
HWND tab;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t cur;
|
2006-07-18 21:08:38 +00:00
|
|
|
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
|
2009-01-09 09:29:17 +00:00
|
|
|
cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0);
|
2006-07-18 21:08:38 +00:00
|
|
|
ShowWindow(pages[cur],SW_HIDE);
|
|
|
|
SendMessage(tab, TCM_SETCURSEL, n, 0);
|
|
|
|
ShowWindow(pages[n],SW_SHOW);
|
|
|
|
mode = n;
|
|
|
|
|
|
|
|
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void EnableConfig(int32_t n)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
//EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
|
|
|
|
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
|
2009-04-14 22:55:32 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
|
2006-07-18 21:08:38 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
|
2009-04-15 05:58:38 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2008-08-19 13:26:56 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
static HBITMAP hbmp = NULL;
|
|
|
|
HDC hdc;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
RECT r, rdlg, chrome, rtab, rcancel, rstart;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t xoffset = 0, yoffset = 0;
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
|
|
|
ZeroMemory(&chrome, sizeof(chrome));
|
|
|
|
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// Load the bitmap into the bitmap control and fetch its dimensions
|
|
|
|
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
|
|
|
|
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;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
rdlg.right += xoffset;
|
|
|
|
rdlg.bottom += yoffset;
|
|
|
|
|
|
|
|
// Move the controls to their new positions
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
|
|
|
|
|
|
|
|
// Move the main dialogue to the centre of the screen
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Add tabs to the tab control
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
TCITEM tab;
|
|
|
|
|
|
|
|
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
|
|
|
|
|
|
|
|
ZeroMemory(&tab, sizeof(tab));
|
|
|
|
tab.mask = TCIF_TEXT;
|
2008-12-19 00:53:54 +00:00
|
|
|
tab.pszText = TEXT("Setup");
|
2006-11-16 03:02:42 +00:00
|
|
|
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
|
|
|
|
tab.mask = TCIF_TEXT;
|
2008-12-19 00:53:54 +00:00
|
|
|
tab.pszText = TEXT("Message Log");
|
2006-11-16 03:02:42 +00:00
|
|
|
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
|
|
|
|
ZeroMemory(&r, sizeof(r));
|
2006-07-18 21:08:38 +00:00
|
|
|
GetClientRect(hwnd, &r);
|
2006-11-16 03:02:42 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
// Create the pages and position them in the tab control, but hide them
|
|
|
|
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
|
|
|
|
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
|
|
|
|
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_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
|
|
|
|
GetClientRect(pages[TAB_MESSAGES],&r);
|
|
|
|
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
|
|
|
|
r.left = r.top = 0;
|
|
|
|
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
|
|
|
|
|
|
|
|
// Set a tab stop in the game data listbox
|
2006-07-18 21:08:38 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
DWORD tabs[1] = { 150 };
|
2008-08-19 13:26:56 +00:00
|
|
|
(void)ListBox_SetTabStops(GetDlgItem(pages[TAB_CONFIG], IDCDATA), 1, tabs);
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
|
|
|
|
SetWindowText(hwndDlg, apptitle);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2006-11-16 03:02:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR nmhdr = (LPNMHDR)lParam;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t cur;
|
2006-11-16 03:02:42 +00:00
|
|
|
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
|
2009-01-09 09:29:17 +00:00
|
|
|
cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
|
2006-11-16 03:02:42 +00:00
|
|
|
switch (nmhdr->code)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case TCN_SELCHANGING:
|
|
|
|
{
|
|
|
|
if (cur < 0 || !pages[cur]) break;
|
|
|
|
ShowWindow(pages[cur],SW_HIDE);
|
|
|
|
return TRUE;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2006-11-16 03:02:42 +00:00
|
|
|
case TCN_SELCHANGE:
|
|
|
|
{
|
|
|
|
if (cur < 0 || !pages[cur]) break;
|
|
|
|
ShowWindow(pages[cur],SW_SHOW);
|
2006-11-15 01:16:55 +00:00
|
|
|
return TRUE;
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
if (mode == TAB_CONFIG) done = 0;
|
|
|
|
else quitevent++;
|
|
|
|
return TRUE;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
if (hbmp)
|
|
|
|
{
|
|
|
|
DeleteObject(hbmp);
|
|
|
|
hbmp = NULL;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
if (pages[TAB_CONFIG])
|
|
|
|
{
|
|
|
|
DestroyWindow(pages[TAB_CONFIG]);
|
|
|
|
pages[TAB_CONFIG] = NULL;
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
startupdlg = NULL;
|
|
|
|
return TRUE;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
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;
|
2006-11-15 01:16:55 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
if ((HWND)lParam == pages[TAB_MESSAGES])
|
Win64 support! (Meaning it works, not that we recommend it for everyday use.)
This includes a complete Windows header and library refresh, including the addition of 64-bit compiled libs:
*libogg 1.3.0
*libvorbis 1.3.3
*zlib 1.2.7
*libpng 1.5.13
*libvpx 9a3de881c0e681ba1a79a166a86308bbc84b4acd
*SDL_mixer 1.2.12 (for RENDERTYPE=SDL)
*DirectX import libraries: dsound and dxguid (now included)
To build in 64-bit, you essentially need MinGW's MSYS (but not MinGW itself) and MinGW-w64 at the top of your PATH. The target is automatically detected using `$(CC) -dumpmachine`. The EDukeWiki will get detailed instrucitons.
All compiler and linker warnings when building in 64-bit mode have been fixed.
Remaining 64-bit to-do:
- The ebacktrace dll does not build under 64-bit. It uses code specific to the format of 32-bit executables and will have to be ported to work with 64-bit executables. A future 64-bit version will be named ebacktrace1-64.dll.
- RENDERTYPE=SDL crashes in SDL_mixer's Mix_Linked_Version().
- DirectInput gives an error and does not function. This only affects joysticks, and the error never happens without any plugged in.
- Port the classic renderer ASM to 64-bit. (Just kidding, this is way out of my league.)
This commit includes a fair bit of Makefile development spanning all platforms, including simplifying the SDLCONFIG code, fixing build on Mac OS X (thanks rhoenie!), globally factoring Apple brew/port inclusion, enforcing that all -L come before all -l, and ensuring that $(shell ) is always :='d.
In addition, I have resurrected the old GCC_MAJOR and GCC_MINOR detection using `$(CC) -dumpversion`, but I have made it failsafe in case the command fails or the version is manually specified. I have applied this new fine-grained detection where applicable, including allowing LTO, and restraining -W's to versions that support them.
git-svn-id: https://svn.eduke32.com/eduke32@3278 1a8010ca-5511-0410-912e-c29ae57300e0
2012-12-13 02:37:20 +00:00
|
|
|
return (BOOL)(intptr_t)GetSysColorBrush(COLOR_WINDOW);
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_open(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
INITCOMMONCONTROLSEX icc;
|
|
|
|
if (startupdlg) return 1;
|
|
|
|
icc.dwSize = sizeof(icc);
|
|
|
|
icc.dwICC = ICC_TAB_CLASSES;
|
|
|
|
InitCommonControlsEx(&icc);
|
|
|
|
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (startupdlg)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
SetPage(TAB_MESSAGES);
|
|
|
|
EnableConfig(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_close(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
if (!startupdlg) return 1;
|
|
|
|
DestroyWindow(startupdlg);
|
|
|
|
startupdlg = NULL;
|
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_puts(const char *buf)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
const char *p = NULL, *q = NULL;
|
2008-07-10 05:37:36 +00:00
|
|
|
static char workbuf[1024];
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t newline = 0;
|
|
|
|
int32_t curlen, linesbefore, linesafter;
|
2006-07-18 21:08:38 +00:00
|
|
|
HWND edctl;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t vis;
|
2008-07-10 05:37:36 +00:00
|
|
|
static HWND dactrl = NULL;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
if (!startupdlg) return 1;
|
|
|
|
|
|
|
|
edctl = pages[TAB_MESSAGES];
|
|
|
|
if (!edctl) return -1;
|
|
|
|
|
2008-07-10 05:37:36 +00:00
|
|
|
if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
|
|
|
|
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
|
|
|
|
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
|
|
|
|
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
|
|
|
|
p = buf;
|
2006-11-15 01:16:55 +00:00
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (newline)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
|
|
|
|
newline = 0;
|
|
|
|
}
|
|
|
|
q = p;
|
|
|
|
while (*q && *q != '\n') q++;
|
2009-06-09 06:19:58 +00:00
|
|
|
Bmemcpy(workbuf, p, q-p);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (*q == '\n')
|
|
|
|
{
|
|
|
|
if (!q[1])
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
newline = 1;
|
|
|
|
workbuf[q-p] = 0;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
workbuf[q-p] = '\r';
|
|
|
|
workbuf[q-p+1] = '\n';
|
|
|
|
workbuf[q-p+2] = 0;
|
|
|
|
}
|
|
|
|
p = q+1;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
workbuf[q-p] = 0;
|
|
|
|
p = q;
|
|
|
|
}
|
|
|
|
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
|
|
|
|
}
|
|
|
|
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
|
|
|
|
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
|
|
|
|
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
|
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_settitle(const char *str)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
if (!startupdlg) return 1;
|
|
|
|
SetWindowText(startupdlg, str);
|
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_idle(void *v)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
if (!startupdlg || !IsWindow(startupdlg)) return 0;
|
2010-08-02 08:13:51 +00:00
|
|
|
if (IsDialogMessage(startupdlg, (MSG *)v)) return 1;
|
2006-07-18 21:08:38 +00:00
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_run(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
MSG msg;
|
|
|
|
if (!startupdlg) return 1;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2006-07-18 21:08:38 +00:00
|
|
|
done = -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2006-07-13 23:13:06 +00:00
|
|
|
#ifdef JFAUD
|
2006-07-18 21:08:38 +00:00
|
|
|
EnumAudioDevs(&wavedevs, NULL, NULL);
|
2006-07-13 23:13:06 +00:00
|
|
|
#endif
|
2006-07-18 21:08:38 +00:00
|
|
|
SetPage(TAB_CONFIG);
|
|
|
|
EnableConfig(1);
|
|
|
|
|
2009-04-14 23:34:48 +00:00
|
|
|
settings.flags = 0;
|
|
|
|
if (ud.config.ScreenMode) settings.flags |= 1;
|
2009-12-13 01:23:44 +00:00
|
|
|
#ifdef POLYMER
|
2009-04-14 22:55:32 +00:00
|
|
|
if (glrendmode == 4) settings.flags |= 2;
|
2009-12-13 01:23:44 +00:00
|
|
|
#endif
|
2009-04-14 23:34:48 +00:00
|
|
|
if (ud.config.NoAutoLoad) settings.flags |= 4;
|
2007-08-27 00:20:15 +00:00
|
|
|
settings.xdim = ud.config.ScreenWidth;
|
|
|
|
settings.ydim = ud.config.ScreenHeight;
|
|
|
|
settings.bpp = ud.config.ScreenBPP;
|
|
|
|
settings.forcesetup = ud.config.ForceSetup;
|
|
|
|
settings.usemouse = ud.config.UseMouse;
|
|
|
|
settings.usejoy = ud.config.UseJoystick;
|
2008-11-20 14:06:36 +00:00
|
|
|
settings.game = g_gameType;
|
2008-07-22 09:05:34 +00:00
|
|
|
// settings.crcval = 0;
|
2012-06-03 16:09:33 +00:00
|
|
|
Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH);
|
2010-01-16 23:08:17 +00:00
|
|
|
settings.gamedir = g_modDir;
|
2006-07-18 21:08:38 +00:00
|
|
|
PopulateForm(-1);
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
while (done < 0)
|
|
|
|
{
|
|
|
|
switch (GetMessage(&msg, NULL, 0,0))
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case 0:
|
|
|
|
done = 1;
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
return -1;
|
|
|
|
default:
|
|
|
|
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
break;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPage(TAB_MESSAGES);
|
|
|
|
EnableConfig(0);
|
2006-11-15 01:16:55 +00:00
|
|
|
if (done)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2009-04-14 22:55:32 +00:00
|
|
|
ud.config.ScreenMode = (settings.flags&1);
|
2009-12-13 01:23:44 +00:00
|
|
|
#ifdef POLYMER
|
2009-04-14 22:55:32 +00:00
|
|
|
if (settings.flags & 2) glrendmode = 4;
|
|
|
|
else glrendmode = 3;
|
2009-12-13 01:23:44 +00:00
|
|
|
#endif
|
2009-04-14 23:34:48 +00:00
|
|
|
if (settings.flags & 4) ud.config.NoAutoLoad = 1;
|
|
|
|
else ud.config.NoAutoLoad = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.ScreenWidth = settings.xdim;
|
|
|
|
ud.config.ScreenHeight = settings.ydim;
|
|
|
|
ud.config.ScreenBPP = settings.bpp;
|
|
|
|
ud.config.ForceSetup = settings.forcesetup;
|
|
|
|
ud.config.UseMouse = settings.usemouse;
|
|
|
|
ud.config.UseJoystick = settings.usejoy;
|
2012-03-28 19:44:33 +00:00
|
|
|
|
|
|
|
clearGrpNamePtr();
|
|
|
|
g_grpNamePtr = dup_filename(settings.selectedgrp);
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_gameType = settings.game;
|
2008-08-19 11:05:21 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_noSetup == 0 && settings.gamedir != NULL)
|
2010-01-16 23:08:17 +00:00
|
|
|
Bstrcpy(g_modDir,settings.gamedir);
|
|
|
|
else Bsprintf(g_modDir,"/");
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2012-03-26 22:03:40 +00:00
|
|
|
for (i = 0; i<NUMGRPFILES; i++) if (settings.crcval == grpfiles[i].crcval) break;
|
|
|
|
if (i != NUMGRPFILES)
|
2013-04-08 18:30:39 +00:00
|
|
|
{
|
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
|
|
|
g_gameNamePtr = grpfiles[i].name;
|
2013-04-08 18:30:39 +00:00
|
|
|
g_dependencyCRC = grpfiles[i].dependency;
|
|
|
|
if (grpfiles[i].scriptname && g_scriptNamePtr == NULL)
|
|
|
|
g_scriptNamePtr = dup_filename(grpfiles[i].scriptname);
|
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (wavedevs)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
struct audioenumdev *d, *e;
|
2009-10-07 06:47:35 +00:00
|
|
|
Bfree(wavedevs->drvs);
|
2006-11-15 01:16:55 +00:00
|
|
|
for (e=wavedevs->devs; e; e=d)
|
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
d = e->next;
|
2009-10-07 06:47:35 +00:00
|
|
|
if (e->devs) Bfree(e->devs);
|
|
|
|
Bfree(e);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2009-10-07 06:47:35 +00:00
|
|
|
Bfree(wavedevs);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return done;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|