Extract ARCodeWidget/GeckoCodeWidget code loading to functions
This commit is contained in:
parent
ee35aa49a2
commit
232d24109d
|
@ -35,21 +35,7 @@ ARCodeWidget::ARCodeWidget(std::string game_id, u16 game_revision, bool restart_
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
|
|
||||||
if (!m_game_id.empty())
|
LoadCodes();
|
||||||
{
|
|
||||||
Common::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");
|
|
||||||
|
|
||||||
const Common::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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ARCodeWidget::~ARCodeWidget() = default;
|
ARCodeWidget::~ARCodeWidget() = default;
|
||||||
|
@ -65,11 +51,6 @@ void ARCodeWidget::CreateWidgets()
|
||||||
m_code_edit = new NonDefaultQPushButton(tr("&Edit Code..."));
|
m_code_edit = new NonDefaultQPushButton(tr("&Edit Code..."));
|
||||||
m_code_remove = new NonDefaultQPushButton(tr("&Remove Code"));
|
m_code_remove = new NonDefaultQPushButton(tr("&Remove Code"));
|
||||||
|
|
||||||
m_code_list->setEnabled(!m_game_id.empty());
|
|
||||||
m_code_add->setEnabled(!m_game_id.empty());
|
|
||||||
m_code_edit->setEnabled(false);
|
|
||||||
m_code_remove->setEnabled(false);
|
|
||||||
|
|
||||||
m_code_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_code_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
auto* button_layout = new QHBoxLayout;
|
auto* button_layout = new QHBoxLayout;
|
||||||
|
@ -218,6 +199,30 @@ void ARCodeWidget::UpdateList()
|
||||||
m_code_list->setDragDropMode(QAbstractItemView::InternalMove);
|
m_code_list->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ARCodeWidget::LoadCodes()
|
||||||
|
{
|
||||||
|
if (!m_game_id.empty())
|
||||||
|
{
|
||||||
|
Common::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");
|
||||||
|
|
||||||
|
const Common::IniFile game_ini_default =
|
||||||
|
SConfig::LoadDefaultGameIni(m_game_id, m_game_revision);
|
||||||
|
m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_code_list->setEnabled(!m_game_id.empty());
|
||||||
|
m_code_add->setEnabled(!m_game_id.empty());
|
||||||
|
m_code_edit->setEnabled(false);
|
||||||
|
m_code_remove->setEnabled(false);
|
||||||
|
|
||||||
|
UpdateList();
|
||||||
|
OnSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void ARCodeWidget::SaveCodes()
|
void ARCodeWidget::SaveCodes()
|
||||||
{
|
{
|
||||||
if (m_game_id.empty())
|
if (m_game_id.empty())
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
void CreateWidgets();
|
void CreateWidgets();
|
||||||
void ConnectWidgets();
|
void ConnectWidgets();
|
||||||
void UpdateList();
|
void UpdateList();
|
||||||
|
void LoadCodes();
|
||||||
void SaveCodes();
|
void SaveCodes();
|
||||||
void SortAlphabetically();
|
void SortAlphabetically();
|
||||||
void SortEnabledCodesFirst();
|
void SortEnabledCodesFirst();
|
||||||
|
|
|
@ -42,20 +42,7 @@ GeckoCodeWidget::GeckoCodeWidget(std::string game_id, std::string gametdb_id, u1
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
|
|
||||||
if (!m_game_id.empty())
|
LoadCodes();
|
||||||
{
|
|
||||||
Common::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");
|
|
||||||
|
|
||||||
const Common::IniFile game_ini_default =
|
|
||||||
SConfig::LoadDefaultGameIni(m_game_id, m_game_revision);
|
|
||||||
m_gecko_codes = Gecko::LoadCodes(game_ini_default, game_ini_local);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoCodeWidget::~GeckoCodeWidget() = default;
|
GeckoCodeWidget::~GeckoCodeWidget() = default;
|
||||||
|
@ -93,17 +80,6 @@ void GeckoCodeWidget::CreateWidgets()
|
||||||
|
|
||||||
m_download_codes->setToolTip(tr("Download Codes from the WiiRD Database"));
|
m_download_codes->setToolTip(tr("Download Codes from the WiiRD Database"));
|
||||||
|
|
||||||
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;
|
auto* layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->addWidget(m_warning);
|
layout->addWidget(m_warning);
|
||||||
|
@ -253,6 +229,35 @@ void GeckoCodeWidget::RemoveCode()
|
||||||
SaveCodes();
|
SaveCodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeckoCodeWidget::LoadCodes()
|
||||||
|
{
|
||||||
|
if (!m_game_id.empty())
|
||||||
|
{
|
||||||
|
Common::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");
|
||||||
|
|
||||||
|
const Common::IniFile game_ini_default =
|
||||||
|
SConfig::LoadDefaultGameIni(m_game_id, m_game_revision);
|
||||||
|
m_gecko_codes = Gecko::LoadCodes(game_ini_default, game_ini_local);
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
UpdateList();
|
||||||
|
}
|
||||||
|
|
||||||
void GeckoCodeWidget::SaveCodes()
|
void GeckoCodeWidget::SaveCodes()
|
||||||
{
|
{
|
||||||
if (m_game_id.empty())
|
if (m_game_id.empty())
|
||||||
|
|
|
@ -52,6 +52,7 @@ private:
|
||||||
void EditCode();
|
void EditCode();
|
||||||
void RemoveCode();
|
void RemoveCode();
|
||||||
void DownloadCodes();
|
void DownloadCodes();
|
||||||
|
void LoadCodes();
|
||||||
void SaveCodes();
|
void SaveCodes();
|
||||||
void SortAlphabetically();
|
void SortAlphabetically();
|
||||||
void SortEnabledCodesFirst();
|
void SortEnabledCodesFirst();
|
||||||
|
|
Loading…
Reference in New Issue