Merge pull request #10018 from JosJuice/code-allow-name-line

DolphinQt: Allow $ line when entering AR/Gecko code
This commit is contained in:
Mai M 2021-08-13 13:22:25 -04:00 committed by GitHub
commit 82969db7de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 2 deletions

View File

@ -122,6 +122,8 @@ void CheatCodeEditor::ConnectWidgets()
bool CheatCodeEditor::AcceptAR()
{
QString name = m_name_edit->text();
std::vector<ActionReplay::AREntry> entries;
std::vector<std::string> encrypted_lines;
@ -134,6 +136,14 @@ bool CheatCodeEditor::AcceptAR()
if (line.isEmpty())
continue;
if (i == 0 && line[0] == u'$')
{
if (name.isEmpty())
name = line.right(line.size() - 1);
continue;
}
QStringList values = line.split(QLatin1Char{' '});
bool good = true;
@ -220,7 +230,7 @@ bool CheatCodeEditor::AcceptAR()
return false;
}
m_ar_code->name = m_name_edit->text().toStdString();
m_ar_code->name = name.toStdString();
m_ar_code->ops = std::move(entries);
m_ar_code->user_defined = true;
@ -229,6 +239,8 @@ bool CheatCodeEditor::AcceptAR()
bool CheatCodeEditor::AcceptGecko()
{
QString name = m_name_edit->text();
std::vector<Gecko::GeckoCode::Code> entries;
QStringList lines = m_code_edit->toPlainText().split(QLatin1Char{'\n'});
@ -240,6 +252,14 @@ bool CheatCodeEditor::AcceptGecko()
if (line.isEmpty())
continue;
if (i == 0 && line[0] == u'$')
{
if (name.isEmpty())
name = line.right(line.size() - 1);
continue;
}
QStringList values = line.split(QLatin1Char{' '});
bool good = values.size() == 2;
@ -283,7 +303,7 @@ bool CheatCodeEditor::AcceptGecko()
return false;
}
m_gecko_code->name = m_name_edit->text().toStdString();
m_gecko_code->name = name.toStdString();
m_gecko_code->creator = m_creator_edit->text().toStdString();
m_gecko_code->codes = std::move(entries);
m_gecko_code->notes = SplitString(m_notes_edit->toPlainText().toStdString(), '\n');