Added save ROM as hex editor functionality
This commit is contained in:
parent
08feb4710b
commit
14f0da12c7
|
@ -10,6 +10,7 @@
|
|||
#include <QScrollBar>
|
||||
#include <QPainter>
|
||||
#include <QMenuBar>
|
||||
#include <QFileDialog>
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "../../types.h"
|
||||
|
@ -308,6 +309,14 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
|
|||
saveROM->setStatusTip(tr("Save ROM File"));
|
||||
connect(saveROM, SIGNAL(triggered()), this, SLOT(saveRomFile(void)) );
|
||||
|
||||
fileMenu->addAction(saveROM);
|
||||
|
||||
// File -> Save ROM As
|
||||
saveROM = new QAction(tr("Save ROM As"), this);
|
||||
//saveROM->setShortcuts(QKeySequence::Open);
|
||||
saveROM->setStatusTip(tr("Save ROM File As"));
|
||||
connect(saveROM, SIGNAL(triggered()), this, SLOT(saveRomFileAs(void)) );
|
||||
|
||||
fileMenu->addAction(saveROM);
|
||||
|
||||
// View
|
||||
|
@ -524,7 +533,52 @@ void HexEditorDialog_t::gotoAddress( int newAddr )
|
|||
//----------------------------------------------------------------------------
|
||||
void HexEditorDialog_t::saveRomFile(void)
|
||||
{
|
||||
printf("ROM File: '%s'\n", getRomFile() );
|
||||
//FlushUndoBuffer();
|
||||
iNesSave();
|
||||
//UpdateColorTable();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void HexEditorDialog_t::saveRomFileAs(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
QFileDialog dialog(this, tr("Save ROM To File") );
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter(tr("NES Files (*.nes *.NES) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||
dialog.setDefaultSuffix( tr(".nes") );
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
iNesSaveAs( filename.toStdString().c_str() );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void HexEditorDialog_t::setViewRAM(void)
|
||||
|
|
|
@ -158,6 +158,7 @@ class HexEditorDialog_t : public QDialog
|
|||
void vbarChanged(int value);
|
||||
void hbarChanged(int value);
|
||||
void saveRomFile(void);
|
||||
void saveRomFileAs(void);
|
||||
void setViewRAM(void);
|
||||
void setViewPPU(void);
|
||||
void setViewOAM(void);
|
||||
|
|
|
@ -956,7 +956,7 @@ init_ok:
|
|||
}
|
||||
|
||||
// bbit edited: the whole function below was added
|
||||
int iNesSave() {
|
||||
int iNesSave(void) {
|
||||
char name[2048];
|
||||
|
||||
strcpy(name, LoadedRomFName);
|
||||
|
@ -967,7 +967,7 @@ int iNesSave() {
|
|||
return iNesSaveAs(name);
|
||||
}
|
||||
|
||||
int iNesSaveAs(char* name)
|
||||
int iNesSaveAs(const char* name)
|
||||
{
|
||||
//adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function
|
||||
//caitsith2: done. iNesSave() now gets filename and calls iNesSaveAs with that filename.
|
||||
|
|
|
@ -43,8 +43,8 @@ extern uint8 *VROM;
|
|||
extern uint32 VROM_size;
|
||||
extern uint32 ROM_size;
|
||||
extern uint8 *ExtraNTARAM;
|
||||
extern int iNesSave(); //bbit Edited: line added
|
||||
extern int iNesSaveAs(char* name);
|
||||
extern int iNesSave(void); //bbit Edited: line added
|
||||
extern int iNesSaveAs(const char* name);
|
||||
extern char LoadedRomFName[2048]; //bbit Edited: line added
|
||||
extern const TMasterRomInfo* MasterRomInfo;
|
||||
extern TMasterRomInfoParams MasterRomInfoParams;
|
||||
|
|
Loading…
Reference in New Issue