Movie play window for Qt GUI in work.

This commit is contained in:
Matthew Budd 2020-11-05 06:49:50 -05:00
parent 9bc07b8c2c
commit 4314ccbfc3
4 changed files with 348 additions and 72 deletions

View File

@ -430,6 +430,7 @@ set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/HotKeyConf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/PaletteConf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/GuiConf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/MoviePlay.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/MovieOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/LuaControl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/CheatsConf.cpp

View File

@ -24,6 +24,7 @@
#include "Qt/HotKeyConf.h"
#include "Qt/PaletteConf.h"
#include "Qt/GuiConf.h"
#include "Qt/MoviePlay.h"
#include "Qt/MovieOptions.h"
#include "Qt/LuaControl.h"
#include "Qt/CheatsConf.h"
@ -660,10 +661,10 @@ void consoleWin_t::createMainMenu(void)
// Movie
movieMenu = menuBar()->addMenu(tr("Movie"));
// Movie -> Open
openMovAct = new QAction(tr("Open"), this);
// Movie -> Play
openMovAct = new QAction(tr("Play"), this);
openMovAct->setShortcut( QKeySequence(tr("Shift+F7")));
openMovAct->setStatusTip(tr("Open Movie File"));
openMovAct->setStatusTip(tr("Play Movie File"));
connect(openMovAct, SIGNAL(triggered()), this, SLOT(openMovie(void)) );
movieMenu->addAction(openMovAct);
@ -1606,79 +1607,88 @@ void consoleWin_t::emuSetFrameAdvDelay(void)
void consoleWin_t::openMovie(void)
{
int ret, useNativeFileDialogVal;
QString filename;
std::string last;
char dir[512];
char replayReadOnlySetting;
QFileDialog dialog(this, tr("Open FM2 Movie") );
MoviePlayDialog_t *win;
dialog.setFileMode(QFileDialog::ExistingFile);
win = new MoviePlayDialog_t(this);
dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
g_config->getOption ("SDL.LastOpenMovie", &last );
getDirFromFile( last.c_str(), dir );
dialog.setDirectory( tr(dir) );
// 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();
int pauseframe;
g_config->getOption ("SDL.PauseFrame", &pauseframe);
g_config->setOption ("SDL.PauseFrame", 0);
FCEUI_printf ("Playing back movie located at %s\n", filename.toStdString().c_str() );
if (suggestReadOnlyReplay)
{
replayReadOnlySetting = true;
}
else
{
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
}
fceuWrapperLock();
if (FCEUI_LoadMovie( filename.toStdString().c_str(),
replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
{
printf("Error: Could not open movie file: %s \n", filename.toStdString().c_str() );
}
g_config->setOption ("SDL.LastOpenMovie", filename.toStdString().c_str() );
fceuWrapperUnLock();
return;
win->show();
}
//void consoleWin_t::openMovie(void)
//{
// int ret, useNativeFileDialogVal;
// QString filename;
// std::string last;
// char dir[512];
// char replayReadOnlySetting;
// QFileDialog dialog(this, tr("Open FM2 Movie") );
//
// dialog.setFileMode(QFileDialog::ExistingFile);
//
// dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)"));
//
// dialog.setViewMode(QFileDialog::List);
// dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
// dialog.setLabelText( QFileDialog::Accept, tr("Open") );
//
// g_config->getOption ("SDL.LastOpenMovie", &last );
//
// getDirFromFile( last.c_str(), dir );
//
// dialog.setDirectory( tr(dir) );
//
// // 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();
//
// int pauseframe;
// g_config->getOption ("SDL.PauseFrame", &pauseframe);
// g_config->setOption ("SDL.PauseFrame", 0);
//
// FCEUI_printf ("Playing back movie located at %s\n", filename.toStdString().c_str() );
//
// if (suggestReadOnlyReplay)
// {
// replayReadOnlySetting = true;
// }
// else
// {
// replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
// }
//
// fceuWrapperLock();
// if (FCEUI_LoadMovie( filename.toStdString().c_str(),
// replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
// {
// printf("Error: Could not open movie file: %s \n", filename.toStdString().c_str() );
// }
// g_config->setOption ("SDL.LastOpenMovie", filename.toStdString().c_str() );
// fceuWrapperUnLock();
//
// return;
//}
void consoleWin_t::stopMovie(void)
{
fceuWrapperLock();

View File

@ -0,0 +1,209 @@
// MoviePlay.cpp
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <QHeaderView>
#include <QCloseEvent>
#include <QFileDialog>
#include <QGridLayout>
#include "../../fceu.h"
#include "../../movie.h"
#include "Qt/main.h"
#include "Qt/dface.h"
#include "Qt/input.h"
#include "Qt/config.h"
#include "Qt/keyscan.h"
#include "Qt/fceuWrapper.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/MoviePlay.h"
//----------------------------------------------------------------------------
MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
: QDialog( parent )
{
QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox;
QGroupBox *frame;
QGridLayout *grid;
QLabel *lbl;
setWindowTitle("Movie Play");
mainLayout = new QVBoxLayout();
hbox = new QHBoxLayout();
lbl = new QLabel( tr("File:") );
movSelBox = new QComboBox();
movBrowseBtn = new QPushButton( tr("Browse") );
hbox->addWidget( lbl );
hbox->addWidget( movSelBox );
hbox->addWidget( movBrowseBtn );
mainLayout->addLayout( hbox );
frame = new QGroupBox( tr("Parameters:") );
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
frame->setLayout( vbox );
openReadOnly = new QCheckBox( tr("Open Read-Only") );
pauseAtFrame = new QCheckBox( tr("Pause Movie At Frame") );
pauseAtFrameEntry = new QLineEdit();
vbox->addWidget( openReadOnly );
vbox->addLayout( hbox );
hbox->addWidget( pauseAtFrame );
hbox->addWidget( pauseAtFrameEntry );
mainLayout->addWidget( frame );
grid = new QGridLayout();
mainLayout->addLayout( grid );
movLenLbl = new QLabel();
movFramesLbl = new QLabel();
recCountLbl = new QLabel();
recFromLbl = new QLabel();
romUsedLbl = new QLabel();
romCsumLbl = new QLabel();
curCsumLbl = new QLabel();
emuUsedLbl = new QLabel();
palUsedLbl = new QLabel();
newppuUsedLbl = new QLabel();
grid->addWidget( new QLabel( tr("Length:") ) , 0, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("Frames:") ) , 1, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("Record Count:") ) , 2, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("Recorded From:") ) , 3, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("ROM Used:") ) , 4, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("ROM Checksum:") ) , 5, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("Current ROM Sum:") ) , 6, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("Emulator Used:") ) , 7, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("PAL:") ) , 8, 0, Qt::AlignRight );
grid->addWidget( new QLabel( tr("New PPU:") ) , 9, 0, Qt::AlignRight );
grid->addWidget( movLenLbl , 0, 1, Qt::AlignLeft );
grid->addWidget( movFramesLbl , 1, 1, Qt::AlignLeft );
grid->addWidget( recCountLbl , 2, 1, Qt::AlignLeft );
grid->addWidget( recFromLbl , 3, 1, Qt::AlignLeft );
grid->addWidget( romUsedLbl , 4, 1, Qt::AlignLeft );
grid->addWidget( romCsumLbl , 5, 1, Qt::AlignLeft );
grid->addWidget( curCsumLbl , 6, 1, Qt::AlignLeft );
grid->addWidget( emuUsedLbl , 7, 1, Qt::AlignLeft );
grid->addWidget( palUsedLbl , 8, 1, Qt::AlignLeft );
grid->addWidget( newppuUsedLbl , 9, 1, Qt::AlignLeft );
setLayout( mainLayout );
connect( movBrowseBtn , SIGNAL(clicked(void)), this, SLOT(openMovie(void)) );
}
//----------------------------------------------------------------------------
MoviePlayDialog_t::~MoviePlayDialog_t(void)
{
printf("Destroy Movie Play Window\n");
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::closeEvent(QCloseEvent *event)
{
printf("Movie Play Close Window Event\n");
done(0);
deleteLater();
event->accept();
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
//void MoviePlayDialog_t::readOnlyReplayChanged( int state )
//{
// suggestReadOnlyReplay = (state != Qt::Unchecked);
//}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::openMovie(void)
{
int ret, useNativeFileDialogVal;
QString filename;
std::string last;
char dir[512];
char replayReadOnlySetting;
QFileDialog dialog(this, tr("Open FM2 Movie") );
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
g_config->getOption ("SDL.LastOpenMovie", &last );
getDirFromFile( last.c_str(), dir );
dialog.setDirectory( tr(dir) );
// 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();
int pauseframe;
g_config->getOption ("SDL.PauseFrame", &pauseframe);
g_config->setOption ("SDL.PauseFrame", 0);
FCEUI_printf ("Playing back movie located at %s\n", filename.toStdString().c_str() );
if (suggestReadOnlyReplay)
{
replayReadOnlySetting = true;
}
else
{
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
}
//fceuWrapperLock();
//if (FCEUI_LoadMovie( filename.toStdString().c_str(),
// replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
//{
// printf("Error: Could not open movie file: %s \n", filename.toStdString().c_str() );
//}
g_config->setOption ("SDL.LastOpenMovie", filename.toStdString().c_str() );
//fceuWrapperUnLock();
return;
}
//----------------------------------------------------------------------------

View File

@ -0,0 +1,56 @@
// MoviePlay.h
//
#pragma once
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QFrame>
#include <QGroupBox>
#include "Qt/main.h"
class MoviePlayDialog_t : public QDialog
{
Q_OBJECT
public:
MoviePlayDialog_t(QWidget *parent = 0);
~MoviePlayDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
QComboBox *movSelBox;
QPushButton *movBrowseBtn;
QCheckBox *openReadOnly;
QCheckBox *pauseAtFrame;
QLineEdit *pauseAtFrameEntry;
QLabel *movLenLbl;
QLabel *movFramesLbl;
QLabel *recCountLbl;
QLabel *recFromLbl;
QLabel *romUsedLbl;
QLabel *romCsumLbl;
QLabel *curCsumLbl;
QLabel *emuUsedLbl;
QLabel *palUsedLbl;
QLabel *newppuUsedLbl;
private:
public slots:
void closeWindow(void);
private slots:
void openMovie(void);
//void readOnlyReplayChanged( int state );
};