Hide the additional parameters field as it is not implemented

This commit is contained in:
Magnus Norddahl 2024-01-18 11:59:10 +01:00
commit fbceb44b60
4 changed files with 41 additions and 1 deletions

View file

@ -815,6 +815,8 @@ int LineEdit::GetCharacterIndex(double mouse_x)
void LineEdit::UpdateTextClipping()
{
Canvas* canvas = GetCanvas();
if (!canvas)
return;
Size text_size = GetVisualTextSize(canvas, clip_start_offset, (int)text.size() - clip_start_offset);

View file

@ -7,10 +7,15 @@
#include "version.h"
#include "i_interface.h"
#include "gstrings.h"
#include "c_cvars.h"
#include <zwidget/core/resourcedata.h>
#include <zwidget/window/window.h>
#include <zwidget/widgets/tabwidget/tabwidget.h>
#if defined(EXTRAARGS)
CVAR(String, additional_parameters, "", CVAR_ARCHIVE | CVAR_NOSET | CVAR_GLOBALCONFIG);
#endif
int LauncherWindow::ExecModal(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags)
{
Size screenSize = GetScreenSize();
@ -46,6 +51,10 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
UpdateLanguage();
#if defined(EXTRAARGS)
PlayGame->SetExtraArgs(static_cast<FString>(additional_parameters).GetChars());
#endif
Pages->SetCurrentWidget(PlayGame);
PlayGame->SetFocus();
}
@ -54,11 +63,15 @@ void LauncherWindow::Start()
{
Settings->Save();
#if defined(EXTRAARGS)
std::string extraargs = PlayGame->GetExtraArgs();
if (!extraargs.empty())
if (extraargs != static_cast<FString>(additional_parameters).GetChars())
{
additional_parameters = extraargs.c_str();
// To do: restart the process like the cocoa backend is doing?
}
#endif
ExecResult = PlayGame->GetSelectedGame();
DisplayWindow::ExitLoop();

View file

@ -12,9 +12,13 @@ PlayGamePage::PlayGamePage(LauncherWindow* launcher, WadStuff* wads, int numwads
{
WelcomeLabel = new TextLabel(this);
SelectLabel = new TextLabel(this);
#if defined(EXTRAARGS)
ParametersLabel = new TextLabel(this);
#endif
GamesList = new ListView(this);
#if defined(EXTRAARGS)
ParametersEdit = new LineEdit(this);
#endif
for (int i = 0; i < numwads; i++)
{
@ -40,10 +44,17 @@ PlayGamePage::PlayGamePage(LauncherWindow* launcher, WadStuff* wads, int numwads
GamesList->OnActivated = [=]() { OnGamesListActivated(); };
}
#if defined(EXTRAARGS)
void PlayGamePage::SetExtraArgs(const std::string& args)
{
ParametersEdit->SetText(args);
}
std::string PlayGamePage::GetExtraArgs()
{
return ParametersEdit->GetText();
}
#endif
int PlayGamePage::GetSelectedGame()
{
@ -53,7 +64,9 @@ int PlayGamePage::GetSelectedGame()
void PlayGamePage::UpdateLanguage()
{
SelectLabel->SetText(GStrings("PICKER_SELECT"));
#if defined(EXTRAARGS)
ParametersLabel->SetText(GStrings("PICKER_ADDPARM"));
#endif
FString welcomeText = GStrings("PICKER_WELCOME");
welcomeText.Substitute("%s", GAMENAME);
WelcomeLabel->SetText(welcomeText.GetChars());
@ -85,6 +98,7 @@ void PlayGamePage::OnGeometryChanged()
y = GetHeight() - 10.0;
#if defined(EXTRAARGS)
double editHeight = 24.0;
y -= editHeight;
ParametersEdit->SetFrameGeometry(0.0, y, GetWidth(), editHeight);
@ -94,6 +108,7 @@ void PlayGamePage::OnGeometryChanged()
y -= labelHeight;
ParametersLabel->SetFrameGeometry(0.0, y, GetWidth(), labelHeight);
y -= 10.0;
#endif
double listViewBottom = y - 10.0;
GamesList->SetFrameGeometry(0.0, listViewTop, GetWidth(), std::max(listViewBottom - listViewTop, 0.0));

View file

@ -2,6 +2,8 @@
#include <zwidget/core/widget.h>
// #define EXTRAARGS
class LauncherWindow;
class TextLabel;
class ListView;
@ -14,7 +16,11 @@ public:
PlayGamePage(LauncherWindow* launcher, WadStuff* wads, int numwads, int defaultiwad);
void UpdateLanguage();
#if defined(EXTRAARGS)
void SetExtraArgs(const std::string& args);
std::string GetExtraArgs();
#endif
int GetSelectedGame();
private:
@ -26,7 +32,11 @@ private:
TextLabel* WelcomeLabel = nullptr;
TextLabel* SelectLabel = nullptr;
#if defined(EXTRAARGS)
TextLabel* ParametersLabel = nullptr;
#endif
ListView* GamesList = nullptr;
#if defined(EXTRAARGS)
LineEdit* ParametersEdit = nullptr;
#endif
};