Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10018 from JosJuice/code-allow-name-line
DolphinQt: Allow $ line when entering AR/Gecko code
  • Loading branch information
lioncash committed Aug 13, 2021
2 parents e2ccad7 + cda442d commit 82969db
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Source/Core/DolphinQt/Config/CheatCodeEditor.cpp
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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'});
Expand All @@ -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;
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 82969db

Please sign in to comment.