2015-12-20 05:24:48 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/MenuBar.h"
|
2017-08-24 15:38:31 +00:00
|
|
|
|
2017-11-02 10:37:51 +00:00
|
|
|
#include <cinttypes>
|
2021-02-27 20:04:45 +00:00
|
|
|
#include <future>
|
2017-11-02 10:37:51 +00:00
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
#include <QAction>
|
2021-01-13 08:55:52 +00:00
|
|
|
#include <QActionGroup>
|
2016-02-11 11:59:44 +00:00
|
|
|
#include <QDesktopServices>
|
2017-05-04 21:01:12 +00:00
|
|
|
#include <QFileDialog>
|
2018-02-14 22:25:01 +00:00
|
|
|
#include <QFontDialog>
|
|
|
|
#include <QInputDialog>
|
2017-05-08 17:03:59 +00:00
|
|
|
#include <QMap>
|
2016-02-11 11:59:44 +00:00
|
|
|
#include <QUrl>
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2023-07-14 03:10:18 +00:00
|
|
|
#include "Common/Align.h"
|
2017-08-24 14:35:47 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
|
|
|
#include "Common/FileUtil.h"
|
2017-11-02 10:37:51 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2017-11-02 16:34:04 +00:00
|
|
|
|
2023-06-08 01:37:13 +00:00
|
|
|
#include "Core/AchievementManager.h"
|
2018-02-14 22:25:01 +00:00
|
|
|
#include "Core/Boot/Boot.h"
|
2017-06-14 09:58:11 +00:00
|
|
|
#include "Core/CommonTitles.h"
|
2023-05-26 13:35:50 +00:00
|
|
|
#include "Core/Config/AchievementSettings.h"
|
2021-10-14 00:29:04 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-06-22 22:11:53 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2017-08-27 11:55:05 +00:00
|
|
|
#include "Core/Core.h"
|
2018-02-14 22:25:01 +00:00
|
|
|
#include "Core/Debugger/RSO.h"
|
|
|
|
#include "Core/HLE/HLE.h"
|
2020-03-10 09:41:59 +00:00
|
|
|
#include "Core/HW/AddressSpace.h"
|
2020-04-28 17:10:50 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2018-05-12 20:39:14 +00:00
|
|
|
#include "Core/HW/WiiSave.h"
|
2017-08-27 11:55:05 +00:00
|
|
|
#include "Core/HW/Wiimote.h"
|
2017-06-14 09:58:11 +00:00
|
|
|
#include "Core/IOS/ES/ES.h"
|
2023-07-14 03:10:18 +00:00
|
|
|
#include "Core/IOS/FS/FileSystem.h"
|
2017-06-14 09:58:11 +00:00
|
|
|
#include "Core/IOS/IOS.h"
|
2018-01-24 14:25:35 +00:00
|
|
|
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
2017-08-27 11:55:05 +00:00
|
|
|
#include "Core/Movie.h"
|
2018-11-23 10:02:00 +00:00
|
|
|
#include "Core/NetPlayProto.h"
|
2018-04-09 13:31:20 +00:00
|
|
|
#include "Core/PowerPC/JitInterface.h"
|
2018-05-17 21:09:55 +00:00
|
|
|
#include "Core/PowerPC/MMU.h"
|
2018-02-14 22:25:01 +00:00
|
|
|
#include "Core/PowerPC/PPCAnalyst.h"
|
|
|
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
2018-04-09 13:31:20 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2018-02-14 22:25:01 +00:00
|
|
|
#include "Core/PowerPC/SignatureDB/SignatureDB.h"
|
2016-02-15 01:56:40 +00:00
|
|
|
#include "Core/State.h"
|
2022-12-02 19:07:30 +00:00
|
|
|
#include "Core/System.h"
|
2017-10-06 19:45:28 +00:00
|
|
|
#include "Core/TitleDatabase.h"
|
2017-10-03 14:45:59 +00:00
|
|
|
#include "Core/WiiUtils.h"
|
2017-11-02 16:34:04 +00:00
|
|
|
|
2019-02-23 18:18:16 +00:00
|
|
|
#include "DiscIO/Enums.h"
|
2017-08-24 15:38:31 +00:00
|
|
|
#include "DiscIO/NANDImporter.h"
|
2017-11-02 16:34:04 +00:00
|
|
|
#include "DiscIO/WiiSaveBanner.h"
|
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/AboutDialog.h"
|
|
|
|
#include "DolphinQt/Host.h"
|
2022-08-28 01:03:32 +00:00
|
|
|
#include "DolphinQt/NANDRepairDialog.h"
|
2021-10-10 02:28:59 +00:00
|
|
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
2019-03-04 19:49:00 +00:00
|
|
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
2021-02-27 20:04:45 +00:00
|
|
|
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
|
2023-07-30 22:42:15 +00:00
|
|
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
|
|
|
#include "DolphinQt/Updater.h"
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2019-02-26 19:40:38 +00:00
|
|
|
#include "UICommon/AutoUpdate.h"
|
2017-12-31 19:33:36 +00:00
|
|
|
#include "UICommon/GameFile.h"
|
|
|
|
|
2019-01-21 20:05:31 +00:00
|
|
|
QPointer<MenuBar> MenuBar::s_menu_bar;
|
|
|
|
|
2019-10-12 16:04:51 +00:00
|
|
|
QString MenuBar::GetSignatureSelector() const
|
|
|
|
{
|
|
|
|
return QStringLiteral("%1 (*.dsy);; %2 (*.csv);; %3 (*.mega)")
|
|
|
|
.arg(tr("Dolphin Signature File"), tr("Dolphin Signature CSV File"),
|
|
|
|
tr("WiiTools Signature MEGA File"));
|
|
|
|
}
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
|
|
|
{
|
2019-01-21 20:05:31 +00:00
|
|
|
s_menu_bar = this;
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
AddFileMenu();
|
2016-02-15 01:56:40 +00:00
|
|
|
AddEmulationMenu();
|
2017-08-27 11:55:05 +00:00
|
|
|
AddMovieMenu();
|
2017-06-06 11:49:49 +00:00
|
|
|
AddOptionsMenu();
|
2017-05-04 21:01:12 +00:00
|
|
|
AddToolsMenu();
|
2015-12-20 05:24:48 +00:00
|
|
|
AddViewMenu();
|
2018-04-09 13:31:20 +00:00
|
|
|
AddJITMenu();
|
2018-02-14 22:25:01 +00:00
|
|
|
AddSymbolsMenu();
|
2016-02-11 11:59:44 +00:00
|
|
|
AddHelpMenu();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-09-04 18:12:13 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
2022-08-08 01:25:19 +00:00
|
|
|
[=, this](Core::State state) { OnEmulationStateChanged(state); });
|
2018-05-05 22:17:06 +00:00
|
|
|
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this,
|
|
|
|
[this] { OnEmulationStateChanged(Core::GetState()); });
|
|
|
|
|
2017-09-04 18:12:13 +00:00
|
|
|
OnEmulationStateChanged(Core::GetState());
|
2017-09-13 17:33:45 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::DebugModeToggled, this, &MenuBar::OnDebugModeToggled);
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
connect(this, &MenuBar::SelectionChanged, this, &MenuBar::OnSelectionChanged);
|
|
|
|
connect(this, &MenuBar::RecordingStatusChanged, this, &MenuBar::OnRecordingStatusChanged);
|
|
|
|
connect(this, &MenuBar::ReadOnlyModeChanged, this, &MenuBar::OnReadOnlyModeChanged);
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 18:12:13 +00:00
|
|
|
void MenuBar::OnEmulationStateChanged(Core::State state)
|
2016-02-15 01:56:40 +00:00
|
|
|
{
|
2017-09-04 18:12:13 +00:00
|
|
|
bool running = state != Core::State::Uninitialized;
|
|
|
|
bool playing = running && state != Core::State::Paused;
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2018-03-23 00:18:53 +00:00
|
|
|
// File
|
|
|
|
m_eject_disc->setEnabled(running);
|
|
|
|
m_change_disc->setEnabled(running);
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
// Emulation
|
2017-09-04 18:12:13 +00:00
|
|
|
m_play_action->setEnabled(!playing);
|
|
|
|
m_play_action->setVisible(!playing);
|
|
|
|
m_pause_action->setEnabled(playing);
|
|
|
|
m_pause_action->setVisible(playing);
|
|
|
|
m_stop_action->setEnabled(running);
|
|
|
|
m_stop_action->setVisible(running);
|
|
|
|
m_reset_action->setEnabled(running);
|
|
|
|
m_fullscreen_action->setEnabled(running);
|
|
|
|
m_screenshot_action->setEnabled(running);
|
|
|
|
m_state_save_menu->setEnabled(running);
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2023-06-08 01:37:13 +00:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
2023-12-11 18:18:02 +00:00
|
|
|
const bool hardcore = AchievementManager::GetInstance().IsHardcoreModeActive();
|
2023-06-08 01:37:13 +00:00
|
|
|
m_state_load_menu->setEnabled(running && !hardcore);
|
2023-06-08 01:46:49 +00:00
|
|
|
m_frame_advance_action->setEnabled(running && !hardcore);
|
2023-06-08 01:37:13 +00:00
|
|
|
#else // USE_RETRO_ACHIEVEMENTS
|
|
|
|
m_state_load_menu->setEnabled(running);
|
2023-06-08 01:46:49 +00:00
|
|
|
m_frame_advance_action->setEnabled(running);
|
2023-06-08 01:37:13 +00:00
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2017-08-27 11:55:05 +00:00
|
|
|
// Movie
|
2017-09-04 18:12:13 +00:00
|
|
|
m_recording_read_only->setEnabled(running);
|
|
|
|
if (!running)
|
2019-06-08 06:39:12 +00:00
|
|
|
{
|
2017-09-04 18:12:13 +00:00
|
|
|
m_recording_stop->setEnabled(false);
|
2019-06-08 06:39:12 +00:00
|
|
|
m_recording_export->setEnabled(false);
|
|
|
|
}
|
2019-08-14 11:45:07 +00:00
|
|
|
m_recording_play->setEnabled(m_game_selected && !running);
|
2023-07-20 21:55:25 +00:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
m_recording_play->setEnabled(m_game_selected && !running && !hardcore);
|
|
|
|
#else // USE_RETRO_ACHIEVEMENTS
|
|
|
|
m_recording_play->setEnabled(m_game_selected && !running);
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
2019-08-14 11:45:07 +00:00
|
|
|
m_recording_start->setEnabled((m_game_selected || running) && !Movie::IsPlayingInput());
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2018-04-09 13:31:20 +00:00
|
|
|
// JIT
|
|
|
|
m_jit_interpreter_core->setEnabled(running);
|
|
|
|
m_jit_block_linking->setEnabled(!running);
|
|
|
|
m_jit_disable_cache->setEnabled(!running);
|
2023-10-01 20:54:09 +00:00
|
|
|
m_jit_disable_fastmem_arena->setEnabled(!running);
|
2023-12-10 19:50:58 +00:00
|
|
|
m_jit_disable_large_entry_points_map->setEnabled(!running);
|
2018-04-09 13:31:20 +00:00
|
|
|
m_jit_clear_cache->setEnabled(running);
|
|
|
|
m_jit_log_coverage->setEnabled(!running);
|
|
|
|
m_jit_search_instruction->setEnabled(running);
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
// Symbols
|
|
|
|
m_symbols->setEnabled(running);
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
UpdateStateSlotMenu();
|
2017-09-04 18:12:13 +00:00
|
|
|
UpdateToolsMenu(running);
|
2017-09-13 17:33:45 +00:00
|
|
|
|
|
|
|
OnDebugModeToggled(Settings::Instance().IsDebugModeEnabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::OnDebugModeToggled(bool enabled)
|
|
|
|
{
|
2018-02-14 22:25:01 +00:00
|
|
|
// Options
|
|
|
|
m_boot_to_pause->setVisible(enabled);
|
|
|
|
m_automatic_start->setVisible(enabled);
|
2021-10-17 07:18:48 +00:00
|
|
|
m_reset_ignore_panic_handler->setVisible(enabled);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_change_font->setVisible(enabled);
|
|
|
|
|
|
|
|
// View
|
|
|
|
m_show_code->setVisible(enabled);
|
2017-09-13 17:33:45 +00:00
|
|
|
m_show_registers->setVisible(enabled);
|
2020-03-21 07:48:49 +00:00
|
|
|
m_show_threads->setVisible(enabled);
|
2017-09-27 06:53:05 +00:00
|
|
|
m_show_watch->setVisible(enabled);
|
2017-10-03 16:43:44 +00:00
|
|
|
m_show_breakpoints->setVisible(enabled);
|
2018-03-16 11:39:53 +00:00
|
|
|
m_show_memory->setVisible(enabled);
|
2020-04-19 19:30:50 +00:00
|
|
|
m_show_network->setVisible(enabled);
|
2018-04-09 13:31:20 +00:00
|
|
|
m_show_jit->setVisible(enabled);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
if (enabled)
|
2018-04-09 13:31:20 +00:00
|
|
|
{
|
|
|
|
addMenu(m_jit);
|
2018-02-14 22:25:01 +00:00
|
|
|
addMenu(m_symbols);
|
2018-04-09 13:31:20 +00:00
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
else
|
2018-04-09 13:31:20 +00:00
|
|
|
{
|
|
|
|
removeAction(m_jit->menuAction());
|
2018-02-14 22:25:01 +00:00
|
|
|
removeAction(m_symbols->menuAction());
|
2018-04-09 13:31:20 +00:00
|
|
|
}
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddFileMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* file_menu = addMenu(tr("&File"));
|
2023-04-19 16:25:59 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
|
|
|
m_open_action = file_menu->addAction(tr("&Open..."), QKeySequence::Open, this, &MenuBar::Open);
|
|
|
|
#else
|
2020-02-26 19:31:10 +00:00
|
|
|
m_open_action = file_menu->addAction(tr("&Open..."), this, &MenuBar::Open, QKeySequence::Open);
|
2023-04-19 16:25:59 +00:00
|
|
|
#endif
|
2018-03-23 00:18:53 +00:00
|
|
|
|
|
|
|
file_menu->addSeparator();
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_change_disc = file_menu->addAction(tr("Change &Disc..."), this, &MenuBar::ChangeDisc);
|
|
|
|
m_eject_disc = file_menu->addAction(tr("&Eject Disc"), this, &MenuBar::EjectDisc);
|
2018-03-23 00:18:53 +00:00
|
|
|
|
|
|
|
file_menu->addSeparator();
|
|
|
|
|
2023-01-16 08:36:24 +00:00
|
|
|
m_open_user_folder =
|
2023-01-16 17:29:44 +00:00
|
|
|
file_menu->addAction(tr("Open &User Folder"), this, &MenuBar::OpenUserFolder);
|
2023-01-16 08:36:24 +00:00
|
|
|
|
|
|
|
file_menu->addSeparator();
|
|
|
|
|
2020-02-26 19:31:10 +00:00
|
|
|
m_exit_action = file_menu->addAction(tr("E&xit"), this, &MenuBar::Exit);
|
2021-04-25 00:18:28 +00:00
|
|
|
m_exit_action->setShortcuts({QKeySequence::Quit, QKeySequence(Qt::ALT | Qt::Key_F4)});
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 21:01:12 +00:00
|
|
|
void MenuBar::AddToolsMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* tools_menu = addMenu(tr("&Tools"));
|
2017-08-24 13:11:04 +00:00
|
|
|
|
2019-05-18 22:24:25 +00:00
|
|
|
tools_menu->addAction(tr("&Resource Pack Manager"), this,
|
|
|
|
[this] { emit ShowResourcePackManager(); });
|
2018-01-25 18:54:50 +00:00
|
|
|
|
2021-09-16 04:50:21 +00:00
|
|
|
tools_menu->addAction(tr("&Cheats Manager"), this, [this] { emit ShowCheatsManager(); });
|
2018-03-26 02:17:47 +00:00
|
|
|
|
2019-05-18 22:24:25 +00:00
|
|
|
tools_menu->addAction(tr("FIFO Player"), this, &MenuBar::ShowFIFOPlayer);
|
2017-08-24 13:11:04 +00:00
|
|
|
|
2023-01-24 21:51:02 +00:00
|
|
|
auto* usb_device_menu = new QMenu(tr("Emulated USB Devices"), tools_menu);
|
|
|
|
usb_device_menu->addAction(tr("&Skylanders Portal"), this, &MenuBar::ShowSkylanderPortal);
|
|
|
|
usb_device_menu->addAction(tr("&Infinity Base"), this, &MenuBar::ShowInfinityBase);
|
|
|
|
tools_menu->addMenu(usb_device_menu);
|
2023-01-07 22:54:36 +00:00
|
|
|
|
2017-08-24 13:11:04 +00:00
|
|
|
tools_menu->addSeparator();
|
|
|
|
|
2019-05-18 22:24:25 +00:00
|
|
|
tools_menu->addAction(tr("Start &NetPlay..."), this, &MenuBar::StartNetPlay);
|
|
|
|
tools_menu->addAction(tr("Browse &NetPlay Sessions...."), this, &MenuBar::BrowseNetPlay);
|
2017-06-14 09:58:11 +00:00
|
|
|
|
2017-08-24 14:35:47 +00:00
|
|
|
tools_menu->addSeparator();
|
2019-05-18 22:24:25 +00:00
|
|
|
|
2023-05-26 13:35:50 +00:00
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
|
|
if (Config::Get(Config::RA_ENABLED))
|
|
|
|
{
|
|
|
|
tools_menu->addAction(tr("Achievements"), this, [this] { emit ShowAchievementsWindow(); });
|
|
|
|
|
|
|
|
tools_menu->addSeparator();
|
|
|
|
}
|
|
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
|
2017-08-24 14:35:47 +00:00
|
|
|
QMenu* gc_ipl = tools_menu->addMenu(tr("Load GameCube Main Menu"));
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_ntscj_ipl = gc_ipl->addAction(tr("NTSC-J"), this,
|
|
|
|
[this] { emit BootGameCubeIPL(DiscIO::Region::NTSC_J); });
|
|
|
|
m_ntscu_ipl = gc_ipl->addAction(tr("NTSC-U"), this,
|
|
|
|
[this] { emit BootGameCubeIPL(DiscIO::Region::NTSC_U); });
|
2017-08-24 14:35:47 +00:00
|
|
|
m_pal_ipl =
|
2018-07-09 08:02:10 +00:00
|
|
|
gc_ipl->addAction(tr("PAL"), this, [this] { emit BootGameCubeIPL(DiscIO::Region::PAL); });
|
2017-08-24 14:35:47 +00:00
|
|
|
|
2019-05-18 22:24:25 +00:00
|
|
|
tools_menu->addAction(tr("Memory Card Manager"), this, [this] { emit ShowMemcardManager(); });
|
2017-08-30 14:44:28 +00:00
|
|
|
|
2017-07-20 15:52:45 +00:00
|
|
|
tools_menu->addSeparator();
|
|
|
|
|
2017-07-06 09:00:37 +00:00
|
|
|
// Label will be set by a NANDRefresh later
|
2019-07-30 11:57:06 +00:00
|
|
|
m_boot_sysmenu = tools_menu->addAction(QString{}, this, [this] { emit BootWiiSystemMenu(); });
|
2019-05-18 22:24:25 +00:00
|
|
|
m_wad_install_action = tools_menu->addAction(tr("Install WAD..."), this, &MenuBar::InstallWAD);
|
|
|
|
m_manage_nand_menu = tools_menu->addMenu(tr("Manage NAND"));
|
|
|
|
m_import_backup = m_manage_nand_menu->addAction(tr("Import BootMii NAND Backup..."), this,
|
|
|
|
[this] { emit ImportNANDBackup(); });
|
|
|
|
m_check_nand = m_manage_nand_menu->addAction(tr("Check NAND..."), this, &MenuBar::CheckNAND);
|
|
|
|
m_extract_certificates = m_manage_nand_menu->addAction(tr("Extract Certificates from NAND"), this,
|
|
|
|
&MenuBar::NANDExtractCertificates);
|
2017-08-26 12:41:53 +00:00
|
|
|
|
2017-07-06 09:00:37 +00:00
|
|
|
m_boot_sysmenu->setEnabled(false);
|
|
|
|
|
2020-09-12 22:53:17 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::NANDRefresh, this, [this] { UpdateToolsMenu(false); });
|
2017-07-06 09:00:37 +00:00
|
|
|
|
2017-06-14 09:58:11 +00:00
|
|
|
m_perform_online_update_menu = tools_menu->addMenu(tr("Perform Online System Update"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_perform_online_update_for_current_region = m_perform_online_update_menu->addAction(
|
|
|
|
tr("Current Region"), this, [this] { emit PerformOnlineUpdate(""); });
|
2017-06-14 09:58:11 +00:00
|
|
|
m_perform_online_update_menu->addSeparator();
|
2018-07-09 08:02:10 +00:00
|
|
|
m_perform_online_update_menu->addAction(tr("Europe"), this,
|
|
|
|
[this] { emit PerformOnlineUpdate("EUR"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("Japan"), this,
|
|
|
|
[this] { emit PerformOnlineUpdate("JPN"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("Korea"), this,
|
|
|
|
[this] { emit PerformOnlineUpdate("KOR"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("United States"), this,
|
|
|
|
[this] { emit PerformOnlineUpdate("USA"); });
|
2018-01-24 14:25:35 +00:00
|
|
|
|
2019-05-18 22:24:25 +00:00
|
|
|
tools_menu->addSeparator();
|
|
|
|
|
2023-12-15 15:15:21 +00:00
|
|
|
m_import_wii_save =
|
|
|
|
tools_menu->addAction(tr("Import Wii Save..."), this, &MenuBar::ImportWiiSave);
|
|
|
|
m_export_wii_saves =
|
|
|
|
tools_menu->addAction(tr("Export All Wii Saves"), this, &MenuBar::ExportWiiSaves);
|
2019-05-18 22:24:25 +00:00
|
|
|
|
2019-03-17 17:51:50 +00:00
|
|
|
QMenu* menu = new QMenu(tr("Connect Wii Remotes"), tools_menu);
|
2018-01-24 14:25:35 +00:00
|
|
|
|
|
|
|
tools_menu->addSeparator();
|
|
|
|
tools_menu->addMenu(menu);
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2018-07-09 08:02:10 +00:00
|
|
|
m_wii_remotes[i] = menu->addAction(tr("Connect Wii Remote %1").arg(i + 1), this,
|
|
|
|
[this, i] { emit ConnectWiiRemote(i); });
|
2018-01-24 14:25:35 +00:00
|
|
|
m_wii_remotes[i]->setCheckable(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu->addSeparator();
|
|
|
|
|
|
|
|
m_wii_remotes[4] =
|
2018-07-09 08:02:10 +00:00
|
|
|
menu->addAction(tr("Connect Balance Board"), this, [this] { emit ConnectWiiRemote(4); });
|
2018-01-24 14:25:35 +00:00
|
|
|
m_wii_remotes[4]->setCheckable(true);
|
2017-05-04 21:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
void MenuBar::AddEmulationMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* emu_menu = addMenu(tr("&Emulation"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_play_action = emu_menu->addAction(tr("&Play"), this, &MenuBar::Play);
|
|
|
|
m_pause_action = emu_menu->addAction(tr("&Pause"), this, &MenuBar::Pause);
|
|
|
|
m_stop_action = emu_menu->addAction(tr("&Stop"), this, &MenuBar::Stop);
|
|
|
|
m_reset_action = emu_menu->addAction(tr("&Reset"), this, &MenuBar::Reset);
|
|
|
|
m_fullscreen_action = emu_menu->addAction(tr("Toggle &Fullscreen"), this, &MenuBar::Fullscreen);
|
|
|
|
m_frame_advance_action = emu_menu->addAction(tr("&Frame Advance"), this, &MenuBar::FrameAdvance);
|
2017-07-16 00:36:37 +00:00
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_screenshot_action = emu_menu->addAction(tr("Take Screenshot"), this, &MenuBar::Screenshot);
|
2017-07-16 00:36:37 +00:00
|
|
|
|
|
|
|
emu_menu->addSeparator();
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
AddStateLoadMenu(emu_menu);
|
|
|
|
AddStateSaveMenu(emu_menu);
|
|
|
|
AddStateSlotMenu(emu_menu);
|
|
|
|
UpdateStateSlotMenu();
|
2019-08-01 17:59:29 +00:00
|
|
|
|
|
|
|
for (QMenu* menu : {m_state_load_menu, m_state_save_menu, m_state_slot_menu})
|
|
|
|
connect(menu, &QMenu::aboutToShow, this, &MenuBar::UpdateStateSlotMenu);
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateLoadMenu(QMenu* emu_menu)
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
m_state_load_menu = emu_menu->addMenu(tr("&Load State"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_state_load_menu->addAction(tr("Load State from File"), this, &MenuBar::StateLoad);
|
|
|
|
m_state_load_menu->addAction(tr("Load State from Selected Slot"), this, &MenuBar::StateLoadSlot);
|
2016-02-15 01:56:40 +00:00
|
|
|
m_state_load_slots_menu = m_state_load_menu->addMenu(tr("Load State from Slot"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_state_load_menu->addAction(tr("Undo Load State"), this, &MenuBar::StateLoadUndo);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
2019-07-30 11:57:06 +00:00
|
|
|
QAction* action = m_state_load_slots_menu->addAction(QString{});
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2022-08-08 01:25:19 +00:00
|
|
|
connect(action, &QAction::triggered, this, [=, this]() { emit StateLoadSlotAt(i); });
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateSaveMenu(QMenu* emu_menu)
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
m_state_save_menu = emu_menu->addMenu(tr("Sa&ve State"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_state_save_menu->addAction(tr("Save State to File"), this, &MenuBar::StateSave);
|
|
|
|
m_state_save_menu->addAction(tr("Save State to Selected Slot"), this, &MenuBar::StateSaveSlot);
|
|
|
|
m_state_save_menu->addAction(tr("Save State to Oldest Slot"), this, &MenuBar::StateSaveOldest);
|
2016-02-15 01:56:40 +00:00
|
|
|
m_state_save_slots_menu = m_state_save_menu->addMenu(tr("Save State to Slot"));
|
2018-07-09 08:02:10 +00:00
|
|
|
m_state_save_menu->addAction(tr("Undo Save State"), this, &MenuBar::StateSaveUndo);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
2019-07-30 11:57:06 +00:00
|
|
|
QAction* action = m_state_save_slots_menu->addAction(QString{});
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2022-08-08 01:25:19 +00:00
|
|
|
connect(action, &QAction::triggered, this, [=, this]() { emit StateSaveSlotAt(i); });
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateSlotMenu(QMenu* emu_menu)
|
|
|
|
{
|
|
|
|
m_state_slot_menu = emu_menu->addMenu(tr("Select State Slot"));
|
|
|
|
m_state_slots = new QActionGroup(this);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
2019-07-30 11:57:06 +00:00
|
|
|
QAction* action = m_state_slot_menu->addAction(QString{});
|
2016-02-15 01:56:40 +00:00
|
|
|
action->setCheckable(true);
|
|
|
|
action->setActionGroup(m_state_slots);
|
2017-05-31 07:17:39 +00:00
|
|
|
if (Settings::Instance().GetStateSlot() == i)
|
2016-02-15 01:56:40 +00:00
|
|
|
action->setChecked(true);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2022-08-08 01:25:19 +00:00
|
|
|
connect(action, &QAction::triggered, this, [=, this]() { emit SetStateSlot(i); });
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::UpdateStateSlotMenu()
|
|
|
|
{
|
|
|
|
QList<QAction*> actions_slot = m_state_slots->actions();
|
|
|
|
QList<QAction*> actions_load = m_state_load_slots_menu->actions();
|
|
|
|
QList<QAction*> actions_save = m_state_save_slots_menu->actions();
|
|
|
|
for (int i = 0; i < actions_slot.length(); i++)
|
|
|
|
{
|
|
|
|
int slot = i + 1;
|
|
|
|
QString info = QString::fromStdString(State::GetInfoStringOfSlot(slot));
|
2017-07-23 08:50:20 +00:00
|
|
|
actions_load.at(i)->setText(tr("Load from Slot %1 - %2").arg(slot).arg(info));
|
|
|
|
actions_save.at(i)->setText(tr("Save to Slot %1 - %2").arg(slot).arg(info));
|
|
|
|
actions_slot.at(i)->setText(tr("Select Slot %1 - %2").arg(slot).arg(info));
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddViewMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* view_menu = addMenu(tr("&View"));
|
2017-08-03 14:43:50 +00:00
|
|
|
QAction* show_log = view_menu->addAction(tr("Show &Log"));
|
2017-06-29 10:46:20 +00:00
|
|
|
show_log->setCheckable(true);
|
|
|
|
show_log->setChecked(Settings::Instance().IsLogVisible());
|
|
|
|
|
|
|
|
connect(show_log, &QAction::toggled, &Settings::Instance(), &Settings::SetLogVisible);
|
|
|
|
|
2017-08-03 14:43:50 +00:00
|
|
|
QAction* show_log_config = view_menu->addAction(tr("Show Log &Configuration"));
|
2017-06-29 10:46:20 +00:00
|
|
|
show_log_config->setCheckable(true);
|
|
|
|
show_log_config->setChecked(Settings::Instance().IsLogConfigVisible());
|
|
|
|
|
|
|
|
connect(show_log_config, &QAction::toggled, &Settings::Instance(),
|
|
|
|
&Settings::SetLogConfigVisible);
|
|
|
|
|
2018-04-19 09:32:00 +00:00
|
|
|
QAction* show_toolbar = view_menu->addAction(tr("Show &Toolbar"));
|
|
|
|
show_toolbar->setCheckable(true);
|
|
|
|
show_toolbar->setChecked(Settings::Instance().IsToolBarVisible());
|
|
|
|
|
|
|
|
connect(show_toolbar, &QAction::toggled, &Settings::Instance(), &Settings::SetToolBarVisible);
|
|
|
|
|
2017-06-29 10:46:20 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::LogVisibilityChanged, show_log, &QAction::setChecked);
|
|
|
|
connect(&Settings::Instance(), &Settings::LogConfigVisibilityChanged, show_log_config,
|
|
|
|
&QAction::setChecked);
|
2018-04-19 09:32:00 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::ToolBarVisibilityChanged, show_toolbar,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
|
|
|
QAction* lock_widgets = view_menu->addAction(tr("&Lock Widgets In Place"));
|
|
|
|
lock_widgets->setCheckable(true);
|
|
|
|
lock_widgets->setChecked(Settings::Instance().AreWidgetsLocked());
|
|
|
|
|
|
|
|
connect(lock_widgets, &QAction::toggled, &Settings::Instance(), &Settings::SetWidgetsLocked);
|
2017-06-29 10:46:20 +00:00
|
|
|
|
|
|
|
view_menu->addSeparator();
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
m_show_code = view_menu->addAction(tr("&Code"));
|
|
|
|
m_show_code->setCheckable(true);
|
|
|
|
m_show_code->setChecked(Settings::Instance().IsCodeVisible());
|
|
|
|
|
|
|
|
connect(m_show_code, &QAction::toggled, &Settings::Instance(), &Settings::SetCodeVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::CodeVisibilityChanged, m_show_code,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2017-09-13 17:33:45 +00:00
|
|
|
m_show_registers = view_menu->addAction(tr("&Registers"));
|
|
|
|
m_show_registers->setCheckable(true);
|
|
|
|
m_show_registers->setChecked(Settings::Instance().IsRegistersVisible());
|
|
|
|
|
|
|
|
connect(m_show_registers, &QAction::toggled, &Settings::Instance(),
|
|
|
|
&Settings::SetRegistersVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::RegistersVisibilityChanged, m_show_registers,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2020-03-21 07:48:49 +00:00
|
|
|
m_show_threads = view_menu->addAction(tr("&Threads"));
|
|
|
|
m_show_threads->setCheckable(true);
|
|
|
|
m_show_threads->setChecked(Settings::Instance().IsThreadsVisible());
|
|
|
|
|
|
|
|
connect(m_show_threads, &QAction::toggled, &Settings::Instance(), &Settings::SetThreadsVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::ThreadsVisibilityChanged, m_show_threads,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2018-09-08 13:58:15 +00:00
|
|
|
// i18n: This kind of "watch" is used for watching emulated memory.
|
|
|
|
// It's not related to timekeeping devices.
|
2017-09-27 06:53:05 +00:00
|
|
|
m_show_watch = view_menu->addAction(tr("&Watch"));
|
|
|
|
m_show_watch->setCheckable(true);
|
|
|
|
m_show_watch->setChecked(Settings::Instance().IsWatchVisible());
|
|
|
|
|
|
|
|
connect(m_show_watch, &QAction::toggled, &Settings::Instance(), &Settings::SetWatchVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::WatchVisibilityChanged, m_show_watch,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2017-10-03 16:43:44 +00:00
|
|
|
m_show_breakpoints = view_menu->addAction(tr("&Breakpoints"));
|
|
|
|
m_show_breakpoints->setCheckable(true);
|
|
|
|
m_show_breakpoints->setChecked(Settings::Instance().IsBreakpointsVisible());
|
|
|
|
|
|
|
|
connect(m_show_breakpoints, &QAction::toggled, &Settings::Instance(),
|
|
|
|
&Settings::SetBreakpointsVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::BreakpointsVisibilityChanged, m_show_breakpoints,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2018-03-16 11:39:53 +00:00
|
|
|
m_show_memory = view_menu->addAction(tr("&Memory"));
|
|
|
|
m_show_memory->setCheckable(true);
|
|
|
|
m_show_memory->setChecked(Settings::Instance().IsMemoryVisible());
|
|
|
|
|
|
|
|
connect(m_show_memory, &QAction::toggled, &Settings::Instance(), &Settings::SetMemoryVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::MemoryVisibilityChanged, m_show_memory,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2020-04-19 19:30:50 +00:00
|
|
|
m_show_network = view_menu->addAction(tr("&Network"));
|
|
|
|
m_show_network->setCheckable(true);
|
|
|
|
m_show_network->setChecked(Settings::Instance().IsNetworkVisible());
|
|
|
|
|
|
|
|
connect(m_show_network, &QAction::toggled, &Settings::Instance(), &Settings::SetNetworkVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::NetworkVisibilityChanged, m_show_network,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2018-04-09 13:31:20 +00:00
|
|
|
m_show_jit = view_menu->addAction(tr("&JIT"));
|
|
|
|
m_show_jit->setCheckable(true);
|
|
|
|
m_show_jit->setChecked(Settings::Instance().IsJITVisible());
|
|
|
|
connect(m_show_jit, &QAction::toggled, &Settings::Instance(), &Settings::SetJITVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::JITVisibilityChanged, m_show_jit, &QAction::setChecked);
|
|
|
|
|
2022-12-18 08:43:28 +00:00
|
|
|
m_show_assembler = view_menu->addAction(tr("&Assembler"));
|
|
|
|
m_show_assembler->setCheckable(true);
|
|
|
|
m_show_assembler->setChecked(Settings::Instance().IsAssemblerVisible());
|
|
|
|
connect(m_show_assembler, &QAction::toggled, &Settings::Instance(),
|
|
|
|
&Settings::SetAssemblerVisible);
|
|
|
|
connect(&Settings::Instance(), &Settings::AssemblerVisibilityChanged, m_show_assembler,
|
|
|
|
&QAction::setChecked);
|
|
|
|
|
2017-09-13 17:33:45 +00:00
|
|
|
view_menu->addSeparator();
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
AddGameListTypeSection(view_menu);
|
|
|
|
view_menu->addSeparator();
|
2017-08-05 08:28:53 +00:00
|
|
|
AddListColumnsMenu(view_menu);
|
2017-07-11 14:13:09 +00:00
|
|
|
view_menu->addSeparator();
|
|
|
|
AddShowPlatformsMenu(view_menu);
|
|
|
|
AddShowRegionsMenu(view_menu);
|
2018-03-21 10:13:53 +00:00
|
|
|
|
2018-10-14 16:03:10 +00:00
|
|
|
view_menu->addSeparator();
|
2020-09-27 00:40:56 +00:00
|
|
|
QAction* const purge_action =
|
|
|
|
view_menu->addAction(tr("Purge Game List Cache"), this, &MenuBar::PurgeGameListCache);
|
|
|
|
purge_action->setEnabled(false);
|
|
|
|
connect(&Settings::Instance(), &Settings::GameListRefreshRequested, purge_action,
|
|
|
|
[purge_action] { purge_action->setEnabled(false); });
|
2020-09-27 02:01:54 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::GameListRefreshStarted, purge_action,
|
2020-09-27 00:40:56 +00:00
|
|
|
[purge_action] { purge_action->setEnabled(true); });
|
2018-03-21 10:13:53 +00:00
|
|
|
view_menu->addSeparator();
|
2023-04-19 16:25:59 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
|
|
|
view_menu->addAction(tr("Search"), QKeySequence::Find, this, &MenuBar::ShowSearch);
|
|
|
|
#else
|
2020-02-26 19:31:10 +00:00
|
|
|
view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find);
|
2023-04-19 16:25:59 +00:00
|
|
|
#endif
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
void MenuBar::AddOptionsMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* options_menu = addMenu(tr("&Options"));
|
2023-04-19 16:25:59 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
|
|
|
options_menu->addAction(tr("Co&nfiguration"), QKeySequence::Preferences, this,
|
|
|
|
&MenuBar::Configure);
|
|
|
|
#else
|
2020-02-26 19:37:02 +00:00
|
|
|
options_menu->addAction(tr("Co&nfiguration"), this, &MenuBar::Configure,
|
|
|
|
QKeySequence::Preferences);
|
2023-04-19 16:25:59 +00:00
|
|
|
#endif
|
2017-07-16 21:11:11 +00:00
|
|
|
options_menu->addSeparator();
|
2018-07-09 08:02:10 +00:00
|
|
|
options_menu->addAction(tr("&Graphics Settings"), this, &MenuBar::ConfigureGraphics);
|
|
|
|
options_menu->addAction(tr("&Audio Settings"), this, &MenuBar::ConfigureAudio);
|
2018-11-23 10:02:00 +00:00
|
|
|
m_controllers_action =
|
|
|
|
options_menu->addAction(tr("&Controller Settings"), this, &MenuBar::ConfigureControllers);
|
2018-07-09 08:02:10 +00:00
|
|
|
options_menu->addAction(tr("&Hotkey Settings"), this, &MenuBar::ConfigureHotkeys);
|
2020-06-12 05:27:34 +00:00
|
|
|
options_menu->addAction(tr("&Free Look Settings"), this, &MenuBar::ConfigureFreelook);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
options_menu->addSeparator();
|
|
|
|
|
|
|
|
// Debugging mode only
|
2018-03-19 17:52:46 +00:00
|
|
|
m_boot_to_pause = options_menu->addAction(tr("Boot to Pause"));
|
2018-02-14 22:25:01 +00:00
|
|
|
m_boot_to_pause->setCheckable(true);
|
|
|
|
m_boot_to_pause->setChecked(SConfig::GetInstance().bBootToPause);
|
|
|
|
|
|
|
|
connect(m_boot_to_pause, &QAction::toggled, this,
|
2018-05-14 14:07:52 +00:00
|
|
|
[](bool enable) { SConfig::GetInstance().bBootToPause = enable; });
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
m_automatic_start = options_menu->addAction(tr("&Automatic Start"));
|
|
|
|
m_automatic_start->setCheckable(true);
|
|
|
|
m_automatic_start->setChecked(SConfig::GetInstance().bAutomaticStart);
|
|
|
|
|
|
|
|
connect(m_automatic_start, &QAction::toggled, this,
|
2018-05-14 14:07:52 +00:00
|
|
|
[](bool enable) { SConfig::GetInstance().bAutomaticStart = enable; });
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2021-10-17 07:18:48 +00:00
|
|
|
m_reset_ignore_panic_handler = options_menu->addAction(tr("Reset Ignore Panic Handler"));
|
|
|
|
|
|
|
|
connect(m_reset_ignore_panic_handler, &QAction::triggered, this, []() {
|
2022-09-24 11:03:45 +00:00
|
|
|
Config::DeleteKey(Config::LayerType::CurrentRun, Config::MAIN_USE_PANIC_HANDLERS);
|
2021-10-17 07:18:48 +00:00
|
|
|
});
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_change_font = options_menu->addAction(tr("&Font..."), this, &MenuBar::ChangeDebugFont);
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-24 22:19:36 +00:00
|
|
|
void MenuBar::InstallUpdateManually()
|
|
|
|
{
|
2022-04-02 18:52:51 +00:00
|
|
|
const std::string autoupdate_track = Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK);
|
|
|
|
const std::string manual_track = autoupdate_track.empty() ? "dev" : autoupdate_track;
|
|
|
|
auto* const updater = new Updater(this->parentWidget(), manual_track,
|
|
|
|
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
|
2018-05-24 22:19:36 +00:00
|
|
|
|
2022-11-01 06:08:35 +00:00
|
|
|
updater->CheckForUpdate();
|
2018-05-24 22:19:36 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 11:59:44 +00:00
|
|
|
void MenuBar::AddHelpMenu()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
QMenu* help_menu = addMenu(tr("&Help"));
|
2018-05-24 22:19:36 +00:00
|
|
|
|
2017-07-23 10:58:32 +00:00
|
|
|
QAction* website = help_menu->addAction(tr("&Website"));
|
2017-05-05 08:08:01 +00:00
|
|
|
connect(website, &QAction::triggered, this,
|
|
|
|
[]() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); });
|
2017-07-23 10:58:32 +00:00
|
|
|
QAction* documentation = help_menu->addAction(tr("Online &Documentation"));
|
2017-05-05 08:08:01 +00:00
|
|
|
connect(documentation, &QAction::triggered, this, []() {
|
2016-02-11 11:59:44 +00:00
|
|
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides")));
|
|
|
|
});
|
2017-07-23 10:58:32 +00:00
|
|
|
QAction* github = help_menu->addAction(tr("&GitHub Repository"));
|
2017-05-05 08:08:01 +00:00
|
|
|
connect(github, &QAction::triggered, this, []() {
|
|
|
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin")));
|
|
|
|
});
|
2019-08-05 14:51:02 +00:00
|
|
|
QAction* bugtracker = help_menu->addAction(tr("&Bug Tracker"));
|
|
|
|
connect(bugtracker, &QAction::triggered, this, []() {
|
|
|
|
QDesktopServices::openUrl(
|
|
|
|
QUrl(QStringLiteral("https://bugs.dolphin-emu.org/projects/emulator")));
|
|
|
|
});
|
2017-05-05 08:08:01 +00:00
|
|
|
|
2019-02-26 19:40:38 +00:00
|
|
|
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
|
|
|
{
|
|
|
|
help_menu->addSeparator();
|
2018-05-24 22:19:36 +00:00
|
|
|
|
2019-02-26 19:40:38 +00:00
|
|
|
help_menu->addAction(tr("&Check for Updates..."), this, &MenuBar::InstallUpdateManually);
|
|
|
|
}
|
2018-05-24 22:19:36 +00:00
|
|
|
|
2019-02-26 19:40:38 +00:00
|
|
|
#ifndef __APPLE__
|
2017-05-05 08:08:01 +00:00
|
|
|
help_menu->addSeparator();
|
2019-02-26 19:40:38 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
help_menu->addAction(tr("&About"), this, &MenuBar::ShowAboutDialog);
|
2016-02-11 11:59:44 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
|
|
|
{
|
2017-08-05 08:28:53 +00:00
|
|
|
QAction* list_view = view_menu->addAction(tr("List View"));
|
2015-12-20 05:24:48 +00:00
|
|
|
list_view->setCheckable(true);
|
|
|
|
|
2017-08-05 08:28:53 +00:00
|
|
|
QAction* grid_view = view_menu->addAction(tr("Grid View"));
|
|
|
|
grid_view->setCheckable(true);
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
QActionGroup* list_group = new QActionGroup(this);
|
|
|
|
list_group->addAction(list_view);
|
2017-08-05 08:28:53 +00:00
|
|
|
list_group->addAction(grid_view);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2017-08-05 08:28:53 +00:00
|
|
|
bool prefer_list = Settings::Instance().GetPreferredView();
|
|
|
|
list_view->setChecked(prefer_list);
|
|
|
|
grid_view->setChecked(!prefer_list);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
|
|
|
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
2017-08-05 08:28:53 +00:00
|
|
|
connect(grid_view, &QAction::triggered, this, &MenuBar::ShowGrid);
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 08:28:53 +00:00
|
|
|
void MenuBar::AddListColumnsMenu(QMenu* view_menu)
|
2015-12-20 05:24:48 +00:00
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
static const QMap<QString, const Config::Info<bool>*> columns{
|
|
|
|
{tr("Platform"), &Config::MAIN_GAMELIST_COLUMN_PLATFORM},
|
|
|
|
{tr("Banner"), &Config::MAIN_GAMELIST_COLUMN_BANNER},
|
|
|
|
{tr("Title"), &Config::MAIN_GAMELIST_COLUMN_TITLE},
|
|
|
|
{tr("Description"), &Config::MAIN_GAMELIST_COLUMN_DESCRIPTION},
|
|
|
|
{tr("Maker"), &Config::MAIN_GAMELIST_COLUMN_MAKER},
|
|
|
|
{tr("File Name"), &Config::MAIN_GAMELIST_COLUMN_FILE_NAME},
|
|
|
|
{tr("File Path"), &Config::MAIN_GAMELIST_COLUMN_FILE_PATH},
|
|
|
|
{tr("Game ID"), &Config::MAIN_GAMELIST_COLUMN_GAME_ID},
|
|
|
|
{tr("Region"), &Config::MAIN_GAMELIST_COLUMN_REGION},
|
|
|
|
{tr("File Size"), &Config::MAIN_GAMELIST_COLUMN_FILE_SIZE},
|
|
|
|
{tr("File Format"), &Config::MAIN_GAMELIST_COLUMN_FILE_FORMAT},
|
|
|
|
{tr("Block Size"), &Config::MAIN_GAMELIST_COLUMN_BLOCK_SIZE},
|
|
|
|
{tr("Compression"), &Config::MAIN_GAMELIST_COLUMN_COMPRESSION},
|
|
|
|
{tr("Tags"), &Config::MAIN_GAMELIST_COLUMN_TAGS}};
|
2017-05-08 17:03:59 +00:00
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
QActionGroup* column_group = new QActionGroup(this);
|
2019-01-21 20:05:31 +00:00
|
|
|
m_cols_menu = view_menu->addMenu(tr("List Columns"));
|
2015-12-20 05:24:48 +00:00
|
|
|
column_group->setExclusive(false);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-05-08 17:03:59 +00:00
|
|
|
for (const auto& key : columns.keys())
|
2015-12-20 05:24:48 +00:00
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
const Config::Info<bool>* const config = columns[key];
|
2019-01-21 20:05:31 +00:00
|
|
|
QAction* action = column_group->addAction(m_cols_menu->addAction(key));
|
2015-12-20 05:24:48 +00:00
|
|
|
action->setCheckable(true);
|
2021-12-26 22:46:35 +00:00
|
|
|
action->setChecked(Config::Get(*config));
|
2017-05-08 17:03:59 +00:00
|
|
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
2021-12-26 22:46:35 +00:00
|
|
|
Config::SetBase(*config, value);
|
2017-05-08 17:03:59 +00:00
|
|
|
emit ColumnVisibilityToggled(key, value);
|
|
|
|
});
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-04 21:01:12 +00:00
|
|
|
|
2017-07-11 14:13:09 +00:00
|
|
|
void MenuBar::AddShowPlatformsMenu(QMenu* view_menu)
|
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
static const QMap<QString, const Config::Info<bool>*> platform_map{
|
|
|
|
{tr("Show Wii"), &Config::MAIN_GAMELIST_LIST_WII},
|
|
|
|
{tr("Show GameCube"), &Config::MAIN_GAMELIST_LIST_GC},
|
|
|
|
{tr("Show WAD"), &Config::MAIN_GAMELIST_LIST_WAD},
|
|
|
|
{tr("Show ELF/DOL"), &Config::MAIN_GAMELIST_LIST_ELF_DOL}};
|
2017-07-11 14:13:09 +00:00
|
|
|
|
|
|
|
QActionGroup* platform_group = new QActionGroup(this);
|
|
|
|
QMenu* plat_menu = view_menu->addMenu(tr("Show Platforms"));
|
|
|
|
platform_group->setExclusive(false);
|
|
|
|
|
|
|
|
for (const auto& key : platform_map.keys())
|
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
const Config::Info<bool>* const config = platform_map[key];
|
2017-07-11 14:13:09 +00:00
|
|
|
QAction* action = platform_group->addAction(plat_menu->addAction(key));
|
|
|
|
action->setCheckable(true);
|
2021-12-26 22:46:35 +00:00
|
|
|
action->setChecked(Config::Get(*config));
|
2017-07-11 14:13:09 +00:00
|
|
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
2021-12-26 22:46:35 +00:00
|
|
|
Config::SetBase(*config, value);
|
2017-07-11 14:13:09 +00:00
|
|
|
emit GameListPlatformVisibilityToggled(key, value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddShowRegionsMenu(QMenu* view_menu)
|
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
static const QMap<QString, const Config::Info<bool>*> region_map{
|
|
|
|
{tr("Show JPN"), &Config::MAIN_GAMELIST_LIST_JPN},
|
|
|
|
{tr("Show PAL"), &Config::MAIN_GAMELIST_LIST_PAL},
|
|
|
|
{tr("Show USA"), &Config::MAIN_GAMELIST_LIST_USA},
|
|
|
|
{tr("Show Australia"), &Config::MAIN_GAMELIST_LIST_AUSTRALIA},
|
|
|
|
{tr("Show France"), &Config::MAIN_GAMELIST_LIST_FRANCE},
|
|
|
|
{tr("Show Germany"), &Config::MAIN_GAMELIST_LIST_GERMANY},
|
|
|
|
{tr("Show Italy"), &Config::MAIN_GAMELIST_LIST_ITALY},
|
|
|
|
{tr("Show Korea"), &Config::MAIN_GAMELIST_LIST_KOREA},
|
|
|
|
{tr("Show Netherlands"), &Config::MAIN_GAMELIST_LIST_NETHERLANDS},
|
|
|
|
{tr("Show Russia"), &Config::MAIN_GAMELIST_LIST_RUSSIA},
|
|
|
|
{tr("Show Spain"), &Config::MAIN_GAMELIST_LIST_SPAIN},
|
|
|
|
{tr("Show Taiwan"), &Config::MAIN_GAMELIST_LIST_TAIWAN},
|
|
|
|
{tr("Show World"), &Config::MAIN_GAMELIST_LIST_WORLD},
|
|
|
|
{tr("Show Unknown"), &Config::MAIN_GAMELIST_LIST_UNKNOWN}};
|
2017-07-11 14:13:09 +00:00
|
|
|
|
2020-10-29 16:29:41 +00:00
|
|
|
QMenu* const region_menu = view_menu->addMenu(tr("Show Regions"));
|
|
|
|
const QAction* const show_all_regions = region_menu->addAction(tr("Show All"));
|
|
|
|
const QAction* const hide_all_regions = region_menu->addAction(tr("Hide All"));
|
|
|
|
region_menu->addSeparator();
|
2017-07-11 14:13:09 +00:00
|
|
|
|
|
|
|
for (const auto& key : region_map.keys())
|
|
|
|
{
|
2021-12-26 22:46:35 +00:00
|
|
|
const Config::Info<bool>* const config = region_map[key];
|
2020-10-29 16:29:41 +00:00
|
|
|
QAction* const menu_item = region_menu->addAction(key);
|
|
|
|
menu_item->setCheckable(true);
|
2021-12-26 22:46:35 +00:00
|
|
|
menu_item->setChecked(Config::Get(*config));
|
2020-10-29 16:29:41 +00:00
|
|
|
|
|
|
|
const auto set_visibility = [this, config, key, menu_item](bool visibility) {
|
|
|
|
menu_item->setChecked(visibility);
|
2021-12-26 22:46:35 +00:00
|
|
|
Config::SetBase(*config, visibility);
|
2020-10-29 16:29:41 +00:00
|
|
|
emit GameListRegionVisibilityToggled(key, visibility);
|
|
|
|
};
|
|
|
|
const auto set_visible = std::bind(set_visibility, true);
|
|
|
|
const auto set_hidden = std::bind(set_visibility, false);
|
|
|
|
|
|
|
|
connect(menu_item, &QAction::toggled, set_visibility);
|
|
|
|
connect(show_all_regions, &QAction::triggered, menu_item, set_visible);
|
|
|
|
connect(hide_all_regions, &QAction::triggered, menu_item, set_hidden);
|
2017-07-11 14:13:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-27 11:55:05 +00:00
|
|
|
void MenuBar::AddMovieMenu()
|
|
|
|
{
|
|
|
|
auto* movie_menu = addMenu(tr("&Movie"));
|
|
|
|
m_recording_start =
|
2018-07-09 08:02:10 +00:00
|
|
|
movie_menu->addAction(tr("Start Re&cording Input"), this, [this] { emit StartRecording(); });
|
2017-08-27 11:55:05 +00:00
|
|
|
m_recording_play =
|
2018-07-09 08:02:10 +00:00
|
|
|
movie_menu->addAction(tr("P&lay Input Recording..."), this, [this] { emit PlayRecording(); });
|
|
|
|
m_recording_stop = movie_menu->addAction(tr("Stop Playing/Recording Input"), this,
|
|
|
|
[this] { emit StopRecording(); });
|
2017-08-27 11:55:05 +00:00
|
|
|
m_recording_export =
|
2018-07-09 08:02:10 +00:00
|
|
|
movie_menu->addAction(tr("Export Recording..."), this, [this] { emit ExportRecording(); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
m_recording_start->setEnabled(false);
|
|
|
|
m_recording_play->setEnabled(false);
|
|
|
|
m_recording_stop->setEnabled(false);
|
|
|
|
m_recording_export->setEnabled(false);
|
|
|
|
|
2017-11-02 13:32:16 +00:00
|
|
|
m_recording_read_only = movie_menu->addAction(tr("&Read-Only Mode"));
|
2017-08-27 11:55:05 +00:00
|
|
|
m_recording_read_only->setCheckable(true);
|
|
|
|
m_recording_read_only->setChecked(Movie::IsReadOnly());
|
|
|
|
connect(m_recording_read_only, &QAction::toggled, [](bool value) { Movie::SetReadOnly(value); });
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
movie_menu->addAction(tr("TAS Input"), this, [this] { emit ShowTASInput(); });
|
2018-01-27 13:35:02 +00:00
|
|
|
|
2017-08-27 11:55:05 +00:00
|
|
|
movie_menu->addSeparator();
|
|
|
|
|
|
|
|
auto* pause_at_end = movie_menu->addAction(tr("Pause at End of Movie"));
|
|
|
|
pause_at_end->setCheckable(true);
|
2021-12-27 18:39:35 +00:00
|
|
|
pause_at_end->setChecked(Config::Get(Config::MAIN_MOVIE_PAUSE_MOVIE));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(pause_at_end, &QAction::toggled,
|
2021-12-27 18:39:35 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_PAUSE_MOVIE, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2021-11-30 04:03:36 +00:00
|
|
|
auto* rerecord_counter = movie_menu->addAction(tr("Show Rerecord Counter"));
|
|
|
|
rerecord_counter->setCheckable(true);
|
2021-12-27 18:39:35 +00:00
|
|
|
rerecord_counter->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD));
|
2021-11-30 04:03:36 +00:00
|
|
|
connect(rerecord_counter, &QAction::toggled,
|
2021-12-27 18:39:35 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_RERECORD, value); });
|
2021-11-30 04:03:36 +00:00
|
|
|
|
2017-08-27 11:55:05 +00:00
|
|
|
auto* lag_counter = movie_menu->addAction(tr("Show Lag Counter"));
|
|
|
|
lag_counter->setCheckable(true);
|
2022-01-01 16:53:12 +00:00
|
|
|
lag_counter->setChecked(Config::Get(Config::MAIN_SHOW_LAG));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(lag_counter, &QAction::toggled,
|
2022-01-01 16:53:12 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_SHOW_LAG, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
auto* frame_counter = movie_menu->addAction(tr("Show Frame Counter"));
|
|
|
|
frame_counter->setCheckable(true);
|
2022-01-01 16:53:12 +00:00
|
|
|
frame_counter->setChecked(Config::Get(Config::MAIN_SHOW_FRAME_COUNT));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(frame_counter, &QAction::toggled,
|
2022-01-01 16:53:12 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_SHOW_FRAME_COUNT, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
auto* input_display = movie_menu->addAction(tr("Show Input Display"));
|
|
|
|
input_display->setCheckable(true);
|
2021-12-27 18:39:35 +00:00
|
|
|
input_display->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY));
|
|
|
|
connect(input_display, &QAction::toggled, [](bool value) {
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY, value);
|
|
|
|
});
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
auto* system_clock = movie_menu->addAction(tr("Show System Clock"));
|
|
|
|
system_clock->setCheckable(true);
|
2021-12-27 18:39:35 +00:00
|
|
|
system_clock->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_RTC));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(system_clock, &QAction::toggled,
|
2021-12-27 18:39:35 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_RTC, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
movie_menu->addSeparator();
|
|
|
|
|
|
|
|
auto* dump_frames = movie_menu->addAction(tr("Dump Frames"));
|
|
|
|
dump_frames->setCheckable(true);
|
2021-12-27 18:39:35 +00:00
|
|
|
dump_frames->setChecked(Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(dump_frames, &QAction::toggled,
|
2021-12-27 18:39:35 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_DUMP_FRAMES, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
|
|
|
|
auto* dump_audio = movie_menu->addAction(tr("Dump Audio"));
|
|
|
|
dump_audio->setCheckable(true);
|
2021-10-14 00:29:04 +00:00
|
|
|
dump_audio->setChecked(Config::Get(Config::MAIN_DUMP_AUDIO));
|
2017-08-27 11:55:05 +00:00
|
|
|
connect(dump_audio, &QAction::toggled,
|
2021-10-14 00:29:04 +00:00
|
|
|
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_DUMP_AUDIO, value); });
|
2017-08-27 11:55:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-09 13:31:20 +00:00
|
|
|
void MenuBar::AddJITMenu()
|
|
|
|
{
|
|
|
|
m_jit = addMenu(tr("JIT"));
|
|
|
|
|
|
|
|
m_jit_interpreter_core = m_jit->addAction(tr("Interpreter Core"));
|
|
|
|
m_jit_interpreter_core->setCheckable(true);
|
2022-01-03 06:07:32 +00:00
|
|
|
m_jit_interpreter_core->setChecked(Config::Get(Config::MAIN_CPU_CORE) ==
|
2018-06-15 12:11:18 +00:00
|
|
|
PowerPC::CPUCore::Interpreter);
|
2018-04-09 13:31:20 +00:00
|
|
|
|
2018-05-29 14:40:05 +00:00
|
|
|
connect(m_jit_interpreter_core, &QAction::toggled, [](bool enabled) {
|
2023-03-28 18:26:52 +00:00
|
|
|
Core::System::GetInstance().GetPowerPC().SetMode(enabled ? PowerPC::CoreMode::Interpreter :
|
|
|
|
PowerPC::CoreMode::JIT);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
|
|
|
|
2018-04-09 13:31:20 +00:00
|
|
|
m_jit->addSeparator();
|
|
|
|
|
|
|
|
m_jit_block_linking = m_jit->addAction(tr("JIT Block Linking Off"));
|
|
|
|
m_jit_block_linking->setCheckable(true);
|
|
|
|
m_jit_block_linking->setChecked(SConfig::GetInstance().bJITNoBlockLinking);
|
2018-05-29 14:40:05 +00:00
|
|
|
connect(m_jit_block_linking, &QAction::toggled, [this](bool enabled) {
|
|
|
|
SConfig::GetInstance().bJITNoBlockLinking = enabled;
|
|
|
|
ClearCache();
|
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_disable_cache = m_jit->addAction(tr("Disable JIT Cache"));
|
|
|
|
m_jit_disable_cache->setCheckable(true);
|
|
|
|
m_jit_disable_cache->setChecked(SConfig::GetInstance().bJITNoBlockCache);
|
2018-05-29 14:40:05 +00:00
|
|
|
connect(m_jit_disable_cache, &QAction::toggled, [this](bool enabled) {
|
|
|
|
SConfig::GetInstance().bJITNoBlockCache = enabled;
|
|
|
|
ClearCache();
|
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
2020-06-02 10:18:45 +00:00
|
|
|
m_jit_disable_fastmem = m_jit->addAction(tr("Disable Fastmem"));
|
|
|
|
m_jit_disable_fastmem->setCheckable(true);
|
2022-01-06 00:51:29 +00:00
|
|
|
m_jit_disable_fastmem->setChecked(!Config::Get(Config::MAIN_FASTMEM));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_disable_fastmem, &QAction::toggled,
|
|
|
|
[](bool enabled) { Config::SetBaseOrCurrent(Config::MAIN_FASTMEM, !enabled); });
|
2020-06-02 10:18:45 +00:00
|
|
|
|
2023-10-01 20:54:09 +00:00
|
|
|
m_jit_disable_fastmem_arena = m_jit->addAction(tr("Disable Fastmem Arena"));
|
|
|
|
m_jit_disable_fastmem_arena->setCheckable(true);
|
|
|
|
m_jit_disable_fastmem_arena->setChecked(!Config::Get(Config::MAIN_FASTMEM_ARENA));
|
|
|
|
connect(m_jit_disable_fastmem_arena, &QAction::toggled,
|
|
|
|
[](bool enabled) { Config::SetBaseOrCurrent(Config::MAIN_FASTMEM_ARENA, !enabled); });
|
|
|
|
|
2023-12-10 19:50:58 +00:00
|
|
|
m_jit_disable_large_entry_points_map = m_jit->addAction(tr("Disable Large Entry Points Map"));
|
|
|
|
m_jit_disable_large_entry_points_map->setCheckable(true);
|
|
|
|
m_jit_disable_large_entry_points_map->setChecked(
|
|
|
|
!Config::Get(Config::MAIN_LARGE_ENTRY_POINTS_MAP));
|
|
|
|
connect(m_jit_disable_large_entry_points_map, &QAction::toggled, [](bool enabled) {
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_LARGE_ENTRY_POINTS_MAP, !enabled);
|
|
|
|
});
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_jit_clear_cache = m_jit->addAction(tr("Clear Cache"), this, &MenuBar::ClearCache);
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit->addSeparator();
|
|
|
|
|
|
|
|
m_jit_log_coverage =
|
2018-07-09 08:02:10 +00:00
|
|
|
m_jit->addAction(tr("Log JIT Instruction Coverage"), this, &MenuBar::LogInstructions);
|
2018-04-09 13:31:20 +00:00
|
|
|
m_jit_search_instruction =
|
2018-07-09 08:02:10 +00:00
|
|
|
m_jit->addAction(tr("Search for an Instruction"), this, &MenuBar::SearchInstruction);
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit->addSeparator();
|
|
|
|
|
|
|
|
m_jit_off = m_jit->addAction(tr("JIT Off (JIT Core)"));
|
|
|
|
m_jit_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_off, &QAction::toggled,
|
|
|
|
[](bool enabled) { Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_OFF, enabled); });
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_off = m_jit->addAction(tr("JIT LoadStore Off"));
|
|
|
|
m_jit_loadstore_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_lbzx_off = m_jit->addAction(tr("JIT LoadStore lbzx Off"));
|
|
|
|
m_jit_loadstore_lbzx_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_lbzx_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_LBZX_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_lbzx_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_LBZX_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_lxz_off = m_jit->addAction(tr("JIT LoadStore lXz Off"));
|
|
|
|
m_jit_loadstore_lxz_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_lxz_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_LXZ_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_lxz_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_LXZ_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_lwz_off = m_jit->addAction(tr("JIT LoadStore lwz Off"));
|
|
|
|
m_jit_loadstore_lwz_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_lwz_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_LWZ_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_lwz_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_LWZ_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_floating_off = m_jit->addAction(tr("JIT LoadStore Floating Off"));
|
|
|
|
m_jit_loadstore_floating_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_floating_off->setChecked(
|
|
|
|
Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_FLOATING_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_floating_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_FLOATING_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_loadstore_paired_off = m_jit->addAction(tr("JIT LoadStore Paired Off"));
|
|
|
|
m_jit_loadstore_paired_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_loadstore_paired_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_LOAD_STORE_PAIRED_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_loadstore_paired_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_LOAD_STORE_PAIRED_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_floatingpoint_off = m_jit->addAction(tr("JIT FloatingPoint Off"));
|
|
|
|
m_jit_floatingpoint_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_floatingpoint_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_FLOATING_POINT_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_floatingpoint_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_FLOATING_POINT_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_integer_off = m_jit->addAction(tr("JIT Integer Off"));
|
|
|
|
m_jit_integer_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_integer_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_INTEGER_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_integer_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_INTEGER_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_paired_off = m_jit->addAction(tr("JIT Paired Off"));
|
|
|
|
m_jit_paired_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_paired_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_PAIRED_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_paired_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_PAIRED_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
m_jit_systemregisters_off = m_jit->addAction(tr("JIT SystemRegisters Off"));
|
|
|
|
m_jit_systemregisters_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_systemregisters_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_SYSTEM_REGISTERS_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_systemregisters_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_SYSTEM_REGISTERS_OFF, enabled);
|
2018-05-29 14:40:05 +00:00
|
|
|
});
|
2018-07-08 18:32:40 +00:00
|
|
|
|
|
|
|
m_jit_branch_off = m_jit->addAction(tr("JIT Branch Off"));
|
|
|
|
m_jit_branch_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_branch_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_BRANCH_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_branch_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_BRANCH_OFF, enabled);
|
2018-07-08 18:32:40 +00:00
|
|
|
});
|
2019-11-16 10:25:26 +00:00
|
|
|
|
|
|
|
m_jit_register_cache_off = m_jit->addAction(tr("JIT Register Cache Off"));
|
|
|
|
m_jit_register_cache_off->setCheckable(true);
|
2021-12-28 02:20:28 +00:00
|
|
|
m_jit_register_cache_off->setChecked(Config::Get(Config::MAIN_DEBUG_JIT_REGISTER_CACHE_OFF));
|
2022-04-10 09:06:40 +00:00
|
|
|
connect(m_jit_register_cache_off, &QAction::toggled, [](bool enabled) {
|
2021-12-28 02:20:28 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DEBUG_JIT_REGISTER_CACHE_OFF, enabled);
|
2019-11-16 10:25:26 +00:00
|
|
|
});
|
2018-04-09 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
void MenuBar::AddSymbolsMenu()
|
|
|
|
{
|
|
|
|
m_symbols = addMenu(tr("Symbols"));
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_symbols->addAction(tr("&Clear Symbols"), this, &MenuBar::ClearSymbols);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2018-03-19 17:52:46 +00:00
|
|
|
auto* generate = m_symbols->addMenu(tr("&Generate Symbols From"));
|
2018-07-09 08:02:10 +00:00
|
|
|
generate->addAction(tr("Address"), this, &MenuBar::GenerateSymbolsFromAddress);
|
|
|
|
generate->addAction(tr("Signature Database"), this, &MenuBar::GenerateSymbolsFromSignatureDB);
|
|
|
|
generate->addAction(tr("RSO Modules"), this, &MenuBar::GenerateSymbolsFromRSO);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_symbols->addSeparator();
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_symbols->addAction(tr("&Load Symbol Map"), this, &MenuBar::LoadSymbolMap);
|
|
|
|
m_symbols->addAction(tr("&Save Symbol Map"), this, &MenuBar::SaveSymbolMap);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_symbols->addSeparator();
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_symbols->addAction(tr("Load &Other Map File..."), this, &MenuBar::LoadOtherSymbolMap);
|
2018-10-09 00:59:55 +00:00
|
|
|
m_symbols->addAction(tr("Load &Bad Map File..."), this, &MenuBar::LoadBadSymbolMap);
|
2018-07-09 08:02:10 +00:00
|
|
|
m_symbols->addAction(tr("Save Symbol Map &As..."), this, &MenuBar::SaveSymbolMapAs);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_symbols->addSeparator();
|
|
|
|
|
2018-10-09 00:59:55 +00:00
|
|
|
m_symbols->addAction(tr("Sa&ve Code"), this, &MenuBar::SaveCode);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_symbols->addSeparator();
|
|
|
|
|
2018-10-09 00:59:55 +00:00
|
|
|
m_symbols->addAction(tr("C&reate Signature File..."), this, &MenuBar::CreateSignatureFile);
|
|
|
|
m_symbols->addAction(tr("Append to &Existing Signature File..."), this,
|
|
|
|
&MenuBar::AppendSignatureFile);
|
|
|
|
m_symbols->addAction(tr("Combine &Two Signature Files..."), this,
|
|
|
|
&MenuBar::CombineSignatureFiles);
|
|
|
|
m_symbols->addAction(tr("Appl&y Signature File..."), this, &MenuBar::ApplySignatureFile);
|
2018-02-14 22:25:01 +00:00
|
|
|
m_symbols->addSeparator();
|
|
|
|
|
2018-07-09 08:02:10 +00:00
|
|
|
m_symbols->addAction(tr("&Patch HLE Functions"), this, &MenuBar::PatchHLEFunctions);
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
2017-06-14 09:58:11 +00:00
|
|
|
void MenuBar::UpdateToolsMenu(bool emulation_started)
|
|
|
|
{
|
2017-07-06 09:00:37 +00:00
|
|
|
m_boot_sysmenu->setEnabled(!emulation_started);
|
2017-07-06 09:01:32 +00:00
|
|
|
m_perform_online_update_menu->setEnabled(!emulation_started);
|
2022-04-11 04:08:19 +00:00
|
|
|
m_ntscj_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(JAP_DIR)));
|
|
|
|
m_ntscu_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(USA_DIR)));
|
|
|
|
m_pal_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(EUR_DIR)));
|
2023-08-11 22:46:51 +00:00
|
|
|
m_wad_install_action->setEnabled(!emulation_started);
|
2017-08-24 15:38:31 +00:00
|
|
|
m_import_backup->setEnabled(!emulation_started);
|
2017-10-03 14:45:59 +00:00
|
|
|
m_check_nand->setEnabled(!emulation_started);
|
2023-12-15 15:15:21 +00:00
|
|
|
m_import_wii_save->setEnabled(!emulation_started);
|
|
|
|
m_export_wii_saves->setEnabled(!emulation_started);
|
2017-07-06 09:00:37 +00:00
|
|
|
|
2017-07-06 09:01:32 +00:00
|
|
|
if (!emulation_started)
|
2017-06-14 09:58:11 +00:00
|
|
|
{
|
|
|
|
IOS::HLE::Kernel ios;
|
2023-05-13 03:01:29 +00:00
|
|
|
const auto tmd = ios.GetESCore().FindInstalledTMD(Titles::SYSTEM_MENU);
|
2017-07-06 09:00:37 +00:00
|
|
|
|
|
|
|
const QString sysmenu_version =
|
2022-10-21 21:22:49 +00:00
|
|
|
tmd.IsValid() ? QString::fromStdString(
|
|
|
|
DiscIO::GetSysMenuVersionString(tmd.GetTitleVersion(), tmd.IsvWii())) :
|
|
|
|
QString{};
|
|
|
|
|
|
|
|
const QString sysmenu_text = (tmd.IsValid() && tmd.IsvWii()) ? tr("Load vWii System Menu %1") :
|
|
|
|
tr("Load Wii System Menu %1");
|
|
|
|
|
|
|
|
m_boot_sysmenu->setText(sysmenu_text.arg(sysmenu_version));
|
2017-07-06 09:00:37 +00:00
|
|
|
|
2017-07-06 09:01:32 +00:00
|
|
|
m_boot_sysmenu->setEnabled(tmd.IsValid());
|
2017-07-06 09:00:37 +00:00
|
|
|
|
2017-06-14 09:58:11 +00:00
|
|
|
for (QAction* action : m_perform_online_update_menu->actions())
|
|
|
|
action->setEnabled(!tmd.IsValid());
|
|
|
|
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
|
|
|
}
|
2018-01-24 14:25:35 +00:00
|
|
|
|
2021-04-12 10:49:29 +00:00
|
|
|
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
|
|
|
const bool enable_wiimotes = emulation_started && bt != nullptr;
|
2018-01-24 14:25:35 +00:00
|
|
|
|
2018-06-20 19:27:31 +00:00
|
|
|
for (std::size_t i = 0; i < m_wii_remotes.size(); i++)
|
2018-01-24 14:25:35 +00:00
|
|
|
{
|
2018-06-20 19:27:31 +00:00
|
|
|
QAction* const wii_remote = m_wii_remotes[i];
|
|
|
|
|
|
|
|
wii_remote->setEnabled(enable_wiimotes);
|
2018-01-24 14:25:35 +00:00
|
|
|
if (enable_wiimotes)
|
2018-06-21 15:31:26 +00:00
|
|
|
wii_remote->setChecked(bt->AccessWiimoteByIndex(i)->IsConnected());
|
2018-01-24 14:25:35 +00:00
|
|
|
}
|
2017-06-14 09:58:11 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 21:01:12 +00:00
|
|
|
void MenuBar::InstallWAD()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString wad_file = DolphinFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select a title to install to NAND"), QString(), tr("WAD files (*.wad)"));
|
2017-05-04 21:01:12 +00:00
|
|
|
|
|
|
|
if (wad_file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2017-12-31 19:33:36 +00:00
|
|
|
if (WiiUtils::InstallWAD(wad_file.toStdString()))
|
2017-05-04 21:01:12 +00:00
|
|
|
{
|
2017-12-31 19:33:36 +00:00
|
|
|
Settings::Instance().NANDRefresh();
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(this, tr("Success"),
|
|
|
|
tr("Successfully installed this title to the NAND."));
|
2017-05-04 21:01:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::critical(this, tr("Failure"), tr("Failed to install this title to the NAND."));
|
2017-05-04 21:01:12 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-24 13:11:04 +00:00
|
|
|
|
|
|
|
void MenuBar::ImportWiiSave()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString file =
|
|
|
|
DolphinFileDialog::getOpenFileName(this, tr("Select the save file"), QDir::currentPath(),
|
|
|
|
tr("Wii save files (*.bin);;"
|
|
|
|
"All Files (*)"));
|
2017-08-24 13:11:04 +00:00
|
|
|
|
2018-05-13 11:18:19 +00:00
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2018-06-01 18:41:52 +00:00
|
|
|
auto can_overwrite = [&] {
|
2020-12-31 22:26:16 +00:00
|
|
|
return ModalMessageBox::question(
|
|
|
|
this, tr("Save Import"),
|
|
|
|
tr("Save data for this title already exists in the NAND. Consider backing up "
|
|
|
|
"the current data before overwriting.\nOverwrite now?")) == QMessageBox::Yes;
|
2018-06-01 18:41:52 +00:00
|
|
|
};
|
2020-12-31 22:26:16 +00:00
|
|
|
|
|
|
|
const auto result = WiiSave::Import(file.toStdString(), can_overwrite);
|
|
|
|
switch (result)
|
|
|
|
{
|
|
|
|
case WiiSave::CopyResult::Success:
|
|
|
|
ModalMessageBox::information(this, tr("Save Import"), tr("Successfully imported save file."));
|
|
|
|
break;
|
|
|
|
case WiiSave::CopyResult::CorruptedSource:
|
|
|
|
ModalMessageBox::critical(this, tr("Save Import"),
|
|
|
|
tr("Failed to import save file. The given file appears to be "
|
|
|
|
"corrupted or is not a valid Wii save."));
|
|
|
|
break;
|
|
|
|
case WiiSave::CopyResult::TitleMissing:
|
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Save Import"),
|
|
|
|
tr("Failed to import save file. Please launch the game once, then try again."));
|
|
|
|
break;
|
|
|
|
case WiiSave::CopyResult::Cancelled:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Save Import"),
|
|
|
|
tr("Failed to import save file. Your NAND may be corrupt, or something is preventing "
|
|
|
|
"access to files within it. Try repairing your NAND (Tools -> Manage NAND -> Check "
|
|
|
|
"NAND...), then import the save again."));
|
|
|
|
break;
|
|
|
|
}
|
2017-08-24 13:11:04 +00:00
|
|
|
}
|
2017-08-24 13:21:21 +00:00
|
|
|
|
|
|
|
void MenuBar::ExportWiiSaves()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString export_dir = DolphinFileDialog::getExistingDirectory(
|
2018-05-13 13:34:30 +00:00
|
|
|
this, tr("Select Export Directory"), QString::fromStdString(File::GetUserPath(D_USER_IDX)),
|
|
|
|
QFileDialog::ShowDirsOnly);
|
|
|
|
if (export_dir.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const size_t count = WiiSave::ExportAll(export_dir.toStdString());
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(this, tr("Save Export"),
|
|
|
|
tr("Exported %n save(s)", "", static_cast<int>(count)));
|
2017-08-24 13:21:21 +00:00
|
|
|
}
|
2017-08-24 15:38:31 +00:00
|
|
|
|
2017-10-03 14:45:59 +00:00
|
|
|
void MenuBar::CheckNAND()
|
|
|
|
{
|
|
|
|
IOS::HLE::Kernel ios;
|
2017-10-06 19:45:28 +00:00
|
|
|
WiiUtils::NANDCheckResult result = WiiUtils::CheckNAND(ios);
|
|
|
|
if (!result.bad)
|
2017-10-03 14:45:59 +00:00
|
|
|
{
|
2023-07-14 03:10:18 +00:00
|
|
|
const bool overfull = result.used_clusters_user > IOS::HLE::FS::USER_CLUSTERS ||
|
|
|
|
result.used_clusters_system > IOS::HLE::FS::SYSTEM_CLUSTERS;
|
|
|
|
const QString user_cluster_message =
|
|
|
|
tr("The user-accessible part of your NAND contains %1 blocks (%2 KiB) "
|
|
|
|
"of data, out of an allowed maximum of %3 blocks (%4 KiB).")
|
|
|
|
.arg(Common::AlignUp(result.used_clusters_user, IOS::HLE::FS::CLUSTERS_PER_BLOCK) /
|
|
|
|
IOS::HLE::FS::CLUSTERS_PER_BLOCK)
|
|
|
|
.arg((result.used_clusters_user * IOS::HLE::FS::CLUSTER_SIZE) / 1024)
|
|
|
|
.arg(IOS::HLE::FS::USER_CLUSTERS / IOS::HLE::FS::CLUSTERS_PER_BLOCK)
|
|
|
|
.arg((IOS::HLE::FS::USER_CLUSTERS * IOS::HLE::FS::CLUSTER_SIZE) / 1024);
|
|
|
|
const QString system_cluster_message =
|
|
|
|
tr("The system-reserved part of your NAND contains %1 blocks (%2 KiB) "
|
|
|
|
"of data, out of an allowed maximum of %3 blocks (%4 KiB).")
|
|
|
|
.arg(Common::AlignUp(result.used_clusters_system, IOS::HLE::FS::CLUSTERS_PER_BLOCK) /
|
|
|
|
IOS::HLE::FS::CLUSTERS_PER_BLOCK)
|
|
|
|
.arg((result.used_clusters_system * IOS::HLE::FS::CLUSTER_SIZE) / 1024)
|
|
|
|
.arg(IOS::HLE::FS::SYSTEM_CLUSTERS / IOS::HLE::FS::CLUSTERS_PER_BLOCK)
|
|
|
|
.arg((IOS::HLE::FS::SYSTEM_CLUSTERS * IOS::HLE::FS::CLUSTER_SIZE) / 1024);
|
|
|
|
|
|
|
|
if (overfull)
|
|
|
|
{
|
|
|
|
ModalMessageBox::warning(this, tr("NAND Check"),
|
|
|
|
QStringLiteral("<b>%1</b><br/><br/>%2<br/><br/>%3")
|
|
|
|
.arg(tr("Your NAND contains more data than allowed. Wii "
|
|
|
|
"software may behave incorrectly or not allow saving."))
|
|
|
|
.arg(user_cluster_message)
|
|
|
|
.arg(system_cluster_message));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ModalMessageBox::information(this, tr("NAND Check"),
|
|
|
|
QStringLiteral("<b>%1</b><br/><br/>%2<br/><br/>%3")
|
|
|
|
.arg(tr("No issues have been detected."))
|
|
|
|
.arg(user_cluster_message)
|
|
|
|
.arg(system_cluster_message));
|
|
|
|
}
|
2017-10-03 14:45:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-30 22:42:15 +00:00
|
|
|
{
|
|
|
|
NANDRepairDialog dialog(result, this);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
}
|
2017-10-06 19:45:28 +00:00
|
|
|
|
2017-10-03 14:45:59 +00:00
|
|
|
if (WiiUtils::RepairNAND(ios))
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(this, tr("NAND Check"), tr("The NAND has been repaired."));
|
2017-10-03 14:45:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::critical(this, tr("NAND Check"),
|
|
|
|
tr("The NAND could not be repaired. It is recommended to back up "
|
|
|
|
"your current data and start over with a fresh NAND."));
|
2017-10-03 14:45:59 +00:00
|
|
|
}
|
|
|
|
|
2017-08-26 12:41:53 +00:00
|
|
|
void MenuBar::NANDExtractCertificates()
|
|
|
|
{
|
2021-12-29 22:19:21 +00:00
|
|
|
if (DiscIO::NANDImporter().ExtractCertificates())
|
2017-08-26 12:41:53 +00:00
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(this, tr("Success"),
|
|
|
|
tr("Successfully extracted certificates from NAND"));
|
2017-08-26 12:41:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Failed to extract certificates from NAND"));
|
2017-08-26 12:41:53 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2017-12-31 19:33:36 +00:00
|
|
|
void MenuBar::OnSelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file)
|
2017-08-27 11:55:05 +00:00
|
|
|
{
|
2019-08-14 11:45:07 +00:00
|
|
|
m_game_selected = !!game_file;
|
2017-08-27 11:55:05 +00:00
|
|
|
|
2019-08-14 11:45:07 +00:00
|
|
|
m_recording_play->setEnabled(m_game_selected && !Core::IsRunning());
|
|
|
|
m_recording_start->setEnabled((m_game_selected || Core::IsRunning()) && !Movie::IsPlayingInput());
|
2017-08-27 11:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::OnRecordingStatusChanged(bool recording)
|
|
|
|
{
|
2019-08-14 11:45:07 +00:00
|
|
|
m_recording_start->setEnabled(!recording && (m_game_selected || Core::IsRunning()));
|
2017-08-27 11:55:05 +00:00
|
|
|
m_recording_stop->setEnabled(recording);
|
2019-06-08 06:39:12 +00:00
|
|
|
m_recording_export->setEnabled(recording);
|
2017-08-27 11:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::OnReadOnlyModeChanged(bool read_only)
|
|
|
|
{
|
|
|
|
m_recording_read_only->setChecked(read_only);
|
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
void MenuBar::ChangeDebugFont()
|
|
|
|
{
|
|
|
|
bool okay;
|
|
|
|
QFont font = QFontDialog::getFont(&okay, Settings::Instance().GetDebugFont(), this,
|
|
|
|
tr("Pick a debug font"));
|
|
|
|
|
|
|
|
if (okay)
|
|
|
|
Settings::Instance().SetDebugFont(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::ClearSymbols()
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
auto result = ModalMessageBox::warning(this, tr("Confirmation"),
|
|
|
|
tr("Do you want to clear the list of symbol names?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::Cancel);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
if (result == QMessageBox::Cancel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_symbolDB.Clear();
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::GenerateSymbolsFromAddress()
|
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR,
|
2022-12-02 19:07:30 +00:00
|
|
|
Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &g_symbolDB);
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::GenerateSymbolsFromSignatureDB()
|
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR,
|
2022-12-02 19:07:30 +00:00
|
|
|
Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &g_symbolDB);
|
2018-02-14 22:25:01 +00:00
|
|
|
SignatureDB db(SignatureDB::HandlerType::DSY);
|
|
|
|
if (db.Load(File::GetSysDirectory() + TOTALDB))
|
|
|
|
{
|
2023-02-12 10:07:11 +00:00
|
|
|
db.Apply(guard, &g_symbolDB);
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(
|
2018-02-14 22:25:01 +00:00
|
|
|
this, tr("Information"),
|
|
|
|
tr("Generated symbol names from '%1'").arg(QString::fromStdString(TOTALDB)));
|
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::critical(
|
2018-02-14 22:25:01 +00:00
|
|
|
this, tr("Error"),
|
|
|
|
tr("'%1' not found, no symbol names generated").arg(QString::fromStdString(TOTALDB)));
|
|
|
|
}
|
|
|
|
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::GenerateSymbolsFromRSO()
|
|
|
|
{
|
2020-03-10 09:41:59 +00:00
|
|
|
// i18n: RSO refers to a proprietary format for shared objects (like DLL files).
|
|
|
|
const int ret =
|
|
|
|
ModalMessageBox::question(this, tr("RSO auto-detection"), tr("Auto-detect RSO modules?"));
|
|
|
|
if (ret == QMessageBox::Yes)
|
|
|
|
return GenerateSymbolsFromRSOAuto();
|
|
|
|
|
2021-08-21 17:35:21 +00:00
|
|
|
const QString text =
|
|
|
|
QInputDialog::getText(this, tr("Input"), tr("Enter the RSO module address:"),
|
|
|
|
QLineEdit::Normal, QString{}, nullptr, Qt::WindowCloseButtonHint);
|
2018-02-14 22:25:01 +00:00
|
|
|
bool good;
|
2021-08-21 17:35:21 +00:00
|
|
|
const uint address = text.toUInt(&good, 16);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
if (!good)
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Invalid RSO module address: %1").arg(text));
|
2018-02-14 22:25:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
RSOChainView rso_chain;
|
2023-02-12 10:07:11 +00:00
|
|
|
if (rso_chain.Load(guard, static_cast<u32>(address)))
|
2018-02-14 22:25:01 +00:00
|
|
|
{
|
2023-02-12 10:07:11 +00:00
|
|
|
rso_chain.Apply(guard, &g_symbolDB);
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Failed to load RSO module at %1").arg(text));
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 09:41:59 +00:00
|
|
|
void MenuBar::GenerateSymbolsFromRSOAuto()
|
|
|
|
{
|
2021-02-27 20:04:45 +00:00
|
|
|
ParallelProgressDialog progress(tr("Modules found: %1").arg(0), tr("Cancel"), 0, 0, this);
|
|
|
|
progress.GetRaw()->setWindowTitle(tr("Detecting RSO Modules"));
|
|
|
|
progress.GetRaw()->setMinimumDuration(1000 * 10);
|
|
|
|
progress.GetRaw()->setWindowModality(Qt::WindowModal);
|
2020-03-10 09:41:59 +00:00
|
|
|
|
2021-02-27 20:04:45 +00:00
|
|
|
auto future = std::async(std::launch::async, [&progress, this]() -> RSOVector {
|
|
|
|
progress.SetValue(0);
|
|
|
|
auto matches = DetectRSOModules(progress);
|
|
|
|
progress.Reset();
|
2020-03-10 09:41:59 +00:00
|
|
|
|
2021-02-27 20:04:45 +00:00
|
|
|
return matches;
|
|
|
|
});
|
2023-07-30 22:42:15 +00:00
|
|
|
SetQWidgetWindowDecorations(progress.GetRaw());
|
2021-02-27 20:04:45 +00:00
|
|
|
progress.GetRaw()->exec();
|
2020-03-10 09:41:59 +00:00
|
|
|
|
2021-08-21 17:35:21 +00:00
|
|
|
const auto matches = future.get();
|
2020-03-10 09:41:59 +00:00
|
|
|
|
|
|
|
QStringList items;
|
|
|
|
for (const auto& match : matches)
|
|
|
|
{
|
|
|
|
const QString item = QLatin1String("%1 %2");
|
|
|
|
items << item.arg(QString::number(match.first, 16), QString::fromStdString(match.second));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (items.empty())
|
|
|
|
{
|
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Unable to auto-detect RSO module"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok;
|
2021-08-21 17:35:21 +00:00
|
|
|
const QString item =
|
|
|
|
QInputDialog::getItem(this, tr("Input"), tr("Select the RSO module address:"), items, 0,
|
|
|
|
false, &ok, Qt::WindowCloseButtonHint);
|
2020-03-10 09:41:59 +00:00
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
RSOChainView rso_chain;
|
|
|
|
const u32 address = item.mid(0, item.indexOf(QLatin1Char(' '))).toUInt(nullptr, 16);
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
|
|
|
if (rso_chain.Load(guard, address))
|
2020-03-10 09:41:59 +00:00
|
|
|
{
|
2023-02-12 10:07:11 +00:00
|
|
|
rso_chain.Apply(guard, &g_symbolDB);
|
2020-03-10 09:41:59 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Failed to load RSO module at %1").arg(address));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-27 20:04:45 +00:00
|
|
|
RSOVector MenuBar::DetectRSOModules(ParallelProgressDialog& progress)
|
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2021-02-27 20:04:45 +00:00
|
|
|
constexpr std::array<std::string_view, 2> search_for = {".elf", ".plf"};
|
|
|
|
|
|
|
|
const AddressSpace::Accessors* accessors =
|
|
|
|
AddressSpace::GetAccessors(AddressSpace::Type::Effective);
|
|
|
|
|
|
|
|
RSOVector matches;
|
|
|
|
|
|
|
|
// Find filepath to elf/plf commonly used by RSO modules
|
|
|
|
for (const auto& str : search_for)
|
|
|
|
{
|
|
|
|
u32 next = 0;
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
if (progress.WasCanceled())
|
|
|
|
{
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
auto found_addr = accessors->Search(guard, next, reinterpret_cast<const u8*>(str.data()),
|
|
|
|
str.size() + 1, true);
|
2021-02-27 20:04:45 +00:00
|
|
|
|
|
|
|
if (!found_addr.has_value())
|
|
|
|
break;
|
|
|
|
|
|
|
|
next = *found_addr + 1;
|
|
|
|
|
|
|
|
// Non-null data can precede the module name.
|
|
|
|
// Get the maximum name length that a module could have.
|
2023-02-12 10:07:11 +00:00
|
|
|
auto get_max_module_name_len = [&guard, found_addr] {
|
2021-02-27 20:04:45 +00:00
|
|
|
constexpr u32 MODULE_NAME_MAX_LENGTH = 260;
|
|
|
|
u32 len = 0;
|
|
|
|
|
|
|
|
for (; len < MODULE_NAME_MAX_LENGTH; ++len)
|
|
|
|
{
|
2023-03-12 19:31:10 +00:00
|
|
|
const auto res = PowerPC::MMU::HostRead_U8(guard, *found_addr - (len + 1));
|
2021-02-27 20:04:45 +00:00
|
|
|
if (!std::isprint(res))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (progress.WasCanceled())
|
|
|
|
{
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto max_name_length = get_max_module_name_len();
|
|
|
|
auto found = false;
|
|
|
|
u32 module_name_length = 0;
|
|
|
|
|
|
|
|
// Look for the Module Name Offset Field based on each possible length
|
|
|
|
for (u32 i = 0; i < max_name_length; ++i)
|
|
|
|
{
|
|
|
|
if (progress.WasCanceled())
|
|
|
|
{
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto lookup_addr = (*found_addr - max_name_length) + i;
|
|
|
|
|
|
|
|
const std::array<u8, 4> ref = {
|
|
|
|
static_cast<u8>(lookup_addr >> 24), static_cast<u8>(lookup_addr >> 16),
|
|
|
|
static_cast<u8>(lookup_addr >> 8), static_cast<u8>(lookup_addr)};
|
|
|
|
|
|
|
|
// Get the field (Module Name Offset) that point to the string
|
|
|
|
const auto module_name_offset_addr =
|
2023-02-12 10:07:11 +00:00
|
|
|
accessors->Search(guard, lookup_addr, ref.data(), ref.size(), false);
|
2021-02-27 20:04:45 +00:00
|
|
|
if (!module_name_offset_addr.has_value())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// The next 4 bytes should be the module name length
|
2023-02-12 10:07:11 +00:00
|
|
|
module_name_length = accessors->ReadU32(guard, *module_name_offset_addr + 4);
|
2021-02-27 20:04:45 +00:00
|
|
|
if (module_name_length == max_name_length - i + str.length())
|
|
|
|
{
|
|
|
|
found_addr = module_name_offset_addr;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
continue;
|
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
const auto module_name_offset = accessors->ReadU32(guard, *found_addr);
|
2021-02-27 20:04:45 +00:00
|
|
|
|
|
|
|
// Go to the beginning of the RSO header
|
2023-03-12 19:31:10 +00:00
|
|
|
matches.emplace_back(*found_addr - 16, PowerPC::MMU::HostGetString(guard, module_name_offset,
|
|
|
|
module_name_length));
|
2021-02-27 20:04:45 +00:00
|
|
|
|
|
|
|
progress.SetLabelText(tr("Modules found: %1").arg(matches.size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
void MenuBar::LoadSymbolMap()
|
|
|
|
{
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
std::string existing_map_file, writable_map_file;
|
|
|
|
bool map_exists = CBoot::FindMapFile(&existing_map_file, &writable_map_file);
|
|
|
|
|
|
|
|
if (!map_exists)
|
|
|
|
{
|
|
|
|
g_symbolDB.Clear();
|
2023-02-12 10:07:11 +00:00
|
|
|
|
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
|
|
|
PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR + 0x1300000,
|
|
|
|
Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &g_symbolDB);
|
|
|
|
SignatureDB db(SignatureDB::HandlerType::DSY);
|
|
|
|
if (db.Load(File::GetSysDirectory() + TOTALDB))
|
|
|
|
db.Apply(guard, &g_symbolDB);
|
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Warning"),
|
|
|
|
tr("'%1' not found, scanning for common functions instead")
|
|
|
|
.arg(QString::fromStdString(writable_map_file)));
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-10 18:05:25 +00:00
|
|
|
const QString existing_map_file_path = QString::fromStdString(existing_map_file);
|
|
|
|
|
|
|
|
if (!TryLoadMapFile(existing_map_file_path))
|
|
|
|
return;
|
|
|
|
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::information(this, tr("Information"),
|
|
|
|
tr("Loaded symbols from '%1'").arg(existing_map_file_path));
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
2023-01-10 04:40:02 +00:00
|
|
|
HLE::PatchFunctions(system);
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::SaveSymbolMap()
|
|
|
|
{
|
|
|
|
std::string existing_map_file, writable_map_file;
|
|
|
|
CBoot::FindMapFile(&existing_map_file, &writable_map_file);
|
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
TrySaveSymbolMap(QString::fromStdString(writable_map_file));
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::LoadOtherSymbolMap()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getOpenFileName(
|
2018-07-10 18:05:25 +00:00
|
|
|
this, tr("Load map file"), QString::fromStdString(File::GetUserPath(D_MAPS_IDX)),
|
|
|
|
tr("Dolphin Map File (*.map)"));
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
if (!TryLoadMapFile(file))
|
|
|
|
return;
|
|
|
|
|
2023-01-10 04:40:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
HLE::PatchFunctions(system);
|
2018-05-11 20:38:32 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 00:59:55 +00:00
|
|
|
void MenuBar::LoadBadSymbolMap()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getOpenFileName(
|
2018-10-09 00:59:55 +00:00
|
|
|
this, tr("Load map file"), QString::fromStdString(File::GetUserPath(D_MAPS_IDX)),
|
|
|
|
tr("Dolphin Map File (*.map)"));
|
|
|
|
|
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!TryLoadMapFile(file, true))
|
|
|
|
return;
|
|
|
|
|
2023-01-10 04:40:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
HLE::PatchFunctions(system);
|
2018-10-09 00:59:55 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
void MenuBar::SaveSymbolMapAs()
|
|
|
|
{
|
|
|
|
const std::string& title_id_str = SConfig::GetInstance().m_debugger_game_id;
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getSaveFileName(
|
2018-02-14 22:25:01 +00:00
|
|
|
this, tr("Save map file"),
|
|
|
|
QString::fromStdString(File::GetUserPath(D_MAPS_IDX) + "/" + title_id_str + ".map"),
|
|
|
|
tr("Dolphin Map File (*.map)"));
|
|
|
|
|
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
TrySaveSymbolMap(file);
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::SaveCode()
|
|
|
|
{
|
|
|
|
std::string existing_map_file, writable_map_file;
|
|
|
|
CBoot::FindMapFile(&existing_map_file, &writable_map_file);
|
|
|
|
|
|
|
|
const std::string path =
|
2018-03-28 02:27:48 +00:00
|
|
|
writable_map_file.substr(0, writable_map_file.find_last_of('.')) + "_code.map";
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
bool success;
|
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
success = g_symbolDB.SaveCodeMap(guard, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!success)
|
2018-07-10 18:05:25 +00:00
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(
|
2018-07-10 18:05:25 +00:00
|
|
|
this, tr("Error"),
|
|
|
|
tr("Failed to save code map to path '%1'").arg(QString::fromStdString(path)));
|
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 00:59:55 +00:00
|
|
|
bool MenuBar::TryLoadMapFile(const QString& path, const bool bad)
|
2018-02-14 22:25:01 +00:00
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
|
|
|
|
if (!g_symbolDB.LoadMap(guard, path.toStdString(), bad))
|
2018-07-10 18:05:25 +00:00
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Failed to load map file '%1'").arg(path));
|
2018-07-10 18:05:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::TrySaveSymbolMap(const QString& path)
|
|
|
|
{
|
|
|
|
if (g_symbolDB.SaveSymbolMap(path.toStdString()))
|
2018-02-14 22:25:01 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"),
|
|
|
|
tr("Failed to save symbol map to path '%1'").arg(path));
|
2018-07-10 18:05:25 +00:00
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
void MenuBar::CreateSignatureFile()
|
|
|
|
{
|
|
|
|
const QString text = QInputDialog::getText(
|
2021-08-21 17:35:21 +00:00
|
|
|
this, tr("Input"), tr("Only export symbols with prefix:\n(Blank for all symbols)"),
|
|
|
|
QLineEdit::Normal, QString{}, nullptr, Qt::WindowCloseButtonHint);
|
2018-02-14 22:25:01 +00:00
|
|
|
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getSaveFileName(this, tr("Save signature file"),
|
|
|
|
QDir::homePath(), GetSignatureSelector());
|
2018-02-14 22:25:01 +00:00
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2018-07-10 18:05:25 +00:00
|
|
|
const std::string prefix = text.toStdString();
|
|
|
|
const std::string save_path = file.toStdString();
|
2018-02-14 22:25:01 +00:00
|
|
|
SignatureDB db(save_path);
|
|
|
|
db.Populate(&g_symbolDB, prefix);
|
2018-07-10 18:05:25 +00:00
|
|
|
|
|
|
|
if (!db.Save(save_path))
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"), tr("Failed to save signature file '%1'").arg(file));
|
2018-07-10 18:05:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
|
2018-10-09 00:59:55 +00:00
|
|
|
void MenuBar::AppendSignatureFile()
|
|
|
|
{
|
|
|
|
const QString text = QInputDialog::getText(
|
2021-08-21 17:35:21 +00:00
|
|
|
this, tr("Input"), tr("Only append symbols with prefix:\n(Blank for all symbols)"),
|
|
|
|
QLineEdit::Normal, QString{}, nullptr, Qt::WindowCloseButtonHint);
|
2018-10-09 00:59:55 +00:00
|
|
|
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getSaveFileName(this, tr("Append signature to"),
|
|
|
|
QDir::homePath(), GetSignatureSelector());
|
2018-10-09 00:59:55 +00:00
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const std::string prefix = text.toStdString();
|
|
|
|
const std::string signature_path = file.toStdString();
|
|
|
|
SignatureDB db(signature_path);
|
|
|
|
db.Populate(&g_symbolDB, prefix);
|
|
|
|
db.List();
|
|
|
|
db.Load(signature_path);
|
|
|
|
if (!db.Save(signature_path))
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"),
|
|
|
|
tr("Failed to append to signature file '%1'").arg(file));
|
2018-10-09 00:59:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::ApplySignatureFile()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString file = DolphinFileDialog::getOpenFileName(this, tr("Apply signature file"),
|
|
|
|
QDir::homePath(), GetSignatureSelector());
|
2018-10-09 00:59:55 +00:00
|
|
|
|
|
|
|
if (file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const std::string load_path = file.toStdString();
|
|
|
|
SignatureDB db(load_path);
|
|
|
|
db.Load(load_path);
|
2023-02-12 10:07:11 +00:00
|
|
|
{
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
2023-02-12 10:07:11 +00:00
|
|
|
db.Apply(guard, &g_symbolDB);
|
|
|
|
}
|
2018-10-09 00:59:55 +00:00
|
|
|
db.List();
|
2023-01-10 04:40:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
HLE::PatchFunctions(system);
|
2018-10-09 00:59:55 +00:00
|
|
|
emit NotifySymbolsUpdated();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::CombineSignatureFiles()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString priorityFile = DolphinFileDialog::getOpenFileName(
|
2019-10-12 16:04:51 +00:00
|
|
|
this, tr("Choose priority input file"), QDir::homePath(), GetSignatureSelector());
|
2018-10-09 00:59:55 +00:00
|
|
|
if (priorityFile.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString secondaryFile = DolphinFileDialog::getOpenFileName(
|
2019-10-12 16:04:51 +00:00
|
|
|
this, tr("Choose secondary input file"), QDir::homePath(), GetSignatureSelector());
|
2018-10-09 00:59:55 +00:00
|
|
|
if (secondaryFile.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2021-10-10 02:28:59 +00:00
|
|
|
const QString saveFile = DolphinFileDialog::getSaveFileName(
|
|
|
|
this, tr("Save combined output file as"), QDir::homePath(), GetSignatureSelector());
|
2018-10-09 00:59:55 +00:00
|
|
|
if (saveFile.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const std::string load_pathPriorityFile = priorityFile.toStdString();
|
|
|
|
const std::string load_pathSecondaryFile = secondaryFile.toStdString();
|
|
|
|
const std::string save_path = saveFile.toStdString();
|
|
|
|
SignatureDB db(load_pathPriorityFile);
|
|
|
|
db.Load(load_pathPriorityFile);
|
|
|
|
db.Load(load_pathSecondaryFile);
|
|
|
|
if (!db.Save(save_path))
|
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::warning(this, tr("Error"),
|
|
|
|
tr("Failed to save to signature file '%1'").arg(saveFile));
|
2018-10-09 00:59:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:25:01 +00:00
|
|
|
void MenuBar::PatchHLEFunctions()
|
|
|
|
{
|
2023-01-10 04:40:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
HLE::PatchFunctions(system);
|
2018-02-14 22:25:01 +00:00
|
|
|
}
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
void MenuBar::ClearCache()
|
|
|
|
{
|
2023-03-25 14:46:19 +00:00
|
|
|
Core::RunAsCPUThread([] { Core::System::GetInstance().GetJitInterface().ClearCache(); });
|
2018-04-09 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::LogInstructions()
|
|
|
|
{
|
|
|
|
PPCTables::LogCompiledInstructions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::SearchInstruction()
|
|
|
|
{
|
|
|
|
bool good;
|
2021-08-21 17:35:21 +00:00
|
|
|
const QString op =
|
|
|
|
QInputDialog::getText(this, tr("Search instruction"), tr("Instruction:"), QLineEdit::Normal,
|
|
|
|
QString{}, &good, Qt::WindowCloseButtonHint);
|
2018-04-09 13:31:20 +00:00
|
|
|
|
|
|
|
if (!good)
|
|
|
|
return;
|
|
|
|
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
|
2023-03-08 00:58:05 +00:00
|
|
|
Core::CPUThreadGuard guard(system);
|
2023-02-12 10:07:11 +00:00
|
|
|
|
2018-04-09 13:31:20 +00:00
|
|
|
bool found = false;
|
2022-12-02 19:07:30 +00:00
|
|
|
for (u32 addr = Memory::MEM1_BASE_ADDR; addr < Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal();
|
2020-04-28 17:10:50 +00:00
|
|
|
addr += 4)
|
2018-04-09 13:31:20 +00:00
|
|
|
{
|
2023-03-12 19:31:10 +00:00
|
|
|
const auto ins_name = QString::fromStdString(
|
2023-03-28 19:59:39 +00:00
|
|
|
PPCTables::GetInstructionName(PowerPC::MMU::HostRead_U32(guard, addr), addr));
|
2018-04-09 13:31:20 +00:00
|
|
|
if (op == ins_name)
|
|
|
|
{
|
2020-11-26 02:13:50 +00:00
|
|
|
NOTICE_LOG_FMT(POWERPC, "Found {} at {:08x}", op.toStdString(), addr);
|
2018-04-09 13:31:20 +00:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
2020-11-26 02:13:50 +00:00
|
|
|
NOTICE_LOG_FMT(POWERPC, "Opcode {} not found", op.toStdString());
|
2018-04-09 13:31:20 +00:00
|
|
|
}
|