Prevent misconfigured Triforce launches and warn on mismatched hardware

This commit is contained in:
crediar 2025-07-17 14:36:20 +02:00
commit 001b94a6e2

View file

@ -815,12 +815,12 @@ void MainWindow::ChangeDisc()
if (paths.empty()) if (paths.empty())
return; return;
m_system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{m_system}, paths); m_system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{ m_system }, paths);
} }
void MainWindow::EjectDisc() void MainWindow::EjectDisc()
{ {
m_system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{m_system}, DVD::EjectCause::User); m_system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{ m_system }, DVD::EjectCause::User);
} }
void MainWindow::OpenUserFolder() void MainWindow::OpenUserFolder()
@ -1099,7 +1099,7 @@ void MainWindow::ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
{ {
auto second_game = m_game_list->FindSecondDisc(game); auto second_game = m_game_list->FindSecondDisc(game);
std::vector<std::string> paths = {game.GetFilePath()}; std::vector<std::string> paths = { game.GetFilePath() };
if (second_game != nullptr) if (second_game != nullptr)
paths.push_back(second_game->GetFilePath()); paths.push_back(second_game->GetFilePath());
@ -1147,6 +1147,39 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
} }
} }
/*
When booting Triforce games, we need to ensure that the hardware is set up correctly.
*/
const auto volume_type =
std::get<BootParameters::Disc>(parameters->parameters).volume->GetVolumeType();
const bool triforce_hardware_sp1 = Config::Get(Config::MAIN_SERIAL_PORT_1) == ExpansionInterface::EXIDeviceType::Baseboard;
const bool triforce_hardware_port_1 = Config::Get(Config::GetInfoForSIDevice(0)) == SerialInterface::SIDevices::SIDEVICE_AM_BASEBOARD;
if (volume_type == DiscIO::Platform::Triforce)
{
if (!triforce_hardware_sp1 || !triforce_hardware_port_1)
{
ModalMessageBox::critical(
this, tr("Error"), tr("To boot a Triforce game, SP1 and Port 1 must be set to Triforce Baseboard."),
QMessageBox::Ok);
HideRenderWidget();
return;
}
}
else
{
/*
Some Triforce tools don't include a boot.id file, but they can still be launched.
*/
if (triforce_hardware_sp1 || triforce_hardware_port_1)
{
ModalMessageBox::warning(
this, tr("Warning"), tr("Non-Triforce games cannot be booted with Triforce hardware attached."),
QMessageBox::Ok);
}
}
// If we're running, only start a new game once we've stopped the last. // If we're running, only start a new game once we've stopped the last.
if (!Core::IsUninitialized(m_system)) if (!Core::IsUninitialized(m_system))
{ {
@ -1337,7 +1370,7 @@ void MainWindow::ShowGeneralWindow()
void MainWindow::ShowAboutDialog() void MainWindow::ShowAboutDialog()
{ {
AboutDialog about{this}; AboutDialog about{ this };
about.exec(); about.exec();
} }
@ -1524,7 +1557,7 @@ void MainWindow::PerformOnlineUpdate(const std::string& region)
void MainWindow::BootWiiSystemMenu() void MainWindow::BootWiiSystemMenu()
{ {
StartGame(std::make_unique<BootParameters>(BootParameters::NANDTitle{Titles::SYSTEM_MENU})); StartGame(std::make_unique<BootParameters>(BootParameters::NANDTitle{ Titles::SYSTEM_MENU }));
} }
void MainWindow::NetPlayInit() void MainWindow::NetPlayInit()
@ -1608,8 +1641,8 @@ bool MainWindow::NetPlayJoin()
const bool is_hosting_netplay = server != nullptr; const bool is_hosting_netplay = server != nullptr;
Settings::Instance().ResetNetPlayClient(new NetPlay::NetPlayClient( Settings::Instance().ResetNetPlayClient(new NetPlay::NetPlayClient(
host_ip, host_port, m_netplay_dialog, nickname, host_ip, host_port, m_netplay_dialog, nickname,
NetPlay::NetTraversalConfig{is_hosting_netplay ? false : is_traversal, traversal_host, NetPlay::NetTraversalConfig{ is_hosting_netplay ? false : is_traversal, traversal_host,
traversal_port})); traversal_port }));
if (!Settings::Instance().GetNetPlayClient()->IsConnected()) if (!Settings::Instance().GetNetPlayClient()->IsConnected())
{ {
@ -1655,8 +1688,8 @@ bool MainWindow::NetPlayHost(const UICommon::GameFile& game)
// Create Server // Create Server
Settings::Instance().ResetNetPlayServer( Settings::Instance().ResetNetPlayServer(
new NetPlay::NetPlayServer(host_port, use_upnp, m_netplay_dialog, new NetPlay::NetPlayServer(host_port, use_upnp, m_netplay_dialog,
NetPlay::NetTraversalConfig{is_traversal, traversal_host, NetPlay::NetTraversalConfig{ is_traversal, traversal_host,
traversal_port, traversal_port_alt})); traversal_port, traversal_port_alt }));
if (!Settings::Instance().GetNetPlayServer()->is_connected) if (!Settings::Instance().GetNetPlayServer()->is_connected)
{ {
@ -1778,7 +1811,7 @@ QSize MainWindow::sizeHint() const
void MainWindow::OnBootGameCubeIPL(DiscIO::Region region) void MainWindow::OnBootGameCubeIPL(DiscIO::Region region)
{ {
StartGame(std::make_unique<BootParameters>(BootParameters::IPL{region})); StartGame(std::make_unique<BootParameters>(BootParameters::IPL{ region }));
} }
void MainWindow::OnImportNANDBackup() void MainWindow::OnImportNANDBackup()
@ -1999,7 +2032,7 @@ void MainWindow::ShowAchievementsWindow()
m_achievements_window->show(); m_achievements_window->show();
m_achievements_window->raise(); m_achievements_window->raise();
m_achievements_window->activateWindow(); m_achievements_window->activateWindow();
m_achievements_window->UpdateData(AchievementManager::UpdatedItems{.all = true}); m_achievements_window->UpdateData(AchievementManager::UpdatedItems{ .all = true });
} }
void MainWindow::ShowAchievementSettings() void MainWindow::ShowAchievementSettings()
@ -2043,7 +2076,7 @@ void MainWindow::ShowCheatsManager()
void MainWindow::ShowRiivolutionBootWidget(const UICommon::GameFile& game) void MainWindow::ShowRiivolutionBootWidget(const UICommon::GameFile& game)
{ {
auto second_game = m_game_list->FindSecondDisc(game); auto second_game = m_game_list->FindSecondDisc(game);
std::vector<std::string> paths = {game.GetFilePath()}; std::vector<std::string> paths = { game.GetFilePath() };
if (second_game != nullptr) if (second_game != nullptr)
paths.push_back(second_game->GetFilePath()); paths.push_back(second_game->GetFilePath());
std::unique_ptr<BootParameters> boot_params = BootParameters::GenerateFromFile(paths); std::unique_ptr<BootParameters> boot_params = BootParameters::GenerateFromFile(paths);