some more small fry

This commit is contained in:
Arisotura 2024-05-24 19:19:23 +02:00
parent b5cc5a2cf7
commit a7bce8e233
9 changed files with 39 additions and 23 deletions

View File

@ -62,11 +62,6 @@ int GL_ScaleFactor;
bool GL_BetterPolygons;
bool GL_HiresCoordinates;
bool LimitFPS;
int MaxFPS;
bool AudioSync;
bool ShowOSD;
bool FirmwareOverrideSettings;
std::string FirmwareUsername;
int FirmwareLanguage;

View File

@ -176,11 +176,6 @@ extern int GL_ScaleFactor;
extern bool GL_BetterPolygons;
extern bool GL_HiresCoordinates;
extern bool LimitFPS;
extern int MaxFPS;
extern bool AudioSync;
extern bool ShowOSD;
extern bool FirmwareOverrideSettings;
extern std::string FirmwareUsername;
extern int FirmwareLanguage;

View File

@ -68,6 +68,10 @@ EmuInstance::EmuInstance(int inst) : instanceID(inst),
{
cheatFile = nullptr;
doLimitFPS = globalCfg.GetBool("LimitFPS");
maxFPS = globalCfg.GetInt("MaxFPS");
doAudioSync = globalCfg.GetBool("AudioSync");
nds = nullptr;
updateConsole(nullptr, nullptr);

View File

@ -225,6 +225,10 @@ public:
std::unique_ptr<SaveManager> ndsSave;
std::unique_ptr<SaveManager> gbaSave;
std::unique_ptr<SaveManager> firmwareSave;
bool doLimitFPS;
int maxFPS;
bool doAudioSync;
private:
std::unique_ptr<melonDS::Savestate> backupState;

View File

@ -407,15 +407,15 @@ void EmuThread::run()
emuInstance->audioVolume = volumeLevel * (256.0 / 31.0);
}
if (Config::AudioSync && !fastforward)
if (emuInstance->doAudioSync && !fastforward)
emuInstance->audioSync();
double frametimeStep = nlines / (60.0 * 263.0);
{
bool limitfps = Config::LimitFPS && !fastforward;
bool limitfps = emuInstance->doLimitFPS && !fastforward;
double practicalFramelimit = limitfps ? frametimeStep : 1.0 / Config::MaxFPS;
double practicalFramelimit = limitfps ? frametimeStep : 1.0 / emuInstance->maxFPS;
double curtime = SDL_GetPerformanceCounter() * perfCountsSec;

View File

@ -31,11 +31,15 @@ InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(pare
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
emuInstance = ((MainWindow*)parent)->getEmuInstance();
auto& cfg = emuInstance->getGlobalConfig();
ui->cbMouseHide->setChecked(Config::MouseHide != 0);
ui->spinMouseHideSeconds->setEnabled(Config::MouseHide != 0);
ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds);
ui->cbPauseLostFocus->setChecked(Config::PauseLostFocus != 0);
ui->spinMaxFPS->setValue(Config::MaxFPS);
ui->spinMaxFPS->setValue(cfg.GetInt("MaxFPS"));
const QList<QString> themeKeys = QStyleFactory::keys();
const QString currentTheme = qApp->style()->objectName();
@ -74,11 +78,14 @@ void InterfaceSettingsDialog::done(int r)
Config::MouseHide = ui->cbMouseHide->isChecked() ? 1:0;
Config::MouseHideSeconds = ui->spinMouseHideSeconds->value();
Config::PauseLostFocus = ui->cbPauseLostFocus->isChecked() ? 1:0;
Config::MaxFPS = ui->spinMaxFPS->value();
emuInstance->maxFPS = ui->spinMaxFPS->value();
QString themeName = ui->cbxUITheme->currentData().toString();
Config::UITheme = themeName.toStdString();
auto& cfg = emuInstance->getGlobalConfig();
cfg.SetInt("MaxFPS", emuInstance->maxFPS);
Config::Save();
if (!Config::UITheme.empty())

View File

@ -24,6 +24,8 @@
namespace Ui { class InterfaceSettingsDialog; }
class InterfaceSettingsDialog;
class EmuInstance;
class InterfaceSettingsDialog : public QDialog
{
Q_OBJECT
@ -60,6 +62,8 @@ private slots:
private:
Ui::InterfaceSettingsDialog* ui;
EmuInstance* emuInstance;
};
#endif // INTERFACESETTINGSDIALOG_H

View File

@ -231,6 +231,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
oldH = Config::WindowHeight;
oldMax = Config::WindowMaximized;
showOSD = windowCfg.GetBool("ShowOSD");
setWindowTitle("melonDS " MELONDS_VERSION);
setAttribute(Qt::WA_DeleteOnClose);
setAcceptDrops(true);
@ -677,10 +679,10 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
}
actScreenFiltering->setChecked(Config::ScreenFilter);
actShowOSD->setChecked(Config::ShowOSD);
actShowOSD->setChecked(showOSD);
actLimitFramerate->setChecked(Config::LimitFPS);
actAudioSync->setChecked(Config::AudioSync);
actLimitFramerate->setChecked(emuInstance->doLimitFPS);
actAudioSync->setChecked(emuInstance->doAudioSync);
if (emuInstance->instanceID > 0)
{
@ -757,7 +759,7 @@ void MainWindow::createScreenPanel()
setCentralWidget(panel);
actScreenFiltering->setEnabled(hasOGL);
panel->osdSetEnabled(Config::ShowOSD);
panel->osdSetEnabled(showOSD);
connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged()));
emit screenLayoutChange();
@ -1989,18 +1991,21 @@ void MainWindow::onChangeScreenFiltering(bool checked)
void MainWindow::onChangeShowOSD(bool checked)
{
Config::ShowOSD = checked?1:0;
panel->osdSetEnabled(Config::ShowOSD);
showOSD = checked;
panel->osdSetEnabled(showOSD);
windowCfg.SetBool("ShowOSD", showOSD);
}
void MainWindow::onChangeLimitFramerate(bool checked)
{
Config::LimitFPS = checked?1:0;
emuInstance->doLimitFPS = checked;
globalCfg.SetBool("LimitFPS", emuInstance->doLimitFPS);
}
void MainWindow::onChangeAudioSync(bool checked)
{
Config::AudioSync = checked?1:0;
emuInstance->doAudioSync = checked;
globalCfg.SetBool("AudioSync", emuInstance->doAudioSync);
}

View File

@ -234,6 +234,8 @@ private:
void createScreenPanel();
bool showOSD;
bool hasOGL;
bool pausedManually = false;