@@ -32,16 +32,10 @@ void CheatCodeEditor::SetARCode(ActionReplay::ARCode* code)
{
m_name_edit->setText (QString::fromStdString (code->name ));
QString s ;
m_code_edit-> clear () ;
for (ActionReplay::AREntry& e : code->ops )
{
s += QStringLiteral (" %1 %2\n " )
.arg (e.cmd_addr , 8 , 16 , QLatin1Char (' 0' ))
.arg (e.value , 8 , 16 , QLatin1Char (' 0' ));
}
m_code_edit->setText (s);
m_code_edit->append (QString::fromStdString (ActionReplay::SerializeLine (e)));
m_creator_label->setHidden (true );
m_creator_edit->setHidden (true );
@@ -57,14 +51,10 @@ void CheatCodeEditor::SetGeckoCode(Gecko::GeckoCode* code)
m_name_edit->setText (QString::fromStdString (code->name ));
m_creator_edit->setText (QString::fromStdString (code->creator ));
QString code_string ;
m_code_edit-> clear () ;
for (const auto & c : code->codes )
code_string += QStringLiteral (" %1 %2\n " )
.arg (c.address , 8 , 16 , QLatin1Char (' 0' ))
.arg (c.data , 8 , 16 , QLatin1Char (' 0' ));
m_code_edit->setText (code_string);
m_code_edit->append (QString::fromStdString (c.original_line ));
QString notes_string;
for (const auto & line : code->notes )
@@ -135,7 +125,6 @@ bool CheatCodeEditor::AcceptAR()
if (line.isEmpty ())
continue ;
if (i == 0 && line[0 ] == u' $' )
{
if (name.isEmpty ())
@@ -144,40 +133,17 @@ bool CheatCodeEditor::AcceptAR()
continue ;
}
QStringList values = line.split (QLatin1Char{' ' });
bool good = true ;
const auto parse_result = ActionReplay::DeserializeLine (line.toStdString ());
u32 addr = 0 ;
u32 value = 0 ;
if (values.size () == 2 )
if (std::holds_alternative<ActionReplay::AREntry>(parse_result))
{
addr = values[0 ].toUInt (&good, 16 );
if (good)
value = values[1 ].toUInt (&good, 16 );
if (good)
entries.push_back (ActionReplay::AREntry (addr, value));
entries.push_back (std::get<ActionReplay::AREntry>(parse_result));
}
else
else if (std::holds_alternative<ActionReplay::EncryptedLine>(parse_result))
{
QStringList blocks = line.split (QLatin1Char{' -' });
if (blocks.size () == 3 && blocks[0 ].size () == 4 && blocks[1 ].size () == 4 &&
blocks[2 ].size () == 5 )
{
encrypted_lines.emplace_back (blocks[0 ].toStdString () + blocks[1 ].toStdString () +
blocks[2 ].toStdString ());
}
else
{
good = false ;
}
encrypted_lines.emplace_back (std::get<ActionReplay::EncryptedLine>(parse_result));
}
if (!good)
else
{
auto result = ModalMessageBox::warning (
this , tr (" Parsing Error" ),
@@ -260,20 +226,11 @@ bool CheatCodeEditor::AcceptGecko()
continue ;
}
QStringList values = line.split (QLatin1Char{' ' });
bool good = values.size () == 2 ;
u32 addr = 0 ;
u32 value = 0 ;
if (good)
addr = values[0 ].toUInt (&good, 16 );
if (good)
value = values[1 ].toUInt (&good, 16 );
if (!good)
if (std::optional<Gecko::GeckoCode::Code> c = Gecko::DeserializeLine (line.toStdString ()))
{
entries.push_back (*c);
}
else
{
auto result = ModalMessageBox::warning (
this , tr (" Parsing Error" ),
@@ -286,15 +243,6 @@ bool CheatCodeEditor::AcceptGecko()
if (result == QMessageBox::Abort)
return false ;
}
else
{
Gecko::GeckoCode::Code c;
c.address = addr;
c.data = value;
c.original_line = line.toStdString ();
entries.push_back (c);
}
}
if (entries.empty ())