Add the additional parameters edit control from the mac version

This commit is contained in:
Magnus Norddahl 2024-01-03 04:25:17 +01:00 committed by Christoph Oelckers
parent 9381813eb5
commit 99fc43932b
3 changed files with 30 additions and 7 deletions

View file

@ -1066,8 +1066,8 @@ void LineEdit::OnPaintFrame(Canvas* canvas)
{
double w = GetFrameGeometry().width;
double h = GetFrameGeometry().height;
Colorf bordercolor = Colorf::fromRgba8(200, 200, 200);
canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf::fromRgba8(255, 255, 255));
Colorf bordercolor = Colorf::fromRgba8(100, 100, 100);
canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf::fromRgba8(38, 38, 38));
canvas->fillRect(Rect::xywh(0.0, 0.0, w, 1.0), bordercolor);
canvas->fillRect(Rect::xywh(0.0, h - 1.0, w, 1.0), bordercolor);
canvas->fillRect(Rect::xywh(0.0, 0.0, 1.0, h - 0.0), bordercolor);
@ -1096,21 +1096,21 @@ void LineEdit::OnPaint(Canvas* canvas)
{
// Draw selection box.
Rect selection_rect = GetSelectionRect();
canvas->fillRect(selection_rect, HasFocus() ? Colorf::fromRgba8(153, 201, 239) : Colorf::fromRgba8(229, 235, 241));
canvas->fillRect(selection_rect, HasFocus() ? Colorf::fromRgba8(100, 100, 100) : Colorf::fromRgba8(68, 68, 68));
}
// Draw text before selection
if (!txt_before.empty())
{
canvas->drawText(Point(0.0, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_before);
canvas->drawText(Point(0.0, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(255, 255, 255), txt_before);
}
if (!txt_selected.empty())
{
canvas->drawText(Point(size_before.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_selected);
canvas->drawText(Point(size_before.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(255, 255, 255), txt_selected);
}
if (!txt_after.empty())
{
canvas->drawText(Point(size_before.width + size_selected.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_after);
canvas->drawText(Point(size_before.width + size_selected.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(255, 255, 255), txt_after);
}
// draw cursor
@ -1119,7 +1119,7 @@ void LineEdit::OnPaint(Canvas* canvas)
if (cursor_blink_visible)
{
Rect cursor_rect = GetCursorRect();
canvas->fillRect(cursor_rect, Colorf::fromRgba8(0, 0, 0));
canvas->fillRect(cursor_rect, Colorf::fromRgba8(255, 255, 255));
}
}
}

View file

@ -10,6 +10,7 @@
#include <zwidget/widgets/textlabel/textlabel.h>
#include <zwidget/widgets/pushbutton/pushbutton.h>
#include <zwidget/widgets/checkboxlabel/checkboxlabel.h>
#include <zwidget/widgets/lineedit/lineedit.h>
EXTERN_CVAR(Bool, queryiwad);
@ -42,6 +43,7 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
SelectLabel = new TextLabel(this);
GeneralLabel = new TextLabel(this);
ExtrasLabel = new TextLabel(this);
ParametersLabel = new TextLabel(this);
FullscreenCheckbox = new CheckboxLabel(this);
DisableAutoloadCheckbox = new CheckboxLabel(this);
DontAskAgainCheckbox = new CheckboxLabel(this);
@ -51,6 +53,7 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
PlayButton = new PushButton(this);
ExitButton = new PushButton(this);
GamesList = new ListView(this);
ParametersEdit = new LineEdit(this);
PlayButton->OnClick = [=]() { OnPlayButtonClicked(); };
ExitButton->OnClick = [=]() { OnExitButtonClicked(); };
@ -68,6 +71,7 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
LightsCheckbox->SetText("Lights");
BrightmapsCheckbox->SetText("Brightmaps");
WidescreenCheckbox->SetText("Widescreen");
ParametersLabel->SetText("Additional Parameters:");
FString welcomeText, versionText;
welcomeText.Format("Welcome to %s!", GAMENAME);
@ -121,6 +125,12 @@ void LauncherWindow::OnPlayButtonClicked()
if (WidescreenCheckbox->GetChecked()) flags |= 8;
*AutoloadFlags = flags;
std::string extraargs = ParametersEdit->GetText();
if (!extraargs.empty())
{
// To do: restart the process like the cocoa backend is doing?
}
ExecResult = GamesList->GetSelectedItem();
DisplayWindow::ExitLoop();
}
@ -164,6 +174,16 @@ void LauncherWindow::OnGeometryChanged()
y -= 20.0;
double editHeight = 24.0;
y -= editHeight;
ParametersEdit->SetFrameGeometry(20.0, y, GetWidth() - 40.0, editHeight);
y -= 5.0;
double labelHeight = ParametersLabel->GetPreferredHeight();
y -= labelHeight;
ParametersLabel->SetFrameGeometry(20.0, y, GetWidth() - 40.0, labelHeight);
y -= 10.0;
double panelWidth = 150.0;
y -= DontAskAgainCheckbox->GetPreferredHeight();
DontAskAgainCheckbox->SetFrameGeometry(20.0, y, 190.0, DontAskAgainCheckbox->GetPreferredHeight());

View file

@ -7,6 +7,7 @@ class TextLabel;
class CheckboxLabel;
class PushButton;
class ListView;
class LineEdit;
struct WadStuff;
class LauncherWindow : public Widget
@ -30,6 +31,7 @@ private:
TextLabel* SelectLabel = nullptr;
TextLabel* GeneralLabel = nullptr;
TextLabel* ExtrasLabel = nullptr;
TextLabel* ParametersLabel = nullptr;
CheckboxLabel* FullscreenCheckbox = nullptr;
CheckboxLabel* DisableAutoloadCheckbox = nullptr;
CheckboxLabel* DontAskAgainCheckbox = nullptr;
@ -39,6 +41,7 @@ private:
PushButton* PlayButton = nullptr;
PushButton* ExitButton = nullptr;
ListView* GamesList = nullptr;
LineEdit* ParametersEdit = nullptr;
int* AutoloadFlags = nullptr;
int ExecResult = -1;