summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2021-09-16 07:12:27 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2021-09-16 08:01:40 +0200
commita4b1ea3d70a051fd60fab7bfa07380366cebc978 (patch)
tree8711d74bc5c55211548b4b6e8471050644c9adb3 /Source/Core
parentaa2d089d1b588a798e33e994cbc791e35b3ecc1e (diff)
Qt/ARCodeWidget: Disable functionality if no game id is given.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/Config/ARCodeWidget.cpp23
1 files 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");