mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 04:01:31 +00:00
added render backend selection to the new IWAD picker.
Unlike VkDoom we still need this.
This commit is contained in:
parent
15e9c95419
commit
a2a7667442
5 changed files with 78 additions and 135 deletions
|
@ -16,6 +16,8 @@ public:
|
|||
void Toggle();
|
||||
|
||||
double GetPreferredHeight() const;
|
||||
std::function<void(bool)> FuncChanged;
|
||||
void SetRadioStyle(bool on) { radiostyle = on; }
|
||||
|
||||
protected:
|
||||
void OnPaint(Canvas* canvas) override;
|
||||
|
@ -27,5 +29,7 @@ protected:
|
|||
private:
|
||||
std::string text;
|
||||
bool checked = false;
|
||||
bool radiostyle = false;
|
||||
bool mouseDownActive = false;
|
||||
|
||||
};
|
||||
|
|
|
@ -84,6 +84,8 @@ void CheckboxLabel::OnKeyUp(EInputKey key)
|
|||
|
||||
void CheckboxLabel::Toggle()
|
||||
{
|
||||
checked = !checked;
|
||||
bool oldchecked = checked;
|
||||
checked = radiostyle? true : !checked;
|
||||
Update();
|
||||
if (checked != oldchecked && FuncChanged) FuncChanged(checked);
|
||||
}
|
||||
|
|
|
@ -344,131 +344,6 @@ static void SetQueryIWad(HWND dialog)
|
|||
queryiwad = query;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// IWADBoxCallback
|
||||
//
|
||||
// Dialog proc for the IWAD selector.
|
||||
//
|
||||
//==========================================================================
|
||||
static int* pAutoloadflags;
|
||||
|
||||
BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int& flags = *pAutoloadflags;;
|
||||
|
||||
HWND ctrl;
|
||||
int i;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Add our program name to the window title
|
||||
{
|
||||
WCHAR label[256];
|
||||
FString newlabel;
|
||||
|
||||
GetWindowTextW(hDlg, label, countof(label));
|
||||
FString alabel(label);
|
||||
newlabel.Format(GAMENAME " %s: %s", GetVersionString(), alabel.GetChars());
|
||||
auto wlabel = newlabel.WideString();
|
||||
SetWindowTextW(hDlg, wlabel.c_str());
|
||||
}
|
||||
|
||||
// [SP] Upstreamed from Zandronum
|
||||
char szString[256];
|
||||
|
||||
// Check the current video settings.
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_SETCHECK, vid_fullscreen ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
switch (vid_preferbackend)
|
||||
{
|
||||
case 1:
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_VULKAN2, BM_SETCHECK, BST_CHECKED, 0 );
|
||||
break;
|
||||
#ifdef HAVE_GLES2
|
||||
case 2:
|
||||
case 3:
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_VULKAN4, BM_SETCHECK, BST_CHECKED, 0 );
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_VULKAN1, BM_SETCHECK, BST_CHECKED, 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// [SP] This is our's
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_NOAUTOLOAD, BM_SETCHECK, (flags & 1) ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_LIGHTS, BM_SETCHECK, (flags & 2) ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_BRIGHTMAPS, BM_SETCHECK, (flags & 4) ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_SETCHECK, (flags & 8) ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
|
||||
// Set up our version string.
|
||||
snprintf(szString, sizeof(szString), "Version %s.", GetVersionString());
|
||||
SetDlgItemTextA (hDlg, IDC_WELCOME_VERSION, szString);
|
||||
|
||||
// Populate the list with all the IWADs found
|
||||
ctrl = GetDlgItem(hDlg, IDC_IWADLIST);
|
||||
for (i = 0; i < NumWads; i++)
|
||||
{
|
||||
const char *filepart = strrchr(WadList[i].Path.GetChars(), '/');
|
||||
if (filepart == NULL)
|
||||
filepart = WadList[i].Path.GetChars();
|
||||
else
|
||||
filepart++;
|
||||
|
||||
FString work;
|
||||
if (*filepart) work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart);
|
||||
else work = WadList[i].Name.GetChars();
|
||||
std::wstring wide = work.WideString();
|
||||
SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)wide.c_str());
|
||||
SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i);
|
||||
}
|
||||
SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0);
|
||||
SetFocus(ctrl);
|
||||
// Set the state of the "Don't ask me again" checkbox
|
||||
ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD);
|
||||
SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0);
|
||||
// Make sure the dialog is in front. If SHIFT was pressed to force it visible,
|
||||
// then the other window will normally be on top.
|
||||
SetForegroundWindow(hDlg);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog (hDlg, -1);
|
||||
}
|
||||
else if (LOWORD(wParam) == IDOK ||
|
||||
(LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK))
|
||||
{
|
||||
SetQueryIWad(hDlg);
|
||||
// [SP] Upstreamed from Zandronum
|
||||
vid_fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED;
|
||||
#ifdef HAVE_GLES2
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN4, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
vid_preferbackend = 2;
|
||||
else
|
||||
#endif
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN2, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
vid_preferbackend = 1;
|
||||
else if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN1, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
vid_preferbackend = 0;
|
||||
|
||||
// [SP] This is our's.
|
||||
flags = 0;
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_NOAUTOLOAD, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 1;
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_LIGHTS, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 2;
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_BRIGHTMAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 4;
|
||||
if (SendDlgItemMessage(hDlg, IDC_WELCOME_WIDESCREEN, BM_GETCHECK, 0, 0) == BST_CHECKED) flags |= 8;
|
||||
ctrl = GetDlgItem (hDlg, IDC_IWADLIST);
|
||||
EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// I_PickIWad
|
||||
|
@ -480,7 +355,6 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
|
|||
int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags)
|
||||
{
|
||||
int vkey;
|
||||
pAutoloadflags = &autoloadflags;
|
||||
if (stricmp(queryiwad_key, "shift") == 0)
|
||||
{
|
||||
vkey = VK_SHIFT;
|
||||
|
@ -495,14 +369,6 @@ int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
|
|||
}
|
||||
if (showwin || (vkey != 0 && GetAsyncKeyState(vkey)))
|
||||
{
|
||||
/*
|
||||
WadList = wads;
|
||||
NumWads = numwads;
|
||||
DefaultWad = defaultiwad;
|
||||
|
||||
return (int)DialogBox(g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG),
|
||||
(HWND)mainwindow.GetHandle(), (DLGPROC)IWADBoxCallback);
|
||||
*/
|
||||
return LauncherWindow::ExecModal(wads, numwads, defaultiwad, &autoloadflags);
|
||||
}
|
||||
return defaultiwad;
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include <zwidget/widgets/checkboxlabel/checkboxlabel.h>
|
||||
#include <zwidget/widgets/lineedit/lineedit.h>
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
EXTERN_CVAR(Int, vid_preferbackend);
|
||||
#endif
|
||||
|
||||
EXTERN_CVAR(Bool, queryiwad);
|
||||
|
||||
int LauncherWindow::ExecModal(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags)
|
||||
|
@ -73,6 +77,17 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
WidescreenCheckbox->SetText("Widescreen");
|
||||
ParametersLabel->SetText("Additional Parameters:");
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
BackendLabel = new TextLabel(this);
|
||||
VulkanCheckbox = new CheckboxLabel(this);
|
||||
OpenGLCheckbox = new CheckboxLabel(this);
|
||||
GLESCheckbox = new CheckboxLabel(this);
|
||||
BackendLabel->SetText("Render Backend");
|
||||
VulkanCheckbox->SetText("Vulkan");
|
||||
OpenGLCheckbox->SetText("OpenGL");
|
||||
GLESCheckbox->SetText("OpenGL ES");
|
||||
#endif
|
||||
|
||||
FString welcomeText, versionText;
|
||||
welcomeText.Format("Welcome to %s!", GAMENAME);
|
||||
versionText.Format("Version %s.", GetVersionString());
|
||||
|
@ -88,6 +103,27 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
BrightmapsCheckbox->SetChecked(flags & 4);
|
||||
WidescreenCheckbox->SetChecked(flags & 8);
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
OpenGLCheckbox->SetRadioStyle(true);
|
||||
VulkanCheckbox->SetRadioStyle(true);
|
||||
GLESCheckbox->SetRadioStyle(true);
|
||||
OpenGLCheckbox->FuncChanged = [this](bool on) { if (on) { VulkanCheckbox->SetChecked(false); GLESCheckbox->SetChecked(false); }};
|
||||
VulkanCheckbox->FuncChanged = [this](bool on) { if (on) { OpenGLCheckbox->SetChecked(false); GLESCheckbox->SetChecked(false); }};
|
||||
GLESCheckbox->FuncChanged = [this](bool on) { if (on) { VulkanCheckbox->SetChecked(false); OpenGLCheckbox->SetChecked(false); }};
|
||||
switch (vid_preferbackend)
|
||||
{
|
||||
case 0:
|
||||
OpenGLCheckbox->SetChecked(true);
|
||||
break;
|
||||
case 1:
|
||||
VulkanCheckbox->SetChecked(true);
|
||||
break;
|
||||
case 2:
|
||||
GLESCheckbox->SetChecked(true);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < numwads; i++)
|
||||
{
|
||||
const char* filepart = strrchr(wads[i].Path.GetChars(), '/');
|
||||
|
@ -125,6 +161,14 @@ void LauncherWindow::OnPlayButtonClicked()
|
|||
if (WidescreenCheckbox->GetChecked()) flags |= 8;
|
||||
*AutoloadFlags = flags;
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
int v = 1;
|
||||
if (OpenGLCheckbox->GetChecked()) v = 0;
|
||||
else if (VulkanCheckbox->GetChecked()) v = 1;
|
||||
else if (GLESCheckbox->GetChecked()) v = 2;
|
||||
if (v != vid_preferbackend) vid_preferbackend = v;
|
||||
#endif
|
||||
|
||||
std::string extraargs = ParametersEdit->GetText();
|
||||
if (!extraargs.empty())
|
||||
{
|
||||
|
@ -185,6 +229,24 @@ void LauncherWindow::OnGeometryChanged()
|
|||
y -= 10.0;
|
||||
|
||||
double panelWidth = 150.0;
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
auto yy = y;
|
||||
y -= GLESCheckbox->GetPreferredHeight();
|
||||
double x = GetWidth() / 2 - panelWidth / 2;
|
||||
GLESCheckbox->SetFrameGeometry(x, y, 190.0, GLESCheckbox->GetPreferredHeight());
|
||||
|
||||
y -= OpenGLCheckbox->GetPreferredHeight();
|
||||
OpenGLCheckbox->SetFrameGeometry(x, y, 190.0, OpenGLCheckbox->GetPreferredHeight());
|
||||
|
||||
y -= VulkanCheckbox->GetPreferredHeight();
|
||||
VulkanCheckbox->SetFrameGeometry(x, y, 190.0, VulkanCheckbox->GetPreferredHeight());
|
||||
|
||||
y -= BackendLabel->GetPreferredHeight();
|
||||
BackendLabel->SetFrameGeometry(x, y, 190.0, BackendLabel->GetPreferredHeight());
|
||||
|
||||
y = yy;
|
||||
#endif
|
||||
y -= DontAskAgainCheckbox->GetPreferredHeight();
|
||||
DontAskAgainCheckbox->SetFrameGeometry(20.0, y, 190.0, DontAskAgainCheckbox->GetPreferredHeight());
|
||||
WidescreenCheckbox->SetFrameGeometry(GetWidth() - 20.0 - panelWidth, y, panelWidth, WidescreenCheckbox->GetPreferredHeight());
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <zwidget/core/widget.h>
|
||||
|
||||
|
||||
#define RENDER_BACKENDS
|
||||
|
||||
class ImageBox;
|
||||
class TextLabel;
|
||||
class CheckboxLabel;
|
||||
|
@ -38,6 +41,12 @@ private:
|
|||
CheckboxLabel* LightsCheckbox = nullptr;
|
||||
CheckboxLabel* BrightmapsCheckbox = nullptr;
|
||||
CheckboxLabel* WidescreenCheckbox = nullptr;
|
||||
#ifdef RENDER_BACKENDS
|
||||
TextLabel* BackendLabel = nullptr;
|
||||
CheckboxLabel* VulkanCheckbox = nullptr;
|
||||
CheckboxLabel* OpenGLCheckbox = nullptr;
|
||||
CheckboxLabel* GLESCheckbox = nullptr;
|
||||
#endif
|
||||
PushButton* PlayButton = nullptr;
|
||||
PushButton* ExitButton = nullptr;
|
||||
ListView* GamesList = nullptr;
|
||||
|
|
Loading…
Reference in a new issue