From aee6e45386f530ebf41ac6ca11c8f26dd217f3de Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 16 Sep 2021 06:49:03 +0200 Subject: [PATCH 1/5] Qt/CheatsManager: Let the 'Configure Dolphin' button shown in the Cheats Manager when Cheats are disabled actually open the settings. --- Source/Core/DolphinQt/CheatsManager.cpp | 4 ++++ Source/Core/DolphinQt/CheatsManager.h | 3 +++ Source/Core/DolphinQt/MainWindow.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/Source/Core/DolphinQt/CheatsManager.cpp b/Source/Core/DolphinQt/CheatsManager.cpp index ba7a9cbc1a..a2be055019 100644 --- a/Source/Core/DolphinQt/CheatsManager.cpp +++ b/Source/Core/DolphinQt/CheatsManager.cpp @@ -78,6 +78,10 @@ void CheatsManager::OnStateChanged(Core::State state) m_tab_widget->insertTab(1, m_gecko_code, tr("Gecko Codes")); m_tab_widget->setTabUnclosable(0); m_tab_widget->setTabUnclosable(1); + + connect(m_ar_code, &ARCodeWidget::OpenGeneralSettings, this, &CheatsManager::OpenGeneralSettings); + connect(m_gecko_code, &GeckoCodeWidget::OpenGeneralSettings, this, + &CheatsManager::OpenGeneralSettings); } void CheatsManager::CreateWidgets() diff --git a/Source/Core/DolphinQt/CheatsManager.h b/Source/Core/DolphinQt/CheatsManager.h index 7cf0bb874f..73dea563d5 100644 --- a/Source/Core/DolphinQt/CheatsManager.h +++ b/Source/Core/DolphinQt/CheatsManager.h @@ -33,6 +33,9 @@ public: explicit CheatsManager(QWidget* parent = nullptr); ~CheatsManager(); +signals: + void OpenGeneralSettings(); + private: void CreateWidgets(); void ConnectWidgets(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 8a687cef47..f7f3f08d46 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -220,6 +220,9 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters, ConnectMenuBar(); ConnectHotkeys(); + connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this, + &MainWindow::ShowGeneralWindow); + InitCoreCallbacks(); NetPlayInit(); From aa2d089d1b588a798e33e994cbc791e35b3ecc1e Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 16 Sep 2021 06:50:21 +0200 Subject: [PATCH 2/5] Qt/MenuBar: Allow opening Cheats Manager regardless of emulation state and configuration. --- Source/Core/DolphinQt/MenuBar.cpp | 10 +--------- Source/Core/DolphinQt/MenuBar.h | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 8f3509b214..1b7cb396d2 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -131,9 +131,6 @@ void MenuBar::OnEmulationStateChanged(Core::State state) // Options m_controllers_action->setEnabled(NetPlay::IsNetPlayRunning() ? !running : true); - // Tools - m_show_cheat_manager->setEnabled(Settings::Instance().GetCheatsEnabled() && running); - // JIT m_jit_interpreter_core->setEnabled(running); m_jit_block_linking->setEnabled(!running); @@ -228,12 +225,7 @@ void MenuBar::AddToolsMenu() tools_menu->addAction(tr("&Resource Pack Manager"), this, [this] { emit ShowResourcePackManager(); }); - m_show_cheat_manager = - tools_menu->addAction(tr("&Cheats Manager"), this, [this] { emit ShowCheatsManager(); }); - - connect(&Settings::Instance(), &Settings::EnableCheatsChanged, this, [this](bool enabled) { - m_show_cheat_manager->setEnabled(Core::GetState() != Core::State::Uninitialized && enabled); - }); + tools_menu->addAction(tr("&Cheats Manager"), this, [this] { emit ShowCheatsManager(); }); tools_menu->addAction(tr("FIFO Player"), this, &MenuBar::ShowFIFOPlayer); diff --git a/Source/Core/DolphinQt/MenuBar.h b/Source/Core/DolphinQt/MenuBar.h index 1ac69022d4..d745f52e9b 100644 --- a/Source/Core/DolphinQt/MenuBar.h +++ b/Source/Core/DolphinQt/MenuBar.h @@ -196,7 +196,6 @@ private: QMenu* m_backup_menu; // Tools - QAction* m_show_cheat_manager; QAction* m_wad_install_action; QMenu* m_perform_online_update_menu; QAction* m_perform_online_update_for_current_region; From a4b1ea3d70a051fd60fab7bfa07380366cebc978 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 16 Sep 2021 07:12:27 +0200 Subject: [PATCH 3/5] Qt/ARCodeWidget: Disable functionality if no game id is given. --- Source/Core/DolphinQt/Config/ARCodeWidget.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp index c3ebe967d3..b45cfb3772 100644 --- a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp @@ -31,14 +31,17 @@ ARCodeWidget::ARCodeWidget(std::string game_id, u16 game_revision, bool restart_ CreateWidgets(); ConnectWidgets(); - IniFile game_ini_local; + if (!m_game_id.empty()) + { + IniFile game_ini_local; - // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI - // will always be stored in GS/${GAMEID}.ini - game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); + // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI + // will always be stored in GS/${GAMEID}.ini + game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); - m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); + const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); + m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); + } UpdateList(); OnSelectionChanged(); @@ -54,6 +57,11 @@ void ARCodeWidget::CreateWidgets() m_code_edit = new QPushButton(tr("&Edit Code...")); m_code_remove = new QPushButton(tr("&Remove Code")); + m_code_list->setEnabled(!m_game_id.empty()); + m_code_add->setEnabled(!m_game_id.empty()); + m_code_edit->setEnabled(!m_game_id.empty()); + m_code_remove->setEnabled(!m_game_id.empty()); + m_code_list->setContextMenuPolicy(Qt::CustomContextMenu); auto* button_layout = new QHBoxLayout; @@ -171,6 +179,9 @@ void ARCodeWidget::UpdateList() void ARCodeWidget::SaveCodes() { + if (m_game_id.empty()) + return; + const auto ini_path = std::string(File::GetUserPath(D_GAMESETTINGS_IDX)).append(m_game_id).append(".ini"); From dd9047f7c5753d77ab1b2da0c3e2cdeb63a300d1 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 16 Sep 2021 07:17:37 +0200 Subject: [PATCH 4/5] Qt/GeckoCodeWidget: Disable functionality if no game id is given. --- .../Core/DolphinQt/Config/GeckoCodeWidget.cpp | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp index 99110d3b37..87783379b7 100644 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp @@ -37,14 +37,17 @@ GeckoCodeWidget::GeckoCodeWidget(std::string game_id, std::string gametdb_id, u1 CreateWidgets(); ConnectWidgets(); - IniFile game_ini_local; + if (!m_game_id.empty()) + { + IniFile game_ini_local; - // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI - // will always be stored in GS/${GAMEID}.ini - game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); + // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI + // will always be stored in GS/${GAMEID}.ini + game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); - m_gecko_codes = Gecko::LoadCodes(game_ini_default, game_ini_local); + const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); + m_gecko_codes = Gecko::LoadCodes(game_ini_default, game_ini_local); + } UpdateList(); } @@ -81,9 +84,16 @@ void GeckoCodeWidget::CreateWidgets() m_download_codes->setToolTip(tr("Download Codes from the WiiRD Database")); - m_download_codes->setEnabled(!m_game_id.empty()); + m_code_list->setEnabled(!m_game_id.empty()); + m_name_label->setEnabled(!m_game_id.empty()); + m_creator_label->setEnabled(!m_game_id.empty()); + m_code_description->setEnabled(!m_game_id.empty()); + m_code_view->setEnabled(!m_game_id.empty()); + + m_add_code->setEnabled(!m_game_id.empty()); m_edit_code->setEnabled(false); m_remove_code->setEnabled(false); + m_download_codes->setEnabled(!m_game_id.empty()); auto* layout = new QVBoxLayout; @@ -228,6 +238,9 @@ void GeckoCodeWidget::RemoveCode() void GeckoCodeWidget::SaveCodes() { + if (m_game_id.empty()) + return; + const auto ini_path = std::string(File::GetUserPath(D_GAMESETTINGS_IDX)).append(m_game_id).append(".ini"); From c40e8ee3a8f3e2e961ae5fcc4442431744741b1a Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 16 Sep 2021 07:35:15 +0200 Subject: [PATCH 5/5] Qt/CheatsManager: Show disabled AR and Gecko tabs when no game is running. --- Source/Core/DolphinQt/CheatsManager.cpp | 16 +++++++++++----- Source/Core/DolphinQt/CheatsManager.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/CheatsManager.cpp b/Source/Core/DolphinQt/CheatsManager.cpp index a2be055019..b5fffd771c 100644 --- a/Source/Core/DolphinQt/CheatsManager.cpp +++ b/Source/Core/DolphinQt/CheatsManager.cpp @@ -30,24 +30,30 @@ CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent) connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &CheatsManager::OnStateChanged); - OnStateChanged(Core::GetState()); - CreateWidgets(); ConnectWidgets(); + + RefreshCodeTabs(Core::GetState(), true); } CheatsManager::~CheatsManager() = default; void CheatsManager::OnStateChanged(Core::State state) { - if (state != Core::State::Running && state != Core::State::Paused) + RefreshCodeTabs(state, false); +} + +void CheatsManager::RefreshCodeTabs(Core::State state, bool force) +{ + if (!force && (state == Core::State::Starting || state == Core::State::Stopping)) return; - const auto& game_id = SConfig::GetInstance().GetGameID(); + const auto& game_id = + state != Core::State::Uninitialized ? SConfig::GetInstance().GetGameID() : std::string(); const auto& game_tdb_id = SConfig::GetInstance().GetGameTDBID(); const u16 revision = SConfig::GetInstance().GetRevision(); - if (m_game_id == game_id && m_game_tdb_id == game_tdb_id && m_revision == revision) + if (!force && m_game_id == game_id && m_game_tdb_id == game_tdb_id && m_revision == revision) return; m_game_id = game_id; diff --git a/Source/Core/DolphinQt/CheatsManager.h b/Source/Core/DolphinQt/CheatsManager.h index 73dea563d5..450e004fe9 100644 --- a/Source/Core/DolphinQt/CheatsManager.h +++ b/Source/Core/DolphinQt/CheatsManager.h @@ -43,6 +43,8 @@ private: void OnNewSessionCreated(const Cheats::CheatSearchSessionBase& session); void OnTabCloseRequested(int index); + void RefreshCodeTabs(Core::State state, bool force); + std::string m_game_id; std::string m_game_tdb_id; u16 m_revision = 0;