DolphinQt: Allow Cheat Search to create multiple AR codes when selecting multiple lines.
This commit is contained in:
parent
369502b49b
commit
c202b55bd4
|
@ -498,7 +498,7 @@ void CheatSearchWidget::OnAddressTableContextMenu()
|
||||||
const QString name = QStringLiteral("mem_%1").arg(address, 8, 16, QLatin1Char('0'));
|
const QString name = QStringLiteral("mem_%1").arg(address, 8, 16, QLatin1Char('0'));
|
||||||
emit RequestWatch(name, address);
|
emit RequestWatch(name, address);
|
||||||
});
|
});
|
||||||
menu->addAction(tr("Generate Action Replay Code"), this, &CheatSearchWidget::GenerateARCode);
|
menu->addAction(tr("Generate Action Replay Code(s)"), this, &CheatSearchWidget::GenerateARCodes);
|
||||||
|
|
||||||
menu->exec(QCursor::pos());
|
menu->exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
@ -521,25 +521,46 @@ void CheatSearchWidget::OnDisplayHexCheckboxStateChanged()
|
||||||
UpdateTableAllCurrentValues(UpdateSource::User);
|
UpdateTableAllCurrentValues(UpdateSource::User);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatSearchWidget::GenerateARCode()
|
void CheatSearchWidget::GenerateARCodes()
|
||||||
{
|
{
|
||||||
if (m_address_table->selectedItems().isEmpty())
|
if (m_address_table->selectedItems().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto* item = m_address_table->selectedItems()[0];
|
bool had_success = false;
|
||||||
if (!item)
|
bool had_error = false;
|
||||||
return;
|
std::optional<Cheats::GenerateActionReplayCodeErrorCode> error_code;
|
||||||
|
|
||||||
|
for (auto* const item : m_address_table->selectedItems())
|
||||||
|
{
|
||||||
const u32 index = item->data(ADDRESS_TABLE_RESULT_INDEX_ROLE).toUInt();
|
const u32 index = item->data(ADDRESS_TABLE_RESULT_INDEX_ROLE).toUInt();
|
||||||
auto result = Cheats::GenerateActionReplayCode(*m_session, index);
|
auto result = Cheats::GenerateActionReplayCode(*m_session, index);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
emit ActionReplayCodeGenerated(*result);
|
emit ActionReplayCodeGenerated(*result);
|
||||||
m_info_label_1->setText(tr("Generated AR code."));
|
had_success = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (result.Error())
|
const auto new_error_code = result.Error();
|
||||||
|
if (!had_error)
|
||||||
|
{
|
||||||
|
error_code = new_error_code;
|
||||||
|
}
|
||||||
|
else if (error_code != new_error_code)
|
||||||
|
{
|
||||||
|
// If we have a different error code signify multiple errors with an empty optional<>.
|
||||||
|
error_code.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
had_error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (had_error)
|
||||||
|
{
|
||||||
|
if (error_code.has_value())
|
||||||
|
{
|
||||||
|
switch (*error_code)
|
||||||
{
|
{
|
||||||
case Cheats::GenerateActionReplayCodeErrorCode::NotVirtualMemory:
|
case Cheats::GenerateActionReplayCodeErrorCode::NotVirtualMemory:
|
||||||
m_info_label_1->setText(tr("Can only generate AR code for values in virtual memory."));
|
m_info_label_1->setText(tr("Can only generate AR code for values in virtual memory."));
|
||||||
|
@ -552,6 +573,15 @@ void CheatSearchWidget::GenerateARCode()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_info_label_1->setText(tr("Multiple errors while generating AR codes."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (had_success)
|
||||||
|
{
|
||||||
|
m_info_label_1->setText(tr("Generated AR code(s)."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatSearchWidget::RefreshCurrentValueTableItem(
|
void CheatSearchWidget::RefreshCurrentValueTableItem(
|
||||||
|
|
|
@ -76,7 +76,7 @@ private:
|
||||||
bool UpdateTableRows(const Core::CPUThreadGuard& guard, size_t begin_index, size_t end_index,
|
bool UpdateTableRows(const Core::CPUThreadGuard& guard, size_t begin_index, size_t end_index,
|
||||||
UpdateSource source);
|
UpdateSource source);
|
||||||
void RecreateGUITable();
|
void RecreateGUITable();
|
||||||
void GenerateARCode();
|
void GenerateARCodes();
|
||||||
int GetVisibleRowsBeginIndex() const;
|
int GetVisibleRowsBeginIndex() const;
|
||||||
int GetVisibleRowsEndIndex() const;
|
int GetVisibleRowsEndIndex() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue