2024-01-04 19:37:57 +00:00
|
|
|
#include "launcherwindow.h"
|
2024-01-11 23:22:08 +00:00
|
|
|
#include "launcherbanner.h"
|
|
|
|
#include "launcherbuttonbar.h"
|
|
|
|
#include "playgamepage.h"
|
|
|
|
#include "settingspage.h"
|
2024-01-04 19:37:57 +00:00
|
|
|
#include "v_video.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "i_interface.h"
|
2024-01-11 23:22:08 +00:00
|
|
|
#include "gstrings.h"
|
|
|
|
#include <zwidget/core/resourcedata.h>
|
2024-01-04 19:37:57 +00:00
|
|
|
#include <zwidget/window/window.h>
|
2024-01-11 23:22:08 +00:00
|
|
|
#include <zwidget/widgets/tabwidget/tabwidget.h>
|
2024-01-04 19:37:57 +00:00
|
|
|
|
|
|
|
int LauncherWindow::ExecModal(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags)
|
|
|
|
{
|
|
|
|
Size screenSize = GetScreenSize();
|
|
|
|
double windowWidth = 615.0;
|
2024-01-11 23:22:08 +00:00
|
|
|
double windowHeight = 700.0;
|
2024-01-04 19:37:57 +00:00
|
|
|
|
|
|
|
auto launcher = std::make_unique<LauncherWindow>(wads, numwads, defaultiwad, autoloadflags);
|
|
|
|
launcher->SetFrameGeometry((screenSize.width - windowWidth) * 0.5, (screenSize.height - windowHeight) * 0.5, windowWidth, windowHeight);
|
|
|
|
launcher->Show();
|
|
|
|
|
|
|
|
DisplayWindow::RunLoop();
|
|
|
|
|
|
|
|
return launcher->ExecResult;
|
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags) : Widget(nullptr, WidgetType::Window)
|
2024-01-04 19:37:57 +00:00
|
|
|
{
|
|
|
|
SetWindowBackground(Colorf::fromRgba8(51, 51, 51));
|
|
|
|
SetWindowBorderColor(Colorf::fromRgba8(51, 51, 51));
|
|
|
|
SetWindowCaptionColor(Colorf::fromRgba8(33, 33, 33));
|
|
|
|
SetWindowCaptionTextColor(Colorf::fromRgba8(226, 223, 219));
|
|
|
|
SetWindowTitle(GAMENAME);
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
Banner = new LauncherBanner(this);
|
|
|
|
Pages = new TabWidget(this);
|
|
|
|
Buttonbar = new LauncherButtonbar(this);
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
PlayGame = new PlayGamePage(this, wads, numwads, defaultiwad);
|
|
|
|
Settings = new SettingsPage(this, autoloadflags);
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
Pages->AddTab(PlayGame, "Play");
|
|
|
|
Pages->AddTab(Settings, "Settings");
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
UpdateLanguage();
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
Pages->SetCurrentWidget(PlayGame);
|
|
|
|
PlayGame->SetFocus();
|
2024-01-04 19:37:57 +00:00
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
void LauncherWindow::Start()
|
2024-01-04 19:37:57 +00:00
|
|
|
{
|
2024-01-11 23:22:08 +00:00
|
|
|
Settings->Save();
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
std::string extraargs = PlayGame->GetExtraArgs();
|
2024-01-04 19:37:57 +00:00
|
|
|
if (!extraargs.empty())
|
|
|
|
{
|
|
|
|
// To do: restart the process like the cocoa backend is doing?
|
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
ExecResult = PlayGame->GetSelectedGame();
|
2024-01-04 19:37:57 +00:00
|
|
|
DisplayWindow::ExitLoop();
|
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
void LauncherWindow::Exit()
|
2024-01-04 19:37:57 +00:00
|
|
|
{
|
|
|
|
ExecResult = -1;
|
|
|
|
DisplayWindow::ExitLoop();
|
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
void LauncherWindow::UpdateLanguage()
|
2024-01-04 19:37:57 +00:00
|
|
|
{
|
2024-01-11 23:22:08 +00:00
|
|
|
Pages->SetTabText(PlayGame, GStrings("PICKER_TAB_PLAY"));
|
|
|
|
Pages->SetTabText(Settings, GStrings("OPTMNU_TITLE"));
|
|
|
|
Banner->UpdateLanguage();
|
|
|
|
PlayGame->UpdateLanguage();
|
|
|
|
Settings->UpdateLanguage();
|
|
|
|
Buttonbar->UpdateLanguage();
|
2024-01-04 19:37:57 +00:00
|
|
|
}
|
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
void LauncherWindow::OnClose()
|
2024-01-04 19:37:57 +00:00
|
|
|
{
|
2024-01-11 23:22:08 +00:00
|
|
|
Exit();
|
|
|
|
}
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
void LauncherWindow::OnGeometryChanged()
|
|
|
|
{
|
|
|
|
double top = 0.0;
|
|
|
|
double bottom = GetHeight();
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
Banner->SetFrameGeometry(0.0, top, GetWidth(), Banner->GetPreferredHeight());
|
|
|
|
top += Banner->GetPreferredHeight();
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
bottom -= Buttonbar->GetPreferredHeight();
|
|
|
|
Buttonbar->SetFrameGeometry(0.0, bottom, GetWidth(), Buttonbar->GetPreferredHeight());
|
2024-01-04 19:37:57 +00:00
|
|
|
|
2024-01-11 23:22:08 +00:00
|
|
|
Pages->SetFrameGeometry(0.0, top, GetWidth(), std::max(bottom - top, 0.0));
|
2024-01-04 19:37:57 +00:00
|
|
|
}
|