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
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-05-25 10:56:00 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2012-11-24 09:13:29 +00:00
|
|
|
#ifndef _WIN32
|
2006-07-01 01:40:18 +00:00
|
|
|
#error Only for Windows
|
|
|
|
#endif
|
|
|
|
|
2016-11-09 22:51:33 +00:00
|
|
|
#include "renderlayer.h"
|
|
|
|
|
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
#define NEED_WINDOWSX_H
|
|
|
|
#define NEED_COMMCTRL_H
|
|
|
|
#define ONLY_USERDEFS
|
|
|
|
|
|
|
|
#include "_control.h"
|
2006-07-01 01:40:18 +00:00
|
|
|
#include "build.h"
|
2017-02-19 22:15:29 +00:00
|
|
|
#include "cache1d.h"
|
2018-11-18 18:13:02 +00:00
|
|
|
#include "compat.h"
|
2017-02-19 22:15:29 +00:00
|
|
|
#include "control.h"
|
2018-11-18 18:13:02 +00:00
|
|
|
#include "keyboard.h"
|
|
|
|
#include "startwin.game.h"
|
|
|
|
#include "windows_inc.h"
|
2019-10-31 22:25:21 +00:00
|
|
|
#include "gamecontrol.h"
|
2012-03-28 19:44:33 +00:00
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
#pragma warning(disable:4244) // There's just a bit too much of these in here...
|
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#define TAB_CONFIG 0
|
2008-08-19 13:26:56 +00:00
|
|
|
#define TAB_MESSAGES 1
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2019-10-27 12:40:24 +00:00
|
|
|
typedef struct {
|
|
|
|
int32_t fullscreen;
|
|
|
|
int32_t xdim;
|
|
|
|
int32_t ydim;
|
|
|
|
int32_t bpp;
|
|
|
|
} ud_setup_t;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
static struct
|
|
|
|
{
|
2019-10-31 22:25:21 +00:00
|
|
|
int grp;
|
2018-11-18 18:13:02 +00:00
|
|
|
ud_setup_t shared;
|
|
|
|
int polymer;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
settings;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
static HWND startupdlg;
|
|
|
|
static HWND pages[3];
|
|
|
|
static int done = -1;
|
|
|
|
static int mode = TAB_CONFIG;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2019-10-31 22:25:21 +00:00
|
|
|
static TArray<GrpEntry> *gamedata;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
static inline void getfilenames(char const *path)
|
2008-08-17 09:01:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2019-09-23 16:17:36 +00:00
|
|
|
// Thanks, Microsoft for not providing alternatives for the dialog control macros. :(
|
|
|
|
#undef SNDMSG
|
|
|
|
#define SNDMSG ::SendMessageA
|
|
|
|
|
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
|
|
|
{
|
2009-07-12 01:55:34 +00:00
|
|
|
char buf[512];
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
if (pgs & POPULATE_GAMEDIRS)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR);
|
2009-07-12 01:55:34 +00:00
|
|
|
|
2019-10-31 22:25:21 +00:00
|
|
|
#if 0 // This doesn't currently work and in its current form is useless anyway. It should offer a real directory picker.
|
2009-07-12 01:55:34 +00:00
|
|
|
getfilenames("/");
|
|
|
|
(void)ComboBox_ResetContent(hwnd);
|
2018-11-18 18:13:02 +00:00
|
|
|
int const r = ComboBox_AddString(hwnd, "None");
|
|
|
|
(void)ComboBox_SetItemData(hwnd, r, 0);
|
|
|
|
(void)ComboBox_SetCurSel(hwnd, r);
|
|
|
|
auto dirs = finddirs;
|
|
|
|
for (int i=1, j=1; dirs != NULL; dirs=dirs->next)
|
2009-07-12 01:55:34 +00:00
|
|
|
{
|
2015-04-09 07:52:01 +00:00
|
|
|
if (Bstrcasecmp(dirs->name, "autoload") == 0)
|
2015-08-15 21:28:17 +00:00
|
|
|
{
|
2015-08-18 07:09:04 +00:00
|
|
|
j++;
|
2015-04-09 07:52:01 +00:00
|
|
|
continue;
|
2015-08-15 21:28:17 +00:00
|
|
|
}
|
2015-04-09 07:52:01 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
(void)ComboBox_AddString(hwnd, dirs->name);
|
2015-08-18 07:09:04 +00:00
|
|
|
(void)ComboBox_SetItemData(hwnd, i, j);
|
2015-04-09 07:52:01 +00:00
|
|
|
|
|
|
|
i++;
|
2015-08-18 07:09:04 +00:00
|
|
|
j++;
|
2009-07-12 01:55:34 +00:00
|
|
|
}
|
2019-10-31 22:25:21 +00:00
|
|
|
#endif
|
2009-07-12 01:55:34 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (pgs & POPULATE_VIDEO)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
|
|
|
|
int mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, settings.shared.bpp, settings.shared.fullscreen, 1);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2019-10-31 22:25:21 +00:00
|
|
|
if (mode < 0 || (settings.shared.bpp < 15))
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
int CONSTEXPR cd[] = { 32, 24, 16, 15, 8, 0 };
|
|
|
|
int i;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; cd[i];)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
if (cd[i] >= settings.shared.bpp) i++;
|
2006-11-15 01:16:55 +00:00
|
|
|
else break;
|
|
|
|
}
|
|
|
|
for (; cd[i]; i++)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, cd[i], settings.shared.fullscreen, 1);
|
2006-07-18 21:08:38 +00:00
|
|
|
if (mode < 0) continue;
|
2018-11-18 18:13:02 +00:00
|
|
|
settings.shared.bpp = cd[i];
|
2006-07-18 21:08:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.shared.fullscreen) ? BST_CHECKED : BST_UNCHECKED));
|
2019-09-23 16:17:36 +00:00
|
|
|
//Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? 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
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
for (int i=0; i<validmodecnt; i++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
if (validmode[i].fs != (settings.shared.fullscreen)) continue;
|
2019-10-31 22:25:21 +00:00
|
|
|
if ((validmode[i].bpp < 15)) continue;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
// all modes get added to the 3D mode list
|
2017-08-27 10:20:48 +00:00
|
|
|
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
|
2018-11-18 18:13:02 +00:00
|
|
|
int const 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_GAME)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2019-10-31 22:25:21 +00:00
|
|
|
int i=0;
|
|
|
|
for (auto& grp : *gamedata)
|
|
|
|
{
|
2019-11-02 20:43:17 +00:00
|
|
|
auto p = grp.FileName.LastIndexOfAny("/\\");
|
|
|
|
auto c = grp.FileName.GetChars();
|
|
|
|
if (p > 0) c += p+1;
|
|
|
|
FStringf grpinfo("%s\t%s", grp.FileInfo.name.GetChars(), c);
|
2019-10-31 22:25:21 +00:00
|
|
|
int const j = ListBox_AddString(hwnd, grpinfo.GetChars());
|
|
|
|
(void)ListBox_SetItemData(hwnd, j, i);
|
|
|
|
i++;
|
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:
|
2018-11-18 18:13:02 +00:00
|
|
|
settings.shared.fullscreen = !settings.shared.fullscreen;
|
2009-04-14 22:55:32 +00:00
|
|
|
PopulateForm(POPULATE_VIDEO);
|
|
|
|
return TRUE;
|
2019-09-23 16:17:36 +00:00
|
|
|
//case IDCPOLYMER:
|
|
|
|
// settings.polymer = !settings.polymer;
|
|
|
|
// if (settings.shared.bpp == 8) settings.shared.bpp = 32;
|
|
|
|
// PopulateForm(POPULATE_VIDEO);
|
|
|
|
// return TRUE;
|
2006-11-16 03:02:42 +00:00
|
|
|
case IDCVMODE:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
int i = ComboBox_GetCurSel((HWND)lParam);
|
2006-11-16 03:02:42 +00:00
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
settings.shared.xdim = validmode[i].xdim;
|
|
|
|
settings.shared.ydim = validmode[i].ydim;
|
|
|
|
settings.shared.bpp = validmode[i].bpp;
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2006-11-16 03:02:42 +00:00
|
|
|
return TRUE;
|
|
|
|
case IDCALWAYSSHOW:
|
2019-10-27 08:38:55 +00:00
|
|
|
displaysetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
|
2006-11-16 03:02:42 +00:00
|
|
|
return TRUE;
|
2009-04-14 22:55:32 +00:00
|
|
|
case IDCAUTOLOAD:
|
2019-10-27 08:38:55 +00:00
|
|
|
noautoload = (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) != BST_CHECKED);
|
2009-04-14 22:55:32 +00:00
|
|
|
return TRUE;
|
2008-08-19 13:26:56 +00:00
|
|
|
case IDCGAMEDIR:
|
2008-08-17 09:01:31 +00:00
|
|
|
return TRUE;
|
2008-08-19 13:26:56 +00:00
|
|
|
case IDCDATA:
|
|
|
|
{
|
|
|
|
if (HIWORD(wParam) != LBN_SELCHANGE) break;
|
2018-11-18 18:13:02 +00:00
|
|
|
intptr_t i = ListBox_GetCurSel((HWND)lParam);
|
2008-08-19 13:26:56 +00:00
|
|
|
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
|
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
2019-10-31 22:25:21 +00:00
|
|
|
settings.grp = i;
|
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
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
static void SetPage(int pageNum)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
HWND tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
|
2019-09-22 21:15:46 +00:00
|
|
|
auto const cur = SendMessageA(tab, TCM_GETCURSEL, 0, 0);
|
2018-11-18 18:13:02 +00:00
|
|
|
ShowWindow(pages[cur], SW_HIDE);
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(tab, TCM_SETCURSEL, pageNum, 0);
|
2018-11-18 18:13:02 +00:00
|
|
|
ShowWindow(pages[pageNum], SW_SHOW);
|
|
|
|
mode = pageNum;
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
static void EnableConfig(bool 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);
|
2018-11-18 18:13:02 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n);
|
2006-07-18 21:08:38 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
|
2018-11-18 18:13:02 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
|
2019-09-23 16:17:36 +00:00
|
|
|
//EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
|
2006-07-18 21:08:38 +00:00
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), 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;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
2018-11-18 18:13:02 +00:00
|
|
|
RECT chrome = {};
|
2006-11-16 03:02:42 +00:00
|
|
|
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
|
2018-11-18 18:13:02 +00:00
|
|
|
RECT rdlg;
|
2006-11-16 03:02:42 +00:00
|
|
|
GetWindowRect(hwndDlg, &rdlg);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
RECT rtab;
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
|
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
// 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;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
RECT rcancel;
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
|
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
rcancel.right -= rcancel.left - 1;
|
|
|
|
rcancel.bottom -= rcancel.top - 1;
|
|
|
|
rcancel.left -= rdlg.left;
|
|
|
|
rcancel.top -= rdlg.top;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
RECT rstart;
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
|
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
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));
|
2018-11-18 18:13:02 +00:00
|
|
|
|
|
|
|
HWND hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_BITMAP);
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
|
|
|
RECT r;
|
2006-11-16 03:02:42 +00:00
|
|
|
GetClientRect(hwnd, &r);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
|
|
|
int const xoffset = r.right;
|
|
|
|
int const yoffset = r.bottom - rdlg.bottom;
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
// 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
|
2018-11-18 18:13:02 +00:00
|
|
|
HDC hdc = GetDC(NULL);
|
2006-11-16 03:02:42 +00:00
|
|
|
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
|
|
|
{
|
2019-09-22 21:15:46 +00:00
|
|
|
static char textSetup[] = "Setup";
|
|
|
|
static char textMessageLog[] = "Message Log";
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
|
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
TCITEMA tab = {};
|
2006-11-16 03:02:42 +00:00
|
|
|
tab.mask = TCIF_TEXT;
|
2016-01-12 10:30:48 +00:00
|
|
|
tab.pszText = textSetup;
|
2019-09-23 16:17:36 +00:00
|
|
|
SendMessageA(hwnd, TCM_INSERTITEMA, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
|
2006-11-16 03:02:42 +00:00
|
|
|
tab.mask = TCIF_TEXT;
|
2016-01-12 10:30:48 +00:00
|
|
|
tab.pszText = textMessageLog;
|
2019-09-23 16:17:36 +00:00
|
|
|
SendMessageA(hwnd, TCM_INSERTITEMA, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
// 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);
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
|
2006-11-16 03:02:42 +00:00
|
|
|
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
|
2018-11-18 18:13:02 +00:00
|
|
|
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
|
|
|
|
SetWindowPos(pages[TAB_CONFIG], hwnd, r.left, r.top, r.right, r.bottom, SWP_HIDEWINDOW);
|
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
|
2018-11-18 18:13:02 +00:00
|
|
|
SetWindowPos(pages[TAB_MESSAGES], hwnd, r.left, r.top, r.right, r.bottom, SWP_HIDEWINDOW);
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
// Tell the editfield acting as the console to exclude the width of the scrollbar
|
2018-11-18 18:13:02 +00:00
|
|
|
GetClientRect(pages[TAB_MESSAGES], &r);
|
2006-11-16 03:02:42 +00:00
|
|
|
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
|
|
|
|
r.left = r.top = 0;
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
// 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));
|
2019-09-22 21:15:46 +00:00
|
|
|
SetWindowTextA(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:
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
auto nmhdr = (LPNMHDR)lParam;
|
2006-11-16 03:02:42 +00:00
|
|
|
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
|
2019-09-22 21:15:46 +00:00
|
|
|
int const cur = SendMessageA(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
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
case TCN_SELCHANGING:
|
|
|
|
case TCN_SELCHANGE:
|
|
|
|
if (cur < 0 || !pages[cur])
|
|
|
|
break;
|
|
|
|
ShowWindow(pages[cur], nmhdr->code == TCN_SELCHANGING ? SW_HIDE : SW_SHOW);
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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
|
|
|
if (startupdlg) return 1;
|
2018-11-18 18:13:02 +00:00
|
|
|
INITCOMMONCONTROLSEX icc = { sizeof(icc), ICC_TAB_CLASSES };
|
2006-07-18 21:08:38 +00:00
|
|
|
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
|
|
|
if (!startupdlg) return 1;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
const HWND edctl = pages[TAB_MESSAGES];
|
|
|
|
|
2006-07-18 21:08:38 +00:00
|
|
|
if (!edctl) return -1;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
static HWND dactrl = NULL;
|
2008-07-10 05:37:36 +00:00
|
|
|
if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
|
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
int const vis = ((int)SendMessageA(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
|
|
|
if (vis)
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(edctl, WM_SETREDRAW, FALSE, 0);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
int const curlen = SendMessageA(edctl, WM_GETTEXTLENGTH, 0,0);
|
|
|
|
SendMessageA(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
int const numlines = SendMessageA(edctl, EM_GETLINECOUNT, 0, 0);
|
2018-11-18 18:13:02 +00:00
|
|
|
static bool newline = false;
|
|
|
|
const char *p = buf;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (newline)
|
|
|
|
{
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
|
2018-11-18 18:13:02 +00:00
|
|
|
newline = false;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2018-11-18 18:13:02 +00:00
|
|
|
const char *q = p;
|
2006-07-18 21:08:38 +00:00
|
|
|
while (*q && *q != '\n') q++;
|
2018-11-18 18:13:02 +00:00
|
|
|
static char workbuf[1024];
|
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])
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
newline = true;
|
2006-07-18 21:08:38 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
2018-11-18 18:13:02 +00:00
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
int const newnumlines = SendMessageA(edctl, EM_GETLINECOUNT, 0, 0);
|
|
|
|
SendMessageA(edctl, EM_LINESCROLL, 0, newnumlines - numlines);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
|
|
|
if (vis)
|
2019-09-22 21:15:46 +00:00
|
|
|
SendMessageA(edctl, WM_SETREDRAW, TRUE, 0);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
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_settitle(const char *str)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-18 21:08:38 +00:00
|
|
|
if (!startupdlg) return 1;
|
2019-09-22 21:15:46 +00:00
|
|
|
SetWindowTextA(startupdlg, str);
|
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_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
|
|
|
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-18 21:08:38 +00:00
|
|
|
SetPage(TAB_CONFIG);
|
|
|
|
EnableConfig(1);
|
|
|
|
|
2019-10-27 12:40:24 +00:00
|
|
|
settings.shared = { ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP };
|
2019-10-31 22:25:21 +00:00
|
|
|
settings.grp = 0;
|
2018-11-18 18:13:02 +00:00
|
|
|
|
2006-07-18 21:08:38 +00:00
|
|
|
PopulateForm(-1);
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
do
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
MSG msg;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
switch (GetMessage(&msg, NULL, 0,0))
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case 0:
|
|
|
|
done = 1;
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
return -1;
|
|
|
|
default:
|
2018-11-18 18:13:02 +00:00
|
|
|
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg))
|
|
|
|
break;
|
2006-11-16 03:02:42 +00:00
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
break;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-18 18:13:02 +00:00
|
|
|
while (done < 0);
|
2006-07-18 21:08:38 +00:00
|
|
|
|
|
|
|
SetPage(TAB_MESSAGES);
|
|
|
|
EnableConfig(0);
|
2018-11-18 18:13:02 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (done)
|
|
|
|
{
|
2019-10-27 12:40:24 +00:00
|
|
|
ScreenWidth = settings.shared.xdim;
|
|
|
|
ScreenHeight = settings.shared.ydim;
|
|
|
|
ScreenMode = settings.shared.fullscreen;
|
|
|
|
ScreenBPP = settings.shared.bpp;
|
2006-07-18 21:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return done;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 22:25:21 +00:00
|
|
|
int ShowStartupWindow(TArray<GrpEntry> &groups)
|
|
|
|
{
|
|
|
|
gamedata = &groups;
|
|
|
|
startwin_open();
|
|
|
|
startwin_settitle("Demolition");
|
|
|
|
|
|
|
|
if (1)//readSetup < 0 || (!g_noSetup && (displaysetup)) || g_commandSetup)
|
|
|
|
{
|
|
|
|
auto choice = startwin_run();
|
|
|
|
if (choice == 0)
|
|
|
|
{
|
2019-10-31 23:32:56 +00:00
|
|
|
startwin_close();
|
|
|
|
return - 1;
|
2019-10-31 22:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
startwin_close();
|
|
|
|
return settings.grp;
|
|
|
|
}
|
2019-09-21 20:53:00 +00:00
|
|
|
|
2016-11-09 22:51:33 +00:00
|
|
|
#endif // STARTUP_SETUP_WINDOW
|
2019-09-21 20:53:00 +00:00
|
|
|
|
|
|
|
|