Added menu logic to load Game Genie ROM file
This commit is contained in:
parent
c41cd863c6
commit
b4280ee33d
|
@ -1,5 +1,8 @@
|
||||||
// GameApp.cpp
|
// GameApp.cpp
|
||||||
//
|
//
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
|
@ -331,7 +334,7 @@ void consoleWin_t::createMainMenu(void)
|
||||||
|
|
||||||
emuMenu->addSeparator();
|
emuMenu->addSeparator();
|
||||||
|
|
||||||
// Options -> Full Screen
|
// Emulation -> Enable Game Genie
|
||||||
gameGenieAct = new QAction(tr("Enable Game Genie"), this);
|
gameGenieAct = new QAction(tr("Enable Game Genie"), this);
|
||||||
//gameGenieAct->setShortcut( QKeySequence(tr("Ctrl+G")));
|
//gameGenieAct->setShortcut( QKeySequence(tr("Ctrl+G")));
|
||||||
gameGenieAct->setCheckable(true);
|
gameGenieAct->setCheckable(true);
|
||||||
|
@ -342,6 +345,16 @@ void consoleWin_t::createMainMenu(void)
|
||||||
|
|
||||||
emuMenu->addAction(gameGenieAct);
|
emuMenu->addAction(gameGenieAct);
|
||||||
|
|
||||||
|
// Emulation -> Load Game Genie ROM
|
||||||
|
loadGgROMAct = new QAction(tr("Load Game Genie ROM"), this);
|
||||||
|
//loadGgROMAct->setShortcut( QKeySequence(tr("Ctrl+G")));
|
||||||
|
loadGgROMAct->setStatusTip(tr("Load Game Genie ROM"));
|
||||||
|
connect(loadGgROMAct, SIGNAL(triggered()), this, SLOT(loadGameGenieROM(void)) );
|
||||||
|
|
||||||
|
emuMenu->addAction(loadGgROMAct);
|
||||||
|
|
||||||
|
emuMenu->addSeparator();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Help
|
// Help
|
||||||
helpMenu = menuBar()->addMenu(tr("Help"));
|
helpMenu = menuBar()->addMenu(tr("Help"));
|
||||||
|
@ -855,6 +868,59 @@ void consoleWin_t::toggleGameGenie(bool checked)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::loadGameGenieROM(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
QString filename;
|
||||||
|
std::string last;
|
||||||
|
QFileDialog dialog(this, tr("Open Game Genie ROM") );
|
||||||
|
|
||||||
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
|
||||||
|
dialog.setNameFilter(tr("GG ROM File (gg.rom)(*Genie*.nes) ;; All files (*)"));
|
||||||
|
|
||||||
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
|
||||||
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
dialog.setDirectory( tr(last.c_str()) );
|
||||||
|
|
||||||
|
// the gnome default file dialog is not playing nice with QT.
|
||||||
|
// TODO make this a config option to use native file dialog.
|
||||||
|
dialog.setOption(QFileDialog::DontUseNativeDialog, true);
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
g_config->setOption ("SDL.LastOpenFile", filename.toStdString().c_str() );
|
||||||
|
|
||||||
|
// copy file to proper place (~/.fceux/gg.rom)
|
||||||
|
std::ifstream f1 ( filename.toStdString().c_str(), std::fstream::binary);
|
||||||
|
std::string fn_out = FCEU_MakeFName (FCEUMKF_GGROM, 0, "");
|
||||||
|
std::ofstream f2 (fn_out.c_str (),
|
||||||
|
std::fstream::trunc | std::fstream::binary);
|
||||||
|
f2 << f1.rdbuf ();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::aboutFCEUX(void)
|
void consoleWin_t::aboutFCEUX(void)
|
||||||
{
|
{
|
||||||
printf("About FCEUX\n");
|
printf("About FCEUX\n");
|
||||||
|
|
|
@ -75,6 +75,7 @@ class consoleWin_t : public QMainWindow
|
||||||
QAction *sresetAct;
|
QAction *sresetAct;
|
||||||
QAction *pauseAct;
|
QAction *pauseAct;
|
||||||
QAction *gameGenieAct;
|
QAction *gameGenieAct;
|
||||||
|
QAction *loadGgROMAct;
|
||||||
|
|
||||||
QTimer *gameTimer;
|
QTimer *gameTimer;
|
||||||
emulatorThread_t *emulatorThread;
|
emulatorThread_t *emulatorThread;
|
||||||
|
@ -124,6 +125,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void consoleSoftReset(void);
|
void consoleSoftReset(void);
|
||||||
void consolePause(void);
|
void consolePause(void);
|
||||||
void toggleGameGenie(bool checked);
|
void toggleGameGenie(bool checked);
|
||||||
|
void loadGameGenieROM(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue