Added movie options dialog window to Qt GUI.

This commit is contained in:
Matthew Budd 2020-11-05 05:24:21 -05:00
parent feff0f79c3
commit d8d696e1a1
9 changed files with 240 additions and 7 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/MovieOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/LuaControl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/CheatsConf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/HexEditor.cpp

View File

@ -24,6 +24,7 @@
#include "Qt/HotKeyConf.h"
#include "Qt/PaletteConf.h"
#include "Qt/GuiConf.h"
#include "Qt/MovieOptions.h"
#include "Qt/LuaControl.h"
#include "Qt/CheatsConf.h"
#include "Qt/HexEditor.h"
@ -378,6 +379,14 @@ void consoleWin_t::createMainMenu(void)
optMenu->addAction(guiConfig);
// Options -> Movie Options
movieConfig = new QAction(tr("Movie Options"), this);
//movieConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
movieConfig->setStatusTip(tr("Movie Options"));
connect(movieConfig, SIGNAL(triggered()), this, SLOT(openMovieOptWin(void)) );
optMenu->addAction(movieConfig);
// Options -> Auto-Resume
autoResume = new QAction(tr("Auto-Resume Play"), this);
//autoResume->setShortcut( QKeySequence(tr("Ctrl+C")));
@ -1203,6 +1212,17 @@ void consoleWin_t::openGuiConfWin(void)
guiConfWin->show();
}
void consoleWin_t::openMovieOptWin(void)
{
MovieOptionsDialog_t *win;
//printf("Open Movie Options Window\n");
win = new MovieOptionsDialog_t(this);
win->show();
}
void consoleWin_t::openCheats(void)
{
//printf("Open GUI Cheat Window\n");
@ -1590,6 +1610,7 @@ void consoleWin_t::openMovie(void)
QString filename;
std::string last;
char dir[512];
char replayReadOnlySetting;
QFileDialog dialog(this, tr("Open FM2 Movie") );
dialog.setFileMode(QFileDialog::ExistingFile);
@ -1637,9 +1658,18 @@ void consoleWin_t::openMovie(void)
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(),
false, pauseframe ? pauseframe : false) == false)
replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
{
printf("Error: Could not open movie file: %s \n", filename.toStdString().c_str() );
}

View File

@ -78,6 +78,7 @@ class consoleWin_t : public QMainWindow
QAction *hotkeyConfig;
QAction *paletteConfig;
QAction *guiConfig;
QAction *movieConfig;
QAction *autoResume;
QAction *fullscreen;
QAction *aboutAct;
@ -145,6 +146,7 @@ class consoleWin_t : public QMainWindow
void openHotkeyConfWin(void);
void openPaletteConfWin(void);
void openGuiConfWin(void);
void openMovieOptWin(void);
void openCodeDataLogger(void);
void openTraceLogger(void);
void toggleAutoResume(void);

View File

@ -0,0 +1,132 @@
// HotKeyConf.cpp
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <QHeaderView>
#include <QCloseEvent>
#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/MovieOptions.h"
//----------------------------------------------------------------------------
MovieOptionsDialog_t::MovieOptionsDialog_t(QWidget *parent)
: QDialog( parent )
{
QVBoxLayout *mainLayout;
setWindowTitle("Movie Options");
mainLayout = new QVBoxLayout();
readOnlyReplay = new QCheckBox( tr("Always Suggest Read-Only Replay") );
pauseAfterPlay = new QCheckBox( tr("Pause After Playback") );
closeAfterPlay = new QCheckBox( tr("Close After Playback") );
bindSaveStates = new QCheckBox( tr("Bind Save-States to Movies") );
dpySubTitles = new QCheckBox( tr("Display Movie Sub Titles") );
putSubTitlesAvi = new QCheckBox( tr("Put Movie Sub Titles in AVI") );
autoBackUp = new QCheckBox( tr("Automatically Backup Movies") );
loadFullStates = new QCheckBox( tr("Load Full Save-State Movies:") );
mainLayout->addWidget( readOnlyReplay );
mainLayout->addWidget( pauseAfterPlay );
mainLayout->addWidget( closeAfterPlay );
mainLayout->addWidget( bindSaveStates );
mainLayout->addWidget( dpySubTitles );
mainLayout->addWidget( putSubTitlesAvi );
mainLayout->addWidget( autoBackUp );
mainLayout->addWidget( loadFullStates );
readOnlyReplay->setChecked( suggestReadOnlyReplay );
pauseAfterPlay->setChecked( pauseAfterPlayback );
closeAfterPlay->setChecked( closeFinishedMovie );
bindSaveStates->setChecked( bindSavestate );
dpySubTitles->setChecked( movieSubtitles );
putSubTitlesAvi->setChecked( subtitlesOnAVI );
autoBackUp->setChecked( autoMovieBackup );
loadFullStates->setChecked( fullSaveStateLoads );
setLayout( mainLayout );
connect( readOnlyReplay , SIGNAL(stateChanged(int)), this, SLOT(readOnlyReplayChanged(int)) );
connect( pauseAfterPlay , SIGNAL(stateChanged(int)), this, SLOT(pauseAfterPlayChanged(int)) );
connect( closeAfterPlay , SIGNAL(stateChanged(int)), this, SLOT(closeAfterPlayChanged(int)) );
connect( bindSaveStates , SIGNAL(stateChanged(int)), this, SLOT(bindSaveStatesChanged(int)) );
connect( dpySubTitles , SIGNAL(stateChanged(int)), this, SLOT(dpySubTitlesChanged(int)) );
connect( putSubTitlesAvi, SIGNAL(stateChanged(int)), this, SLOT(putSubTitlesAviChanged(int)) );
connect( autoBackUp , SIGNAL(stateChanged(int)), this, SLOT(autoBackUpChanged(int)) );
connect( loadFullStates , SIGNAL(stateChanged(int)), this, SLOT(loadFullStatesChanged(int)) );
}
//----------------------------------------------------------------------------
MovieOptionsDialog_t::~MovieOptionsDialog_t(void)
{
printf("Destroy Movie Options Window\n");
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeEvent(QCloseEvent *event)
{
printf("Movie Options Close Window Event\n");
done(0);
deleteLater();
event->accept();
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::readOnlyReplayChanged( int state )
{
suggestReadOnlyReplay = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::pauseAfterPlayChanged( int state )
{
pauseAfterPlayback = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeAfterPlayChanged( int state )
{
closeFinishedMovie = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::bindSaveStatesChanged( int state )
{
bindSavestate = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::dpySubTitlesChanged( int state )
{
movieSubtitles = (state != Qt::Unchecked);
g_config->setOption("SDL.SubtitleDisplay", movieSubtitles);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::putSubTitlesAviChanged( int state )
{
subtitlesOnAVI = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::autoBackUpChanged( int state )
{
autoMovieBackup = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::loadFullStatesChanged( int state )
{
fullSaveStateLoads = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------

View File

@ -0,0 +1,55 @@
// MovieOptions.h
//
#pragma once
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QLabel>
#include <QFrame>
#include <QGroupBox>
#include <QTreeView>
#include <QTreeWidget>
#include "Qt/main.h"
class MovieOptionsDialog_t : public QDialog
{
Q_OBJECT
public:
MovieOptionsDialog_t(QWidget *parent = 0);
~MovieOptionsDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
QCheckBox *readOnlyReplay;
QCheckBox *pauseAfterPlay;
QCheckBox *closeAfterPlay;
QCheckBox *bindSaveStates;
QCheckBox *dpySubTitles;
QCheckBox *putSubTitlesAvi;
QCheckBox *autoBackUp;
QCheckBox *loadFullStates;
private:
public slots:
void closeWindow(void);
private slots:
void readOnlyReplayChanged( int state );
void pauseAfterPlayChanged( int state );
void closeAfterPlayChanged( int state );
void bindSaveStatesChanged( int state );
void dpySubTitlesChanged( int state );
void putSubTitlesAviChanged( int state );
void autoBackUpChanged( int state );
void loadFullStatesChanged( int state );
};

View File

@ -54,6 +54,8 @@ int KillFCEUXonFrame = 0;
bool swapDuty = 0;
bool turbo = false;
bool pauseAfterPlayback = false;
bool suggestReadOnlyReplay = true;
unsigned int gui_draw_area_width = 256;
unsigned int gui_draw_area_height = 256;
@ -696,8 +698,7 @@ int fceuWrapperInit( int argc, char *argv[] )
input_display = id;
// not exactly an id as an true/false switch; still better than creating another int for that
g_config->getOption("SDL.SubtitleDisplay", &id);
extern int movieSubtitles;
movieSubtitles = id;
movieSubtitles = id ? true : false;
}
// load the hotkeys from the config life
@ -725,10 +726,20 @@ int fceuWrapperInit( int argc, char *argv[] )
if(s.find(".fm2") != std::string::npos || s.find(".fm3") != std::string::npos)
{
static int pauseframe;
char replayReadOnlySetting;
g_config->getOption("SDL.PauseFrame", &pauseframe);
g_config->setOption("SDL.PauseFrame", 0);
if (suggestReadOnlyReplay)
{
replayReadOnlySetting = true;
}
else
{
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
}
FCEUI_printf("Playing back movie located at %s\n", s.c_str());
FCEUI_LoadMovie(s.c_str(), false, pauseframe ? pauseframe : false);
FCEUI_LoadMovie(s.c_str(), replayReadOnlySetting, pauseframe ? pauseframe : false);
}
else
{
@ -1354,7 +1365,7 @@ void FCEUI_AviVideoUpdate(const unsigned char* buffer) { }
int FCEUD_ShowStatusIcon(void) {return 0;}
bool FCEUI_AviIsRecording(void) {return false;}
void FCEUI_UseInputPreset(int preset) { }
bool FCEUD_PauseAfterPlayback() { return false; }
bool FCEUD_PauseAfterPlayback() { return pauseAfterPlayback; }
void FCEUD_TurboOn (void) { /* TODO */ };
void FCEUD_TurboOff (void) { /* TODO */ };

View File

@ -13,6 +13,8 @@ extern int gametype;
extern int closeFinishedMovie;
extern bool turbo;
extern bool swapDuty;
extern bool pauseAfterPlayback;
extern bool suggestReadOnlyReplay;
extern unsigned int gui_draw_area_width;
extern unsigned int gui_draw_area_height;

View File

@ -754,8 +754,7 @@ static void KeyboardCommands (void)
if (_keyonly (Hotkeys[HK_TOGGLE_SUBTITLE]))
{
extern int movieSubtitles;
movieSubtitles ^= 1;
movieSubtitles = !movieSubtitles;
FCEUI_DispMessage ("Movie subtitles o%s.", 0,
movieSubtitles ? "n" : "ff");
}

View File

@ -94,6 +94,7 @@ extern int GameAttributes;
extern uint8 PAL;
extern int dendy;
extern bool movieSubtitles;
//#include "driver.h"