mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 12:39:13 +12:00
Formatting
This commit is contained in:
parent
e3c9f0b219
commit
864604c1e7
1 changed files with 15 additions and 16 deletions
|
@ -54,9 +54,8 @@ class CheatEntryWidget : public QWidget {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CheatMetadata& GetMetadata() { return metadata; }
|
const CheatMetadata& getMetadata() { return metadata; }
|
||||||
|
void setMetadata(const CheatMetadata& metadata) { this->metadata = metadata; }
|
||||||
void SetMetadata(const CheatMetadata& metadata) { this->metadata = metadata; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkboxChanged(int state);
|
void checkboxChanged(int state);
|
||||||
|
@ -135,7 +134,7 @@ CheatEditDialog::CheatEditDialog(Emulator* emu, CheatEntryWidget& cheatEntry) :
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout;
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
const CheatMetadata& metadata = cheatEntry.GetMetadata();
|
const CheatMetadata& metadata = cheatEntry.getMetadata();
|
||||||
codeEdit = new QTextEdit;
|
codeEdit = new QTextEdit;
|
||||||
nameEdit = new QLineEdit;
|
nameEdit = new QLineEdit;
|
||||||
nameEdit->setText(metadata.name.c_str());
|
nameEdit->setText(metadata.name.c_str());
|
||||||
|
@ -172,11 +171,11 @@ CheatEditDialog::CheatEditDialog(Emulator* emu, CheatEntryWidget& cheatEntry) :
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
auto buttons = QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
|
auto buttons = QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
|
||||||
QDialogButtonBox* button_box = new QDialogButtonBox(buttons);
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(buttons);
|
||||||
layout->addWidget(button_box);
|
layout->addWidget(buttonBox);
|
||||||
|
|
||||||
connect(button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
connect(this, &QDialog::rejected, this, &CheatEditDialog::rejected);
|
connect(this, &QDialog::rejected, this, &CheatEditDialog::rejected);
|
||||||
connect(this, &QDialog::accepted, this, &CheatEditDialog::accepted);
|
connect(this, &QDialog::accepted, this, &CheatEditDialog::accepted);
|
||||||
}
|
}
|
||||||
|
@ -185,25 +184,25 @@ void CheatEditDialog::accepted() {
|
||||||
QString code = codeEdit->toPlainText();
|
QString code = codeEdit->toPlainText();
|
||||||
code.replace(QRegularExpression("[^0-9a-fA-F]"), "");
|
code.replace(QRegularExpression("[^0-9a-fA-F]"), "");
|
||||||
|
|
||||||
CheatMetadata metadata = cheatEntry.GetMetadata();
|
CheatMetadata metadata = cheatEntry.getMetadata();
|
||||||
metadata.name = nameEdit->text().toStdString();
|
metadata.name = nameEdit->text().toStdString();
|
||||||
metadata.code = code.toStdString();
|
metadata.code = code.toStdString();
|
||||||
|
|
||||||
std::vector<uint8_t> bytes;
|
std::vector<u8> bytes;
|
||||||
for (size_t i = 0; i < metadata.code.size(); i += 2) {
|
for (size_t i = 0; i < metadata.code.size(); i += 2) {
|
||||||
std::string hex = metadata.code.substr(i, 2);
|
std::string hex = metadata.code.substr(i, 2);
|
||||||
bytes.push_back((uint8_t)std::stoul(hex, nullptr, 16));
|
bytes.push_back((u8)std::stoul(hex, nullptr, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->editCheat(cheatEntry.GetMetadata().handle, bytes, [this](u32 handle) {
|
mainWindow->editCheat(cheatEntry.getMetadata().handle, bytes, [this](u32 handle) {
|
||||||
dispatchToMainThread([this, handle]() {
|
dispatchToMainThread([this, handle]() {
|
||||||
if (handle == badCheatHandle) {
|
if (handle == badCheatHandle) {
|
||||||
cheatEntry.Remove();
|
cheatEntry.Remove();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
CheatMetadata metadata = cheatEntry.GetMetadata();
|
CheatMetadata metadata = cheatEntry.getMetadata();
|
||||||
metadata.handle = handle;
|
metadata.handle = handle;
|
||||||
cheatEntry.SetMetadata(metadata);
|
cheatEntry.setMetadata(metadata);
|
||||||
cheatEntry.Update();
|
cheatEntry.Update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,9 +210,9 @@ void CheatEditDialog::accepted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatEditDialog::rejected() {
|
void CheatEditDialog::rejected() {
|
||||||
bool isEditing = cheatEntry.GetMetadata().handle != badCheatHandle;
|
bool isEditing = cheatEntry.getMetadata().handle != badCheatHandle;
|
||||||
if (!isEditing) {
|
if (!isEditing) {
|
||||||
// Was adding a cheat but pressed cancel
|
// Was adding a cheat but user pressed cancel
|
||||||
cheatEntry.Remove();
|
cheatEntry.Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue