This commit is contained in:
Nayla Hanegan 2024-05-12 02:17:59 -04:00
commit 98c174edc4
520 changed files with 74815 additions and 58942 deletions

View file

@ -451,14 +451,14 @@ void MainWindow::CreateComponents()
m_jit_widget = new JITWidget(this);
m_log_widget = new LogWidget(this);
m_log_config_widget = new LogConfigWidget(this);
m_memory_widget = new MemoryWidget(this);
m_memory_widget = new MemoryWidget(Core::System::GetInstance(), this);
m_network_widget = new NetworkWidget(this);
m_register_widget = new RegisterWidget(this);
m_thread_widget = new ThreadWidget(this);
m_watch_widget = new WatchWidget(this);
m_breakpoint_widget = new BreakpointWidget(this);
m_code_widget = new CodeWidget(this);
m_cheats_manager = new CheatsManager(this);
m_cheats_manager = new CheatsManager(Core::System::GetInstance(), this);
m_assembler_widget = new AssemblerWidget(this);
const auto request_watch = [this](QString name, u32 addr) {
@ -501,7 +501,7 @@ void MainWindow::CreateComponents()
connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_memory_widget,
&MemoryWidget::Update);
connect(m_breakpoint_widget, &BreakpointWidget::ShowCode, [this](u32 address) {
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
});
connect(m_breakpoint_widget, &BreakpointWidget::ShowMemory, m_memory_widget,
@ -591,12 +591,6 @@ void MainWindow::ConnectMenuBar()
connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged);
connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged);
connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged);
// Symbols
connect(m_menu_bar, &MenuBar::NotifySymbolsUpdated, [this] {
m_code_widget->UpdateSymbols();
m_code_widget->Update();
});
}
void MainWindow::ConnectHotkeys()
@ -796,15 +790,17 @@ void MainWindow::ChangeDisc()
{
std::vector<std::string> paths = StringListToStdVector(PromptFileNames());
if (!paths.empty())
Core::RunAsCPUThread(
[&paths] { Core::System::GetInstance().GetDVDInterface().ChangeDisc(paths); });
if (paths.empty())
return;
auto& system = Core::System::GetInstance();
system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{system}, paths);
}
void MainWindow::EjectDisc()
{
Core::RunAsCPUThread(
[] { Core::System::GetInstance().GetDVDInterface().EjectDisc(DVD::EjectCause::User); });
auto& system = Core::System::GetInstance();
system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{system}, DVD::EjectCause::User);
}
void MainWindow::OpenUserFolder()
@ -829,9 +825,9 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
// Otherwise, play the default game.
// Otherwise, play the last played game, if there is one.
// Otherwise, prompt for a new game.
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
{
Core::SetState(Core::State::Running);
Core::SetState(Core::System::GetInstance(), Core::State::Running);
}
else
{
@ -859,12 +855,12 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
void MainWindow::Pause()
{
Core::SetState(Core::State::Paused);
Core::SetState(Core::System::GetInstance(), Core::State::Paused);
}
void MainWindow::TogglePause()
{
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
{
Play();
}
@ -907,9 +903,9 @@ void MainWindow::OnStopComplete()
bool MainWindow::RequestStop()
{
if (!Core::IsRunning())
if (!Core::IsRunning(Core::System::GetInstance()))
{
Core::QueueHostJob([this] { OnStopComplete(); }, true);
Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true);
return true;
}
@ -932,13 +928,13 @@ bool MainWindow::RequestStop()
Common::ScopeGuard confirm_lock([this] { m_stop_confirm_showing = false; });
const Core::State state = Core::GetState();
const Core::State state = Core::GetState(Core::System::GetInstance());
// Only pause the game, if NetPlay is not running
bool pause = !Settings::Instance().GetNetPlayClient();
if (pause)
Core::SetState(Core::State::Paused);
Core::SetState(Core::System::GetInstance(), Core::State::Paused);
if (rendered_widget_was_active)
{
@ -968,7 +964,7 @@ bool MainWindow::RequestStop()
m_render_widget->SetWaitingForMessageBox(false);
if (pause)
Core::SetState(state);
Core::SetState(Core::System::GetInstance(), state);
return false;
}
@ -989,8 +985,8 @@ bool MainWindow::RequestStop()
// Unpause because gracefully shutting down needs the game to actually request a shutdown.
// TODO: Do not unpause in debug mode to allow debugging until the complete shutdown.
if (Core::GetState() == Core::State::Paused)
Core::SetState(Core::State::Running);
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
Core::SetState(Core::System::GetInstance(), Core::State::Running);
// Tell NetPlay about the power event
if (NetPlay::IsNetPlayRunning())
@ -1009,9 +1005,9 @@ bool MainWindow::RequestStop()
bool MainWindow::RequestStopNetplay()
{
if (!Core::IsRunning())
if (!Core::IsRunning(Core::System::GetInstance()))
{
Core::QueueHostJob([this] { OnStopComplete(); }, true);
Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true);
return true;
}
@ -1034,13 +1030,13 @@ bool MainWindow::RequestStopNetplay()
Common::ScopeGuard confirm_lock([this] { m_stop_confirm_showing = false; });
const Core::State state = Core::GetState();
const Core::State state = Core::GetState(Core::System::GetInstance());
// Only pause the game, if NetPlay is not running
bool pause = !Settings::Instance().GetNetPlayClient();
if (pause)
Core::SetState(Core::State::Paused);
Core::SetState(Core::System::GetInstance(), Core::State::Paused);
if (rendered_widget_was_active)
{
@ -1072,7 +1068,7 @@ bool MainWindow::RequestStopNetplay()
m_render_widget->SetWaitingForMessageBox(false);
if (pause)
Core::SetState(state);
Core::SetState(Core::System::GetInstance(), state);
return false;
}
@ -1093,8 +1089,8 @@ bool MainWindow::RequestStopNetplay()
// Unpause because gracefully shutting down needs the game to actually request a shutdown.
// TODO: Do not unpause in debug mode to allow debugging until the complete shutdown.
if (Core::GetState() == Core::State::Paused)
Core::SetState(Core::State::Running);
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
Core::SetState(Core::System::GetInstance(), Core::State::Running);
// Tell NetPlay about the power event
if (NetPlay::IsNetPlayRunning())
@ -1113,7 +1109,7 @@ bool MainWindow::RequestStopNetplay()
void MainWindow::ForceStop()
{
Core::Stop();
Core::Stop(Core::System::GetInstance());
}
void MainWindow::Reset()
@ -1127,7 +1123,7 @@ void MainWindow::Reset()
void MainWindow::FrameAdvance()
{
Core::DoFrameStep();
Core::DoFrameStep(Core::System::GetInstance());
}
void MainWindow::FullScreen()
@ -1218,7 +1214,7 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
}
// If we're running, only start a new game once we've stopped the last.
if (Core::GetState() != Core::State::Uninitialized)
if (Core::GetState(Core::System::GetInstance()) != Core::State::Uninitialized)
{
if (!RequestStop())
return;
@ -1232,7 +1228,7 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
ShowRenderWidget();
// Boot up, show an error if it fails to load the game.
if (!BootManager::BootCore(std::move(parameters),
if (!BootManager::BootCore(Core::System::GetInstance(), std::move(parameters),
::GetWindowSystemInfo(m_render_widget->windowHandle())))
{
ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
@ -1518,7 +1514,7 @@ void MainWindow::StateLoad()
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::LoadAs(path.toStdString());
State::LoadAs(Core::System::GetInstance(), path.toStdString());
}
void MainWindow::StateSave()
@ -1530,47 +1526,47 @@ void MainWindow::StateSave()
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::SaveAs(path.toStdString());
State::SaveAs(Core::System::GetInstance(), path.toStdString());
}
void MainWindow::StateLoadSlot()
{
State::Load(m_state_slot);
State::Load(Core::System::GetInstance(), m_state_slot);
}
void MainWindow::StateSaveSlot()
{
State::Save(m_state_slot);
State::Save(Core::System::GetInstance(), m_state_slot);
}
void MainWindow::StateLoadSlotAt(int slot)
{
State::Load(slot);
State::Load(Core::System::GetInstance(), slot);
}
void MainWindow::StateLoadLastSavedAt(int slot)
{
State::LoadLastSaved(slot);
State::LoadLastSaved(Core::System::GetInstance(), slot);
}
void MainWindow::StateSaveSlotAt(int slot)
{
State::Save(slot);
State::Save(Core::System::GetInstance(), slot);
}
void MainWindow::StateLoadUndo()
{
State::UndoLoadState();
State::UndoLoadState(Core::System::GetInstance());
}
void MainWindow::StateSaveUndo()
{
State::UndoSaveState();
State::UndoSaveState(Core::System::GetInstance());
}
void MainWindow::StateSaveOldest()
{
State::SaveFirstSaved();
State::SaveFirstSaved(Core::System::GetInstance());
}
void MainWindow::SetStateSlot(int slot)
@ -1643,7 +1639,7 @@ void MainWindow::NetPlayInit()
bool MainWindow::NetPlayJoin()
{
if (Core::IsRunning())
if (Core::IsRunning(Core::System::GetInstance()))
{
ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!"));
@ -1710,7 +1706,7 @@ bool MainWindow::NetPlayJoin()
bool MainWindow::NetPlayHost(const UICommon::GameFile& game)
{
if (Core::IsRunning())
if (Core::IsRunning(Core::System::GetInstance()))
{
ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!"));
@ -1771,8 +1767,8 @@ void MainWindow::NetPlayQuit()
void MainWindow::UpdateScreenSaverInhibition()
{
const bool inhibit =
Config::Get(Config::MAIN_DISABLE_SCREENSAVER) && (Core::GetState() == Core::State::Running);
const bool inhibit = Config::Get(Config::MAIN_DISABLE_SCREENSAVER) &&
(Core::GetState(Core::System::GetInstance()) == Core::State::Running);
if (inhibit == m_is_screensaver_inhibited)
return;
@ -1957,7 +1953,7 @@ void MainWindow::OnImportNANDBackup()
result.wait();
m_menu_bar->UpdateToolsMenu(Core::IsRunning());
m_menu_bar->UpdateToolsMenu(Core::IsRunning(Core::System::GetInstance()));
}
void MainWindow::OnPlayRecording()
@ -1987,8 +1983,9 @@ void MainWindow::OnPlayRecording()
void MainWindow::OnStartRecording()
{
auto& movie = Core::System::GetInstance().GetMovie();
if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || movie.IsRecordingInput() ||
auto& system = Core::System::GetInstance();
auto& movie = system.GetMovie();
if ((!Core::IsRunningAndStarted() && Core::IsRunning(system)) || movie.IsRecordingInput() ||
movie.IsPlayingInput())
{
return;
@ -2020,7 +2017,7 @@ void MainWindow::OnStartRecording()
{
emit RecordingStatusChanged(true);
if (!Core::IsRunning())
if (!Core::IsRunning(system))
Play();
}
}
@ -2037,12 +2034,13 @@ void MainWindow::OnStopRecording()
void MainWindow::OnExportRecording()
{
Core::RunAsCPUThread([this] {
QString dtm_file = DolphinFileDialog::getSaveFileName(
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
if (!dtm_file.isEmpty())
Core::System::GetInstance().GetMovie().SaveRecording(dtm_file.toStdString());
});
auto& system = Core::System::GetInstance();
const Core::CPUThreadGuard guard(system);
QString dtm_file = DolphinFileDialog::getSaveFileName(
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
if (!dtm_file.isEmpty())
system.GetMovie().SaveRecording(dtm_file.toStdString());
}
void MainWindow::OnActivateChat()
@ -2080,10 +2078,11 @@ void MainWindow::ShowTASInput()
}
}
auto& system = Core::System::GetInstance();
for (int i = 0; i < num_wii_controllers; i++)
{
if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated &&
(!Core::IsRunning() || Core::System::GetInstance().IsWii()))
(!Core::IsRunning(system) || system.IsWii()))
{
SetQWidgetWindowDecorations(m_wii_tas_input_windows[i]);
m_wii_tas_input_windows[i]->show();
@ -2095,13 +2094,12 @@ void MainWindow::ShowTASInput()
void MainWindow::OnConnectWiiRemote(int id)
{
Core::RunAsCPUThread([&] {
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
{
const auto wm = bt->AccessWiimoteByIndex(id);
wm->Activate(!wm->IsConnected());
}
});
const Core::CPUThreadGuard guard(Core::System::GetInstance());
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
{
const auto wm = bt->AccessWiimoteByIndex(id);
wm->Activate(!wm->IsConnected());
}
}
#ifdef USE_RETRO_ACHIEVEMENTS
@ -2116,6 +2114,7 @@ void MainWindow::ShowAchievementsWindow()
m_achievements_window->show();
m_achievements_window->raise();
m_achievements_window->activateWindow();
m_achievements_window->UpdateData(AchievementManager::UpdatedItems{.all = true});
}
void MainWindow::ShowAchievementSettings()