more shady stuff

This commit is contained in:
Nayla Hanegan 2024-08-23 15:42:58 -04:00
commit 2bb83b1adb
16 changed files with 93 additions and 86 deletions

View file

@ -89,9 +89,6 @@ void GeckoCodeWidget::CreateWidgets()
m_add_code = new NonDefaultQPushButton(tr("&Add New Code..."));
m_edit_code = new NonDefaultQPushButton(tr("&Edit Code..."));
m_remove_code = new NonDefaultQPushButton(tr("&Remove Code"));
m_download_codes = new NonDefaultQPushButton(tr("Download Codes"));
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());
@ -102,7 +99,6 @@ void GeckoCodeWidget::CreateWidgets()
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;
@ -135,7 +131,6 @@ void GeckoCodeWidget::CreateWidgets()
btn_layout->addWidget(m_add_code);
btn_layout->addWidget(m_edit_code);
btn_layout->addWidget(m_remove_code);
btn_layout->addWidget(m_download_codes);
layout->addLayout(btn_layout);
@ -155,7 +150,6 @@ void GeckoCodeWidget::ConnectWidgets()
connect(m_add_code, &QPushButton::clicked, this, &GeckoCodeWidget::AddCode);
connect(m_remove_code, &QPushButton::clicked, this, &GeckoCodeWidget::RemoveCode);
connect(m_edit_code, &QPushButton::clicked, this, &GeckoCodeWidget::EditCode);
connect(m_download_codes, &QPushButton::clicked, this, &GeckoCodeWidget::DownloadCodes);
connect(m_warning, &CheatWarningWidget::OpenCheatEnableSettings, this,
&GeckoCodeWidget::OpenGeneralSettings);
#ifdef USE_RETRO_ACHIEVEMENTS
@ -346,43 +340,3 @@ void GeckoCodeWidget::UpdateList()
m_code_list->setDragDropMode(QAbstractItemView::InternalMove);
}
void GeckoCodeWidget::DownloadCodes()
{
bool success;
std::vector<Gecko::GeckoCode> codes = Gecko::DownloadCodes(m_gametdb_id, &success);
if (!success)
{
ModalMessageBox::critical(this, tr("Error"), tr("Failed to download codes."));
return;
}
if (codes.empty())
{
ModalMessageBox::critical(this, tr("Error"), tr("File contained no codes."));
return;
}
size_t added_count = 0;
for (const auto& code : codes)
{
auto it = std::find(m_gecko_codes.begin(), m_gecko_codes.end(), code);
if (it == m_gecko_codes.end())
{
m_gecko_codes.push_back(code);
added_count++;
}
}
UpdateList();
SaveCodes();
ModalMessageBox::information(
this, tr("Download complete"),
tr("Downloaded %1 codes. (added %2)")
.arg(QString::number(codes.size()), QString::number(added_count)));
}

View file

@ -63,8 +63,8 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
connect(graphics_mod_list, &GraphicsModListWidget::OpenGraphicsSettings, this,
&PropertiesDialog::OpenGraphicsSettings);
const int padding_width = 120;
const int padding_height = 100;
const int padding_width = 600;
const int padding_height = 1100;
tab_widget->addTab(GetWrappedWidget(game_config, this, padding_width, padding_height),
tr("Game Config"));
tab_widget->addTab(GetWrappedWidget(patches, this, padding_width, padding_height), tr("Patches"));
@ -106,3 +106,50 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
setLayout(layout);
tab_widget->setCurrentIndex(3);
}
GeckoDialog::GeckoDialog(QWidget* parent) : QDialog(parent)
{
setWindowTitle(QStringLiteral("%1").arg(QString::fromStdString("Modifications")));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout* layout = new QVBoxLayout();
QTabWidget* tab_widget = new QTabWidget(this);
GeckoCodeWidget* mp4_gecko = new GeckoCodeWidget("GMPE01", "GMPE01", 0);
GeckoCodeWidget* mp5_gecko = new GeckoCodeWidget("GP5E01", "GP5E01", 0);
GeckoCodeWidget* mp6_gecko = new GeckoCodeWidget("GP6E01", "GP6E01", 0);
GeckoCodeWidget* mp7_gecko = new GeckoCodeWidget("GP7E01", "GP7E01", 0);
GeckoCodeWidget* mp8_gecko = new GeckoCodeWidget("RM8E01", "RM8E01", 0);
connect(mp4_gecko, &GeckoCodeWidget::OpenGeneralSettings, this,
&GeckoDialog::OpenGeneralSettings);
connect(mp5_gecko, &GeckoCodeWidget::OpenGeneralSettings, this,
&GeckoDialog::OpenGeneralSettings);
connect(mp6_gecko, &GeckoCodeWidget::OpenGeneralSettings, this,
&GeckoDialog::OpenGeneralSettings);
connect(mp7_gecko, &GeckoCodeWidget::OpenGeneralSettings, this,
&GeckoDialog::OpenGeneralSettings);
connect(mp8_gecko, &GeckoCodeWidget::OpenGeneralSettings, this,
&GeckoDialog::OpenGeneralSettings);
const int padding_width = 600;
const int padding_height = 1100;
tab_widget->addTab(GetWrappedWidget(mp4_gecko, this, padding_width, padding_height),
tr("Mario Party 4"));
tab_widget->addTab(GetWrappedWidget(mp5_gecko, this, padding_width, padding_height),
tr("Mario Party 5"));
tab_widget->addTab(GetWrappedWidget(mp6_gecko, this, padding_width, padding_height),
tr("Mario Party 6"));
tab_widget->addTab(GetWrappedWidget(mp7_gecko, this, padding_width, padding_height),
tr("Mario Party 7"));
tab_widget->addTab(GetWrappedWidget(mp8_gecko, this, padding_width, padding_height),
tr("Mario Party 8"));
layout->addWidget(tab_widget);
QDialogButtonBox* close_box = new QDialogButtonBox(QDialogButtonBox::Close);
connect(close_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
layout->addWidget(close_box);
setLayout(layout);
}

View file

@ -23,3 +23,13 @@ signals:
void OpenAchievementSettings();
#endif // USE_RETRO_ACHIEVEMENTS
};
class GeckoDialog final : public QDialog
{
Q_OBJECT
public:
explicit GeckoDialog(QWidget* parent);
signals:
void OpenGeneralSettings();
};