- startup hacks.

Unfortunately nothing of this can be fixed before the resource management has been refactored from the ground up. Sp for now this ugliness needs to suffice.
This commit is contained in:
Christoph Oelckers 2019-09-23 18:17:36 +02:00
parent 07e38f3d12
commit 37907ddd06
4 changed files with 134 additions and 62 deletions

View file

@ -370,35 +370,68 @@ void ChooseGame()
stTaskConfig.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION;
stTaskConfig.pszWindowTitle = L"Demolition";
stTaskConfig.pszMainInstruction = L"Choose your game";
stTaskConfig.pszContent = L"";
stTaskConfig.cButtons = 3;
TASKDIALOG_BUTTON buttons[] = {
{1000,L"EDuke32"},
{1001,L"RedNukem"},
{1002,L"Blood"},
};
stTaskConfig.pButtons = buttons;
stTaskConfig.nDefaultButton = 1000;
if (SUCCEEDED(TaskDialogIndirect(&stTaskConfig, &nResult, NULL, NULL)))
if (!gi)
{
//API call succeeded, now , check return values
if (nResult == 1000)
// Gross hack to allow selecting the games without rewriting the entire front end.
// That's for later.
// This popup should go away anyway and be replaced by something nicer.
stTaskConfig.pszWindowTitle = L"Demolition";
stTaskConfig.pszMainInstruction = L"Choose your game";
stTaskConfig.pszContent = L"";
stTaskConfig.cButtons = 7;
TASKDIALOG_BUTTON buttons[] = {
{1000,L"Duke Nukem 3D"},
{1001,L"Nam"},
{1002,L"WW2 GI"},
{1003,L"Redneck Rampage"},
{1004,L"Redneck Rides Again"},
{1005,L"Blood"},
{1006,L"Ion Fury"},
};
stTaskConfig.pButtons = buttons;
stTaskConfig.nDefaultButton = 1000;
if (SUCCEEDED(TaskDialogIndirect(&stTaskConfig, &nResult, NULL, NULL)))
{
gi = &Duke::Interface;
}
else if (nResult == 1001)
{
gi = &Redneck::Interface;
}
else if (nResult == 1002)
{
gi = &Blood::Interface;
//API call succeeded, now , check return values
if (nResult == 1000)
{
chdir("c:/Doom/Play_Build/Duke Nukem 3D");
gi = &Duke::Interface;
}
else if (nResult == 1001)
{
chdir("c:/Doom/Play_Build/Nam");
gi = &Duke::Interface;
}
else if (nResult == 1002)
{
chdir("c:/Doom/Play_Build/WW2GI");
gi = &Duke::Interface;
}
else if (nResult == 1003)
{
chdir("c:/Doom/Play_Build/Redneck Rampage");
gi = &Redneck::Interface;
}
else if (nResult == 1004)
{
chdir("c:/Doom/Play_Build/Redneck Rides Again");
gi = &Redneck::Interface;
}
else if (nResult == 1005)
{
chdir("c:/Doom/Play_Build/Blood");
gi = &Blood::Interface;
}
else if (nResult == 1006)
{
chdir("c:/Doom/Play_Build/Ion Fury");
gi = &Duke::Interface;
}
}
if (gi == nullptr) exit(1);
}
if (gi == nullptr) exit(1);
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
@ -407,14 +440,58 @@ int main(int argc, char *argv[])
#endif
{
#ifdef _WIN32
char* argvbuf;
int32_t buildargc = win_buildargs(&argvbuf);
const char** buildargv = (const char**)Xmalloc(sizeof(char*) * (buildargc + 1));
char* wp = argvbuf;
for (bssize_t i = 0; i < buildargc; i++, wp++)
{
buildargv[i] = wp;
while (*wp) wp++;
}
buildargv[buildargc] = NULL;
#else
auto buildargc = argc;
auto buildargv = argv;
#endif
for (int i = 0; i < buildargc - 1; i++)
{
if (!strcmp(buildargv[i], "-maindir"))
{
const char* dir = buildargv[i + 1];
if (!chdir(dir))
{
FILE* f = fopen("blood.rff", "rb");
if (f)
{
gi = &Blood::Interface;
fclose(f);
}
else
{
f = fopen("redneck.grp", "rb");
if (f)
{
gi = &Redneck::Interface;
fclose(f);
}
else
gi = &Duke::Interface;
}
}
}
}
// Hack to be able to choose from the available game frontends until the startup dialogue can be moved out of the frontend code.
if (!gi) ChooseGame();
#if defined _WIN32 && defined SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING
// Thread naming interferes with debugging using MinGW-w64's GDB.
SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
#endif
// Hack to be able to choose from the available game frontends until the startup dialogue can be moved out of the frontend code.
ChooseGame();
int32_t r;
#ifdef USE_OPENGL
@ -458,22 +535,13 @@ int main(int argc, char *argv[])
gtkbuild_init(&argc, &argv);
#endif
startwin_open();
maybe_redirect_outputs();
#ifdef _WIN32
char *argvbuf;
int32_t buildargc = win_buildargs(&argvbuf);
const char **buildargv = (const char **) Xmalloc(sizeof(char *)*(buildargc+1));
char *wp = argvbuf;
for (bssize_t i=0; i<buildargc; i++, wp++)
{
buildargv[i] = wp;
while (*wp) wp++;
}
buildargv[buildargc] = NULL;
#ifdef USE_PHYSFS
PHYSFS_init(buildargv[0]);

View file

@ -99,6 +99,10 @@ static inline void getfilenames(char const *path)
#define INPUT_JOYSTICK 2
#define INPUT_ALL 3
// Thanks, Microsoft for not providing alternatives for the dialog control macros. :(
#undef SNDMSG
#define SNDMSG ::SendMessageA
const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboard and joystick", "All supported devices" };
static void PopulateForm(int32_t pgs)
@ -158,7 +162,7 @@ static void PopulateForm(int32_t pgs)
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.shared.fullscreen) ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
//Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
(void)ComboBox_ResetContent(hwnd);
@ -237,11 +241,11 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
settings.shared.fullscreen = !settings.shared.fullscreen;
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCPOLYMER:
settings.polymer = !settings.polymer;
if (settings.shared.bpp == 8) settings.shared.bpp = 32;
PopulateForm(POPULATE_VIDEO);
return TRUE;
//case IDCPOLYMER:
// settings.polymer = !settings.polymer;
// if (settings.shared.bpp == 8) settings.shared.bpp = 32;
// PopulateForm(POPULATE_VIDEO);
// return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
@ -355,7 +359,7 @@ static void EnableConfig(bool n)
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
//EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
}
@ -455,10 +459,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
TCITEMA tab = {};
tab.mask = TCIF_TEXT;
tab.pszText = textSetup;
SendMessageA(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
SendMessageA(hwnd, TCM_INSERTITEMA, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = textMessageLog;
SendMessageA(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
SendMessageA(hwnd, TCM_INSERTITEMA, (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));

View file

@ -198,11 +198,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
c = oc;
if ((*c == '-')
#ifdef _WIN32
|| (*c == '/')
#endif
)
if (*c == '-')
{
shortopt = 0;

View file

@ -97,6 +97,10 @@ static inline void getfilenames(char const *path)
#define INPUT_JOYSTICK 2
#define INPUT_ALL 3
// Thanks, Microsoft for not providing alternatives for the dialog control macros. :(
#undef SNDMSG
#define SNDMSG ::SendMessageA
const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboard and joystick", "All supported devices" };
static void PopulateForm(int32_t pgs)
@ -156,7 +160,7 @@ static void PopulateForm(int32_t pgs)
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.shared.fullscreen) ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
//Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
(void)ComboBox_ResetContent(hwnd);
@ -235,11 +239,11 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
settings.shared.fullscreen = !settings.shared.fullscreen;
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCPOLYMER:
settings.polymer = !settings.polymer;
if (settings.shared.bpp == 8) settings.shared.bpp = 32;
PopulateForm(POPULATE_VIDEO);
return TRUE;
//case IDCPOLYMER:
// settings.polymer = !settings.polymer;
// if (settings.shared.bpp == 8) settings.shared.bpp = 32;
// PopulateForm(POPULATE_VIDEO);
// return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
@ -353,7 +357,7 @@ static void EnableConfig(bool n)
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
//EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
}
@ -453,10 +457,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
TCITEMA tab = {};
tab.mask = TCIF_TEXT;
tab.pszText = textSetup;
SendMessageA(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
SendMessageA(hwnd, TCM_INSERTITEMA, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = textMessageLog;
SendMessageA(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
SendMessageA(hwnd, TCM_INSERTITEMA, (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));