Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions hex_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void hex_editor::set_focus()
emit update_status_text(get_status_text());
hex->setFocus();
buffer->set_active();
emit update_save_state(0);
update_save_state(0);
update_window();
}

Expand Down Expand Up @@ -135,7 +135,7 @@ void hex_editor::goto_diff(bool direction)
if(offset != -1){
goto_offset(buffer->pc_to_snes(offset));
}else{
update_status_text("No differences found!");
emit update_status_text("No differences found!");
}
}

Expand Down Expand Up @@ -410,7 +410,7 @@ void hex_editor::count(QString find, bool mode)
if(result < 0){
search_error(result, find);
}else{
update_status_text(QString::number(result) + " Results found for " + find);
emit update_status_text(QString::number(result) + " Results found for " + find);
}

}
Expand Down Expand Up @@ -458,7 +458,7 @@ void hex_editor::replace_all(QString find, QString replace, bool mode)
if(result < 0){
search_error(result, find, replace);
}else{
update_status_text(QString::number(result) + " Results found for " + find);
emit update_status_text(QString::number(result) + " Results found for " + find);
}
update_save_state(1);
}
Expand Down Expand Up @@ -680,11 +680,11 @@ void hex_editor::set_offset(int o)
void hex_editor::search_error(int error, QString find, QString replace_with)
{
if(error == ROM_buffer::INVALID_REPLACE){
update_status_text("Error: Invalid replace hex string: " + replace_with);
emit update_status_text("Error: Invalid replace hex string: " + replace_with);
}else if(error == ROM_buffer::INVALID_FIND){
update_status_text("Error: Invalid find hex string: " + find);
emit update_status_text("Error: Invalid find hex string: " + find);
}else if(error == ROM_buffer::NOT_FOUND){
update_status_text("Error: String " + find + " not found.");
emit update_status_text("Error: String " + find + " not found.");
}
}

Expand Down
10 changes: 4 additions & 6 deletions rom_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,31 @@ void ROM_buffer::remove_copy_header()

void ROM_buffer::open(QString path)
{
if(ROM.isOpen()){
ROM.close();
}
ROM.setFileName(path);
ROM.open(QFile::ReadWrite);
ROM.open(QFile::ReadOnly);
buffer = ROM.readAll();
if(ROM.size() < 0x8000){
ROM_error = "The ROM is too small to be valid.";
return;
}
ROM.close();
analyze();
}

void ROM_buffer::save(QString path)
{
QFileInfo info(ROM);
if(path != "" && path != info.absolutePath()){
ROM.close();
ROM.setFileName(path);
ROM.open(QFile::ReadWrite);
}
ROM.open(QFile::WriteOnly);
if(header_size()){
ROM.seek(0);
ROM.write(header_buffer);
}
ROM.seek(header_size());
ROM.write(buffer);
ROM.close();
}

void ROM_buffer::initialize_undo(QUndoGroup *undo_group)
Expand Down