Successful loading of a movie from the movie play window. Styling update for debugger window for dark themes.
This commit is contained in:
parent
bbb878c20d
commit
412ca246c7
|
@ -2734,15 +2734,45 @@ QAsmView::QAsmView(QWidget *parent)
|
||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
QColor fg("black"), bg("white");
|
QColor fg("black"), bg("white");
|
||||||
|
QColor c;
|
||||||
|
|
||||||
|
useDarkTheme = false;
|
||||||
|
|
||||||
font.setFamily("Courier New");
|
font.setFamily("Courier New");
|
||||||
font.setStyle( QFont::StyleNormal );
|
font.setStyle( QFont::StyleNormal );
|
||||||
font.setStyleHint( QFont::Monospace );
|
font.setStyleHint( QFont::Monospace );
|
||||||
|
|
||||||
pal = this->palette();
|
pal = this->palette();
|
||||||
pal.setColor(QPalette::Base , bg );
|
|
||||||
pal.setColor(QPalette::Background, bg );
|
//c = pal.color(QPalette::Base);
|
||||||
pal.setColor(QPalette::WindowText, fg );
|
//printf("Base: R:%i G:%i B:%i \n", c.red(), c.green(), c.blue() );
|
||||||
|
|
||||||
|
//c = pal.color(QPalette::Background);
|
||||||
|
//printf("BackGround: R:%i G:%i B:%i \n", c.red(), c.green(), c.blue() );
|
||||||
|
|
||||||
|
// Figure out if we are using a light or dark theme by checking the
|
||||||
|
// default window text grayscale color. If more white, then we will
|
||||||
|
// use white text on black background, else we do the opposite.
|
||||||
|
c = pal.color(QPalette::WindowText);
|
||||||
|
|
||||||
|
if ( qGray( c.red(), c.green(), c.blue() ) > 128 )
|
||||||
|
{
|
||||||
|
useDarkTheme = true;
|
||||||
|
}
|
||||||
|
//printf("WindowText: R:%i G:%i B:%i \n", c.red(), c.green(), c.blue() );
|
||||||
|
|
||||||
|
if ( useDarkTheme )
|
||||||
|
{
|
||||||
|
pal.setColor(QPalette::Base , fg );
|
||||||
|
pal.setColor(QPalette::Background, fg );
|
||||||
|
pal.setColor(QPalette::WindowText, bg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pal.setColor(QPalette::Base , bg );
|
||||||
|
pal.setColor(QPalette::Background, bg );
|
||||||
|
pal.setColor(QPalette::WindowText, fg );
|
||||||
|
}
|
||||||
|
|
||||||
this->parent = (ConsoleDebugger*)parent;
|
this->parent = (ConsoleDebugger*)parent;
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
|
@ -3047,6 +3077,8 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
int x,y,l, row, nrow, selAddr;
|
int x,y,l, row, nrow, selAddr;
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
QColor black("black");
|
||||||
|
bool forceDarkColor = false;
|
||||||
|
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
viewWidth = event->rect().width();
|
viewWidth = event->rect().width();
|
||||||
|
@ -3087,13 +3119,15 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
x = -pxLineXScroll;
|
x = -pxLineXScroll;
|
||||||
l = lineOffset + row;
|
l = lineOffset + row;
|
||||||
painter.setPen( this->palette().color(QPalette::WindowText));
|
|
||||||
|
forceDarkColor = false;
|
||||||
|
|
||||||
if ( asmPC != NULL )
|
if ( asmPC != NULL )
|
||||||
{
|
{
|
||||||
if ( l == asmPC->line )
|
if ( l == asmPC->line )
|
||||||
{
|
{
|
||||||
painter.fillRect( 0, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("pink") );
|
painter.fillRect( 0, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("pink") );
|
||||||
|
forceDarkColor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3102,6 +3136,16 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
if ( asmEntry[l]->type != dbg_asm_entry_t::ASM_TEXT )
|
if ( asmEntry[l]->type != dbg_asm_entry_t::ASM_TEXT )
|
||||||
{
|
{
|
||||||
painter.fillRect( 0, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("light blue") );
|
painter.fillRect( 0, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("light blue") );
|
||||||
|
forceDarkColor = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( forceDarkColor )
|
||||||
|
{
|
||||||
|
painter.setPen( black );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter.setPen( this->palette().color(QPalette::WindowText));
|
||||||
}
|
}
|
||||||
painter.drawText( x, y, tr(asmEntry[l]->text.c_str()) );
|
painter.drawText( x, y, tr(asmEntry[l]->text.c_str()) );
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ class QAsmView : public QWidget
|
||||||
dbg_asm_entry_t *asmPC;
|
dbg_asm_entry_t *asmPC;
|
||||||
std::vector <dbg_asm_entry_t*> asmEntry;
|
std::vector <dbg_asm_entry_t*> asmEntry;
|
||||||
|
|
||||||
|
bool useDarkTheme;
|
||||||
bool displayROMoffsets;
|
bool displayROMoffsets;
|
||||||
bool symbolicDebugEnable;
|
bool symbolicDebugEnable;
|
||||||
bool registerNameEnable;
|
bool registerNameEnable;
|
||||||
|
|
|
@ -116,8 +116,13 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
|
|
||||||
connect( cancelButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) );
|
connect( cancelButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) );
|
||||||
|
connect( okButton , SIGNAL(clicked(void)), this, SLOT(playMovie(void)) );
|
||||||
|
|
||||||
connect( movBrowseBtn , SIGNAL(clicked(void)), this, SLOT(openMovie(void)) );
|
connect( movBrowseBtn , SIGNAL(clicked(void)), this, SLOT(openMovie(void)) );
|
||||||
|
|
||||||
|
doScan();
|
||||||
|
|
||||||
|
updateMovieText();
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
MoviePlayDialog_t::~MoviePlayDialog_t(void)
|
MoviePlayDialog_t::~MoviePlayDialog_t(void)
|
||||||
|
@ -145,13 +150,228 @@ void MoviePlayDialog_t::closeWindow(void)
|
||||||
// suggestReadOnlyReplay = (state != Qt::Unchecked);
|
// suggestReadOnlyReplay = (state != Qt::Unchecked);
|
||||||
//}
|
//}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
void MoviePlayDialog_t::updateMovieText(void)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
std::string path;
|
||||||
|
FCEUFILE* fp;
|
||||||
|
MOVIE_INFO info;
|
||||||
|
bool scanok;
|
||||||
|
char stmp[256];
|
||||||
|
|
||||||
|
if ( movSelBox->count() == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
idx = movSelBox->currentIndex();
|
||||||
|
|
||||||
|
path = movSelBox->itemText(idx).toStdString();
|
||||||
|
|
||||||
|
fp = FCEU_fopen( path.c_str(),0,"rb",0);
|
||||||
|
|
||||||
|
if ( fp == NULL )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scanok = FCEUI_MovieGetInfo(fp, info, false);
|
||||||
|
|
||||||
|
if ( scanok )
|
||||||
|
{
|
||||||
|
double div;
|
||||||
|
|
||||||
|
sprintf(stmp, "%u", (unsigned)info.num_frames);
|
||||||
|
|
||||||
|
movFramesLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
div = (FCEUI_GetCurrentVidSystem(0,0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing
|
||||||
|
double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding
|
||||||
|
int num_seconds = (int)tempCount;
|
||||||
|
int fraction = (int)((tempCount - num_seconds) * 100);
|
||||||
|
int seconds = num_seconds % 60;
|
||||||
|
int minutes = (num_seconds / 60) % 60;
|
||||||
|
int hours = (num_seconds / 60 / 60) % 60;
|
||||||
|
sprintf(stmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction);
|
||||||
|
|
||||||
|
movLenLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
sprintf(stmp, "%u", (unsigned)info.rerecord_count);
|
||||||
|
|
||||||
|
recCountLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
recFromLbl->setText( tr(info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate") ) );
|
||||||
|
|
||||||
|
romUsedLbl->setText( tr(info.name_of_rom_used.c_str()) );
|
||||||
|
|
||||||
|
romCsumLbl->setText( tr(md5_asciistr(info.md5_of_rom_used)) );
|
||||||
|
|
||||||
|
if ( GameInfo )
|
||||||
|
{
|
||||||
|
curCsumLbl->setText( tr(md5_asciistr(GameInfo->MD5)) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curCsumLbl->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.emu_version_used < 20000 )
|
||||||
|
{
|
||||||
|
sprintf( stmp, "FCEU %d.%02d.%02d%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( stmp, "FCEUX %d.%02d.%02d", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100);
|
||||||
|
}
|
||||||
|
emuUsedLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
palUsedLbl->setText( tr(info.pal ? "On" : "Off") );
|
||||||
|
|
||||||
|
newppuUsedLbl->setText( tr(info.ppuflag ? "On" : "Off") );
|
||||||
|
}
|
||||||
|
delete fp;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int MoviePlayDialog_t::addFileToList( const char *file, bool setActive )
|
||||||
|
{
|
||||||
|
int n=0;
|
||||||
|
|
||||||
|
for (int i=0; i<movSelBox->count(); i++)
|
||||||
|
{
|
||||||
|
if ( strcmp( file, movSelBox->itemText(i).toStdString().c_str() ) == 0 )
|
||||||
|
{
|
||||||
|
if ( setActive )
|
||||||
|
{
|
||||||
|
movSelBox->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n = movSelBox->count();
|
||||||
|
|
||||||
|
movSelBox->addItem( tr(file), n );
|
||||||
|
|
||||||
|
if ( setActive )
|
||||||
|
{
|
||||||
|
movSelBox->setCurrentIndex(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 )
|
||||||
|
{
|
||||||
|
FCEUFILE* fp;
|
||||||
|
MOVIE_INFO info;
|
||||||
|
bool scanok, md5Match = false;
|
||||||
|
|
||||||
|
fp = FCEU_fopen( path,0,"rb",0);
|
||||||
|
|
||||||
|
if ( fp == NULL )
|
||||||
|
{
|
||||||
|
return md5Match;
|
||||||
|
}
|
||||||
|
scanok = FCEUI_MovieGetInfo(fp, info, true);
|
||||||
|
|
||||||
|
if ( scanok )
|
||||||
|
{
|
||||||
|
if ( strcmp( md5, md5_asciistr(info.md5_of_rom_used) ) == 0 )
|
||||||
|
{
|
||||||
|
md5Match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete fp;
|
||||||
|
|
||||||
|
return md5Match;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void MoviePlayDialog_t::doScan(void)
|
||||||
|
{
|
||||||
|
std::string path;
|
||||||
|
QDir dir;
|
||||||
|
QFileInfoList list;
|
||||||
|
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||||
|
const QStringList filters( { "*.fm2" } );
|
||||||
|
char md5[256];
|
||||||
|
|
||||||
|
md5[0] = 0;
|
||||||
|
|
||||||
|
if ( GameInfo )
|
||||||
|
{
|
||||||
|
strcpy( md5, md5_asciistr(GameInfo->MD5) );
|
||||||
|
}
|
||||||
|
|
||||||
|
path = std::string(baseDir) + "/movies/";
|
||||||
|
|
||||||
|
dir.setPath( QString::fromStdString(path) );
|
||||||
|
|
||||||
|
list = dir.entryInfoList( filters, QDir::Files );
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo = list.at(i);
|
||||||
|
|
||||||
|
path = std::string(baseDir) + "/movies/" + fileInfo.fileName().toStdString();
|
||||||
|
|
||||||
|
//printf("File: '%s'\n", path.c_str() );
|
||||||
|
|
||||||
|
if ( checkMD5Sum( path.c_str(), md5 ) )
|
||||||
|
{
|
||||||
|
addFileToList( path.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void MoviePlayDialog_t::playMovie(void)
|
||||||
|
{
|
||||||
|
int idx, pauseframe = 0;
|
||||||
|
bool replayReadOnlySetting, movieLoadError = false;
|
||||||
|
|
||||||
|
if ( movSelBox->count() == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string path;
|
||||||
|
|
||||||
|
idx = movSelBox->currentIndex();
|
||||||
|
|
||||||
|
path = movSelBox->itemText(idx).toStdString();
|
||||||
|
|
||||||
|
if (suggestReadOnlyReplay)
|
||||||
|
{
|
||||||
|
replayReadOnlySetting = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
fceuWrapperLock();
|
||||||
|
if (FCEUI_LoadMovie( path.c_str(),
|
||||||
|
replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
|
||||||
|
{
|
||||||
|
movieLoadError = true;
|
||||||
|
}
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
|
||||||
|
if ( movieLoadError )
|
||||||
|
{
|
||||||
|
printf("Error: Could not open movie file: %s \n", path.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
closeWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void MoviePlayDialog_t::openMovie(void)
|
void MoviePlayDialog_t::openMovie(void)
|
||||||
{
|
{
|
||||||
int ret, useNativeFileDialogVal;
|
int ret, useNativeFileDialogVal;
|
||||||
QString filename;
|
QString filename;
|
||||||
std::string last;
|
std::string last;
|
||||||
char dir[512];
|
char dir[512];
|
||||||
char replayReadOnlySetting;
|
char md5Match = 0;
|
||||||
QFileDialog dialog(this, tr("Open FM2 Movie") );
|
QFileDialog dialog(this, tr("Open FM2 Movie") );
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
@ -193,22 +413,26 @@ void MoviePlayDialog_t::openMovie(void)
|
||||||
}
|
}
|
||||||
qDebug() << "selected file path : " << filename.toUtf8();
|
qDebug() << "selected file path : " << filename.toUtf8();
|
||||||
|
|
||||||
int pauseframe;
|
if ( GameInfo )
|
||||||
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;
|
char md5[256];
|
||||||
}
|
|
||||||
else
|
strcpy( md5, md5_asciistr(GameInfo->MD5) );
|
||||||
{
|
|
||||||
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
|
if ( checkMD5Sum( filename.toStdString().c_str(), md5 ) )
|
||||||
|
{
|
||||||
|
md5Match = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !md5Match )
|
||||||
|
{
|
||||||
|
printf("Warning MD5 Mismatch\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
movSelBox->addItem( filename, movSelBox->count() );
|
addFileToList( filename.toStdString().c_str(), true );
|
||||||
|
|
||||||
|
updateMovieText();
|
||||||
//fceuWrapperLock();
|
//fceuWrapperLock();
|
||||||
//if (FCEUI_LoadMovie( filename.toStdString().c_str(),
|
//if (FCEUI_LoadMovie( filename.toStdString().c_str(),
|
||||||
// replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
|
// replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
|
||||||
|
|
|
@ -46,11 +46,16 @@ class MoviePlayDialog_t : public QDialog
|
||||||
QLabel *newppuUsedLbl;
|
QLabel *newppuUsedLbl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void doScan(void);
|
||||||
|
void updateMovieText(void);
|
||||||
|
int addFileToList( const char *file, bool setActive = false );
|
||||||
|
bool checkMD5Sum( const char *path, const char *md5 );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeWindow(void);
|
void closeWindow(void);
|
||||||
private slots:
|
private slots:
|
||||||
void openMovie(void);
|
void openMovie(void);
|
||||||
|
void playMovie(void);
|
||||||
//void readOnlyReplayChanged( int state );
|
//void readOnlyReplayChanged( int state );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue