Save state of cheat window checkbox options for Qt GUI.

This commit is contained in:
mjbudd77 2021-08-14 07:46:05 -04:00
parent 8b59b85be8
commit 03a40f22ac
3 changed files with 41 additions and 5 deletions

View File

@ -29,6 +29,7 @@
#include <QFileDialog>
#include <QScreen>
#include <QGuiApplication>
#include <QMessageBox>
#include <QSettings>
#include "../../types.h"
@ -96,6 +97,8 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
pauseWhileActive = false;
wasPausedByCheats = false;
g_config->getOption("SDL.CheatsWindowPause", &pauseWhileActive);
//resize( 512, 512 );
// Window Layout Box
@ -418,6 +421,7 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
hbox = new QHBoxLayout();
pauseBox = new QCheckBox(tr("Pause emulation when this window is active"));
pauseBox->setChecked(pauseWhileActive);
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
@ -1029,8 +1033,13 @@ void GuiCheatsDialog_t::actvCheatItemClicked(QTreeWidgetItem *item, int column)
//----------------------------------------------------------------------------
void GuiCheatsDialog_t::globalEnableCheats(int state)
{
int val = state != Qt::Unchecked;
g_config->setOption("SDL.CheatsDisabled", !val);
g_config->save();
fceuWrapperLock();
FCEUI_GlobalToggleCheat(state != Qt::Unchecked);
FCEUI_GlobalToggleCheat(val);
fceuWrapperUnLock();
}
//----------------------------------------------------------------------------
@ -1038,19 +1047,36 @@ void GuiCheatsDialog_t::autoLoadSaveCheats(int state)
{
if (state == Qt::Unchecked)
{
printf("If this option is unchecked, you must manually save the cheats by yourself, or all the changes you made to the cheat list would be discarded silently without any asking once you close the game!\nDo you really want to do it in this way?");
int ret;
const char *msg = "If this option is unchecked, you must manually save the cheats by yourself, or all the changes you made to the cheat list would be discarded silently without any asking once you close the game!\nDo you really want to do it in this way?";
ret = QMessageBox::warning( this, QObject::tr("Cheat Manual Save Warning"),
QString::fromStdString(msg), QMessageBox::Yes | QMessageBox::No );
if ( ret == QMessageBox::Yes )
{
disableAutoLSCheats = 2;
}
else
{
autoSave->setCheckState( Qt::Checked );
}
}
else
{
disableAutoLSCheats = 0;
}
g_config->setOption("SDL.CheatsDisableAutoLS", disableAutoLSCheats);
g_config->save();
}
//----------------------------------------------------------------------------
void GuiCheatsDialog_t::pauseWindowState(int state)
{
pauseWhileActive = (state != Qt::Unchecked);
g_config->setOption("SDL.CheatsWindowPause", pauseWhileActive);
g_config->save();
if (pauseWhileActive)
{
if (EmulationPaused == 0)

View File

@ -603,9 +603,14 @@ InitConfig()
config->addOption("SDL.AviVideoFormat", AVI_RGB24);
#endif
// Cheat Options
config->addOption("SDL.CheatsDisabled", 0);
config->addOption("SDL.CheatsDisableAutoLS", 0);
config->addOption("SDL.CheatsWindowPause", 0);
// Hex Editor Options
config->addOption("hexEditBgColor", "SDL.HexEditBgColor", "#000000");
config->addOption("hexEditFgColor", "SDL.HexEditFgColor", "#FFFFFF");
config->addOption("SDL.HexEditBgColor", "#000000");
config->addOption("SDL.HexEditFgColor", "#FFFFFF");
config->addOption("SDL.HexEditCursorColorRC", "#000080");
config->addOption("SDL.HexEditAltColColor" , "#545454");
config->addOption("SDL.HexEditFont" , "");

View File

@ -47,6 +47,7 @@
#include "common/cheat.h"
#include "../../fceu.h"
#include "../../cheat.h"
#include "../../movie.h"
#include "../../version.h"
@ -744,6 +745,10 @@ int fceuWrapperInit( int argc, char *argv[] )
AutoResumePlay = false;
}
// Cheats
g_config->getOption ("SDL.CheatsDisabled" , &globalCheatDisabled);
g_config->getOption ("SDL.CheatsDisableAutoLS", &disableAutoLSCheats);
g_config->getOption ("SDL.DrawInputAids", &drawInputAidsEnable);
// Initialize Autofire Pattern