State recorder config dialog in work for Qt GUI.
This commit is contained in:
parent
bc6164260d
commit
f87d746350
|
@ -551,6 +551,7 @@ set(SRC_DRIVERS_SDL
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleUtilities.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/StateRecorderConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/iNesHeaderEditor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/SplashScreen.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TraceLogger.cpp
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
#include "Qt/MoviePlay.h"
|
||||
#include "Qt/MovieRecord.h"
|
||||
#include "Qt/MovieOptions.h"
|
||||
#include "Qt/StateRecorderConf.h"
|
||||
#include "Qt/TimingConf.h"
|
||||
#include "Qt/FrameTimingStats.h"
|
||||
#include "Qt/LuaControl.h"
|
||||
|
@ -1218,6 +1219,15 @@ void consoleWin_t::createMainMenu(void)
|
|||
|
||||
optMenu->addAction(timingConfig);
|
||||
|
||||
// Options -> State Recorder Config
|
||||
stateRecordConfig = new QAction(tr("&State Recorder Config"), this);
|
||||
//stateRecordConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
|
||||
stateRecordConfig->setStatusTip(tr("State Recorder Configure"));
|
||||
stateRecordConfig->setIcon( QIcon(":icons/media-record.png") );
|
||||
connect(stateRecordConfig, SIGNAL(triggered()), this, SLOT(openStateRecorderConfWin(void)) );
|
||||
|
||||
optMenu->addAction(stateRecordConfig);
|
||||
|
||||
// Options -> Movie Options
|
||||
movieConfig = new QAction(tr("&Movie Options"), this);
|
||||
//movieConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
|
||||
|
@ -3864,6 +3874,15 @@ void consoleWin_t::toggleTurboMode(void)
|
|||
NoWaiting ^= 1;
|
||||
}
|
||||
|
||||
void consoleWin_t::openStateRecorderConfWin(void)
|
||||
{
|
||||
StateRecorderDialog_t *win;
|
||||
|
||||
win = new StateRecorderDialog_t(this);
|
||||
|
||||
win->show();
|
||||
}
|
||||
|
||||
void consoleWin_t::openMovie(void)
|
||||
{
|
||||
MoviePlayDialog_t *win;
|
||||
|
|
|
@ -211,6 +211,7 @@ class consoleWin_t : public QMainWindow
|
|||
QAction *hotkeyConfig;
|
||||
QAction *paletteConfig;
|
||||
QAction *guiConfig;
|
||||
QAction *stateRecordConfig;
|
||||
QAction *timingConfig;
|
||||
QAction *movieConfig;
|
||||
QAction *autoResume;
|
||||
|
@ -344,6 +345,7 @@ class consoleWin_t : public QMainWindow
|
|||
void openPaletteConfWin(void);
|
||||
void openGuiConfWin(void);
|
||||
void openTimingConfWin(void);
|
||||
void openStateRecorderConfWin(void);
|
||||
void openPaletteEditorWin(void);
|
||||
void openAviRiffViewer(void);
|
||||
void openTimingStatWin(void);
|
||||
|
|
|
@ -0,0 +1,225 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2022 thor2016
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// StateRecorderConf.cpp
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QGridLayout>
|
||||
#include <QSettings>
|
||||
|
||||
#include "Qt/StateRecorderConf.h"
|
||||
|
||||
#include "../../fceu.h"
|
||||
#include "../../state.h"
|
||||
#include "../../emufile.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
StateRecorderDialog_t::StateRecorderDialog_t(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QVBoxLayout *mainLayout;
|
||||
QHBoxLayout *hbox, *hbox1;
|
||||
QGroupBox *frame, *frame1;
|
||||
QGridLayout *grid, *memStatsGrid;
|
||||
QSettings settings;
|
||||
|
||||
setWindowTitle("State Recorder Config");
|
||||
|
||||
mainLayout = new QVBoxLayout();
|
||||
grid = new QGridLayout();
|
||||
|
||||
recorderEnable = new QCheckBox(tr("Auto Start Recorder at ROM Load"));
|
||||
snapMinutes = new QSpinBox();
|
||||
snapSeconds = new QSpinBox();
|
||||
historyDuration = new QSpinBox();
|
||||
|
||||
snapSeconds->setMinimum(0);
|
||||
snapSeconds->setMaximum(60);
|
||||
snapSeconds->setValue(3);
|
||||
snapMinutes->setMinimum(0);
|
||||
snapMinutes->setMaximum(60);
|
||||
snapMinutes->setValue(0);
|
||||
historyDuration->setMinimum(1);
|
||||
historyDuration->setMaximum(180);
|
||||
historyDuration->setValue(15);
|
||||
|
||||
frame = new QGroupBox(tr("Retain History For:"));
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
hbox->addWidget( historyDuration);
|
||||
hbox->addWidget( new QLabel( tr("Minutes") ) );
|
||||
|
||||
frame->setLayout(hbox);
|
||||
|
||||
grid->addWidget( recorderEnable, 0, 0 );
|
||||
grid->addWidget( frame , 1, 0 );
|
||||
|
||||
frame1 = new QGroupBox(tr("Time Between Snapshots:"));
|
||||
hbox1 = new QHBoxLayout();
|
||||
frame1->setLayout(hbox1);
|
||||
grid->addWidget( frame1, 2, 0 );
|
||||
|
||||
frame = new QGroupBox();
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
hbox1->addWidget(frame);
|
||||
hbox->addWidget( snapMinutes);
|
||||
hbox->addWidget( new QLabel( tr("Minutes") ) );
|
||||
|
||||
frame->setLayout(hbox);
|
||||
|
||||
frame = new QGroupBox();
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
hbox1->addWidget(frame);
|
||||
hbox->addWidget( snapSeconds);
|
||||
hbox->addWidget( new QLabel( tr("Seconds") ) );
|
||||
|
||||
frame->setLayout(hbox);
|
||||
|
||||
frame = new QGroupBox( tr("Memory Usage:") );
|
||||
memStatsGrid = new QGridLayout();
|
||||
|
||||
numSnapsLbl = new QLineEdit();
|
||||
snapMemSizeLbl = new QLineEdit();
|
||||
totalMemUsageLbl = new QLineEdit();
|
||||
|
||||
numSnapsLbl->setReadOnly(true);
|
||||
snapMemSizeLbl->setReadOnly(true);
|
||||
totalMemUsageLbl->setReadOnly(true);
|
||||
|
||||
grid->addWidget(frame, 1, 2, 2, 2);
|
||||
frame->setLayout(memStatsGrid);
|
||||
memStatsGrid->addWidget( new QLabel( tr("Number of\nSnapshots:") ), 0, 0 );
|
||||
memStatsGrid->addWidget( numSnapsLbl, 0, 1 );
|
||||
|
||||
memStatsGrid->addWidget( new QLabel( tr("Snapshot Size:") ), 1, 0 );
|
||||
memStatsGrid->addWidget( snapMemSizeLbl, 1, 1 );
|
||||
|
||||
memStatsGrid->addWidget( new QLabel( tr("Total Size:") ), 2, 0 );
|
||||
memStatsGrid->addWidget( totalMemUsageLbl, 2, 1 );
|
||||
|
||||
mainLayout->addLayout(grid);
|
||||
|
||||
hbox = new QHBoxLayout();
|
||||
mainLayout->addLayout(hbox);
|
||||
|
||||
closeButton = new QPushButton( tr("Close") );
|
||||
applyButton = new QPushButton( tr("Apply") );
|
||||
|
||||
closeButton->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
applyButton->setIcon( style()->standardIcon( QStyle::SP_DialogApplyButton ) );
|
||||
|
||||
hbox->addWidget(applyButton, 1);
|
||||
hbox->addStretch(8);
|
||||
hbox->addWidget(closeButton, 1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
restoreGeometry(settings.value("stateRecorderWindow/geometry").toByteArray());
|
||||
|
||||
recalcMemoryUsage();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
StateRecorderDialog_t::~StateRecorderDialog_t(void)
|
||||
{
|
||||
//printf("Destroy State Recorder Config Window\n");
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void StateRecorderDialog_t::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("stateRecorderWindow/geometry", saveGeometry());
|
||||
done(0);
|
||||
deleteLater();
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void StateRecorderDialog_t::closeWindow(void)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("stateRecorderWindow/geometry", saveGeometry());
|
||||
done(0);
|
||||
deleteLater();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void StateRecorderDialog_t::recalcMemoryUsage(void)
|
||||
{
|
||||
char stmp[64];
|
||||
|
||||
float fhistMin = static_cast<float>( historyDuration->value() );
|
||||
float fsnapMin = static_cast<float>( snapMinutes->value() ) +
|
||||
( static_cast<float>( snapSeconds->value() ) / 60.0f );
|
||||
|
||||
float fnumSnaps = fhistMin / fsnapMin;
|
||||
float fsnapSize = 10.0f * 1024.0f;
|
||||
float ftotalSize;
|
||||
constexpr float oneKiloByte = 1024.0f;
|
||||
constexpr float oneMegaByte = 1024.0f * 1024.0f;
|
||||
|
||||
int inumSnaps = static_cast<int>( fnumSnaps + 0.5f );
|
||||
|
||||
sprintf( stmp, "%i", inumSnaps );
|
||||
|
||||
numSnapsLbl->setText( tr(stmp) );
|
||||
|
||||
if (GameInfo)
|
||||
{
|
||||
EMUFILE_MEMORY em;
|
||||
int compressionLevel = 0;
|
||||
|
||||
FCEUSS_SaveMS( &em, compressionLevel );
|
||||
|
||||
fsnapSize = static_cast<float>( em.size() ) / 1024.0f;
|
||||
}
|
||||
|
||||
if (fsnapSize >= oneKiloByte)
|
||||
{
|
||||
sprintf( stmp, "%.02f kB", fsnapSize / oneKiloByte );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( stmp, "%.0f B", fsnapSize );
|
||||
}
|
||||
|
||||
snapMemSizeLbl->setText( tr(stmp) );
|
||||
|
||||
ftotalSize = fsnapSize * static_cast<float>(inumSnaps);
|
||||
|
||||
if (ftotalSize >= oneMegaByte)
|
||||
{
|
||||
sprintf( stmp, "%.02f MB", ftotalSize / oneMegaByte );
|
||||
}
|
||||
else if (ftotalSize >= oneKiloByte)
|
||||
{
|
||||
sprintf( stmp, "%.02f kB", ftotalSize / oneKiloByte );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( stmp, "%.0f B", ftotalSize );
|
||||
}
|
||||
|
||||
totalMemUsageLbl->setText( tr(stmp) );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
|
@ -0,0 +1,47 @@
|
|||
// StateRecorderConf.h
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QSpinBox>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
|
||||
class StateRecorderDialog_t : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StateRecorderDialog_t(QWidget *parent = 0);
|
||||
~StateRecorderDialog_t(void);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
QSpinBox *snapMinutes;
|
||||
QSpinBox *snapSeconds;
|
||||
QSpinBox *historyDuration;
|
||||
QCheckBox *recorderEnable;
|
||||
QLineEdit *numSnapsLbl;
|
||||
QLineEdit *snapMemSizeLbl;
|
||||
QLineEdit *totalMemUsageLbl;
|
||||
QPushButton *applyButton;
|
||||
QPushButton *closeButton;
|
||||
|
||||
void recalcMemoryUsage(void);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
|
||||
};
|
Loading…
Reference in New Issue