remove some shitty strings
This commit is contained in:
parent
9b498f95c6
commit
2128333a94
|
@ -26,10 +26,9 @@
|
|||
// TODO: more user-friendly error reporting
|
||||
|
||||
|
||||
ARCodeFile::ARCodeFile(const char* filename)
|
||||
ARCodeFile::ARCodeFile(std::string filename)
|
||||
{
|
||||
memset(Filename, 0, sizeof(Filename));
|
||||
strncpy(Filename, filename, 1023);
|
||||
Filename = filename;
|
||||
|
||||
Error = false;
|
||||
|
||||
|
@ -91,7 +90,7 @@ bool ARCodeFile::Load()
|
|||
if (isincat) Categories.push_back(curcat);
|
||||
isincat = true;
|
||||
|
||||
memcpy(curcat.Name, catname, 128);
|
||||
curcat.Name = catname;
|
||||
curcat.Codes.clear();
|
||||
}
|
||||
else if (!strncasecmp(start, "CODE", 4))
|
||||
|
@ -118,7 +117,7 @@ bool ARCodeFile::Load()
|
|||
if (isincode) curcat.Codes.push_back(curcode);
|
||||
isincode = true;
|
||||
|
||||
memcpy(curcode.Name, codename, 128);
|
||||
curcode.Name = codename;
|
||||
curcode.Enabled = enable!=0;
|
||||
curcode.CodeLen = 0;
|
||||
}
|
||||
|
@ -172,12 +171,12 @@ bool ARCodeFile::Save()
|
|||
ARCodeCat& cat = *it;
|
||||
|
||||
if (it != Categories.begin()) fprintf(f, "\r\n");
|
||||
fprintf(f, "CAT %s\r\n\r\n", cat.Name);
|
||||
fprintf(f, "CAT %s\r\n\r\n", cat.Name.c_str());
|
||||
|
||||
for (ARCodeList::iterator jt = cat.Codes.begin(); jt != cat.Codes.end(); jt++)
|
||||
{
|
||||
ARCode& code = *jt;
|
||||
fprintf(f, "CODE %d %s\r\n", code.Enabled, code.Name);
|
||||
fprintf(f, "CODE %d %s\r\n", code.Enabled, code.Name.c_str());
|
||||
|
||||
for (u32 i = 0; i < code.CodeLen; i+=2)
|
||||
{
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
#ifndef ARCODEFILE_H
|
||||
#define ARCODEFILE_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct ARCode
|
||||
{
|
||||
char Name[128];
|
||||
std::string Name;
|
||||
bool Enabled;
|
||||
u32 CodeLen;
|
||||
u32 Code[2*64];
|
||||
|
@ -35,7 +36,7 @@ typedef std::list<ARCode> ARCodeList;
|
|||
|
||||
struct ARCodeCat
|
||||
{
|
||||
char Name[128];
|
||||
std::string Name;
|
||||
ARCodeList Codes;
|
||||
};
|
||||
|
||||
|
@ -45,7 +46,7 @@ typedef std::list<ARCodeCat> ARCodeCatList;
|
|||
class ARCodeFile
|
||||
{
|
||||
public:
|
||||
ARCodeFile(const char* filename);
|
||||
ARCodeFile(std::string filename);
|
||||
~ARCodeFile();
|
||||
|
||||
bool Error;
|
||||
|
@ -56,7 +57,7 @@ public:
|
|||
ARCodeCatList Categories;
|
||||
|
||||
private:
|
||||
char Filename[1024];
|
||||
std::string Filename;
|
||||
};
|
||||
|
||||
#endif // ARCODEFILE_H
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
class ROMSource
|
||||
{
|
||||
public:
|
||||
virtual ~ROMSource();
|
||||
virtual ~ROMSource() = 0;
|
||||
|
||||
//
|
||||
//virtual
|
||||
};
|
||||
|
||||
#endif // ROMSOURCE_H
|
||||
|
|
|
@ -55,7 +55,7 @@ CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Cheats
|
|||
{
|
||||
ARCodeCat& cat = *i;
|
||||
|
||||
QStandardItem* catitem = new QStandardItem(cat.Name);
|
||||
QStandardItem* catitem = new QStandardItem(QString::fromStdString(cat.Name));
|
||||
catitem->setEditable(true);
|
||||
catitem->setData(QVariant::fromValue(i));
|
||||
root->appendRow(catitem);
|
||||
|
@ -64,7 +64,7 @@ CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Cheats
|
|||
{
|
||||
ARCode& code = *j;
|
||||
|
||||
QStandardItem* codeitem = new QStandardItem(code.Name);
|
||||
QStandardItem* codeitem = new QStandardItem(QString::fromStdString(code.Name));
|
||||
codeitem->setEditable(true);
|
||||
codeitem->setCheckable(true);
|
||||
codeitem->setCheckState(code.Enabled ? Qt::Checked : Qt::Unchecked);
|
||||
|
@ -113,13 +113,12 @@ void CheatsDialog::on_btnNewCat_clicked()
|
|||
|
||||
ARCodeCat cat;
|
||||
cat.Codes.clear();
|
||||
memset(cat.Name, 0, 128);
|
||||
strncpy(cat.Name, "(new category)", 127);
|
||||
cat.Name = "(new category)";
|
||||
|
||||
codeFile->Categories.push_back(cat);
|
||||
ARCodeCatList::iterator id = codeFile->Categories.end(); id--;
|
||||
|
||||
QStandardItem* catitem = new QStandardItem(cat.Name);
|
||||
QStandardItem* catitem = new QStandardItem(QString::fromStdString(cat.Name));
|
||||
catitem->setEditable(true);
|
||||
catitem->setData(QVariant::fromValue(id));
|
||||
root->appendRow(catitem);
|
||||
|
@ -160,8 +159,7 @@ void CheatsDialog::on_btnNewARCode_clicked()
|
|||
ARCodeCat& cat = *it_cat;
|
||||
|
||||
ARCode code;
|
||||
memset(code.Name, 0, 128);
|
||||
strncpy(code.Name, "(new AR code)", 127);
|
||||
code.Name = "(new AR code)";
|
||||
code.Enabled = true;
|
||||
code.CodeLen = 0;
|
||||
memset(code.Code, 0, sizeof(code.Code));
|
||||
|
@ -169,7 +167,7 @@ void CheatsDialog::on_btnNewARCode_clicked()
|
|||
cat.Codes.push_back(code);
|
||||
ARCodeList::iterator id = cat.Codes.end(); id--;
|
||||
|
||||
QStandardItem* codeitem = new QStandardItem(code.Name);
|
||||
QStandardItem* codeitem = new QStandardItem(QString::fromStdString(code.Name));
|
||||
codeitem->setEditable(true);
|
||||
codeitem->setCheckable(true);
|
||||
codeitem->setCheckState(code.Enabled ? Qt::Checked : Qt::Unchecked);
|
||||
|
@ -275,13 +273,12 @@ void CheatsDialog::onCheatEntryModified(QStandardItem* item)
|
|||
|
||||
if (item->text().isEmpty())
|
||||
{
|
||||
QString oldname = QString(cat.Name);
|
||||
QString oldname = QString::fromStdString(cat.Name);
|
||||
item->setText(oldname.isEmpty() ? "(blank category name?)" : oldname);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(cat.Name, item->text().toStdString().c_str(), 127);
|
||||
cat.Name[127] = '\0';
|
||||
cat.Name = item->text().toStdString();
|
||||
}
|
||||
}
|
||||
else if (data.canConvert<ARCodeList::iterator>())
|
||||
|
@ -290,13 +287,12 @@ void CheatsDialog::onCheatEntryModified(QStandardItem* item)
|
|||
|
||||
if (item->text().isEmpty())
|
||||
{
|
||||
QString oldname = QString(code.Name);
|
||||
QString oldname = QString::fromStdString(code.Name);
|
||||
item->setText(oldname.isEmpty() ? "(blank code name?)" : oldname);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(code.Name, item->text().toStdString().c_str(), 127);
|
||||
code.Name[127] = '\0';
|
||||
code.Name = item->text().toStdString();
|
||||
}
|
||||
|
||||
code.Enabled = (item->checkState() == Qt::Checked);
|
||||
|
|
Loading…
Reference in New Issue