vkdoom_m/src/launcher/launcherbuttonbar.cpp
Boondorl 9701bfaa5c Added multiplayer tab for launcher + backend improvements
Adds a multiplayer tab to allow hosting and joining games from within the GZDoom launcher rather than needed to use the command line. This has its own set of defaults independent from the main play page which necessitated rewriting how this information is passed and stored in the backend. A startup info struct is now passed back which has its defaults set from the cvars and then propagates any changes to it back to the defaults after selection is complete, making it much simpler to interface with the engine defaults.
2025-07-05 18:12:21 -03:00

53 lines
1.4 KiB
C++

#include "launcherbuttonbar.h"
#include "launcherwindow.h"
#include "gstrings.h"
#include <zwidget/widgets/pushbutton/pushbutton.h>
LauncherButtonbar::LauncherButtonbar(LauncherWindow* parent) : Widget(parent)
{
PlayButton = new PushButton(this);
ExitButton = new PushButton(this);
PlayButton->OnClick = [=]() { OnPlayButtonClicked(); };
ExitButton->OnClick = [=]() { OnExitButtonClicked(); };
}
void LauncherButtonbar::UpdateLanguage()
{
auto launcher = GetLauncher();
if (!launcher->IsInMultiplayer())
PlayButton->SetText(GStrings.GetString("PICKER_PLAY"));
else if (launcher->IsHosting())
PlayButton->SetText(GStrings.GetString("PICKER_PLAYHOST"));
else
PlayButton->SetText(GStrings.GetString("PICKER_PLAYJOIN"));
ExitButton->SetText(GStrings.GetString("PICKER_EXIT"));
}
double LauncherButtonbar::GetPreferredHeight() const
{
return 20.0 + std::max(PlayButton->GetPreferredHeight(), ExitButton->GetPreferredHeight());
}
void LauncherButtonbar::OnGeometryChanged()
{
PlayButton->SetFrameGeometry(20.0, 10.0, 120.0, PlayButton->GetPreferredHeight());
ExitButton->SetFrameGeometry(GetWidth() - 20.0 - 120.0, 10.0, 120.0, PlayButton->GetPreferredHeight());
}
void LauncherButtonbar::OnPlayButtonClicked()
{
GetLauncher()->Start();
}
void LauncherButtonbar::OnExitButtonClicked()
{
GetLauncher()->Exit();
}
LauncherWindow* LauncherButtonbar::GetLauncher() const
{
return static_cast<LauncherWindow*>(Parent());
}