2015-11-27 01:33:07 -07:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-11-27 01:33:07 -07:00
|
|
|
|
2021-12-09 19:22:16 -07:00
|
|
|
#include "DolphinQt/MainWindow.h"
|
|
|
|
|
2017-06-15 17:42:12 -06:00
|
|
|
#include <QApplication>
|
2017-06-24 09:00:37 -06:00
|
|
|
#include <QCloseEvent>
|
2017-12-31 12:33:36 -07:00
|
|
|
#include <QDateTime>
|
2023-01-16 01:36:24 -07:00
|
|
|
#include <QDesktopServices>
|
2015-11-27 01:33:07 -07:00
|
|
|
#include <QDir>
|
2017-06-26 15:22:40 -06:00
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QDropEvent>
|
|
|
|
#include <QFileInfo>
|
2015-11-27 01:33:07 -07:00
|
|
|
#include <QIcon>
|
2017-06-26 15:22:40 -06:00
|
|
|
#include <QMimeData>
|
2018-07-14 21:20:59 -06:00
|
|
|
#include <QStackedWidget>
|
2023-04-25 01:12:59 -06:00
|
|
|
#include <QStyleHints>
|
2018-03-21 04:13:53 -06:00
|
|
|
#include <QVBoxLayout>
|
2018-10-03 07:03:22 -06:00
|
|
|
#include <QWindow>
|
2017-08-24 09:38:31 -06:00
|
|
|
|
2022-10-11 20:21:51 -06:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2017-08-24 09:38:31 -06:00
|
|
|
#include <future>
|
2017-12-25 10:07:29 -07:00
|
|
|
#include <optional>
|
2020-06-15 05:16:01 -06:00
|
|
|
#include <variant>
|
2015-11-27 01:33:07 -07:00
|
|
|
|
2018-05-22 13:30:54 -06:00
|
|
|
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "QtUtils/SignalDaemon.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-19 00:25:57 -06:00
|
|
|
#ifndef _WIN32
|
2018-10-03 07:03:13 -06:00
|
|
|
#include <qpa/qplatformnativeinterface.h>
|
|
|
|
#endif
|
|
|
|
|
2019-11-10 15:58:39 -07:00
|
|
|
#include "Common/ScopeGuard.h"
|
2017-09-09 13:52:35 -06:00
|
|
|
#include "Common/Version.h"
|
2018-10-03 07:03:22 -06:00
|
|
|
#include "Common/WindowSystemInfo.h"
|
2017-06-05 12:36:30 -06:00
|
|
|
|
2023-03-18 10:38:53 -06:00
|
|
|
#include "Core/AchievementManager.h"
|
2017-05-27 07:43:40 -06:00
|
|
|
#include "Core/Boot/Boot.h"
|
2015-11-27 01:33:07 -07:00
|
|
|
#include "Core/BootManager.h"
|
2017-07-06 03:01:32 -06:00
|
|
|
#include "Core/CommonTitles.h"
|
2023-06-17 12:13:38 -06:00
|
|
|
#include "Core/Config/AchievementSettings.h"
|
2018-07-06 19:29:46 -06:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-07-21 14:48:21 -06:00
|
|
|
#include "Core/Config/NetplaySettings.h"
|
2024-02-05 17:41:25 -07:00
|
|
|
#include "Core/Config/UISettings.h"
|
2022-01-25 12:34:03 -07:00
|
|
|
#include "Core/Config/WiimoteSettings.h"
|
2015-11-27 01:33:07 -07:00
|
|
|
#include "Core/Core.h"
|
2020-06-11 23:27:34 -06:00
|
|
|
#include "Core/FreeLookManager.h"
|
2018-03-22 18:18:53 -06:00
|
|
|
#include "Core/HW/DVD/DVDInterface.h"
|
2021-07-04 05:02:03 -06:00
|
|
|
#include "Core/HW/GBAPad.h"
|
2017-05-23 14:12:01 -06:00
|
|
|
#include "Core/HW/GCKeyboard.h"
|
|
|
|
#include "Core/HW/GCPad.h"
|
2016-02-14 18:56:40 -07:00
|
|
|
#include "Core/HW/ProcessorInterface.h"
|
2019-06-07 16:25:32 -06:00
|
|
|
#include "Core/HW/SI/SI_Device.h"
|
2017-05-23 14:12:01 -06:00
|
|
|
#include "Core/HW/Wiimote.h"
|
|
|
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
|
|
|
#include "Core/HotkeyManager.h"
|
2018-01-24 07:25:35 -07:00
|
|
|
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
|
|
|
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
2016-02-14 18:56:40 -07:00
|
|
|
#include "Core/Movie.h"
|
2017-07-21 14:48:21 -06:00
|
|
|
#include "Core/NetPlayClient.h"
|
2017-05-09 10:49:10 -06:00
|
|
|
#include "Core/NetPlayProto.h"
|
2017-07-21 14:48:21 -06:00
|
|
|
#include "Core/NetPlayServer.h"
|
2016-02-14 18:56:40 -07:00
|
|
|
#include "Core/State.h"
|
2023-01-03 18:52:40 -07:00
|
|
|
#include "Core/System.h"
|
2021-04-12 04:49:29 -06:00
|
|
|
#include "Core/WiiUtils.h"
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2021-09-25 22:17:51 -06:00
|
|
|
#include "DiscIO/DirectoryBlob.h"
|
2017-08-24 09:38:31 -06:00
|
|
|
#include "DiscIO/NANDImporter.h"
|
2021-09-25 22:17:51 -06:00
|
|
|
#include "DiscIO/RiivolutionPatcher.h"
|
2017-08-24 09:38:31 -06:00
|
|
|
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/AboutDialog.h"
|
2023-05-26 07:35:50 -06:00
|
|
|
#include "DolphinQt/Achievements/AchievementsWindow.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/CheatsManager.h"
|
|
|
|
#include "DolphinQt/Config/ControllersWindow.h"
|
2020-06-11 23:27:34 -06:00
|
|
|
#include "DolphinQt/Config/FreeLookWindow.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
|
|
|
|
#include "DolphinQt/Config/LogConfigWidget.h"
|
|
|
|
#include "DolphinQt/Config/LogWidget.h"
|
|
|
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
|
|
|
#include "DolphinQt/Config/SettingsWindow.h"
|
2022-12-18 01:43:28 -07:00
|
|
|
#include "DolphinQt/Debugger/AssemblerWidget.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Debugger/BreakpointWidget.h"
|
|
|
|
#include "DolphinQt/Debugger/CodeViewWidget.h"
|
|
|
|
#include "DolphinQt/Debugger/CodeWidget.h"
|
|
|
|
#include "DolphinQt/Debugger/JITWidget.h"
|
|
|
|
#include "DolphinQt/Debugger/MemoryWidget.h"
|
2020-04-19 13:30:50 -06:00
|
|
|
#include "DolphinQt/Debugger/NetworkWidget.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Debugger/RegisterWidget.h"
|
2020-03-21 01:48:49 -06:00
|
|
|
#include "DolphinQt/Debugger/ThreadWidget.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Debugger/WatchWidget.h"
|
2018-07-03 15:50:08 -06:00
|
|
|
#include "DolphinQt/DiscordHandler.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/FIFO/FIFOPlayerWindow.h"
|
|
|
|
#include "DolphinQt/GCMemcardManager.h"
|
2018-07-14 21:20:59 -06:00
|
|
|
#include "DolphinQt/GameList/GameList.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Host.h"
|
|
|
|
#include "DolphinQt/HotkeyScheduler.h"
|
2023-01-24 14:51:02 -07:00
|
|
|
#include "DolphinQt/InfinityBase/InfinityBaseWindow.h"
|
2018-07-14 21:20:59 -06:00
|
|
|
#include "DolphinQt/MenuBar.h"
|
2020-06-15 05:16:01 -06:00
|
|
|
#include "DolphinQt/NKitWarningDialog.h"
|
2019-03-30 07:50:57 -06:00
|
|
|
#include "DolphinQt/NetPlay/NetPlayBrowser.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/NetPlay/NetPlayDialog.h"
|
|
|
|
#include "DolphinQt/NetPlay/NetPlaySetupDialog.h"
|
2021-10-09 20:28:59 -06:00
|
|
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
2019-06-11 15:00:02 -06:00
|
|
|
#include "DolphinQt/QtUtils/FileOpenEventFilter.h"
|
2019-03-04 12:49:00 -07:00
|
|
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
2020-03-29 16:28:16 -06:00
|
|
|
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
|
|
|
#include "DolphinQt/QtUtils/RunOnObject.h"
|
2023-07-30 16:42:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/QtUtils/WindowActivationEventFilter.h"
|
2018-07-14 21:20:59 -06:00
|
|
|
#include "DolphinQt/RenderWidget.h"
|
2018-11-17 08:36:28 -07:00
|
|
|
#include "DolphinQt/ResourcePackManager.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/Resources.h"
|
2021-09-25 22:17:51 -06:00
|
|
|
#include "DolphinQt/RiivolutionBootWidget.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/SearchBar.h"
|
|
|
|
#include "DolphinQt/Settings.h"
|
2023-01-07 15:54:36 -07:00
|
|
|
#include "DolphinQt/SkylanderPortal/SkylanderPortalWindow.h"
|
2022-11-19 03:16:10 -07:00
|
|
|
#include "DolphinQt/TAS/GBATASInputWindow.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/TAS/GCTASInputWindow.h"
|
|
|
|
#include "DolphinQt/TAS/WiiTASInputWindow.h"
|
2018-07-14 21:20:59 -06:00
|
|
|
#include "DolphinQt/ToolBar.h"
|
2018-07-06 16:40:15 -06:00
|
|
|
#include "DolphinQt/WiiUpdate.h"
|
2015-11-27 01:33:07 -07:00
|
|
|
|
2017-05-23 14:12:01 -06:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2022-03-08 14:16:54 -07:00
|
|
|
#include "InputCommon/GCAdapter.h"
|
2017-05-23 14:12:01 -06:00
|
|
|
|
2018-05-26 22:24:13 -06:00
|
|
|
#include "UICommon/DiscordPresence.h"
|
2018-07-10 13:37:55 -06:00
|
|
|
#include "UICommon/GameFile.h"
|
2018-11-17 08:36:28 -07:00
|
|
|
#include "UICommon/ResourcePack/Manager.h"
|
|
|
|
#include "UICommon/ResourcePack/Manifest.h"
|
|
|
|
#include "UICommon/ResourcePack/ResourcePack.h"
|
|
|
|
|
2017-06-24 09:00:37 -06:00
|
|
|
#include "UICommon/UICommon.h"
|
|
|
|
|
2019-03-24 08:57:36 -06:00
|
|
|
#include "VideoCommon/NetPlayChatUI.h"
|
2018-05-31 20:05:59 -06:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
2021-02-22 06:32:53 -07:00
|
|
|
#ifdef HAVE_XRANDR
|
2017-06-15 17:42:12 -06:00
|
|
|
#include "UICommon/X11Utils.h"
|
2019-11-12 17:50:16 -07:00
|
|
|
// This #define within X11/X.h conflicts with our WiimoteSource enum.
|
|
|
|
#undef None
|
2017-06-15 17:42:12 -06:00
|
|
|
#endif
|
|
|
|
|
2018-05-22 13:30:54 -06:00
|
|
|
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
|
|
|
void MainWindow::OnSignal()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InstallSignalHandler()
|
|
|
|
{
|
|
|
|
struct sigaction sa;
|
|
|
|
sa.sa_handler = &SignalDaemon::HandleInterrupt;
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
sa.sa_flags = SA_RESETHAND;
|
|
|
|
sigaction(SIGINT, &sa, nullptr);
|
|
|
|
sigaction(SIGTERM, &sa, nullptr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-03 07:03:22 -06:00
|
|
|
static WindowSystemType GetWindowSystemType()
|
|
|
|
{
|
|
|
|
// Determine WSI type based on Qt platform.
|
|
|
|
QString platform_name = QGuiApplication::platformName();
|
|
|
|
if (platform_name == QStringLiteral("windows"))
|
|
|
|
return WindowSystemType::Windows;
|
|
|
|
else if (platform_name == QStringLiteral("cocoa"))
|
|
|
|
return WindowSystemType::MacOS;
|
|
|
|
else if (platform_name == QStringLiteral("xcb"))
|
|
|
|
return WindowSystemType::X11;
|
|
|
|
else if (platform_name == QStringLiteral("wayland"))
|
|
|
|
return WindowSystemType::Wayland;
|
2020-12-12 13:25:51 -07:00
|
|
|
else if (platform_name == QStringLiteral("haiku"))
|
|
|
|
return WindowSystemType::Haiku;
|
2018-10-03 07:03:22 -06:00
|
|
|
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(
|
2018-10-03 07:03:22 -06:00
|
|
|
nullptr, QStringLiteral("Error"),
|
|
|
|
QString::asprintf("Unknown Qt platform: %s", platform_name.toStdString().c_str()));
|
|
|
|
return WindowSystemType::Headless;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WindowSystemInfo GetWindowSystemInfo(QWindow* window)
|
|
|
|
{
|
|
|
|
WindowSystemInfo wsi;
|
|
|
|
wsi.type = GetWindowSystemType();
|
|
|
|
|
|
|
|
// Our Win32 Qt external doesn't have the private API.
|
2020-12-12 13:25:51 -07:00
|
|
|
#if defined(WIN32) || defined(__APPLE__) || defined(__HAIKU__)
|
2020-03-11 07:09:28 -06:00
|
|
|
wsi.render_window = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
|
|
|
wsi.render_surface = wsi.render_window;
|
2018-10-03 07:03:22 -06:00
|
|
|
#else
|
|
|
|
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
|
|
|
wsi.display_connection = pni->nativeResourceForWindow("display", window);
|
|
|
|
if (wsi.type == WindowSystemType::Wayland)
|
2020-03-11 07:09:28 -06:00
|
|
|
wsi.render_window = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
|
2018-10-03 07:03:22 -06:00
|
|
|
else
|
2020-03-11 07:09:28 -06:00
|
|
|
wsi.render_window = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
|
|
|
wsi.render_surface = wsi.render_window;
|
2018-10-03 07:03:22 -06:00
|
|
|
#endif
|
2019-01-18 07:35:00 -07:00
|
|
|
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
|
2018-10-03 07:03:22 -06:00
|
|
|
|
|
|
|
return wsi;
|
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
static std::vector<std::string> StringListToStdVector(QStringList list)
|
|
|
|
{
|
|
|
|
std::vector<std::string> result;
|
|
|
|
result.reserve(list.size());
|
|
|
|
|
|
|
|
for (const QString& s : list)
|
|
|
|
result.push_back(s.toStdString());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boot_parameters,
|
2019-03-27 07:26:17 -06:00
|
|
|
const std::string& movie_path)
|
2024-10-24 22:41:35 -06:00
|
|
|
: QMainWindow(nullptr), m_system(system)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2022-01-13 16:04:22 -07:00
|
|
|
setWindowTitle(QString::fromStdString(Common::GetScmRevStr()));
|
2018-03-26 00:13:15 -06:00
|
|
|
setWindowIcon(Resources::GetAppIcon());
|
2016-05-04 00:25:53 -06:00
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
2017-06-26 15:22:40 -06:00
|
|
|
setAcceptDrops(true);
|
2018-10-03 01:34:27 -06:00
|
|
|
setAttribute(Qt::WA_NativeWindow);
|
2015-11-27 01:33:07 -07:00
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
CreateComponents();
|
|
|
|
|
|
|
|
ConnectGameList();
|
2018-03-23 19:13:56 -06:00
|
|
|
ConnectHost();
|
2016-02-09 21:42:06 -07:00
|
|
|
ConnectToolBar();
|
|
|
|
ConnectRenderWidget();
|
|
|
|
ConnectStack();
|
|
|
|
ConnectMenuBar();
|
2024-05-22 22:08:26 -06:00
|
|
|
|
|
|
|
QSettings& settings = Settings::GetQSettings();
|
|
|
|
restoreState(settings.value(QStringLiteral("mainwindow/state")).toByteArray());
|
|
|
|
restoreGeometry(settings.value(QStringLiteral("mainwindow/geometry")).toByteArray());
|
2024-06-04 01:26:04 -06:00
|
|
|
if (!Settings::Instance().IsBatchModeEnabled())
|
2024-06-23 11:49:14 -06:00
|
|
|
{
|
|
|
|
SetQWidgetWindowDecorations(this);
|
2024-06-04 01:26:04 -06:00
|
|
|
show();
|
2024-06-23 11:49:14 -06:00
|
|
|
}
|
2024-05-22 22:08:26 -06:00
|
|
|
|
|
|
|
InitControllers();
|
2018-02-14 15:25:01 -07:00
|
|
|
ConnectHotkeys();
|
2017-05-23 14:12:01 -06:00
|
|
|
|
2023-04-25 01:12:59 -06:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
|
|
|
connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this,
|
2024-09-26 10:48:53 -06:00
|
|
|
[this](Qt::ColorScheme colorScheme) {
|
|
|
|
Settings::Instance().ApplyStyle();
|
|
|
|
if (m_skylander_window)
|
|
|
|
m_skylander_window->RefreshList();
|
|
|
|
});
|
2023-04-25 01:12:59 -06:00
|
|
|
#endif
|
|
|
|
|
2021-09-15 22:49:03 -06:00
|
|
|
connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this,
|
|
|
|
&MainWindow::ShowGeneralWindow);
|
|
|
|
|
2023-11-15 10:03:21 -07:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
2023-06-07 19:53:38 -06:00
|
|
|
connect(m_cheats_manager, &CheatsManager::OpenAchievementSettings, this,
|
|
|
|
&MainWindow::ShowAchievementSettings);
|
2023-11-15 10:03:21 -07:00
|
|
|
connect(m_game_list, &GameList::OpenAchievementSettings, this,
|
|
|
|
&MainWindow::ShowAchievementSettings);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2017-06-16 07:27:00 -06:00
|
|
|
InitCoreCallbacks();
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
NetPlayInit();
|
2017-10-01 16:09:07 -06:00
|
|
|
|
2023-06-17 12:13:38 -06:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
2023-12-11 11:18:02 -07:00
|
|
|
AchievementManager::GetInstance().Init();
|
2024-10-03 07:01:00 -06:00
|
|
|
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
|
|
|
Settings::Instance().SetDebugModeEnabled(false);
|
2023-06-17 12:13:38 -06:00
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2018-05-22 13:30:54 -06:00
|
|
|
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
|
|
|
auto* daemon = new SignalDaemon(this);
|
|
|
|
|
|
|
|
connect(daemon, &SignalDaemon::InterruptReceived, this, &MainWindow::OnSignal);
|
|
|
|
|
|
|
|
InstallSignalHandler();
|
|
|
|
#endif
|
|
|
|
|
2017-10-01 16:09:07 -06:00
|
|
|
if (boot_parameters)
|
2019-03-27 07:26:17 -06:00
|
|
|
{
|
2018-05-13 07:03:48 -06:00
|
|
|
m_pending_boot = std::move(boot_parameters);
|
2018-04-19 03:32:00 -06:00
|
|
|
|
2019-03-27 07:26:17 -06:00
|
|
|
if (!movie_path.empty())
|
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
std::optional<std::string> savestate_path;
|
2024-10-24 22:41:35 -06:00
|
|
|
if (m_system.GetMovie().PlayInput(movie_path, &savestate_path))
|
2021-11-20 11:38:09 -07:00
|
|
|
{
|
|
|
|
m_pending_boot->boot_session_data.SetSavestateData(std::move(savestate_path),
|
|
|
|
DeleteSavestateAfterBoot::No);
|
2019-03-27 07:26:17 -06:00
|
|
|
emit RecordingStatusChanged(true);
|
2021-11-20 11:38:09 -07:00
|
|
|
}
|
2019-03-27 07:26:17 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-25 09:18:56 -06:00
|
|
|
m_state_slot =
|
|
|
|
std::clamp(Settings::Instance().GetStateSlot(), 1, static_cast<int>(State::NUM_STATES));
|
|
|
|
|
2018-05-12 16:59:09 -06:00
|
|
|
m_render_widget_geometry = settings.value(QStringLiteral("renderwidget/geometry")).toByteArray();
|
2018-08-19 16:39:57 -06:00
|
|
|
|
|
|
|
// Restoring of window states can sometimes go wrong, resulting in widgets being visible when they
|
|
|
|
// shouldn't be so we have to reapply all our rules afterwards.
|
|
|
|
Settings::Instance().RefreshWidgetVisibility();
|
2018-11-17 08:36:28 -07:00
|
|
|
|
|
|
|
if (!ResourcePack::Init())
|
2021-08-24 09:10:47 -06:00
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(this, tr("Error"),
|
2021-08-24 09:10:47 -06:00
|
|
|
tr("Error occurred while loading some texture packs"));
|
|
|
|
}
|
2018-11-17 08:36:28 -07:00
|
|
|
|
|
|
|
for (auto& pack : ResourcePack::GetPacks())
|
|
|
|
{
|
|
|
|
if (!pack.IsValid())
|
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(this, tr("Error"),
|
|
|
|
tr("Invalid Pack %1 provided: %2")
|
|
|
|
.arg(QString::fromStdString(pack.GetPath()))
|
|
|
|
.arg(QString::fromStdString(pack.GetError())));
|
2018-11-17 08:36:28 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-05-09 04:28:04 -06:00
|
|
|
|
|
|
|
Host::GetInstance()->SetMainWindowHandle(reinterpret_cast<void*>(winId()));
|
2024-06-23 11:49:14 -06:00
|
|
|
|
|
|
|
if (m_pending_boot != nullptr)
|
|
|
|
{
|
|
|
|
StartGame(std::move(m_pending_boot));
|
|
|
|
m_pending_boot.reset();
|
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2016-02-14 18:04:16 -07:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2019-04-05 01:12:25 -06:00
|
|
|
// Shut down NetPlay first to avoid race condition segfault
|
|
|
|
Settings::Instance().ResetNetPlayClient();
|
|
|
|
Settings::Instance().ResetNetPlayServer();
|
|
|
|
|
2023-03-18 10:38:53 -06:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
2023-12-11 11:18:02 -07:00
|
|
|
AchievementManager::GetInstance().Shutdown();
|
2023-03-18 10:38:53 -06:00
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2019-01-19 02:37:07 -07:00
|
|
|
delete m_render_widget;
|
|
|
|
delete m_netplay_dialog;
|
2018-08-13 06:15:09 -06:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2019-01-19 02:37:07 -07:00
|
|
|
delete m_gc_tas_input_windows[i];
|
2022-11-19 03:16:10 -07:00
|
|
|
delete m_gba_tas_input_windows[i];
|
2019-01-19 02:37:07 -07:00
|
|
|
delete m_wii_tas_input_windows[i];
|
2018-08-13 06:15:09 -06:00
|
|
|
}
|
|
|
|
|
2017-05-31 22:11:54 -06:00
|
|
|
ShutdownControllers();
|
2017-09-13 11:33:45 -06:00
|
|
|
|
2018-04-19 03:32:00 -06:00
|
|
|
QSettings& settings = Settings::GetQSettings();
|
|
|
|
|
2024-06-07 04:58:00 -06:00
|
|
|
if (!Settings::Instance().IsBatchModeEnabled())
|
|
|
|
{
|
|
|
|
settings.setValue(QStringLiteral("mainwindow/state"), saveState());
|
|
|
|
settings.setValue(QStringLiteral("mainwindow/geometry"), saveGeometry());
|
|
|
|
}
|
2018-05-08 08:00:20 -06:00
|
|
|
|
2018-05-12 16:59:09 -06:00
|
|
|
settings.setValue(QStringLiteral("renderwidget/geometry"), m_render_widget_geometry);
|
2018-05-10 04:05:58 -06:00
|
|
|
|
|
|
|
Config::Save();
|
2016-02-14 18:04:16 -07:00
|
|
|
}
|
|
|
|
|
2023-03-25 18:16:53 -06:00
|
|
|
WindowSystemInfo MainWindow::GetWindowSystemInfo() const
|
|
|
|
{
|
|
|
|
return ::GetWindowSystemInfo(m_render_widget->windowHandle());
|
|
|
|
}
|
|
|
|
|
2017-05-23 14:12:01 -06:00
|
|
|
void MainWindow::InitControllers()
|
|
|
|
{
|
|
|
|
if (g_controller_interface.IsInit())
|
|
|
|
return;
|
|
|
|
|
2023-03-25 18:16:53 -06:00
|
|
|
UICommon::InitControllers(::GetWindowSystemInfo(windowHandle()));
|
2021-04-27 15:43:04 -06:00
|
|
|
|
2017-06-06 05:49:49 -06:00
|
|
|
m_hotkey_scheduler = new HotkeyScheduler();
|
|
|
|
m_hotkey_scheduler->Start();
|
2018-05-11 17:31:42 -06:00
|
|
|
|
2021-04-27 15:43:04 -06:00
|
|
|
// Defaults won't work reliably without loading and saving the config first
|
2018-05-11 17:31:42 -06:00
|
|
|
|
|
|
|
Wiimote::LoadConfig();
|
|
|
|
Wiimote::GetConfig()->SaveConfig();
|
|
|
|
|
|
|
|
Pad::LoadConfig();
|
|
|
|
Pad::GetConfig()->SaveConfig();
|
|
|
|
|
2021-07-04 05:02:03 -06:00
|
|
|
Pad::LoadGBAConfig();
|
|
|
|
Pad::GetGBAConfig()->SaveConfig();
|
|
|
|
|
2018-05-11 17:31:42 -06:00
|
|
|
Keyboard::LoadConfig();
|
|
|
|
Keyboard::GetConfig()->SaveConfig();
|
2020-06-11 23:27:34 -06:00
|
|
|
|
|
|
|
FreeLook::LoadInputConfig();
|
|
|
|
FreeLook::GetInputConfig()->SaveConfig();
|
2017-05-23 14:12:01 -06:00
|
|
|
}
|
|
|
|
|
2017-05-31 22:11:54 -06:00
|
|
|
void MainWindow::ShutdownControllers()
|
|
|
|
{
|
2017-06-06 05:49:49 -06:00
|
|
|
m_hotkey_scheduler->Stop();
|
|
|
|
|
2022-06-03 00:32:21 -06:00
|
|
|
Settings::Instance().UnregisterDevicesChangedCallback();
|
|
|
|
|
2021-04-27 15:43:04 -06:00
|
|
|
UICommon::ShutdownControllers();
|
2017-06-06 05:49:49 -06:00
|
|
|
|
|
|
|
m_hotkey_scheduler->deleteLater();
|
|
|
|
}
|
|
|
|
|
2017-06-16 07:27:00 -06:00
|
|
|
void MainWindow::InitCoreCallbacks()
|
|
|
|
{
|
2022-08-07 19:25:19 -06:00
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
|
2017-09-04 11:57:42 -06:00
|
|
|
if (state == Core::State::Uninitialized)
|
2017-09-04 12:12:13 -06:00
|
|
|
OnStopComplete();
|
2018-06-08 11:59:24 -06:00
|
|
|
|
|
|
|
if (state == Core::State::Running && m_fullscreen_requested)
|
|
|
|
{
|
|
|
|
FullScreen();
|
|
|
|
m_fullscreen_requested = false;
|
|
|
|
}
|
2017-09-04 11:57:42 -06:00
|
|
|
});
|
2017-06-24 09:00:37 -06:00
|
|
|
installEventFilter(this);
|
|
|
|
m_render_widget->installEventFilter(this);
|
2019-06-11 15:00:02 -06:00
|
|
|
|
|
|
|
// Handle file open events
|
|
|
|
auto* filter = new FileOpenEventFilter(QGuiApplication::instance());
|
2022-08-07 19:25:19 -06:00
|
|
|
connect(filter, &FileOpenEventFilter::fileOpened, this, [this](const QString& file_name) {
|
2019-06-11 15:00:02 -06:00
|
|
|
StartGame(BootParameters::GenerateFromFile(file_name.toStdString()));
|
|
|
|
});
|
2017-06-16 07:27:00 -06:00
|
|
|
}
|
|
|
|
|
2017-06-14 19:49:56 -06:00
|
|
|
static void InstallHotkeyFilter(QWidget* dialog)
|
2017-06-06 05:49:49 -06:00
|
|
|
{
|
2019-03-17 11:51:50 -06:00
|
|
|
auto* filter = new WindowActivationEventFilter(dialog);
|
2017-06-06 05:49:49 -06:00
|
|
|
dialog->installEventFilter(filter);
|
|
|
|
|
2017-06-14 19:49:56 -06:00
|
|
|
filter->connect(filter, &WindowActivationEventFilter::windowDeactivated,
|
|
|
|
[] { HotkeyManagerEmu::Enable(true); });
|
|
|
|
filter->connect(filter, &WindowActivationEventFilter::windowActivated,
|
|
|
|
[] { HotkeyManagerEmu::Enable(false); });
|
2017-05-31 22:11:54 -06:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::CreateComponents()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2016-02-09 21:42:06 -07:00
|
|
|
m_menu_bar = new MenuBar(this);
|
|
|
|
m_tool_bar = new ToolBar(this);
|
2018-03-21 04:13:53 -06:00
|
|
|
m_search_bar = new SearchBar(this);
|
2016-02-09 21:42:06 -07:00
|
|
|
m_game_list = new GameList(this);
|
2016-02-14 18:04:16 -07:00
|
|
|
m_render_widget = new RenderWidget;
|
2016-02-09 21:42:06 -07:00
|
|
|
m_stack = new QStackedWidget(this);
|
2017-08-30 08:44:28 -06:00
|
|
|
|
2018-01-31 04:35:09 -07:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2018-08-13 06:15:09 -06:00
|
|
|
m_gc_tas_input_windows[i] = new GCTASInputWindow(nullptr, i);
|
2022-11-19 03:16:10 -07:00
|
|
|
m_gba_tas_input_windows[i] = new GBATASInputWindow(nullptr, i);
|
2018-08-13 06:15:09 -06:00
|
|
|
m_wii_tas_input_windows[i] = new WiiTASInputWindow(nullptr, i);
|
2018-01-31 04:35:09 -07:00
|
|
|
}
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
m_jit_widget = new JITWidget(m_system, this);
|
2017-08-27 16:10:06 -06:00
|
|
|
m_log_widget = new LogWidget(this);
|
|
|
|
m_log_config_widget = new LogConfigWidget(this);
|
2024-10-24 22:41:35 -06:00
|
|
|
m_memory_widget = new MemoryWidget(m_system, this);
|
2020-04-19 13:30:50 -06:00
|
|
|
m_network_widget = new NetworkWidget(this);
|
2017-09-13 11:33:45 -06:00
|
|
|
m_register_widget = new RegisterWidget(this);
|
2020-03-21 01:48:49 -06:00
|
|
|
m_thread_widget = new ThreadWidget(this);
|
2017-09-27 00:53:05 -06:00
|
|
|
m_watch_widget = new WatchWidget(this);
|
2017-10-03 10:43:44 -06:00
|
|
|
m_breakpoint_widget = new BreakpointWidget(this);
|
2018-02-14 15:25:01 -07:00
|
|
|
m_code_widget = new CodeWidget(this);
|
2024-10-24 22:41:35 -06:00
|
|
|
m_cheats_manager = new CheatsManager(m_system, this);
|
2022-12-18 01:43:28 -07:00
|
|
|
m_assembler_widget = new AssemblerWidget(this);
|
2017-06-06 05:49:49 -06:00
|
|
|
|
2020-03-21 01:48:49 -06:00
|
|
|
const auto request_watch = [this](QString name, u32 addr) {
|
|
|
|
m_watch_widget->AddWatch(name, addr);
|
|
|
|
};
|
|
|
|
const auto request_breakpoint = [this](u32 addr) { m_breakpoint_widget->AddBP(addr); };
|
|
|
|
const auto request_memory_breakpoint = [this](u32 addr) {
|
|
|
|
m_breakpoint_widget->AddAddressMBP(addr);
|
|
|
|
};
|
|
|
|
const auto request_view_in_memory = [this](u32 addr) { m_memory_widget->SetAddress(addr); };
|
|
|
|
const auto request_view_in_code = [this](u32 addr) {
|
2021-02-14 05:01:32 -07:00
|
|
|
m_code_widget->SetAddress(addr, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
|
2020-03-21 01:48:49 -06:00
|
|
|
};
|
|
|
|
|
2024-04-15 22:52:40 -06:00
|
|
|
connect(m_jit_widget, &JITWidget::SetCodeAddress, m_code_widget, &CodeWidget::OnSetCodeAddress);
|
2020-03-21 01:48:49 -06:00
|
|
|
connect(m_watch_widget, &WatchWidget::RequestMemoryBreakpoint, request_memory_breakpoint);
|
2022-05-27 18:34:47 -06:00
|
|
|
connect(m_watch_widget, &WatchWidget::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress);
|
2020-03-21 01:48:49 -06:00
|
|
|
connect(m_register_widget, &RegisterWidget::RequestMemoryBreakpoint, request_memory_breakpoint);
|
2021-02-17 10:02:23 -07:00
|
|
|
connect(m_register_widget, &RegisterWidget::RequestWatch, request_watch);
|
2020-03-21 01:48:49 -06:00
|
|
|
connect(m_register_widget, &RegisterWidget::RequestViewInMemory, request_view_in_memory);
|
|
|
|
connect(m_register_widget, &RegisterWidget::RequestViewInCode, request_view_in_code);
|
|
|
|
connect(m_thread_widget, &ThreadWidget::RequestBreakpoint, request_breakpoint);
|
|
|
|
connect(m_thread_widget, &ThreadWidget::RequestMemoryBreakpoint, request_memory_breakpoint);
|
|
|
|
connect(m_thread_widget, &ThreadWidget::RequestWatch, request_watch);
|
|
|
|
connect(m_thread_widget, &ThreadWidget::RequestViewInMemory, request_view_in_memory);
|
|
|
|
connect(m_thread_widget, &ThreadWidget::RequestViewInCode, request_view_in_code);
|
2018-03-16 05:39:53 -06:00
|
|
|
|
2024-04-15 22:52:40 -06:00
|
|
|
connect(m_code_widget, &CodeWidget::RequestPPCComparison, m_jit_widget,
|
|
|
|
&JITWidget::OnRequestPPCComparison);
|
2018-12-28 11:12:30 -07:00
|
|
|
connect(m_code_widget, &CodeWidget::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress);
|
|
|
|
connect(m_memory_widget, &MemoryWidget::ShowCode, m_code_widget, [this](u32 address) {
|
2021-02-14 05:01:32 -07:00
|
|
|
m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
|
2018-12-28 11:12:30 -07:00
|
|
|
});
|
2021-02-17 10:12:27 -07:00
|
|
|
connect(m_memory_widget, &MemoryWidget::RequestWatch, request_watch);
|
2018-03-16 05:39:53 -06:00
|
|
|
|
2022-05-27 18:34:47 -06:00
|
|
|
connect(m_breakpoint_widget, &BreakpointWidget::ShowCode, [this](u32 address) {
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::GetState(m_system) == Core::State::Paused)
|
2021-02-14 05:01:32 -07:00
|
|
|
m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
|
2018-05-05 20:55:10 -06:00
|
|
|
});
|
2022-05-27 18:34:47 -06:00
|
|
|
connect(m_breakpoint_widget, &BreakpointWidget::ShowMemory, m_memory_widget,
|
|
|
|
&MemoryWidget::SetAddress);
|
|
|
|
connect(m_cheats_manager, &CheatsManager::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress);
|
2022-12-23 00:07:17 -07:00
|
|
|
connect(m_cheats_manager, &CheatsManager::RequestWatch, request_watch);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::ConnectMenuBar()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2015-12-19 22:24:48 -07:00
|
|
|
setMenuBar(m_menu_bar);
|
2016-02-14 18:56:40 -07:00
|
|
|
// File
|
2015-12-19 22:24:48 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
|
|
|
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
2018-03-22 18:18:53 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::EjectDisc, this, &MainWindow::EjectDisc);
|
|
|
|
connect(m_menu_bar, &MenuBar::ChangeDisc, this, &MainWindow::ChangeDisc);
|
2023-01-16 01:36:24 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::OpenUserFolder, this, &MainWindow::OpenUserFolder);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-02-14 18:56:40 -07:00
|
|
|
// Emulation
|
|
|
|
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
|
2017-12-25 10:07:29 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::Play, this, [this]() { Play(); });
|
2017-07-03 08:04:24 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::Stop, this, &MainWindow::RequestStop);
|
2016-02-14 18:56:40 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::Reset, this, &MainWindow::Reset);
|
|
|
|
connect(m_menu_bar, &MenuBar::Fullscreen, this, &MainWindow::FullScreen);
|
|
|
|
connect(m_menu_bar, &MenuBar::FrameAdvance, this, &MainWindow::FrameAdvance);
|
|
|
|
connect(m_menu_bar, &MenuBar::Screenshot, this, &MainWindow::ScreenShot);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateLoad, this, &MainWindow::StateLoad);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateSave, this, &MainWindow::StateSave);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateLoadSlot, this, &MainWindow::StateLoadSlot);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateSaveSlot, this, &MainWindow::StateSaveSlot);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateLoadSlotAt, this, &MainWindow::StateLoadSlotAt);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateSaveSlotAt, this, &MainWindow::StateSaveSlotAt);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateLoadUndo, this, &MainWindow::StateLoadUndo);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateSaveUndo, this, &MainWindow::StateSaveUndo);
|
|
|
|
connect(m_menu_bar, &MenuBar::StateSaveOldest, this, &MainWindow::StateSaveOldest);
|
|
|
|
connect(m_menu_bar, &MenuBar::SetStateSlot, this, &MainWindow::SetStateSlot);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-06-06 05:49:49 -06:00
|
|
|
// Options
|
2017-07-16 15:11:11 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::Configure, this, &MainWindow::ShowSettingsWindow);
|
|
|
|
connect(m_menu_bar, &MenuBar::ConfigureGraphics, this, &MainWindow::ShowGraphicsWindow);
|
|
|
|
connect(m_menu_bar, &MenuBar::ConfigureAudio, this, &MainWindow::ShowAudioWindow);
|
|
|
|
connect(m_menu_bar, &MenuBar::ConfigureControllers, this, &MainWindow::ShowControllersWindow);
|
2017-06-06 05:49:49 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog);
|
2020-06-11 23:27:34 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ConfigureFreelook, this, &MainWindow::ShowFreeLookWindow);
|
2017-06-06 05:49:49 -06:00
|
|
|
|
2017-06-14 03:58:11 -06:00
|
|
|
// Tools
|
2018-01-25 11:54:50 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowMemcardManager, this, &MainWindow::ShowMemcardManager);
|
2018-11-17 08:36:28 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowResourcePackManager, this,
|
|
|
|
&MainWindow::ShowResourcePackManager);
|
2018-03-25 20:17:47 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowCheatsManager, this, &MainWindow::ShowCheatsManager);
|
2017-08-24 08:35:47 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::BootGameCubeIPL, this, &MainWindow::OnBootGameCubeIPL);
|
2017-08-24 09:38:31 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ImportNANDBackup, this, &MainWindow::OnImportNANDBackup);
|
2017-06-14 03:58:11 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::PerformOnlineUpdate, this, &MainWindow::PerformOnlineUpdate);
|
2017-07-06 03:01:32 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
|
2017-07-21 14:48:21 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::StartNetPlay, this, &MainWindow::ShowNetPlaySetupDialog);
|
2019-03-30 07:50:57 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::BrowseNetPlay, this, &MainWindow::ShowNetPlayBrowser);
|
2017-08-30 08:44:28 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowFIFOPlayer, this, &MainWindow::ShowFIFOPlayer);
|
2023-01-07 15:54:36 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowSkylanderPortal, this, &MainWindow::ShowSkylanderPortal);
|
2023-01-24 14:51:02 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowInfinityBase, this, &MainWindow::ShowInfinityBase);
|
2018-01-24 07:25:35 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote);
|
2017-06-14 03:58:11 -06:00
|
|
|
|
2023-05-26 07:35:50 -06:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
connect(m_menu_bar, &MenuBar::ShowAchievementsWindow, this, &MainWindow::ShowAchievementsWindow);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2017-08-27 05:55:05 -06:00
|
|
|
// Movie
|
|
|
|
connect(m_menu_bar, &MenuBar::PlayRecording, this, &MainWindow::OnPlayRecording);
|
|
|
|
connect(m_menu_bar, &MenuBar::StartRecording, this, &MainWindow::OnStartRecording);
|
|
|
|
connect(m_menu_bar, &MenuBar::StopRecording, this, &MainWindow::OnStopRecording);
|
|
|
|
connect(m_menu_bar, &MenuBar::ExportRecording, this, &MainWindow::OnExportRecording);
|
2018-01-27 06:35:02 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowTASInput, this, &MainWindow::ShowTASInput);
|
2017-08-27 05:55:05 -06:00
|
|
|
|
2016-02-14 18:56:40 -07:00
|
|
|
// View
|
2015-12-19 22:24:48 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
2017-08-05 02:28:53 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
|
2018-10-14 10:03:10 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::PurgeGameListCache, m_game_list, &GameList::PurgeCache);
|
2019-03-17 15:08:59 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowSearch, m_search_bar, &SearchBar::Show);
|
2018-03-21 04:13:53 -06:00
|
|
|
|
2017-05-08 11:03:59 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
|
|
|
|
&GameList::OnColumnVisibilityToggled);
|
2017-06-25 11:40:01 -06:00
|
|
|
|
2017-07-11 08:13:09 -06:00
|
|
|
connect(m_menu_bar, &MenuBar::GameListPlatformVisibilityToggled, m_game_list,
|
|
|
|
&GameList::OnGameListVisibilityChanged);
|
|
|
|
connect(m_menu_bar, &MenuBar::GameListRegionVisibilityToggled, m_game_list,
|
|
|
|
&GameList::OnGameListVisibilityChanged);
|
2017-06-25 11:40:01 -06:00
|
|
|
|
2016-02-11 04:59:44 -07:00
|
|
|
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-08-27 05:55:05 -06:00
|
|
|
connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged);
|
|
|
|
connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged);
|
|
|
|
connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2017-06-06 05:49:49 -06:00
|
|
|
void MainWindow::ConnectHotkeys()
|
|
|
|
{
|
2018-05-09 00:27:04 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::Open, this, &MainWindow::Open);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ChangeDisc, this, &MainWindow::ChangeDisc);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::EjectDisc, this, &MainWindow::EjectDisc);
|
2017-06-06 05:49:49 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close);
|
2021-05-09 04:28:04 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::UnlockCursor, this, &MainWindow::UnlockCursor);
|
2018-02-09 04:54:35 -07:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::TogglePauseHotkey, this, &MainWindow::TogglePause);
|
2019-03-24 08:57:36 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ActivateChat, this, &MainWindow::OnActivateChat);
|
2019-04-02 06:08:27 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::RequestGolfControl, this,
|
|
|
|
&MainWindow::OnRequestGolfControl);
|
2018-06-06 10:28:51 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::RefreshGameListHotkey, this,
|
|
|
|
&MainWindow::RefreshGameList);
|
2017-07-03 08:04:24 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::RequestStop);
|
2018-05-11 19:56:10 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ResetHotkey, this, &MainWindow::Reset);
|
2017-06-06 05:49:49 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ScreenShotHotkey, this, &MainWindow::ScreenShot);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::FullScreenHotkey, this, &MainWindow::FullScreen);
|
|
|
|
|
2018-05-17 12:27:14 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadSlot, this, &MainWindow::StateLoadSlotAt);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveSlot, this, &MainWindow::StateSaveSlotAt);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadLastSaved, this,
|
|
|
|
&MainWindow::StateLoadLastSavedAt);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadUndo, this, &MainWindow::StateLoadUndo);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveUndo, this, &MainWindow::StateSaveUndo);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveOldest, this,
|
|
|
|
&MainWindow::StateSaveOldest);
|
2018-07-01 08:14:29 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveFile, this, &MainWindow::StateSave);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadFile, this, &MainWindow::StateLoad);
|
2018-05-17 12:27:14 -06:00
|
|
|
|
2017-06-06 05:49:49 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadSlotHotkey, this,
|
|
|
|
&MainWindow::StateLoadSlot);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveSlotHotkey, this,
|
|
|
|
&MainWindow::StateSaveSlot);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::SetStateSlotHotkey, this,
|
|
|
|
&MainWindow::SetStateSlot);
|
2022-08-07 11:20:09 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::IncrementSelectedStateSlotHotkey, this,
|
|
|
|
&MainWindow::IncrementSelectedStateSlot);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::DecrementSelectedStateSlotHotkey, this,
|
|
|
|
&MainWindow::DecrementSelectedStateSlot);
|
2017-08-27 05:55:05 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StartRecording, this,
|
|
|
|
&MainWindow::OnStartRecording);
|
2021-09-24 08:31:36 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::PlayRecording, this, &MainWindow::OnPlayRecording);
|
2017-08-27 05:55:05 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ExportRecording, this,
|
|
|
|
&MainWindow::OnExportRecording);
|
2018-01-24 07:25:35 -07:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ConnectWiiRemote, this,
|
|
|
|
&MainWindow::OnConnectWiiRemote);
|
2017-08-27 05:55:05 -06:00
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ToggleReadOnlyMode, [this] {
|
2024-10-24 22:41:35 -06:00
|
|
|
auto& movie = m_system.GetMovie();
|
2024-01-13 05:14:48 -07:00
|
|
|
bool read_only = !movie.IsReadOnly();
|
|
|
|
movie.SetReadOnly(read_only);
|
2017-08-27 05:55:05 -06:00
|
|
|
emit ReadOnlyModeChanged(read_only);
|
|
|
|
});
|
2024-07-02 00:43:35 -06:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::OpenAchievements, this,
|
|
|
|
&MainWindow::ShowAchievementsWindow, Qt::QueuedConnection);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
2018-02-14 15:25:01 -07:00
|
|
|
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::Step, m_code_widget, &CodeWidget::Step);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StepOver, m_code_widget, &CodeWidget::StepOver);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::StepOut, m_code_widget, &CodeWidget::StepOut);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::Skip, m_code_widget, &CodeWidget::Skip);
|
|
|
|
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ShowPC, m_code_widget, &CodeWidget::ShowPC);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::SetPC, m_code_widget, &CodeWidget::SetPC);
|
|
|
|
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::ToggleBreakpoint, m_code_widget,
|
|
|
|
&CodeWidget::ToggleBreakpoint);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::AddBreakpoint, m_code_widget,
|
|
|
|
&CodeWidget::AddBreakpoint);
|
2023-05-25 16:27:00 -06:00
|
|
|
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::SkylandersPortalHotkey, this,
|
|
|
|
&MainWindow::ShowSkylanderPortal);
|
|
|
|
connect(m_hotkey_scheduler, &HotkeyScheduler::InfinityBaseHotkey, this,
|
|
|
|
&MainWindow::ShowInfinityBase);
|
2017-06-06 05:49:49 -06:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::ConnectToolBar()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2015-12-03 21:41:17 -07:00
|
|
|
addToolBar(m_tool_bar);
|
2018-02-14 15:25:01 -07:00
|
|
|
|
|
|
|
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
|
2018-06-04 13:44:46 -06:00
|
|
|
connect(m_tool_bar, &ToolBar::RefreshPressed, this, &MainWindow::RefreshGameList);
|
2018-02-14 15:25:01 -07:00
|
|
|
|
2017-12-25 10:07:29 -07:00
|
|
|
connect(m_tool_bar, &ToolBar::PlayPressed, this, [this]() { Play(); });
|
2015-12-03 21:41:17 -07:00
|
|
|
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
|
2017-07-03 08:04:24 -06:00
|
|
|
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::RequestStop);
|
2015-12-03 21:41:17 -07:00
|
|
|
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
|
|
|
|
connect(m_tool_bar, &ToolBar::ScreenShotPressed, this, &MainWindow::ScreenShot);
|
2016-05-09 07:34:07 -06:00
|
|
|
connect(m_tool_bar, &ToolBar::SettingsPressed, this, &MainWindow::ShowSettingsWindow);
|
2017-05-09 10:49:10 -06:00
|
|
|
connect(m_tool_bar, &ToolBar::ControllersPressed, this, &MainWindow::ShowControllersWindow);
|
2017-06-15 17:42:12 -06:00
|
|
|
connect(m_tool_bar, &ToolBar::GraphicsPressed, this, &MainWindow::ShowGraphicsWindow);
|
2018-02-14 15:25:01 -07:00
|
|
|
|
|
|
|
connect(m_tool_bar, &ToolBar::StepPressed, m_code_widget, &CodeWidget::Step);
|
|
|
|
connect(m_tool_bar, &ToolBar::StepOverPressed, m_code_widget, &CodeWidget::StepOver);
|
|
|
|
connect(m_tool_bar, &ToolBar::StepOutPressed, m_code_widget, &CodeWidget::StepOut);
|
|
|
|
connect(m_tool_bar, &ToolBar::SkipPressed, m_code_widget, &CodeWidget::Skip);
|
|
|
|
connect(m_tool_bar, &ToolBar::ShowPCPressed, m_code_widget, &CodeWidget::ShowPC);
|
|
|
|
connect(m_tool_bar, &ToolBar::SetPCPressed, m_code_widget, &CodeWidget::SetPC);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::ConnectGameList()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2017-12-25 10:07:29 -07:00
|
|
|
connect(m_game_list, &GameList::GameSelected, this, [this]() { Play(); });
|
2017-07-21 14:48:21 -06:00
|
|
|
connect(m_game_list, &GameList::NetPlayHost, this, &MainWindow::NetPlayHost);
|
2021-09-25 22:17:51 -06:00
|
|
|
connect(m_game_list, &GameList::OnStartWithRiivolution, this,
|
|
|
|
&MainWindow::ShowRiivolutionBootWidget);
|
2017-09-10 11:10:45 -06:00
|
|
|
|
|
|
|
connect(m_game_list, &GameList::OpenGeneralSettings, this, &MainWindow::ShowGeneralWindow);
|
2022-03-30 23:44:32 -06:00
|
|
|
connect(m_game_list, &GameList::OpenGraphicsSettings, this, &MainWindow::ShowGraphicsWindow);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::ConnectRenderWidget()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2016-02-09 21:42:06 -07:00
|
|
|
m_rendering_to_main = false;
|
|
|
|
m_render_widget->hide();
|
2015-11-27 01:33:07 -07:00
|
|
|
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
2018-06-08 12:47:15 -06:00
|
|
|
connect(m_render_widget, &RenderWidget::FocusChanged, this, [this](bool focus) {
|
|
|
|
if (m_render_widget->isFullScreen())
|
|
|
|
SetFullScreenResolution(focus);
|
|
|
|
});
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2018-03-23 19:13:56 -06:00
|
|
|
void MainWindow::ConnectHost()
|
|
|
|
{
|
2019-02-01 20:36:44 -07:00
|
|
|
connect(Host::GetInstance(), &Host::RequestStop, this, &MainWindow::RequestStop);
|
2018-03-23 19:13:56 -06:00
|
|
|
}
|
|
|
|
|
2016-02-09 21:42:06 -07:00
|
|
|
void MainWindow::ConnectStack()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2018-03-21 04:13:53 -06:00
|
|
|
auto* widget = new QWidget;
|
|
|
|
auto* layout = new QVBoxLayout;
|
|
|
|
widget->setLayout(layout);
|
|
|
|
|
|
|
|
layout->addWidget(m_game_list);
|
|
|
|
layout->addWidget(m_search_bar);
|
2021-01-13 02:33:01 -07:00
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
2018-03-21 04:13:53 -06:00
|
|
|
|
|
|
|
connect(m_search_bar, &SearchBar::Search, m_game_list, &GameList::SetSearchTerm);
|
|
|
|
|
|
|
|
m_stack->addWidget(widget);
|
2017-06-25 11:40:01 -06:00
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
setCentralWidget(m_stack);
|
2017-08-27 16:10:06 -06:00
|
|
|
|
2019-01-07 08:01:35 -07:00
|
|
|
setDockOptions(DockOption::AllowNestedDocks | DockOption::AllowTabbedDocks);
|
2017-08-27 16:10:06 -06:00
|
|
|
setTabPosition(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea, QTabWidget::North);
|
2018-05-04 20:37:25 -06:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_log_widget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_log_config_widget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_code_widget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_register_widget);
|
2020-03-21 01:48:49 -06:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_thread_widget);
|
2018-05-04 20:37:25 -06:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_watch_widget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_breakpoint_widget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_memory_widget);
|
2020-04-19 13:30:50 -06:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_network_widget);
|
2018-05-04 20:37:25 -06:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_jit_widget);
|
2022-12-18 01:43:28 -07:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, m_assembler_widget);
|
2017-08-27 16:10:06 -06:00
|
|
|
|
|
|
|
tabifyDockWidget(m_log_widget, m_log_config_widget);
|
2018-02-14 15:25:01 -07:00
|
|
|
tabifyDockWidget(m_log_widget, m_code_widget);
|
2017-09-13 11:33:45 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_register_widget);
|
2020-03-21 01:48:49 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_thread_widget);
|
2017-09-27 00:53:05 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_watch_widget);
|
2017-10-03 10:43:44 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_breakpoint_widget);
|
2018-03-16 05:39:53 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_memory_widget);
|
2020-04-19 13:30:50 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_network_widget);
|
2018-04-09 07:31:20 -06:00
|
|
|
tabifyDockWidget(m_log_widget, m_jit_widget);
|
2022-12-18 01:43:28 -07:00
|
|
|
tabifyDockWidget(m_log_widget, m_assembler_widget);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2018-06-04 13:44:46 -06:00
|
|
|
void MainWindow::RefreshGameList()
|
|
|
|
{
|
|
|
|
Settings::Instance().ReloadTitleDB();
|
2018-07-06 12:27:07 -06:00
|
|
|
Settings::Instance().RefreshGameList();
|
2018-06-04 13:44:46 -06:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
QStringList MainWindow::PromptFileNames()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2018-06-05 05:19:44 -06:00
|
|
|
auto& settings = Settings::Instance().GetQSettings();
|
2021-10-09 20:28:59 -06:00
|
|
|
QStringList paths = DolphinFileDialog::getOpenFileNames(
|
2018-06-05 05:19:44 -06:00
|
|
|
this, tr("Select a File"),
|
2019-07-30 05:57:06 -06:00
|
|
|
settings.value(QStringLiteral("mainwindow/lastdir"), QString{}).toString(),
|
2022-07-31 02:14:03 -06:00
|
|
|
QStringLiteral("%1 (*.elf *.dol *.gcm *.iso *.tgc *.wbfs *.ciso *.gcz *.wia *.rvz "
|
|
|
|
"hif_000000.nfs *.wad *.dff *.m3u *.json);;%2 (*)")
|
2021-10-25 18:01:16 -06:00
|
|
|
.arg(tr("All GC/Wii files"))
|
|
|
|
.arg(tr("All Files")));
|
2018-06-05 05:19:44 -06:00
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
if (!paths.isEmpty())
|
2018-06-05 05:19:44 -06:00
|
|
|
{
|
|
|
|
settings.setValue(QStringLiteral("mainwindow/lastdir"),
|
2018-11-05 11:20:45 -07:00
|
|
|
QFileInfo(paths.front()).absoluteDir().absolutePath());
|
2018-06-05 05:19:44 -06:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
return paths;
|
2018-03-22 18:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ChangeDisc()
|
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
std::vector<std::string> paths = StringListToStdVector(PromptFileNames());
|
2018-03-22 18:18:53 -06:00
|
|
|
|
2024-03-04 17:45:25 -07:00
|
|
|
if (paths.empty())
|
|
|
|
return;
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
m_system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{m_system}, paths);
|
2018-03-22 18:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::EjectDisc()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
m_system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{m_system}, DVD::EjectCause::User);
|
2018-03-22 18:18:53 -06:00
|
|
|
}
|
|
|
|
|
2023-01-16 01:36:24 -07:00
|
|
|
void MainWindow::OpenUserFolder()
|
|
|
|
{
|
|
|
|
std::string path = File::GetUserPath(D_USER_IDX);
|
|
|
|
|
|
|
|
QUrl url = QUrl::fromLocalFile(QString::fromStdString(path));
|
|
|
|
QDesktopServices::openUrl(url);
|
|
|
|
}
|
|
|
|
|
2018-03-22 18:18:53 -06:00
|
|
|
void MainWindow::Open()
|
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
QStringList files = PromptFileNames();
|
|
|
|
if (!files.isEmpty())
|
|
|
|
StartGame(StringListToStdVector(files));
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2017-12-25 10:07:29 -07:00
|
|
|
void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
|
|
|
// If we're in a paused game, start it up again.
|
|
|
|
// Otherwise, play the selected game, if there is one.
|
2015-12-30 20:03:13 -07:00
|
|
|
// Otherwise, play the default game.
|
2015-11-27 01:33:07 -07:00
|
|
|
// Otherwise, play the last played game, if there is one.
|
|
|
|
// Otherwise, prompt for a new game.
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::GetState(m_system) == Core::State::Paused)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::SetState(m_system, Core::State::Running);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
std::shared_ptr<const UICommon::GameFile> selection = m_game_list->GetSelectedGame();
|
2017-12-25 10:41:53 -07:00
|
|
|
if (selection)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(selection->GetFilePath(), ScanForSecondDisc::Yes,
|
|
|
|
std::make_unique<BootSessionData>(savestate_path, DeleteSavestateAfterBoot::No));
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-06 19:29:46 -06:00
|
|
|
const QString default_path = QString::fromStdString(Config::Get(Config::MAIN_DEFAULT_ISO));
|
2015-12-30 20:03:13 -07:00
|
|
|
if (!default_path.isEmpty() && QFile::exists(default_path))
|
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(default_path, ScanForSecondDisc::Yes,
|
|
|
|
std::make_unique<BootSessionData>(savestate_path, DeleteSavestateAfterBoot::No));
|
2015-12-30 20:03:13 -07:00
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
else
|
2015-12-30 20:03:13 -07:00
|
|
|
{
|
2017-06-04 14:43:41 -06:00
|
|
|
Open();
|
2015-12-30 20:03:13 -07:00
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::Pause()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::SetState(m_system, Core::State::Paused);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2018-02-09 04:54:35 -07:00
|
|
|
void MainWindow::TogglePause()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::GetState(m_system) == Core::State::Paused)
|
2018-02-09 04:54:35 -07:00
|
|
|
{
|
|
|
|
Play();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-03 08:04:24 -06:00
|
|
|
void MainWindow::OnStopComplete()
|
|
|
|
{
|
|
|
|
m_stop_requested = false;
|
2021-04-24 18:18:28 -06:00
|
|
|
HideRenderWidget(!m_exit_requested, m_exit_requested);
|
2018-05-29 21:44:20 -06:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-08-06 15:56:40 -06:00
|
|
|
if (!m_netplay_dialog->isVisible())
|
|
|
|
Discord::UpdateDiscordPresence();
|
2018-05-29 21:44:20 -06:00
|
|
|
#endif
|
2017-07-03 08:04:24 -06:00
|
|
|
|
2018-05-07 10:38:59 -06:00
|
|
|
SetFullScreenResolution(false);
|
|
|
|
|
2018-04-29 11:13:40 -06:00
|
|
|
if (m_exit_requested || Settings::Instance().IsBatchModeEnabled())
|
2022-12-18 01:43:28 -07:00
|
|
|
{
|
|
|
|
if (m_assembler_widget->ApplicationCloseRequest())
|
|
|
|
{
|
|
|
|
QGuiApplication::exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_exit_requested = false;
|
|
|
|
}
|
|
|
|
}
|
2017-07-03 08:04:24 -06:00
|
|
|
|
|
|
|
// If the current emulation prevented the booting of another, do that now
|
2017-08-24 08:35:47 -06:00
|
|
|
if (m_pending_boot != nullptr)
|
2017-07-03 08:04:24 -06:00
|
|
|
{
|
2017-08-24 08:35:47 -06:00
|
|
|
StartGame(std::move(m_pending_boot));
|
|
|
|
m_pending_boot.reset();
|
2017-07-03 08:04:24 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::RequestStop()
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::IsUninitialized(m_system))
|
2017-07-03 08:04:24 -06:00
|
|
|
{
|
2024-03-18 02:35:42 -06:00
|
|
|
Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true);
|
2017-06-24 09:00:37 -06:00
|
|
|
return true;
|
2017-07-03 08:04:24 -06:00
|
|
|
}
|
2017-06-24 09:00:37 -06:00
|
|
|
|
2021-05-09 04:28:04 -06:00
|
|
|
const bool rendered_widget_was_active =
|
2024-08-27 15:48:37 -06:00
|
|
|
Settings::Instance().IsKeepWindowOnTopEnabled() ||
|
|
|
|
(m_render_widget->isActiveWindow() && !m_render_widget->isFullScreen());
|
2021-05-09 04:28:04 -06:00
|
|
|
QWidget* confirm_parent = (!m_rendering_to_main && rendered_widget_was_active) ?
|
|
|
|
m_render_widget :
|
|
|
|
static_cast<QWidget*>(this);
|
|
|
|
const bool was_cursor_locked = m_render_widget->IsCursorLocked();
|
|
|
|
|
2018-05-08 08:00:20 -06:00
|
|
|
if (!m_render_widget->isFullScreen())
|
2018-05-12 16:59:09 -06:00
|
|
|
m_render_widget_geometry = m_render_widget->saveGeometry();
|
2018-06-04 11:15:57 -06:00
|
|
|
else
|
2018-05-31 20:05:59 -06:00
|
|
|
FullScreen();
|
2018-05-08 08:00:20 -06:00
|
|
|
|
2021-12-30 19:00:39 -07:00
|
|
|
if (Config::Get(Config::MAIN_CONFIRM_ON_STOP))
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2019-11-10 15:58:39 -07:00
|
|
|
if (std::exchange(m_stop_confirm_showing, true))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Common::ScopeGuard confirm_lock([this] { m_stop_confirm_showing = false; });
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
const Core::State state = Core::GetState(m_system);
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
// Only pause the game, if NetPlay is not running
|
2018-07-12 18:37:12 -06:00
|
|
|
bool pause = !Settings::Instance().GetNetPlayClient();
|
2017-06-24 09:00:37 -06:00
|
|
|
|
|
|
|
if (pause)
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::SetState(m_system, Core::State::Paused);
|
2017-06-24 09:00:37 -06:00
|
|
|
|
2021-05-09 04:28:04 -06:00
|
|
|
if (rendered_widget_was_active)
|
|
|
|
{
|
|
|
|
// We have to do this before creating the message box, otherwise we might receive the window
|
|
|
|
// activation event before we know we need to lock the cursor again.
|
|
|
|
m_render_widget->SetCursorLockedOnNextActivation(was_cursor_locked);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is to avoid any "race conditions" between the "Window Activate" message and the
|
|
|
|
// message box returning, which could break cursor locking depending on the order
|
|
|
|
m_render_widget->SetWaitingForMessageBox(true);
|
2019-03-04 12:49:00 -07:00
|
|
|
auto confirm = ModalMessageBox::question(
|
2021-05-09 04:28:04 -06:00
|
|
|
confirm_parent, tr("Confirm"),
|
2019-03-04 12:49:00 -07:00
|
|
|
m_stop_requested ? tr("A shutdown is already in progress. Unsaved data "
|
|
|
|
"may be lost if you stop the current emulation "
|
|
|
|
"before it completes. Force stop?") :
|
2019-11-10 15:58:39 -07:00
|
|
|
tr("Do you want to stop the current emulation?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal);
|
2017-07-03 08:04:24 -06:00
|
|
|
|
2021-05-09 04:28:04 -06:00
|
|
|
// If a user confirmed stopping the emulation, we do not capture the cursor again,
|
|
|
|
// even if the render widget will stay alive for a while.
|
|
|
|
// If a used rejected stopping the emulation, we instead capture the cursor again,
|
|
|
|
// and let them continue playing as if nothing had happened
|
|
|
|
// (assuming cursor locking is on).
|
2017-06-27 10:06:27 -06:00
|
|
|
if (confirm != QMessageBox::Yes)
|
2019-01-26 05:26:56 -07:00
|
|
|
{
|
2021-05-09 04:28:04 -06:00
|
|
|
m_render_widget->SetWaitingForMessageBox(false);
|
|
|
|
|
2019-01-26 05:26:56 -07:00
|
|
|
if (pause)
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::SetState(m_system, state);
|
2019-01-26 05:26:56 -07:00
|
|
|
|
2017-06-27 10:06:27 -06:00
|
|
|
return false;
|
2019-01-26 05:26:56 -07:00
|
|
|
}
|
2021-05-09 04:28:04 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_render_widget->SetCursorLockedOnNextActivation(false);
|
|
|
|
// This needs to be after SetCursorLockedOnNextActivation(false) as it depends on it
|
|
|
|
m_render_widget->SetWaitingForMessageBox(false);
|
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2019-03-13 08:34:00 -06:00
|
|
|
OnStopRecording();
|
2017-06-24 09:00:37 -06:00
|
|
|
// TODO: Add Debugger shutdown
|
|
|
|
|
|
|
|
if (!m_stop_requested && UICommon::TriggerSTMPowerEvent())
|
2016-07-06 18:00:33 -06:00
|
|
|
{
|
2017-06-24 09:00:37 -06:00
|
|
|
m_stop_requested = true;
|
|
|
|
|
|
|
|
// Unpause because gracefully shutting down needs the game to actually request a shutdown.
|
2017-07-03 08:04:24 -06:00
|
|
|
// TODO: Do not unpause in debug mode to allow debugging until the complete shutdown.
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::GetState(m_system) == Core::State::Paused)
|
|
|
|
Core::SetState(m_system, Core::State::Running);
|
2017-06-24 09:00:37 -06:00
|
|
|
|
2018-11-10 20:37:49 -07:00
|
|
|
// Tell NetPlay about the power event
|
|
|
|
if (NetPlay::IsNetPlayRunning())
|
|
|
|
NetPlay::SendPowerButtonEvent();
|
|
|
|
|
2017-07-03 08:04:24 -06:00
|
|
|
return true;
|
2017-06-24 09:00:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ForceStop();
|
2016-07-06 18:00:33 -06:00
|
|
|
#ifdef Q_OS_WIN
|
2017-06-24 09:00:37 -06:00
|
|
|
// Allow windows to idle or turn off display again
|
|
|
|
SetThreadExecutionState(ES_CONTINUOUS);
|
2016-07-06 18:00:33 -06:00
|
|
|
#endif
|
2017-06-24 09:00:37 -06:00
|
|
|
return true;
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ForceStop()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::Stop(m_system);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2016-02-14 18:56:40 -07:00
|
|
|
void MainWindow::Reset()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
auto& movie = m_system.GetMovie();
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.IsRecordingInput())
|
|
|
|
movie.SetReset(true);
|
2024-10-24 22:41:35 -06:00
|
|
|
m_system.GetProcessorInterface().ResetButton_Tap();
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::FrameAdvance()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
Core::DoFrameStep(m_system);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
void MainWindow::FullScreen()
|
|
|
|
{
|
|
|
|
// If the render widget is fullscreen we want to reset it to whatever is in
|
2015-12-20 16:36:39 -07:00
|
|
|
// settings. If it's set to be fullscreen then it just remakes the window,
|
2015-11-27 01:33:07 -07:00
|
|
|
// which probably isn't ideal.
|
|
|
|
bool was_fullscreen = m_render_widget->isFullScreen();
|
2018-05-16 11:54:35 -06:00
|
|
|
|
|
|
|
if (!was_fullscreen)
|
|
|
|
m_render_widget_geometry = m_render_widget->saveGeometry();
|
|
|
|
|
2018-03-21 13:53:37 -06:00
|
|
|
HideRenderWidget(false);
|
2018-05-07 10:38:59 -06:00
|
|
|
SetFullScreenResolution(!was_fullscreen);
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
if (was_fullscreen)
|
2018-05-04 06:14:53 -06:00
|
|
|
{
|
2015-11-27 01:33:07 -07:00
|
|
|
ShowRenderWidget();
|
2018-05-04 06:14:53 -06:00
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
else
|
2018-05-04 06:14:53 -06:00
|
|
|
{
|
2015-11-27 01:33:07 -07:00
|
|
|
m_render_widget->showFullScreen();
|
2018-05-04 06:14:53 -06:00
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2021-05-09 04:28:04 -06:00
|
|
|
void MainWindow::UnlockCursor()
|
|
|
|
{
|
|
|
|
if (!m_render_widget->isFullScreen())
|
|
|
|
m_render_widget->SetCursorLocked(false);
|
|
|
|
}
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
void MainWindow::ScreenShot()
|
|
|
|
{
|
|
|
|
Core::SaveScreenShot();
|
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
void MainWindow::ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
|
2021-11-20 11:38:09 -07:00
|
|
|
std::unique_ptr<BootSessionData> boot_session_data)
|
2017-08-24 08:35:47 -06:00
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
auto second_game = m_game_list->FindSecondDisc(game);
|
|
|
|
|
|
|
|
std::vector<std::string> paths = {game.GetFilePath()};
|
|
|
|
if (second_game != nullptr)
|
|
|
|
paths.push_back(second_game->GetFilePath());
|
|
|
|
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(paths, std::move(boot_session_data));
|
2017-12-31 12:33:36 -07:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
void MainWindow::StartGame(const QString& path, ScanForSecondDisc scan,
|
2021-11-20 11:38:09 -07:00
|
|
|
std::unique_ptr<BootSessionData> boot_session_data)
|
2017-12-31 12:33:36 -07:00
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(path.toStdString(), scan, std::move(boot_session_data));
|
2018-11-05 11:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StartGame(const std::string& path, ScanForSecondDisc scan,
|
2021-11-20 11:38:09 -07:00
|
|
|
std::unique_ptr<BootSessionData> boot_session_data)
|
2018-11-05 11:20:45 -07:00
|
|
|
{
|
|
|
|
if (scan == ScanForSecondDisc::Yes)
|
|
|
|
{
|
|
|
|
std::shared_ptr<const UICommon::GameFile> game = m_game_list->FindGame(path);
|
|
|
|
if (game != nullptr)
|
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
ScanForSecondDiscAndStartGame(*game, std::move(boot_session_data));
|
2018-11-05 11:20:45 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(BootParameters::GenerateFromFile(
|
|
|
|
path, boot_session_data ? std::move(*boot_session_data) : BootSessionData()));
|
2017-08-24 08:35:47 -06:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
void MainWindow::StartGame(const std::vector<std::string>& paths,
|
2021-11-20 11:38:09 -07:00
|
|
|
std::unique_ptr<BootSessionData> boot_session_data)
|
2018-11-05 11:20:45 -07:00
|
|
|
{
|
2021-11-20 11:38:09 -07:00
|
|
|
StartGame(BootParameters::GenerateFromFile(
|
|
|
|
paths, boot_session_data ? std::move(*boot_session_data) : BootSessionData()));
|
2018-11-05 11:20:45 -07:00
|
|
|
}
|
|
|
|
|
2017-08-24 08:35:47 -06:00
|
|
|
void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2020-11-06 01:34:53 -07:00
|
|
|
if (parameters && std::holds_alternative<BootParameters::Disc>(parameters->parameters))
|
2020-06-15 05:16:01 -06:00
|
|
|
{
|
|
|
|
if (std::get<BootParameters::Disc>(parameters->parameters).volume->IsNKit())
|
|
|
|
{
|
|
|
|
if (!NKitWarningDialog::ShowUnlessDisabled())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
// If we're running, only start a new game once we've stopped the last.
|
2024-10-24 22:41:35 -06:00
|
|
|
if (!Core::IsUninitialized(m_system))
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2017-07-03 08:04:24 -06:00
|
|
|
if (!RequestStop())
|
2015-11-27 01:33:07 -07:00
|
|
|
return;
|
2017-07-03 08:04:24 -06:00
|
|
|
|
|
|
|
// As long as the shutdown isn't complete, we can't boot, so let's boot later
|
2017-08-24 08:35:47 -06:00
|
|
|
m_pending_boot = std::move(parameters);
|
2017-07-03 08:04:24 -06:00
|
|
|
return;
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
2018-10-03 07:03:13 -06:00
|
|
|
|
|
|
|
// We need the render widget before booting.
|
|
|
|
ShowRenderWidget();
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
// Boot up, show an error if it fails to load the game.
|
2024-10-24 22:41:35 -06:00
|
|
|
if (!BootManager::BootCore(m_system, std::move(parameters),
|
2023-03-25 18:16:53 -06:00
|
|
|
::GetWindowSystemInfo(m_render_widget->windowHandle())))
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
2018-10-03 07:03:13 -06:00
|
|
|
HideRenderWidget();
|
2015-11-27 01:33:07 -07:00
|
|
|
return;
|
|
|
|
}
|
2018-06-08 11:59:24 -06:00
|
|
|
|
2018-05-29 21:44:20 -06:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-08-06 15:56:40 -06:00
|
|
|
if (!NetPlay::IsNetPlayRunning())
|
|
|
|
Discord::UpdateDiscordPresence();
|
2018-05-29 21:44:20 -06:00
|
|
|
#endif
|
2016-07-06 18:00:33 -06:00
|
|
|
|
2019-03-02 21:41:50 -07:00
|
|
|
if (Config::Get(Config::MAIN_FULLSCREEN))
|
2018-06-08 11:59:24 -06:00
|
|
|
m_fullscreen_requested = true;
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
|
2018-05-07 10:38:59 -06:00
|
|
|
void MainWindow::SetFullScreenResolution(bool fullscreen)
|
|
|
|
{
|
2019-03-02 21:41:50 -07:00
|
|
|
if (Config::Get(Config::MAIN_FULLSCREEN_DISPLAY_RES) == "Auto")
|
2018-05-07 10:38:59 -06:00
|
|
|
return;
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
if (!fullscreen)
|
|
|
|
{
|
|
|
|
ChangeDisplaySettings(nullptr, CDS_FULLSCREEN);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEVMODE screen_settings;
|
|
|
|
memset(&screen_settings, 0, sizeof(screen_settings));
|
|
|
|
screen_settings.dmSize = sizeof(screen_settings);
|
2019-03-02 21:41:50 -07:00
|
|
|
sscanf(Config::Get(Config::MAIN_FULLSCREEN_DISPLAY_RES).c_str(), "%dx%d",
|
2018-05-07 10:38:59 -06:00
|
|
|
&screen_settings.dmPelsWidth, &screen_settings.dmPelsHeight);
|
|
|
|
screen_settings.dmBitsPerPel = 32;
|
|
|
|
screen_settings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
|
|
|
|
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
|
|
|
|
ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
|
|
|
|
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
2018-10-03 01:34:27 -06:00
|
|
|
if (m_xrr_config)
|
|
|
|
m_xrr_config->ToggleDisplayMode(fullscreen);
|
2018-05-07 10:38:59 -06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
void MainWindow::ShowRenderWidget()
|
|
|
|
{
|
2018-05-16 11:54:35 -06:00
|
|
|
SetFullScreenResolution(false);
|
|
|
|
Host::GetInstance()->SetRenderFullscreen(false);
|
|
|
|
|
2019-03-02 21:41:50 -07:00
|
|
|
if (Config::Get(Config::MAIN_RENDER_TO_MAIN))
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
|
|
|
// If we're rendering to main, add it to the stack and update our title when necessary.
|
|
|
|
m_rendering_to_main = true;
|
2018-04-27 07:04:26 -06:00
|
|
|
|
2015-11-27 01:33:07 -07:00
|
|
|
m_stack->setCurrentIndex(m_stack->addWidget(m_render_widget));
|
|
|
|
connect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
2018-05-13 22:43:31 -06:00
|
|
|
m_stack->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
2018-03-24 16:50:03 -06:00
|
|
|
m_stack->repaint();
|
2018-05-13 13:08:34 -06:00
|
|
|
|
|
|
|
Host::GetInstance()->SetRenderFocus(isActiveWindow());
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Otherwise, just show it.
|
|
|
|
m_rendering_to_main = false;
|
2018-04-27 07:04:26 -06:00
|
|
|
|
|
|
|
m_render_widget->showNormal();
|
2018-05-12 16:59:09 -06:00
|
|
|
m_render_widget->restoreGeometry(m_render_widget_geometry);
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 16:33:38 -06:00
|
|
|
void MainWindow::HideRenderWidget(bool reinit, bool is_exit)
|
2015-11-27 01:33:07 -07:00
|
|
|
{
|
|
|
|
if (m_rendering_to_main)
|
|
|
|
{
|
|
|
|
// Remove the widget from the stack and reparent it to nullptr, so that it can draw
|
|
|
|
// itself in a new window if it wants. Disconnect the title updates.
|
|
|
|
m_stack->removeWidget(m_render_widget);
|
|
|
|
m_render_widget->setParent(nullptr);
|
|
|
|
m_rendering_to_main = false;
|
2018-05-13 22:43:31 -06:00
|
|
|
m_stack->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
2015-11-27 01:33:07 -07:00
|
|
|
disconnect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
2022-01-13 16:04:22 -07:00
|
|
|
setWindowTitle(QString::fromStdString(Common::GetScmRevStr()));
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
2018-02-02 07:35:03 -07:00
|
|
|
|
|
|
|
// The following code works around a driver bug that would lead to Dolphin crashing when changing
|
2018-02-09 04:54:35 -07:00
|
|
|
// graphics backends (e.g. OpenGL to Vulkan). To avoid this the render widget is (safely)
|
|
|
|
// recreated
|
2018-03-21 13:53:37 -06:00
|
|
|
if (reinit)
|
|
|
|
{
|
2018-03-22 08:29:08 -06:00
|
|
|
m_render_widget->hide();
|
2018-03-21 13:53:37 -06:00
|
|
|
disconnect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
2018-02-02 07:35:03 -07:00
|
|
|
|
2018-03-21 13:53:37 -06:00
|
|
|
m_render_widget->removeEventFilter(this);
|
|
|
|
m_render_widget->deleteLater();
|
2018-02-02 07:35:03 -07:00
|
|
|
|
2018-03-21 13:53:37 -06:00
|
|
|
m_render_widget = new RenderWidget;
|
2018-02-02 07:35:03 -07:00
|
|
|
|
2018-03-21 13:53:37 -06:00
|
|
|
m_render_widget->installEventFilter(this);
|
|
|
|
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
2018-06-08 12:47:15 -06:00
|
|
|
connect(m_render_widget, &RenderWidget::FocusChanged, this, [this](bool focus) {
|
|
|
|
if (m_render_widget->isFullScreen())
|
|
|
|
SetFullScreenResolution(focus);
|
|
|
|
});
|
2018-10-27 04:06:35 -06:00
|
|
|
|
|
|
|
// The controller interface will still be registered to the old render widget, if the core
|
|
|
|
// has booted. Therefore, we should re-bind it to the main window for now. When the core
|
|
|
|
// is next started, it will be swapped back to the new render widget.
|
2023-03-25 18:16:53 -06:00
|
|
|
g_controller_interface.ChangeWindow(::GetWindowSystemInfo(windowHandle()).render_window,
|
2021-05-20 16:33:38 -06:00
|
|
|
is_exit ? ControllerInterface::WindowChangeReason::Exit :
|
|
|
|
ControllerInterface::WindowChangeReason::Other);
|
2018-03-21 13:53:37 -06:00
|
|
|
}
|
2015-11-27 01:33:07 -07:00
|
|
|
}
|
2016-02-09 21:42:06 -07:00
|
|
|
|
2017-05-09 10:49:10 -06:00
|
|
|
void MainWindow::ShowControllersWindow()
|
|
|
|
{
|
2018-10-14 05:46:54 -06:00
|
|
|
if (!m_controllers_window)
|
|
|
|
{
|
|
|
|
m_controllers_window = new ControllersWindow(this);
|
|
|
|
InstallHotkeyFilter(m_controllers_window);
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_controllers_window);
|
2017-05-09 10:49:10 -06:00
|
|
|
m_controllers_window->show();
|
|
|
|
m_controllers_window->raise();
|
|
|
|
m_controllers_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:27:34 -06:00
|
|
|
void MainWindow::ShowFreeLookWindow()
|
|
|
|
{
|
|
|
|
if (!m_freelook_window)
|
|
|
|
{
|
|
|
|
m_freelook_window = new FreeLookWindow(this);
|
|
|
|
InstallHotkeyFilter(m_freelook_window);
|
2023-06-07 20:14:54 -06:00
|
|
|
|
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
connect(m_freelook_window, &FreeLookWindow::OpenAchievementSettings, this,
|
|
|
|
&MainWindow::ShowAchievementSettings);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
2020-06-11 23:27:34 -06:00
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_freelook_window);
|
2020-06-11 23:27:34 -06:00
|
|
|
m_freelook_window->show();
|
|
|
|
m_freelook_window->raise();
|
|
|
|
m_freelook_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2016-05-09 07:34:07 -06:00
|
|
|
void MainWindow::ShowSettingsWindow()
|
|
|
|
{
|
2018-10-14 05:46:54 -06:00
|
|
|
if (!m_settings_window)
|
|
|
|
{
|
|
|
|
m_settings_window = new SettingsWindow(this);
|
|
|
|
InstallHotkeyFilter(m_settings_window);
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_settings_window);
|
2016-05-09 07:34:07 -06:00
|
|
|
m_settings_window->show();
|
|
|
|
m_settings_window->raise();
|
|
|
|
m_settings_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2017-07-16 15:11:11 -06:00
|
|
|
void MainWindow::ShowAudioWindow()
|
|
|
|
{
|
|
|
|
ShowSettingsWindow();
|
2018-10-14 05:46:54 -06:00
|
|
|
m_settings_window->SelectAudioPane();
|
2017-07-16 15:11:11 -06:00
|
|
|
}
|
|
|
|
|
2017-09-10 11:10:45 -06:00
|
|
|
void MainWindow::ShowGeneralWindow()
|
|
|
|
{
|
|
|
|
ShowSettingsWindow();
|
2018-10-14 05:46:54 -06:00
|
|
|
m_settings_window->SelectGeneralPane();
|
2017-09-10 11:10:45 -06:00
|
|
|
}
|
|
|
|
|
2016-02-11 04:59:44 -07:00
|
|
|
void MainWindow::ShowAboutDialog()
|
|
|
|
{
|
2017-09-14 09:01:43 -06:00
|
|
|
AboutDialog about{this};
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(&about);
|
2017-09-14 09:01:43 -06:00
|
|
|
about.exec();
|
2016-02-11 04:59:44 -07:00
|
|
|
}
|
2016-02-14 18:56:40 -07:00
|
|
|
|
2017-06-06 05:49:49 -06:00
|
|
|
void MainWindow::ShowHotkeyDialog()
|
|
|
|
{
|
2018-10-14 06:15:26 -06:00
|
|
|
if (!m_hotkey_window)
|
|
|
|
{
|
|
|
|
m_hotkey_window = new MappingWindow(this, MappingWindow::Type::MAPPING_HOTKEYS, 0);
|
|
|
|
InstallHotkeyFilter(m_hotkey_window);
|
|
|
|
}
|
2018-07-03 00:24:45 -06:00
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_hotkey_window);
|
2018-10-14 06:15:26 -06:00
|
|
|
m_hotkey_window->show();
|
|
|
|
m_hotkey_window->raise();
|
|
|
|
m_hotkey_window->activateWindow();
|
2017-06-06 05:49:49 -06:00
|
|
|
}
|
|
|
|
|
2017-06-15 17:42:12 -06:00
|
|
|
void MainWindow::ShowGraphicsWindow()
|
|
|
|
{
|
2018-10-14 05:46:54 -06:00
|
|
|
if (!m_graphics_window)
|
|
|
|
{
|
2021-02-22 06:32:53 -07:00
|
|
|
#ifdef HAVE_XRANDR
|
2018-10-03 01:34:27 -06:00
|
|
|
if (GetWindowSystemType() == WindowSystemType::X11)
|
|
|
|
{
|
|
|
|
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
|
|
|
|
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
|
|
|
|
"display", windowHandle())),
|
|
|
|
winId());
|
|
|
|
}
|
2018-10-14 05:46:54 -06:00
|
|
|
#endif
|
2023-04-26 16:35:40 -06:00
|
|
|
m_graphics_window = new GraphicsWindow(this);
|
2018-10-03 01:34:27 -06:00
|
|
|
InstallHotkeyFilter(m_graphics_window);
|
2018-10-14 05:46:54 -06:00
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_graphics_window);
|
2017-06-15 17:42:12 -06:00
|
|
|
m_graphics_window->show();
|
|
|
|
m_graphics_window->raise();
|
|
|
|
m_graphics_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2017-07-21 14:48:21 -06:00
|
|
|
void MainWindow::ShowNetPlaySetupDialog()
|
|
|
|
{
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_netplay_setup_dialog);
|
2017-07-21 14:48:21 -06:00
|
|
|
m_netplay_setup_dialog->show();
|
|
|
|
m_netplay_setup_dialog->raise();
|
|
|
|
m_netplay_setup_dialog->activateWindow();
|
|
|
|
}
|
|
|
|
|
2019-03-30 07:50:57 -06:00
|
|
|
void MainWindow::ShowNetPlayBrowser()
|
|
|
|
{
|
|
|
|
auto* browser = new NetPlayBrowser(this);
|
2020-04-13 06:32:10 -06:00
|
|
|
browser->setAttribute(Qt::WA_DeleteOnClose, true);
|
2019-03-30 07:50:57 -06:00
|
|
|
connect(browser, &NetPlayBrowser::Join, this, &MainWindow::NetPlayJoin);
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(browser);
|
2019-03-30 07:50:57 -06:00
|
|
|
browser->exec();
|
|
|
|
}
|
|
|
|
|
2017-08-30 08:44:28 -06:00
|
|
|
void MainWindow::ShowFIFOPlayer()
|
|
|
|
{
|
2018-10-14 05:46:54 -06:00
|
|
|
if (!m_fifo_window)
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
m_fifo_window = new FIFOPlayerWindow(m_system.GetFifoPlayer(), m_system.GetFifoRecorder());
|
2018-10-14 05:46:54 -06:00
|
|
|
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
|
2018-11-05 11:20:45 -07:00
|
|
|
[this](const QString& path) { StartGame(path, ScanForSecondDisc::No); });
|
2018-10-14 05:46:54 -06:00
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_fifo_window);
|
2017-08-30 08:44:28 -06:00
|
|
|
m_fifo_window->show();
|
|
|
|
m_fifo_window->raise();
|
|
|
|
m_fifo_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2023-01-07 15:54:36 -07:00
|
|
|
void MainWindow::ShowSkylanderPortal()
|
|
|
|
{
|
|
|
|
if (!m_skylander_window)
|
|
|
|
{
|
2023-01-24 14:51:02 -07:00
|
|
|
m_skylander_window = new SkylanderPortalWindow();
|
2023-01-07 15:54:36 -07:00
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_skylander_window);
|
2023-01-07 15:54:36 -07:00
|
|
|
m_skylander_window->show();
|
|
|
|
m_skylander_window->raise();
|
|
|
|
m_skylander_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2023-01-24 14:51:02 -07:00
|
|
|
void MainWindow::ShowInfinityBase()
|
|
|
|
{
|
|
|
|
if (!m_infinity_window)
|
|
|
|
{
|
|
|
|
m_infinity_window = new InfinityBaseWindow();
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_infinity_window);
|
2023-01-24 14:51:02 -07:00
|
|
|
m_infinity_window->show();
|
|
|
|
m_infinity_window->raise();
|
|
|
|
m_infinity_window->activateWindow();
|
|
|
|
}
|
|
|
|
|
2016-02-14 18:56:40 -07:00
|
|
|
void MainWindow::StateLoad()
|
|
|
|
{
|
2024-02-05 17:41:25 -07:00
|
|
|
QString dialog_path = (Config::Get(Config::MAIN_CURRENT_STATE_PATH).empty()) ?
|
|
|
|
QDir::currentPath() :
|
|
|
|
QString::fromStdString(Config::Get(Config::MAIN_CURRENT_STATE_PATH));
|
|
|
|
QString path = DolphinFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
|
|
|
|
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
|
2023-05-01 17:57:58 -06:00
|
|
|
if (!path.isEmpty())
|
2024-10-24 22:41:35 -06:00
|
|
|
State::LoadAs(m_system, path.toStdString());
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateSave()
|
|
|
|
{
|
2024-02-05 17:41:25 -07:00
|
|
|
QString dialog_path = (Config::Get(Config::MAIN_CURRENT_STATE_PATH).empty()) ?
|
|
|
|
QDir::currentPath() :
|
|
|
|
QString::fromStdString(Config::Get(Config::MAIN_CURRENT_STATE_PATH));
|
|
|
|
QString path = DolphinFileDialog::getSaveFileName(
|
|
|
|
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
|
|
|
|
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
|
2023-05-01 17:57:58 -06:00
|
|
|
if (!path.isEmpty())
|
2024-10-24 22:41:35 -06:00
|
|
|
State::SaveAs(m_system, path.toStdString());
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateLoadSlot()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::Load(m_system, m_state_slot);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateSaveSlot()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::Save(m_system, m_state_slot);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateLoadSlotAt(int slot)
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::Load(m_system, slot);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
2018-05-17 12:27:14 -06:00
|
|
|
void MainWindow::StateLoadLastSavedAt(int slot)
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::LoadLastSaved(m_system, slot);
|
2018-05-17 12:27:14 -06:00
|
|
|
}
|
|
|
|
|
2016-02-14 18:56:40 -07:00
|
|
|
void MainWindow::StateSaveSlotAt(int slot)
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::Save(m_system, slot);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateLoadUndo()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::UndoLoadState(m_system);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateSaveUndo()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::UndoSaveState(m_system);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::StateSaveOldest()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
State::SaveFirstSaved(m_system);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::SetStateSlot(int slot)
|
|
|
|
{
|
2017-05-31 01:17:39 -06:00
|
|
|
Settings::Instance().SetStateSlot(slot);
|
2016-02-14 18:56:40 -07:00
|
|
|
m_state_slot = slot;
|
2018-07-01 08:30:12 -06:00
|
|
|
|
2022-10-11 20:21:51 -06:00
|
|
|
Core::DisplayMessage(fmt::format("Selected slot {} - {}", m_state_slot,
|
|
|
|
State::GetInfoStringOfSlot(m_state_slot, false)),
|
2018-07-01 08:30:12 -06:00
|
|
|
2500);
|
2016-02-14 18:56:40 -07:00
|
|
|
}
|
2017-06-24 09:00:37 -06:00
|
|
|
|
2022-08-07 11:20:09 -06:00
|
|
|
void MainWindow::IncrementSelectedStateSlot()
|
|
|
|
{
|
2023-01-28 18:54:41 -07:00
|
|
|
u32 state_slot = m_state_slot + 1;
|
2022-08-07 11:20:09 -06:00
|
|
|
if (state_slot > State::NUM_STATES)
|
|
|
|
state_slot = 1;
|
|
|
|
m_menu_bar->SetStateSlot(state_slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::DecrementSelectedStateSlot()
|
|
|
|
{
|
2023-01-28 18:54:41 -07:00
|
|
|
u32 state_slot = m_state_slot - 1;
|
2022-08-07 11:20:09 -06:00
|
|
|
if (state_slot < 1)
|
|
|
|
state_slot = State::NUM_STATES;
|
|
|
|
m_menu_bar->SetStateSlot(state_slot);
|
|
|
|
}
|
|
|
|
|
2017-06-14 03:58:11 -06:00
|
|
|
void MainWindow::PerformOnlineUpdate(const std::string& region)
|
|
|
|
{
|
|
|
|
WiiUpdate::PerformOnlineUpdate(region, this);
|
2020-03-17 20:52:29 -06:00
|
|
|
// Since the update may have installed a newer system menu, trigger a refresh.
|
|
|
|
Settings::Instance().NANDRefresh();
|
2017-06-14 03:58:11 -06:00
|
|
|
}
|
|
|
|
|
2017-07-06 03:01:32 -06:00
|
|
|
void MainWindow::BootWiiSystemMenu()
|
|
|
|
{
|
2017-10-01 07:41:54 -06:00
|
|
|
StartGame(std::make_unique<BootParameters>(BootParameters::NANDTitle{Titles::SYSTEM_MENU}));
|
2017-07-06 03:01:32 -06:00
|
|
|
}
|
|
|
|
|
2017-07-21 14:48:21 -06:00
|
|
|
void MainWindow::NetPlayInit()
|
|
|
|
{
|
2019-01-17 15:28:07 -07:00
|
|
|
const auto& game_list_model = m_game_list->GetGameListModel();
|
|
|
|
m_netplay_setup_dialog = new NetPlaySetupDialog(game_list_model, this);
|
2021-11-20 11:59:14 -07:00
|
|
|
m_netplay_dialog = new NetPlayDialog(
|
|
|
|
game_list_model,
|
|
|
|
[this](const std::string& path, std::unique_ptr<BootSessionData> boot_session_data) {
|
|
|
|
StartGame(path, ScanForSecondDisc::Yes, std::move(boot_session_data));
|
|
|
|
});
|
2018-07-20 16:27:43 -06:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
|
|
|
m_netplay_discord = new DiscordHandler(this);
|
|
|
|
#endif
|
2017-07-21 14:48:21 -06:00
|
|
|
|
2018-07-03 16:54:50 -06:00
|
|
|
connect(m_netplay_dialog, &NetPlayDialog::Stop, this, &MainWindow::ForceStop);
|
2017-07-21 14:48:21 -06:00
|
|
|
connect(m_netplay_dialog, &NetPlayDialog::rejected, this, &MainWindow::NetPlayQuit);
|
|
|
|
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Join, this, &MainWindow::NetPlayJoin);
|
|
|
|
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Host, this, &MainWindow::NetPlayHost);
|
2018-07-20 16:27:43 -06:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-07-03 15:50:08 -06:00
|
|
|
connect(m_netplay_discord, &DiscordHandler::Join, this, &MainWindow::NetPlayJoin);
|
|
|
|
|
2018-07-20 16:27:43 -06:00
|
|
|
Discord::InitNetPlayFunctionality(*m_netplay_discord);
|
2018-07-03 15:50:08 -06:00
|
|
|
m_netplay_discord->Start();
|
2018-07-20 16:27:43 -06:00
|
|
|
#endif
|
2020-10-18 12:06:11 -06:00
|
|
|
connect(&Settings::Instance(), &Settings::ConfigChanged, this,
|
|
|
|
&MainWindow::UpdateScreenSaverInhibition);
|
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
|
|
|
&MainWindow::UpdateScreenSaverInhibition);
|
2017-07-21 14:48:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::NetPlayJoin()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
if (!Core::IsUninitialized(m_system))
|
2017-07-21 14:48:21 -06:00
|
|
|
{
|
2021-08-24 09:13:53 -06:00
|
|
|
ModalMessageBox::critical(nullptr, tr("Error"),
|
|
|
|
tr("Can't start a NetPlay Session while a game is still running!"));
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_netplay_dialog->isVisible())
|
|
|
|
{
|
2021-08-24 09:13:53 -06:00
|
|
|
ModalMessageBox::critical(nullptr, tr("Error"),
|
|
|
|
tr("A NetPlay Session is already in progress!"));
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-09 16:52:19 -06:00
|
|
|
auto server = Settings::Instance().GetNetPlayServer();
|
|
|
|
|
2017-07-21 14:48:21 -06:00
|
|
|
// Settings
|
2018-07-05 15:52:53 -06:00
|
|
|
const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
|
|
|
|
const bool is_traversal = traversal_choice == "traversal";
|
|
|
|
|
2017-08-10 13:47:27 -06:00
|
|
|
std::string host_ip;
|
|
|
|
u16 host_port;
|
2018-10-09 16:52:19 -06:00
|
|
|
if (server)
|
2017-07-21 14:48:21 -06:00
|
|
|
{
|
|
|
|
host_ip = "127.0.0.1";
|
2018-10-09 16:52:19 -06:00
|
|
|
host_port = server->GetPort();
|
2017-07-21 14:48:21 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-05 15:52:53 -06:00
|
|
|
host_ip = is_traversal ? Config::Get(Config::NETPLAY_HOST_CODE) :
|
|
|
|
Config::Get(Config::NETPLAY_ADDRESS);
|
|
|
|
host_port = Config::Get(Config::NETPLAY_CONNECT_PORT);
|
2017-07-21 14:48:21 -06:00
|
|
|
}
|
|
|
|
|
2017-08-10 13:47:27 -06:00
|
|
|
const std::string traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER);
|
|
|
|
const u16 traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT);
|
|
|
|
const std::string nickname = Config::Get(Config::NETPLAY_NICKNAME);
|
2019-05-30 15:58:31 -06:00
|
|
|
const std::string network_mode = Config::Get(Config::NETPLAY_NETWORK_MODE);
|
|
|
|
const bool host_input_authority = network_mode == "hostinputauthority" || network_mode == "golf";
|
2018-10-09 16:52:19 -06:00
|
|
|
|
|
|
|
if (server)
|
|
|
|
{
|
|
|
|
server->SetHostInputAuthority(host_input_authority);
|
2019-04-01 20:36:48 -06:00
|
|
|
server->AdjustPadBufferSize(Config::Get(Config::NETPLAY_BUFFER_SIZE));
|
2018-10-09 16:52:19 -06:00
|
|
|
}
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
// Create Client
|
2018-10-09 16:52:19 -06:00
|
|
|
const bool is_hosting_netplay = server != nullptr;
|
2018-07-06 17:39:42 -06:00
|
|
|
Settings::Instance().ResetNetPlayClient(new NetPlay::NetPlayClient(
|
2017-08-07 01:22:33 -06:00
|
|
|
host_ip, host_port, m_netplay_dialog, nickname,
|
2018-07-06 17:39:42 -06:00
|
|
|
NetPlay::NetTraversalConfig{is_hosting_netplay ? false : is_traversal, traversal_host,
|
|
|
|
traversal_port}));
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
if (!Settings::Instance().GetNetPlayClient()->IsConnected())
|
|
|
|
{
|
2018-05-06 11:00:17 -06:00
|
|
|
NetPlayQuit();
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_netplay_setup_dialog->close();
|
|
|
|
m_netplay_dialog->show(nickname, is_traversal);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-07 14:58:03 -06:00
|
|
|
bool MainWindow::NetPlayHost(const UICommon::GameFile& game)
|
2017-07-21 14:48:21 -06:00
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
if (!Core::IsUninitialized(m_system))
|
2017-07-21 14:48:21 -06:00
|
|
|
{
|
2021-08-24 09:13:53 -06:00
|
|
|
ModalMessageBox::critical(nullptr, tr("Error"),
|
|
|
|
tr("Can't start a NetPlay Session while a game is still running!"));
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_netplay_dialog->isVisible())
|
|
|
|
{
|
2021-08-24 09:13:53 -06:00
|
|
|
ModalMessageBox::critical(nullptr, tr("Error"),
|
|
|
|
tr("A NetPlay Session is already in progress!"));
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Settings
|
2017-08-10 13:47:27 -06:00
|
|
|
u16 host_port = Config::Get(Config::NETPLAY_HOST_PORT);
|
|
|
|
const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
|
|
|
|
const bool is_traversal = traversal_choice == "traversal";
|
|
|
|
const bool use_upnp = Config::Get(Config::NETPLAY_USE_UPNP);
|
|
|
|
|
|
|
|
const std::string traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER);
|
|
|
|
const u16 traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT);
|
2023-01-12 09:45:49 -07:00
|
|
|
const u16 traversal_port_alt = Config::Get(Config::NETPLAY_TRAVERSAL_PORT_ALT);
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
if (is_traversal)
|
|
|
|
host_port = Config::Get(Config::NETPLAY_LISTEN_PORT);
|
|
|
|
|
|
|
|
// Create Server
|
2023-01-12 09:45:49 -07:00
|
|
|
Settings::Instance().ResetNetPlayServer(
|
|
|
|
new NetPlay::NetPlayServer(host_port, use_upnp, m_netplay_dialog,
|
|
|
|
NetPlay::NetTraversalConfig{is_traversal, traversal_host,
|
|
|
|
traversal_port, traversal_port_alt}));
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
if (!Settings::Instance().GetNetPlayServer()->is_connected)
|
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(
|
2021-08-24 09:13:53 -06:00
|
|
|
nullptr, tr("Failed to open server"),
|
|
|
|
tr("Failed to listen on port %1. Is another instance of the NetPlay server running?")
|
2017-07-21 14:48:21 -06:00
|
|
|
.arg(host_port));
|
2018-05-06 11:00:17 -06:00
|
|
|
NetPlayQuit();
|
2017-07-21 14:48:21 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-07 14:58:03 -06:00
|
|
|
Settings::Instance().GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(),
|
2020-06-10 10:49:22 -06:00
|
|
|
m_game_list->GetNetPlayName(game));
|
2017-07-21 14:48:21 -06:00
|
|
|
|
|
|
|
// Join our local server
|
|
|
|
return NetPlayJoin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::NetPlayQuit()
|
|
|
|
{
|
|
|
|
Settings::Instance().ResetNetPlayClient();
|
|
|
|
Settings::Instance().ResetNetPlayServer();
|
2018-08-06 15:56:40 -06:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-07-03 15:50:08 -06:00
|
|
|
Discord::UpdateDiscordPresence();
|
2018-08-06 15:56:40 -06:00
|
|
|
#endif
|
2017-07-21 14:48:21 -06:00
|
|
|
}
|
|
|
|
|
2020-10-18 12:06:11 -06:00
|
|
|
void MainWindow::UpdateScreenSaverInhibition()
|
2018-01-01 14:15:26 -07:00
|
|
|
{
|
2024-03-28 12:35:13 -06:00
|
|
|
const bool inhibit = Config::Get(Config::MAIN_DISABLE_SCREENSAVER) &&
|
2024-10-24 22:41:35 -06:00
|
|
|
(Core::GetState(m_system) == Core::State::Running);
|
2020-10-18 12:06:11 -06:00
|
|
|
|
2020-10-22 12:19:01 -06:00
|
|
|
if (inhibit == m_is_screensaver_inhibited)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_is_screensaver_inhibited = inhibit;
|
|
|
|
|
2020-10-18 12:06:11 -06:00
|
|
|
UICommon::InhibitScreenSaver(inhibit);
|
2018-01-01 14:15:26 -07:00
|
|
|
}
|
|
|
|
|
2017-06-24 09:00:37 -06:00
|
|
|
bool MainWindow::eventFilter(QObject* object, QEvent* event)
|
|
|
|
{
|
2017-07-03 08:04:24 -06:00
|
|
|
if (event->type() == QEvent::Close)
|
2017-06-24 09:00:37 -06:00
|
|
|
{
|
2017-07-03 08:04:24 -06:00
|
|
|
if (RequestStop() && object == this)
|
|
|
|
m_exit_requested = true;
|
|
|
|
|
2017-06-24 09:00:37 -06:00
|
|
|
static_cast<QCloseEvent*>(event)->ignore();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-26 15:22:40 -06:00
|
|
|
|
2023-07-23 16:13:47 -06:00
|
|
|
QMenu* MainWindow::createPopupMenu()
|
|
|
|
{
|
|
|
|
// Disable the default popup menu as it exposes the debugger UI even when the debugger UI is
|
|
|
|
// disabled, which can lead to user confusion (see e.g. https://bugs.dolphin-emu.org/issues/13306)
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-06-26 15:22:40 -06:00
|
|
|
void MainWindow::dragEnterEvent(QDragEnterEvent* event)
|
|
|
|
{
|
|
|
|
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1)
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::dropEvent(QDropEvent* event)
|
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
const QList<QUrl>& urls = event->mimeData()->urls();
|
2017-06-26 15:22:40 -06:00
|
|
|
if (urls.empty())
|
|
|
|
return;
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
QStringList files;
|
|
|
|
QStringList folders;
|
2017-06-26 15:22:40 -06:00
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
for (const QUrl& url : urls)
|
2017-06-26 15:22:40 -06:00
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
QFileInfo file_info(url.toLocalFile());
|
|
|
|
QString path = file_info.filePath();
|
|
|
|
|
|
|
|
if (!file_info.exists() || !file_info.isReadable())
|
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path));
|
2018-11-05 11:20:45 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
(file_info.isFile() ? files : folders).append(path);
|
2017-06-26 15:22:40 -06:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
if (!files.isEmpty())
|
2017-06-26 15:22:40 -06:00
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
StartGame(StringListToStdVector(files));
|
2017-06-26 15:22:40 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
Settings& settings = Settings::Instance();
|
2019-02-12 15:47:17 -07:00
|
|
|
const bool show_confirm = !settings.GetPaths().empty();
|
2017-06-26 15:22:40 -06:00
|
|
|
|
2018-11-05 11:20:45 -07:00
|
|
|
for (const QString& folder : folders)
|
2017-06-26 15:22:40 -06:00
|
|
|
{
|
2018-11-05 11:20:45 -07:00
|
|
|
if (show_confirm)
|
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
if (ModalMessageBox::question(
|
2018-11-05 11:20:45 -07:00
|
|
|
this, tr("Confirm"),
|
|
|
|
tr("Do you want to add \"%1\" to the list of Game Paths?").arg(folder)) !=
|
|
|
|
QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
settings.AddPath(folder);
|
2017-06-26 15:22:40 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-26 19:24:07 -06:00
|
|
|
|
|
|
|
QSize MainWindow::sizeHint() const
|
|
|
|
{
|
|
|
|
return QSize(800, 600);
|
|
|
|
}
|
2017-08-24 08:35:47 -06:00
|
|
|
|
|
|
|
void MainWindow::OnBootGameCubeIPL(DiscIO::Region region)
|
|
|
|
{
|
|
|
|
StartGame(std::make_unique<BootParameters>(BootParameters::IPL{region}));
|
|
|
|
}
|
2017-08-24 09:38:31 -06:00
|
|
|
|
|
|
|
void MainWindow::OnImportNANDBackup()
|
|
|
|
{
|
2019-03-04 12:49:00 -07:00
|
|
|
auto response = ModalMessageBox::question(
|
2017-08-24 09:38:31 -06:00
|
|
|
this, tr("Question"),
|
|
|
|
tr("Merging a new NAND over your currently selected NAND will overwrite any channels "
|
|
|
|
"and savegames that already exist. This process is not reversible, so it is "
|
|
|
|
"recommended that you keep backups of both NANDs. Are you sure you want to "
|
|
|
|
"continue?"));
|
|
|
|
|
|
|
|
if (response == QMessageBox::No)
|
|
|
|
return;
|
|
|
|
|
2021-10-09 20:28:59 -06:00
|
|
|
QString file =
|
2024-07-28 06:24:38 -06:00
|
|
|
DolphinFileDialog::getOpenFileName(this, tr("Select NAND Backup"), QDir::currentPath(),
|
2021-10-09 20:28:59 -06:00
|
|
|
tr("BootMii NAND backup file (*.bin);;"
|
|
|
|
"All Files (*)"));
|
2017-08-24 09:38:31 -06:00
|
|
|
|
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2020-03-29 16:28:16 -06:00
|
|
|
ParallelProgressDialog dialog(this);
|
|
|
|
dialog.GetRaw()->setMinimum(0);
|
|
|
|
dialog.GetRaw()->setMaximum(0);
|
|
|
|
dialog.GetRaw()->setLabelText(tr("Importing NAND backup"));
|
|
|
|
dialog.GetRaw()->setCancelButton(nullptr);
|
2017-08-24 09:38:31 -06:00
|
|
|
|
2017-09-01 19:20:20 -06:00
|
|
|
auto beginning = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
2017-08-24 09:38:31 -06:00
|
|
|
|
2020-03-29 16:28:16 -06:00
|
|
|
std::future<void> result = std::async(std::launch::async, [&] {
|
2017-10-26 13:22:16 -06:00
|
|
|
DiscIO::NANDImporter().ImportNANDBin(
|
|
|
|
file.toStdString(),
|
|
|
|
[&dialog, beginning] {
|
2020-03-29 16:28:16 -06:00
|
|
|
dialog.SetLabelText(
|
|
|
|
tr("Importing NAND backup\n Time elapsed: %1s")
|
|
|
|
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
2017-10-26 13:22:16 -06:00
|
|
|
},
|
|
|
|
[this] {
|
2018-05-21 16:27:12 -06:00
|
|
|
std::optional<std::string> keys_file = RunOnObject(this, [this] {
|
2021-10-09 20:28:59 -06:00
|
|
|
return DolphinFileDialog::getOpenFileName(
|
2024-07-28 06:24:38 -06:00
|
|
|
this, tr("Select Keys File (OTP/SEEPROM Dump)"), QDir::currentPath(),
|
2021-10-09 20:28:59 -06:00
|
|
|
tr("BootMii keys file (*.bin);;"
|
|
|
|
"All Files (*)"))
|
2017-10-26 13:22:16 -06:00
|
|
|
.toStdString();
|
|
|
|
});
|
2018-05-21 16:27:12 -06:00
|
|
|
if (keys_file)
|
|
|
|
return *keys_file;
|
|
|
|
return std::string("");
|
2017-10-26 13:22:16 -06:00
|
|
|
});
|
2020-03-29 16:28:16 -06:00
|
|
|
dialog.Reset();
|
2017-08-24 09:38:31 -06:00
|
|
|
});
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(dialog.GetRaw());
|
2020-03-29 16:28:16 -06:00
|
|
|
dialog.GetRaw()->exec();
|
2017-08-24 09:38:31 -06:00
|
|
|
|
|
|
|
result.wait();
|
|
|
|
|
2024-07-02 09:27:04 -06:00
|
|
|
m_menu_bar->UpdateToolsMenu(Core::State::Uninitialized);
|
2017-08-24 09:38:31 -06:00
|
|
|
}
|
2017-08-27 05:55:05 -06:00
|
|
|
|
|
|
|
void MainWindow::OnPlayRecording()
|
|
|
|
{
|
2021-10-09 20:28:59 -06:00
|
|
|
QString dtm_file = DolphinFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select the Recording File to Play"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
|
2017-08-27 05:55:05 -06:00
|
|
|
|
|
|
|
if (dtm_file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
auto& movie = m_system.GetMovie();
|
2024-01-13 05:14:48 -07:00
|
|
|
if (!movie.IsReadOnly())
|
2017-08-27 05:55:05 -06:00
|
|
|
{
|
|
|
|
// let's make the read-only flag consistent at the start of a movie.
|
2024-01-13 05:14:48 -07:00
|
|
|
movie.SetReadOnly(true);
|
2017-08-27 05:55:05 -06:00
|
|
|
emit ReadOnlyModeChanged(true);
|
|
|
|
}
|
|
|
|
|
2017-12-25 10:07:29 -07:00
|
|
|
std::optional<std::string> savestate_path;
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.PlayInput(dtm_file.toStdString(), &savestate_path))
|
2017-08-27 05:55:05 -06:00
|
|
|
{
|
|
|
|
emit RecordingStatusChanged(true);
|
|
|
|
|
2017-12-25 10:07:29 -07:00
|
|
|
Play(savestate_path);
|
2017-08-27 05:55:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::OnStartRecording()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
auto& movie = m_system.GetMovie();
|
|
|
|
if (Core::GetState(m_system) == Core::State::Starting ||
|
|
|
|
Core::GetState(m_system) == Core::State::Stopping || movie.IsRecordingInput() ||
|
2024-01-13 05:14:48 -07:00
|
|
|
movie.IsPlayingInput())
|
|
|
|
{
|
2017-08-27 05:55:05 -06:00
|
|
|
return;
|
2024-01-13 05:14:48 -07:00
|
|
|
}
|
2017-08-27 05:55:05 -06:00
|
|
|
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.IsReadOnly())
|
2017-08-27 05:55:05 -06:00
|
|
|
{
|
|
|
|
// The user just chose to record a movie, so that should take precedence
|
2024-01-13 05:14:48 -07:00
|
|
|
movie.SetReadOnly(false);
|
2017-08-27 05:55:05 -06:00
|
|
|
emit ReadOnlyModeChanged(true);
|
|
|
|
}
|
|
|
|
|
2021-07-04 05:38:30 -06:00
|
|
|
Movie::ControllerTypeArray controllers{};
|
|
|
|
Movie::WiimoteEnabledArray wiimotes{};
|
2017-08-27 05:55:05 -06:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2022-01-06 00:08:02 -07:00
|
|
|
const SerialInterface::SIDevices si_device = Config::Get(Config::GetInfoForSIDevice(i));
|
|
|
|
if (si_device == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
2021-07-04 05:38:30 -06:00
|
|
|
controllers[i] = Movie::ControllerType::GBA;
|
2022-01-06 00:08:02 -07:00
|
|
|
else if (SerialInterface::SIDevice_IsGCController(si_device))
|
2021-07-04 05:38:30 -06:00
|
|
|
controllers[i] = Movie::ControllerType::GC;
|
|
|
|
else
|
|
|
|
controllers[i] = Movie::ControllerType::None;
|
2022-01-25 12:34:03 -07:00
|
|
|
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
2017-08-27 05:55:05 -06:00
|
|
|
}
|
|
|
|
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.BeginRecordingInput(controllers, wiimotes))
|
2017-08-27 05:55:05 -06:00
|
|
|
{
|
|
|
|
emit RecordingStatusChanged(true);
|
|
|
|
|
2024-10-24 22:41:35 -06:00
|
|
|
if (Core::IsUninitialized(m_system))
|
2017-08-27 05:55:05 -06:00
|
|
|
Play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::OnStopRecording()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
auto& movie = m_system.GetMovie();
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.IsRecordingInput())
|
2017-08-27 05:55:05 -06:00
|
|
|
OnExportRecording();
|
2024-01-13 05:14:48 -07:00
|
|
|
if (movie.IsMovieActive())
|
|
|
|
movie.EndPlayInput(false);
|
2019-03-13 08:41:57 -06:00
|
|
|
emit RecordingStatusChanged(false);
|
2017-08-27 05:55:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::OnExportRecording()
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
const Core::CPUThreadGuard guard(m_system);
|
2024-03-22 01:43:04 -06:00
|
|
|
|
|
|
|
QString dtm_file = DolphinFileDialog::getSaveFileName(
|
|
|
|
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
|
|
|
|
if (!dtm_file.isEmpty())
|
2024-10-24 22:41:35 -06:00
|
|
|
m_system.GetMovie().SaveRecording(dtm_file.toStdString());
|
2017-08-27 05:55:05 -06:00
|
|
|
}
|
2018-01-24 07:25:35 -07:00
|
|
|
|
2019-03-24 08:57:36 -06:00
|
|
|
void MainWindow::OnActivateChat()
|
|
|
|
{
|
|
|
|
if (g_netplay_chat_ui)
|
|
|
|
g_netplay_chat_ui->Activate();
|
|
|
|
}
|
|
|
|
|
2019-04-02 06:08:27 -06:00
|
|
|
void MainWindow::OnRequestGolfControl()
|
|
|
|
{
|
|
|
|
auto client = Settings::Instance().GetNetPlayClient();
|
|
|
|
if (client)
|
|
|
|
client->RequestGolfControl();
|
|
|
|
}
|
|
|
|
|
2018-01-27 06:35:02 -07:00
|
|
|
void MainWindow::ShowTASInput()
|
|
|
|
{
|
2018-02-06 04:10:28 -07:00
|
|
|
for (int i = 0; i < num_gc_controllers; i++)
|
2018-01-27 06:35:02 -07:00
|
|
|
{
|
2022-01-06 00:08:02 -07:00
|
|
|
const auto si_device = Config::Get(Config::GetInfoForSIDevice(i));
|
2022-11-19 03:16:10 -07:00
|
|
|
if (si_device == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
|
|
|
{
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_gba_tas_input_windows[i]);
|
2022-11-19 03:16:10 -07:00
|
|
|
m_gba_tas_input_windows[i]->show();
|
|
|
|
m_gba_tas_input_windows[i]->raise();
|
|
|
|
m_gba_tas_input_windows[i]->activateWindow();
|
|
|
|
}
|
|
|
|
else if (si_device != SerialInterface::SIDEVICE_NONE &&
|
|
|
|
si_device != SerialInterface::SIDEVICE_GC_GBA)
|
2018-01-27 06:35:02 -07:00
|
|
|
{
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_gc_tas_input_windows[i]);
|
2018-01-27 06:35:02 -07:00
|
|
|
m_gc_tas_input_windows[i]->show();
|
|
|
|
m_gc_tas_input_windows[i]->raise();
|
|
|
|
m_gc_tas_input_windows[i]->activateWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-06 04:10:28 -07:00
|
|
|
for (int i = 0; i < num_wii_controllers; i++)
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2022-01-25 12:34:03 -07:00
|
|
|
if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated &&
|
2024-10-24 22:41:35 -06:00
|
|
|
(!Core::IsRunning(m_system) || m_system.IsWii()))
|
2018-01-31 04:35:09 -07:00
|
|
|
{
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_wii_tas_input_windows[i]);
|
2018-01-31 04:35:09 -07:00
|
|
|
m_wii_tas_input_windows[i]->show();
|
|
|
|
m_wii_tas_input_windows[i]->raise();
|
|
|
|
m_wii_tas_input_windows[i]->activateWindow();
|
|
|
|
}
|
|
|
|
}
|
2018-01-27 06:35:02 -07:00
|
|
|
}
|
|
|
|
|
2018-01-24 07:25:35 -07:00
|
|
|
void MainWindow::OnConnectWiiRemote(int id)
|
|
|
|
{
|
2024-10-24 22:41:35 -06:00
|
|
|
const Core::CPUThreadGuard guard(m_system);
|
2024-03-22 01:43:04 -06:00
|
|
|
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
|
|
|
|
{
|
|
|
|
const auto wm = bt->AccessWiimoteByIndex(id);
|
|
|
|
wm->Activate(!wm->IsConnected());
|
|
|
|
}
|
2018-01-24 07:25:35 -07:00
|
|
|
}
|
2018-01-25 11:54:50 -07:00
|
|
|
|
2023-05-26 07:35:50 -06:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
void MainWindow::ShowAchievementsWindow()
|
|
|
|
{
|
|
|
|
if (!m_achievements_window)
|
|
|
|
{
|
|
|
|
m_achievements_window = new AchievementsWindow(this);
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_achievements_window);
|
2023-05-26 07:35:50 -06:00
|
|
|
m_achievements_window->show();
|
|
|
|
m_achievements_window->raise();
|
|
|
|
m_achievements_window->activateWindow();
|
2024-03-09 18:18:40 -07:00
|
|
|
m_achievements_window->UpdateData(AchievementManager::UpdatedItems{.all = true});
|
2023-05-26 07:35:50 -06:00
|
|
|
}
|
2023-11-15 08:56:15 -07:00
|
|
|
|
|
|
|
void MainWindow::ShowAchievementSettings()
|
|
|
|
{
|
|
|
|
ShowAchievementsWindow();
|
|
|
|
m_achievements_window->ForceSettingsTab();
|
|
|
|
}
|
2023-05-26 07:35:50 -06:00
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2018-01-25 11:54:50 -07:00
|
|
|
void MainWindow::ShowMemcardManager()
|
|
|
|
{
|
|
|
|
GCMemcardManager manager(this);
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(&manager);
|
2018-01-25 11:54:50 -07:00
|
|
|
manager.exec();
|
|
|
|
}
|
2018-03-23 19:13:56 -06:00
|
|
|
|
2018-11-17 08:36:28 -07:00
|
|
|
void MainWindow::ShowResourcePackManager()
|
|
|
|
{
|
|
|
|
ResourcePackManager manager(this);
|
|
|
|
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(&manager);
|
2018-11-17 08:36:28 -07:00
|
|
|
manager.exec();
|
|
|
|
}
|
|
|
|
|
2018-03-25 20:17:47 -06:00
|
|
|
void MainWindow::ShowCheatsManager()
|
|
|
|
{
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(m_cheats_manager);
|
2018-03-25 20:17:47 -06:00
|
|
|
m_cheats_manager->show();
|
|
|
|
}
|
|
|
|
|
2021-09-25 22:17:51 -06:00
|
|
|
void MainWindow::ShowRiivolutionBootWidget(const UICommon::GameFile& game)
|
|
|
|
{
|
|
|
|
auto second_game = m_game_list->FindSecondDisc(game);
|
|
|
|
std::vector<std::string> paths = {game.GetFilePath()};
|
|
|
|
if (second_game != nullptr)
|
|
|
|
paths.push_back(second_game->GetFilePath());
|
2021-11-20 11:38:09 -07:00
|
|
|
std::unique_ptr<BootParameters> boot_params = BootParameters::GenerateFromFile(paths);
|
2021-09-25 22:17:51 -06:00
|
|
|
if (!boot_params)
|
|
|
|
return;
|
|
|
|
if (!std::holds_alternative<BootParameters::Disc>(boot_params->parameters))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto& disc = std::get<BootParameters::Disc>(boot_params->parameters);
|
|
|
|
RiivolutionBootWidget w(disc.volume->GetGameID(), disc.volume->GetRevision(),
|
2021-10-25 19:18:06 -06:00
|
|
|
disc.volume->GetDiscNumber(), game.GetFilePath(), this);
|
2023-07-30 16:42:15 -06:00
|
|
|
SetQWidgetWindowDecorations(&w);
|
2023-06-07 19:53:38 -06:00
|
|
|
|
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
connect(&w, &RiivolutionBootWidget::OpenAchievementSettings, this,
|
|
|
|
&MainWindow::ShowAchievementSettings);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2021-09-25 22:17:51 -06:00
|
|
|
w.exec();
|
|
|
|
if (!w.ShouldBoot())
|
|
|
|
return;
|
|
|
|
|
2021-10-20 19:08:54 -06:00
|
|
|
AddRiivolutionPatches(boot_params.get(), std::move(w.GetPatches()));
|
2021-09-25 22:17:51 -06:00
|
|
|
StartGame(std::move(boot_params));
|
|
|
|
}
|