Added close buttons to Qt GUI config and tools windows. Debug windows still to be evaluated. Only exceptions are when the window has a menu bar with a file -> close option.

This commit is contained in:
mjbudd77 2021-02-20 06:57:25 -05:00
parent e6754c87ba
commit 7dc77269b5
30 changed files with 2925 additions and 2789 deletions

View File

@ -59,18 +59,19 @@ AboutWindow::AboutWindow(QWidget *parent)
{
int i;
QVBoxLayout *mainLayout;
QHBoxLayout *hbox1;
QHBoxLayout *hbox1, *hbox;
QPixmap pm(":fceux1.png");
QPixmap pm2;
QLabel *lbl;
QTextEdit *credits;
QPushButton *closeButton;
char stmp[256];
pm2 = pm.scaled( 64, 64 );
setWindowTitle( tr("About fceuX") );
resize( 512, 512 );
resize( 512, 600 );
mainLayout = new QVBoxLayout();
@ -162,7 +163,19 @@ AboutWindow::AboutWindow(QWidget *parent)
mainLayout->addWidget( credits );
closeButton = new QPushButton( tr("OK") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout( mainLayout );
closeButton->setFocus();
closeButton->setDefault(true);
}
//----------------------------------------------------------------------------
AboutWindow::~AboutWindow(void)
@ -170,3 +183,18 @@ AboutWindow::~AboutWindow(void)
}
//----------------------------------------------------------------------------
void AboutWindow::closeEvent(QCloseEvent *event)
{
printf("About Window Close Event\n");
done(0);
deleteLater();
event->accept();
}
//----------------------------------------------------------------------------
void AboutWindow::closeWindow(void)
{
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------

View File

@ -15,6 +15,7 @@
#include <QGroupBox>
#include <QTreeView>
#include <QTreeWidget>
#include <QCloseEvent>
#include "Qt/main.h"
@ -27,9 +28,11 @@ class AboutWindow : public QDialog
~AboutWindow(void);
protected:
void closeEvent(QCloseEvent *event);
private:
private slots:
public slots:
void closeWindow(void);
};

File diff suppressed because it is too large Load Diff

View File

@ -22,81 +22,80 @@
class GuiCheatsDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
GuiCheatsDialog_t(QWidget *parent = 0);
~GuiCheatsDialog_t(void);
public:
GuiCheatsDialog_t(QWidget *parent = 0);
~GuiCheatsDialog_t(void);
int addSearchResult( uint32_t a, uint8_t last, uint8_t current );
int addSearchResult(uint32_t a, uint8_t last, uint8_t current);
int activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data);
int activeCheatListCB(char *name, uint32 a, uint8 v, int c, int s, int type, void *data);
void showActiveCheatList(bool redraw);
void showActiveCheatList(bool redraw);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QGroupBox *actCheatFrame;
QGroupBox *cheatSearchFrame;
QGroupBox *cheatResultFrame;
QPushButton *addCheatBtn;
QPushButton *delCheatBtn;
QPushButton *modCheatBtn;
QPushButton *importCheatFileBtn;
QPushButton *exportCheatFileBtn;
QPushButton *srchResetBtn;
QPushButton *knownValBtn;
QPushButton *eqValBtn;
QPushButton *neValBtn;
QPushButton *grValBtn;
QPushButton *ltValBtn;
QCheckBox *useNeVal;
QCheckBox *useGrVal;
QCheckBox *useLtVal;
QCheckBox *enaCheats;
QCheckBox *autoSave;
QCheckBox *pauseBox;
QTreeWidget *actvCheatList;
QTreeWidget *srchResults;
QLineEdit *cheatNameEntry;
QLineEdit *cheatAddrEntry;
QLineEdit *cheatValEntry;
QLineEdit *cheatCmpEntry;
QLineEdit *knownValEntry;
QLineEdit *neValEntry;
QLineEdit *grValEntry;
QLineEdit *ltValEntry;
QFont font;
QGroupBox *actCheatFrame;
QGroupBox *cheatSearchFrame;
QGroupBox *cheatResultFrame;
QPushButton *addCheatBtn;
QPushButton *delCheatBtn;
QPushButton *modCheatBtn;
QPushButton *importCheatFileBtn;
QPushButton *exportCheatFileBtn;
QPushButton *srchResetBtn;
QPushButton *knownValBtn;
QPushButton *eqValBtn;
QPushButton *neValBtn;
QPushButton *grValBtn;
QPushButton *ltValBtn;
QCheckBox *useNeVal;
QCheckBox *useGrVal;
QCheckBox *useLtVal;
QCheckBox *enaCheats;
QCheckBox *autoSave;
QCheckBox *pauseBox;
QTreeWidget *actvCheatList;
QTreeWidget *srchResults;
QLineEdit *cheatNameEntry;
QLineEdit *cheatAddrEntry;
QLineEdit *cheatValEntry;
QLineEdit *cheatCmpEntry;
QLineEdit *knownValEntry;
QLineEdit *neValEntry;
QLineEdit *grValEntry;
QLineEdit *ltValEntry;
QFont font;
int fontCharWidth;
int actvCheatIdx;
bool actvCheatRedraw;
bool pauseWhileActive;
bool wasPausedByCheats;
int fontCharWidth;
int actvCheatIdx;
bool actvCheatRedraw;
bool pauseWhileActive;
bool wasPausedByCheats;
private:
void showCheatSearchResults(void);
public slots:
void closeWindow(void);
private slots:
void resetSearchCallback(void);
void knownValueCallback(void);
void equalValueCallback(void);
void notEqualValueCallback(void);
void lessThanValueCallback(void);
void greaterThanValueCallback(void);
void openCheatFile(void);
void saveCheatFile(void);
void addActvCheat(void);
void deleteActvCheat(void);
void updateCheatParameters(void);
void autoLoadSaveCheats(int state);
void globalEnableCheats(int state);
void pauseWindowState(int state);
void actvCheatItemClicked( QTreeWidgetItem *item, int column);
private:
void showCheatSearchResults(void);
public slots:
void closeWindow(void);
private slots:
void resetSearchCallback(void);
void knownValueCallback(void);
void equalValueCallback(void);
void notEqualValueCallback(void);
void lessThanValueCallback(void);
void greaterThanValueCallback(void);
void openCheatFile(void);
void saveCheatFile(void);
void addActvCheat(void);
void deleteActvCheat(void);
void updateCheatParameters(void);
void autoLoadSaveCheats(int state);
void globalEnableCheats(int state);
void pauseWindowState(int state);
void actvCheatItemClicked(QTreeWidgetItem *item, int column);
};
void openCheatDialog(QWidget *parent);

View File

@ -31,53 +31,55 @@
//----------------------------------------------------
ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
int buf;
QHBoxLayout *hbox1, *hbox2;
QVBoxLayout *vbox1, *vbox2;
QHBoxLayout *hbox, *hbox1, *hbox2;
QVBoxLayout *mainLayout, *vbox1, *vbox2;
QPushButton *closeButton;
QLabel *lbl;
QGroupBox *frame;
QSlider *vslider;
setWindowTitle( tr("Sound Config") );
setWindowTitle(tr("Sound Config"));
mainLayout = new QVBoxLayout();
hbox1 = new QHBoxLayout();
vbox1 = new QVBoxLayout();
// Enable Sound Select
enaChkbox = new QCheckBox( tr("Enable Sound") );
enaChkbox = new QCheckBox(tr("Enable Sound"));
// Enable Low Pass Filter Select
enaLowPass = new QCheckBox( tr("Enable Low Pass Filter") );
enaLowPass = new QCheckBox(tr("Enable Low Pass Filter"));
setCheckBoxFromProperty( enaChkbox , "SDL.Sound" );
setCheckBoxFromProperty( enaLowPass, "SDL.Sound.LowPass" );
setCheckBoxFromProperty(enaChkbox, "SDL.Sound");
setCheckBoxFromProperty(enaLowPass, "SDL.Sound.LowPass");
connect(enaChkbox , SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int)) );
connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int)) );
connect(enaChkbox, SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int)));
connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int)));
vbox1->addWidget( enaChkbox );
vbox1->addWidget( enaLowPass );
vbox1->addWidget(enaChkbox);
vbox1->addWidget(enaLowPass);
// Audio Quality Select
hbox2 = new QHBoxLayout();
lbl = new QLabel( tr("Quality:") );
lbl = new QLabel(tr("Quality:"));
qualitySelect = new QComboBox();
qualitySelect->addItem( tr("Low") , 0 );
qualitySelect->addItem( tr("High") , 1 );
qualitySelect->addItem( tr("Very High"), 2 );
qualitySelect->addItem(tr("Low"), 0);
qualitySelect->addItem(tr("High"), 1);
qualitySelect->addItem(tr("Very High"), 2);
setComboBoxFromProperty( qualitySelect, "SDL.Sound.Quality" );
setComboBoxFromProperty(qualitySelect, "SDL.Sound.Quality");
connect(qualitySelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundQualityChanged(int)) );
connect(qualitySelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundQualityChanged(int)));
hbox2->addWidget( lbl );
hbox2->addWidget( qualitySelect );
hbox2->addWidget(lbl);
hbox2->addWidget(qualitySelect);
vbox1->addLayout( hbox2 );
vbox1->addLayout(hbox2);
// Sample Rate Select
hbox2 = new QHBoxLayout();
@ -86,222 +88,234 @@ ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent)
rateSelect = new QComboBox();
rateSelect->addItem( tr("11025"), 11025 );
rateSelect->addItem( tr("22050"), 22050 );
rateSelect->addItem( tr("44100"), 44100 );
rateSelect->addItem( tr("48000"), 48000 );
rateSelect->addItem( tr("96000"), 96000 );
rateSelect->addItem(tr("11025"), 11025);
rateSelect->addItem(tr("22050"), 22050);
rateSelect->addItem(tr("44100"), 44100);
rateSelect->addItem(tr("48000"), 48000);
rateSelect->addItem(tr("96000"), 96000);
setComboBoxFromProperty( rateSelect, "SDL.Sound.Rate" );
setComboBoxFromProperty(rateSelect, "SDL.Sound.Rate");
connect(rateSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundRateChanged(int)) );
connect(rateSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundRateChanged(int)));
g_config->getOption ("SDL.Sound.Rate", &buf);
g_config->getOption("SDL.Sound.Rate", &buf);
hbox2->addWidget( lbl );
hbox2->addWidget( rateSelect );
hbox2->addWidget(lbl);
hbox2->addWidget(rateSelect);
vbox1->addLayout( hbox2 );
vbox1->addLayout(hbox2);
// Buffer Size Select
//
hbox2 = new QHBoxLayout();
lbl = new QLabel( tr("Buffer Size (in ms):") );
lbl = new QLabel(tr("Buffer Size (in ms):"));
bufSizeLabel = new QLabel("128");
bufSizeSlider = new QSlider( Qt::Horizontal );
bufSizeLabel = new QLabel("128");
bufSizeSlider = new QSlider(Qt::Horizontal);
bufSizeSlider->setMinimum( 15);
bufSizeSlider->setMinimum(15);
bufSizeSlider->setMaximum(200);
//bufSizeSlider->setSliderPosition(128);
setSliderFromProperty( bufSizeSlider, bufSizeLabel, "SDL.Sound.BufSize" );
setSliderFromProperty(bufSizeSlider, bufSizeLabel, "SDL.Sound.BufSize");
hbox2->addWidget( lbl );
hbox2->addWidget( bufSizeLabel );
hbox2->addWidget(lbl);
hbox2->addWidget(bufSizeLabel);
vbox1->addLayout( hbox2 );
vbox1->addWidget( bufSizeSlider );
vbox1->addLayout(hbox2);
vbox1->addWidget(bufSizeSlider);
connect(bufSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(bufSizeChanged(int)));
connect(bufSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(bufSizeChanged(int)) );
// Swap Duty Cycles
swapDutyChkbox = new QCheckBox( tr("Swap Duty Cycles") );
vbox1->addWidget( swapDutyChkbox );
swapDutyChkbox = new QCheckBox(tr("Swap Duty Cycles"));
vbox1->addWidget(swapDutyChkbox);
setCheckBoxFromProperty( swapDutyChkbox , "SDL.SwapDuty" );
setCheckBoxFromProperty(swapDutyChkbox, "SDL.SwapDuty");
connect(swapDutyChkbox , SIGNAL(stateChanged(int)), this, SLOT(swapDutyCallback(int)) );
connect(swapDutyChkbox, SIGNAL(stateChanged(int)), this, SLOT(swapDutyCallback(int)));
hbox1->addLayout( vbox1 );
hbox1->addLayout(vbox1);
frame = new QGroupBox(tr("Mixer:"));
hbox2 = new QHBoxLayout();
frame->setLayout( hbox2 );
frame->setLayout(hbox2);
hbox1->addWidget( frame );
hbox1->addWidget(frame);
frame = new QGroupBox(tr("Volume"));
vbox2 = new QVBoxLayout();
volLbl = new QLabel("150");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
frame = new QGroupBox(tr("Volume"));
vbox2 = new QVBoxLayout();
volLbl = new QLabel("150");
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, volLbl, "SDL.Sound.Volume" );
setSliderFromProperty(vslider, volLbl, "SDL.Sound.Volume");
vbox2->addWidget( volLbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(volLbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)) );
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
frame = new QGroupBox(tr("Triangle"));
vbox2 = new QVBoxLayout();
triLbl = new QLabel("255");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
frame = new QGroupBox(tr("Triangle"));
vbox2 = new QVBoxLayout();
triLbl = new QLabel("255");
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, triLbl, "SDL.Sound.TriangleVolume" );
setSliderFromProperty(vslider, triLbl, "SDL.Sound.TriangleVolume");
vbox2->addWidget( triLbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(triLbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(triangleChanged(int)) );
frame = new QGroupBox(tr("Square1"));
vbox2 = new QVBoxLayout();
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(triangleChanged(int)));
frame = new QGroupBox(tr("Square1"));
vbox2 = new QVBoxLayout();
sqr1Lbl = new QLabel("255");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, sqr1Lbl, "SDL.Sound.Square1Volume" );
setSliderFromProperty(vslider, sqr1Lbl, "SDL.Sound.Square1Volume");
vbox2->addWidget( sqr1Lbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(sqr1Lbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square1Changed(int)) );
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square1Changed(int)));
frame = new QGroupBox(tr("Square2"));
vbox2 = new QVBoxLayout();
frame = new QGroupBox(tr("Square2"));
vbox2 = new QVBoxLayout();
sqr2Lbl = new QLabel("255");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, sqr2Lbl, "SDL.Sound.Square2Volume" );
setSliderFromProperty(vslider, sqr2Lbl, "SDL.Sound.Square2Volume");
vbox2->addWidget( sqr2Lbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(sqr2Lbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square2Changed(int)) );
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square2Changed(int)));
frame = new QGroupBox(tr("Noise"));
vbox2 = new QVBoxLayout();
nseLbl = new QLabel("255");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
frame = new QGroupBox(tr("Noise"));
vbox2 = new QVBoxLayout();
nseLbl = new QLabel("255");
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, nseLbl, "SDL.Sound.NoiseVolume" );
setSliderFromProperty(vslider, nseLbl, "SDL.Sound.NoiseVolume");
vbox2->addWidget( nseLbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(nseLbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(noiseChanged(int)) );
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(noiseChanged(int)));
frame = new QGroupBox(tr("PCM"));
vbox2 = new QVBoxLayout();
pcmLbl = new QLabel("255");
vslider = new QSlider( Qt::Vertical );
vslider->setMinimum( 0);
frame = new QGroupBox(tr("PCM"));
vbox2 = new QVBoxLayout();
pcmLbl = new QLabel("255");
vslider = new QSlider(Qt::Vertical);
vslider->setMinimum(0);
vslider->setMaximum(255);
setSliderFromProperty( vslider, pcmLbl, "SDL.Sound.PCMVolume" );
setSliderFromProperty(vslider, pcmLbl, "SDL.Sound.PCMVolume");
vbox2->addWidget( pcmLbl );
vbox2->addWidget( vslider );
frame->setLayout( vbox2 );
hbox2->addWidget( frame );
vbox2->addWidget(pcmLbl);
vbox2->addWidget(vslider);
frame->setLayout(vbox2);
hbox2->addWidget(frame);
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(pcmChanged(int)) );
connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(pcmChanged(int)));
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout(hbox1);
mainLayout->addLayout( hbox );
// Set Final Layout
setLayout( hbox1 );
setLayout(mainLayout);
}
//----------------------------------------------------
ConsoleSndConfDialog_t::~ConsoleSndConfDialog_t(void)
{
printf("Destroy Sound Config Window\n");
printf("Destroy Sound Config Window\n");
}
//----------------------------------------------------------------------------
void ConsoleSndConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("Sound Config Close Window Event\n");
done(0);
printf("Sound Config Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void ConsoleSndConfDialog_t::closeWindow(void)
{
//printf("Sound Close Window\n");
done(0);
//printf("Sound Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::setCheckBoxFromProperty( QCheckBox *cbx, const char *property )
void ConsoleSndConfDialog_t::setCheckBoxFromProperty(QCheckBox *cbx, const char *property)
{
int pval;
g_config->getOption (property, &pval);
int pval;
g_config->getOption(property, &pval);
cbx->setCheckState( pval ? Qt::Checked : Qt::Unchecked );
cbx->setCheckState(pval ? Qt::Checked : Qt::Unchecked);
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::setComboBoxFromProperty( QComboBox *cbx, const char *property )
void ConsoleSndConfDialog_t::setComboBoxFromProperty(QComboBox *cbx, const char *property)
{
int i, pval;
g_config->getOption (property, &pval);
int i, pval;
g_config->getOption(property, &pval);
for (i=0; i<cbx->count(); i++)
for (i = 0; i < cbx->count(); i++)
{
if ( pval == cbx->itemData(i).toInt() )
if (pval == cbx->itemData(i).toInt())
{
cbx->setCurrentIndex(i); break;
cbx->setCurrentIndex(i);
break;
}
}
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property )
void ConsoleSndConfDialog_t::setSliderFromProperty(QSlider *slider, QLabel *lbl, const char *property)
{
int pval;
int pval;
char stmp[32];
g_config->getOption (property, &pval);
slider->setValue( pval );
sprintf( stmp, "%i", pval );
lbl->setText( stmp );
g_config->getOption(property, &pval);
slider->setValue(pval);
sprintf(stmp, "%i", pval);
lbl->setText(stmp);
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::bufSizeChanged(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
bufSizeLabel->setText(stmp);
g_config->setOption ("SDL.Sound.BufSize", value);
g_config->setOption("SDL.Sound.BufSize", value);
// reset sound subsystem for changes to take effect
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
KillSound ();
InitSound ();
KillSound();
InitSound();
fceuWrapperUnLock();
}
}
@ -310,15 +324,15 @@ void ConsoleSndConfDialog_t::volumeChanged(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
volLbl->setText(stmp);
g_config->setOption ("SDL.Sound.Volume", value);
g_config->setOption("SDL.Sound.Volume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetSoundVolume (value);
FCEUI_SetSoundVolume(value);
fceuWrapperUnLock();
}
}
@ -327,15 +341,15 @@ void ConsoleSndConfDialog_t::triangleChanged(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
triLbl->setText(stmp);
g_config->setOption ("SDL.Sound.TriangleVolume", value);
g_config->setOption("SDL.Sound.TriangleVolume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetTriangleVolume (value);
FCEUI_SetTriangleVolume(value);
fceuWrapperUnLock();
}
}
@ -344,15 +358,15 @@ void ConsoleSndConfDialog_t::square1Changed(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
sqr1Lbl->setText(stmp);
g_config->setOption ("SDL.Sound.Square1Volume", value);
g_config->setOption("SDL.Sound.Square1Volume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetSquare1Volume (value);
FCEUI_SetSquare1Volume(value);
fceuWrapperUnLock();
}
}
@ -361,15 +375,15 @@ void ConsoleSndConfDialog_t::square2Changed(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
sqr2Lbl->setText(stmp);
g_config->setOption ("SDL.Sound.Square2Volume", value);
g_config->setOption("SDL.Sound.Square2Volume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetSquare2Volume (value);
FCEUI_SetSquare2Volume(value);
fceuWrapperUnLock();
}
}
@ -378,15 +392,15 @@ void ConsoleSndConfDialog_t::noiseChanged(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
nseLbl->setText(stmp);
g_config->setOption ("SDL.Sound.NoiseVolume", value);
g_config->setOption("SDL.Sound.NoiseVolume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetNoiseVolume (value);
FCEUI_SetNoiseVolume(value);
fceuWrapperUnLock();
}
}
@ -395,41 +409,41 @@ void ConsoleSndConfDialog_t::pcmChanged(int value)
{
char stmp[32];
sprintf( stmp, "%i", value );
sprintf(stmp, "%i", value);
pcmLbl->setText(stmp);
g_config->setOption ("SDL.Sound.PCMVolume", value);
g_config->setOption("SDL.Sound.PCMVolume", value);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetPCMVolume (value);
FCEUI_SetPCMVolume(value);
fceuWrapperUnLock();
}
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::enaSoundStateChange(int value)
{
if ( value )
if (value)
{
int last_soundopt;
g_config->getOption ("SDL.Sound", &last_soundopt);
g_config->setOption ("SDL.Sound", 1);
g_config->getOption("SDL.Sound", &last_soundopt);
g_config->setOption("SDL.Sound", 1);
fceuWrapperLock();
if (GameInfo && !last_soundopt)
{
InitSound ();
InitSound();
}
fceuWrapperUnLock();
}
else
{
g_config->setOption ("SDL.Sound", 0);
g_config->setOption("SDL.Sound", 0);
fceuWrapperLock();
KillSound ();
KillSound();
fceuWrapperUnLock();
}
}
@ -438,66 +452,66 @@ void ConsoleSndConfDialog_t::enaSoundLowPassChange(int value)
{
if (value)
{
g_config->setOption ("SDL.Sound.LowPass", 1);
g_config->setOption("SDL.Sound.LowPass", 1);
fceuWrapperLock();
FCEUI_SetLowPass (1);
FCEUI_SetLowPass(1);
fceuWrapperUnLock();
}
else
{
g_config->setOption ("SDL.Sound.LowPass", 0);
g_config->setOption("SDL.Sound.LowPass", 0);
fceuWrapperLock();
FCEUI_SetLowPass (0);
FCEUI_SetLowPass(0);
fceuWrapperUnLock();
}
g_config->save ();
g_config->save();
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::swapDutyCallback(int value)
{
if (value)
{
g_config->setOption ("SDL.SwapDuty", 1);
g_config->setOption("SDL.SwapDuty", 1);
swapDuty = 1;
}
else
{
g_config->setOption ("SDL.SwapDuty", 0);
g_config->setOption("SDL.SwapDuty", 0);
swapDuty = 0;
}
g_config->save ();
g_config->save();
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::soundQualityChanged(int index)
{
//printf("Sound Quality: %i : %i \n", index, qualitySelect->itemData(index).toInt() );
g_config->setOption ("SDL.Sound.Quality", qualitySelect->itemData(index).toInt() );
g_config->setOption("SDL.Sound.Quality", qualitySelect->itemData(index).toInt());
// reset sound subsystem for changes to take effect
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
KillSound ();
InitSound ();
KillSound();
InitSound();
fceuWrapperUnLock();
}
g_config->save ();
g_config->save();
}
//----------------------------------------------------
void ConsoleSndConfDialog_t::soundRateChanged(int index)
{
//printf("Sound Rate: %i : %i \n", index, rateSelect->itemData(index).toInt() );
g_config->setOption ("SDL.Sound.Rate", rateSelect->itemData(index).toInt() );
g_config->setOption("SDL.Sound.Rate", rateSelect->itemData(index).toInt());
// reset sound subsystem for changes to take effect
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
KillSound ();
InitSound ();
KillSound();
InitSound();
fceuWrapperUnLock();
}
g_config->save ();
g_config->save();
}
//----------------------------------------------------

View File

@ -18,48 +18,47 @@
class ConsoleSndConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
ConsoleSndConfDialog_t(QWidget *parent = 0);
~ConsoleSndConfDialog_t(void);
public:
ConsoleSndConfDialog_t(QWidget *parent = 0);
~ConsoleSndConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QCheckBox *enaChkbox;
QCheckBox *enaLowPass;
QCheckBox *swapDutyChkbox;
QComboBox *qualitySelect;
QComboBox *rateSelect;
QSlider *bufSizeSlider;
QLabel *bufSizeLabel;
QLabel *volLbl;
QLabel *triLbl;
QLabel *sqr1Lbl;
QLabel *sqr2Lbl;
QLabel *nseLbl;
QLabel *pcmLbl;
QCheckBox *enaChkbox;
QCheckBox *enaLowPass;
QCheckBox *swapDutyChkbox;
QComboBox *qualitySelect;
QComboBox *rateSelect;
QSlider *bufSizeSlider;
QLabel *bufSizeLabel;
QLabel *volLbl;
QLabel *triLbl;
QLabel *sqr1Lbl;
QLabel *sqr2Lbl;
QLabel *nseLbl;
QLabel *pcmLbl;
void setCheckBoxFromProperty( QCheckBox *cbx, const char *property );
void setComboBoxFromProperty( QComboBox *cbx, const char *property );
void setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property );
private slots:
void closeWindow(void);
void bufSizeChanged(int value);
void volumeChanged(int value);
void triangleChanged(int value);
void square1Changed(int value);
void square2Changed(int value);
void noiseChanged(int value);
void pcmChanged(int value);
void enaSoundStateChange(int value);
void enaSoundLowPassChange(int value);
void swapDutyCallback(int value);
void soundQualityChanged(int index);
void soundRateChanged(int index);
void setCheckBoxFromProperty(QCheckBox *cbx, const char *property);
void setComboBoxFromProperty(QComboBox *cbx, const char *property);
void setSliderFromProperty(QSlider *slider, QLabel *lbl, const char *property);
private slots:
void closeWindow(void);
void bufSizeChanged(int value);
void volumeChanged(int value);
void triangleChanged(int value);
void square1Changed(int value);
void square2Changed(int value);
void noiseChanged(int value);
void pcmChanged(int value);
void enaSoundStateChange(int value);
void enaSoundLowPassChange(int value);
void swapDutyCallback(int value);
void soundQualityChanged(int index);
void soundRateChanged(int index);
};
#endif

View File

@ -39,118 +39,127 @@
//----------------------------------------------------------------------------
FrameTimingDialog_t::FrameTimingDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox;
QTreeWidgetItem *item;
QPushButton *resetBtn;
QPushButton *resetBtn, *closeButton;
struct frameTimingStat_t stats;
getFrameTimingStats( &stats );
getFrameTimingStats(&stats);
setWindowTitle("Frame Timing Statistics");
resize( 512, 512 );
resize(512, 512);
mainLayout = new QVBoxLayout();
vbox = new QVBoxLayout();
statFrame = new QGroupBox( tr("Timing Statistics") );
statFrame->setLayout( vbox );
vbox = new QVBoxLayout();
statFrame = new QGroupBox(tr("Timing Statistics"));
statFrame->setLayout(vbox);
tree = new QTreeWidget();
vbox->addWidget( tree );
vbox->addWidget(tree);
tree->setColumnCount(4);
item = new QTreeWidgetItem();
item->setText( 0, tr( "Parameter" ) );
item->setText( 1, tr( "Target" ) );
item->setText( 2, tr( "Current" ) );
item->setText( 3, tr( "Minimum" ) );
item->setText( 4, tr( "Maximum" ) );
item->setTextAlignment( 0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignCenter);
item->setTextAlignment( 2, Qt::AlignCenter);
item->setTextAlignment( 3, Qt::AlignCenter);
item->setTextAlignment( 4, Qt::AlignCenter);
item->setText(0, tr("Parameter"));
item->setText(1, tr("Target"));
item->setText(2, tr("Current"));
item->setText(3, tr("Minimum"));
item->setText(4, tr("Maximum"));
item->setTextAlignment(0, Qt::AlignLeft);
item->setTextAlignment(1, Qt::AlignCenter);
item->setTextAlignment(2, Qt::AlignCenter);
item->setTextAlignment(3, Qt::AlignCenter);
item->setTextAlignment(4, Qt::AlignCenter);
tree->setHeaderItem( item );
tree->header()->setSectionResizeMode( QHeaderView::Stretch );
tree->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
tree->setHeaderItem(item);
tree->header()->setSectionResizeMode(QHeaderView::Stretch);
tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
frameTimeAbs = new QTreeWidgetItem();
frameTimeDel = new QTreeWidgetItem();
frameTimeWork = new QTreeWidgetItem();
frameTimeIdle = new QTreeWidgetItem();
frameTimeAbs = new QTreeWidgetItem();
frameTimeDel = new QTreeWidgetItem();
frameTimeWork = new QTreeWidgetItem();
frameTimeIdle = new QTreeWidgetItem();
frameTimeWorkPct = new QTreeWidgetItem();
frameTimeIdlePct = new QTreeWidgetItem();
frameLateCount = new QTreeWidgetItem();
frameLateCount = new QTreeWidgetItem();
tree->addTopLevelItem( frameTimeAbs );
tree->addTopLevelItem( frameTimeDel );
tree->addTopLevelItem( frameTimeWork );
tree->addTopLevelItem( frameTimeIdle );
tree->addTopLevelItem( frameTimeWorkPct );
tree->addTopLevelItem( frameTimeIdlePct );
tree->addTopLevelItem( frameLateCount );
tree->addTopLevelItem(frameTimeAbs);
tree->addTopLevelItem(frameTimeDel);
tree->addTopLevelItem(frameTimeWork);
tree->addTopLevelItem(frameTimeIdle);
tree->addTopLevelItem(frameTimeWorkPct);
tree->addTopLevelItem(frameTimeIdlePct);
tree->addTopLevelItem(frameLateCount);
frameTimeAbs->setFlags( Qt::ItemIsEnabled | Qt::ItemNeverHasChildren );
frameTimeDel->setFlags( Qt::ItemIsEnabled | Qt::ItemNeverHasChildren );
frameTimeAbs->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
frameTimeDel->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
frameTimeAbs->setText( 0, tr("Frame Period ms") );
frameTimeDel->setText( 0, tr("Frame Delta ms") );
frameTimeWork->setText( 0, tr("Frame Work ms") );
frameTimeIdle->setText( 0, tr("Frame Idle ms") );
frameTimeWorkPct->setText( 0, tr("Frame Work %") );
frameTimeIdlePct->setText( 0, tr("Frame Idle %") );
frameLateCount->setText( 0, tr("Frame Late Count") );
frameTimeAbs->setText(0, tr("Frame Period ms"));
frameTimeDel->setText(0, tr("Frame Delta ms"));
frameTimeWork->setText(0, tr("Frame Work ms"));
frameTimeIdle->setText(0, tr("Frame Idle ms"));
frameTimeWorkPct->setText(0, tr("Frame Work %"));
frameTimeIdlePct->setText(0, tr("Frame Idle %"));
frameLateCount->setText(0, tr("Frame Late Count"));
frameTimeAbs->setTextAlignment( 0, Qt::AlignLeft);
frameTimeDel->setTextAlignment( 0, Qt::AlignLeft);
frameTimeWork->setTextAlignment( 0, Qt::AlignLeft);
frameTimeIdle->setTextAlignment( 0, Qt::AlignLeft);
frameTimeWorkPct->setTextAlignment( 0, Qt::AlignLeft);
frameTimeIdlePct->setTextAlignment( 0, Qt::AlignLeft);
frameLateCount->setTextAlignment( 0, Qt::AlignLeft);
frameTimeAbs->setTextAlignment(0, Qt::AlignLeft);
frameTimeDel->setTextAlignment(0, Qt::AlignLeft);
frameTimeWork->setTextAlignment(0, Qt::AlignLeft);
frameTimeIdle->setTextAlignment(0, Qt::AlignLeft);
frameTimeWorkPct->setTextAlignment(0, Qt::AlignLeft);
frameTimeIdlePct->setTextAlignment(0, Qt::AlignLeft);
frameLateCount->setTextAlignment(0, Qt::AlignLeft);
for (int i=0; i<4; i++)
for (int i = 0; i < 4; i++)
{
frameTimeAbs->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeDel->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeWork->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeIdle->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeWorkPct->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeIdlePct->setTextAlignment( i+1, Qt::AlignCenter);
frameLateCount->setTextAlignment( i+1, Qt::AlignCenter);
frameTimeAbs->setTextAlignment(i + 1, Qt::AlignCenter);
frameTimeDel->setTextAlignment(i + 1, Qt::AlignCenter);
frameTimeWork->setTextAlignment(i + 1, Qt::AlignCenter);
frameTimeIdle->setTextAlignment(i + 1, Qt::AlignCenter);
frameTimeWorkPct->setTextAlignment(i + 1, Qt::AlignCenter);
frameTimeIdlePct->setTextAlignment(i + 1, Qt::AlignCenter);
frameLateCount->setTextAlignment(i + 1, Qt::AlignCenter);
}
hbox = new QHBoxLayout();
timingEnable = new QCheckBox( tr("Enable Timing Statistics Calculations") );
resetBtn = new QPushButton( tr("Reset") );
hbox = new QHBoxLayout();
timingEnable = new QCheckBox(tr("Enable Timing Statistics Calculations"));
resetBtn = new QPushButton(tr("Reset"));
resetBtn->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
timingEnable->setChecked( stats.enabled );
statFrame->setEnabled( stats.enabled );
timingEnable->setChecked(stats.enabled);
statFrame->setEnabled(stats.enabled);
hbox->addWidget( timingEnable );
hbox->addWidget( resetBtn );
hbox->addWidget(timingEnable);
hbox->addWidget(resetBtn);
connect( timingEnable, SIGNAL(stateChanged(int)), this, SLOT(timingEnableChanged(int)) );
connect( resetBtn , SIGNAL(clicked(void)) , this, SLOT(resetTimingClicked(void)) );
connect(timingEnable, SIGNAL(stateChanged(int)), this, SLOT(timingEnableChanged(int)));
connect(resetBtn, SIGNAL(clicked(void)), this, SLOT(resetTimingClicked(void)));
mainLayout->addLayout( hbox );
mainLayout->addWidget( statFrame );
mainLayout->addLayout(hbox);
mainLayout->addWidget(statFrame);
setLayout( mainLayout );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout(mainLayout);
updateTimingStats();
updateTimer = new QTimer( this );
updateTimer = new QTimer(this);
connect( updateTimer, &QTimer::timeout, this, &FrameTimingDialog_t::updatePeriodic );
updateTimer->start( 200 ); // 5hz
connect(updateTimer, &QTimer::timeout, this, &FrameTimingDialog_t::updatePeriodic);
updateTimer->start(200); // 5hz
}
//----------------------------------------------------------------------------
FrameTimingDialog_t::~FrameTimingDialog_t(void)
@ -179,92 +188,92 @@ void FrameTimingDialog_t::updateTimingStats(void)
char stmp[128];
struct frameTimingStat_t stats;
getFrameTimingStats( &stats );
getFrameTimingStats(&stats);
// Absolute
sprintf( stmp, "%.3f", stats.frameTimeAbs.tgt * 1e3 );
frameTimeAbs->setText( 1, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeAbs.tgt * 1e3);
frameTimeAbs->setText(1, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeAbs.cur * 1e3 );
frameTimeAbs->setText( 2, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeAbs.cur * 1e3);
frameTimeAbs->setText(2, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeAbs.min * 1e3 );
frameTimeAbs->setText( 3, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeAbs.min * 1e3);
frameTimeAbs->setText(3, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeAbs.max * 1e3 );
frameTimeAbs->setText( 4, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeAbs.max * 1e3);
frameTimeAbs->setText(4, tr(stmp));
// Delta
sprintf( stmp, "%.3f", stats.frameTimeDel.tgt * 1e3 );
frameTimeDel->setText( 1, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeDel.tgt * 1e3);
frameTimeDel->setText(1, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeDel.cur * 1e3 );
frameTimeDel->setText( 2, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeDel.cur * 1e3);
frameTimeDel->setText(2, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeDel.min * 1e3 );
frameTimeDel->setText( 3, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeDel.min * 1e3);
frameTimeDel->setText(3, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeDel.max * 1e3 );
frameTimeDel->setText( 4, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeDel.max * 1e3);
frameTimeDel->setText(4, tr(stmp));
// Work
sprintf( stmp, "lt %.3f", stats.frameTimeWork.tgt * 1e3 );
frameTimeWork->setText( 1, tr(stmp) );
sprintf(stmp, "lt %.3f", stats.frameTimeWork.tgt * 1e3);
frameTimeWork->setText(1, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeWork.cur * 1e3 );
frameTimeWork->setText( 2, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeWork.cur * 1e3);
frameTimeWork->setText(2, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeWork.min * 1e3 );
frameTimeWork->setText( 3, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeWork.min * 1e3);
frameTimeWork->setText(3, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeWork.max * 1e3 );
frameTimeWork->setText( 4, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeWork.max * 1e3);
frameTimeWork->setText(4, tr(stmp));
// Idle
sprintf( stmp, "gt %.3f", stats.frameTimeIdle.tgt * 1e3 );
frameTimeIdle->setText( 1, tr(stmp) );
sprintf(stmp, "gt %.3f", stats.frameTimeIdle.tgt * 1e3);
frameTimeIdle->setText(1, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeIdle.cur * 1e3 );
frameTimeIdle->setText( 2, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeIdle.cur * 1e3);
frameTimeIdle->setText(2, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeIdle.min * 1e3 );
frameTimeIdle->setText( 3, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeIdle.min * 1e3);
frameTimeIdle->setText(3, tr(stmp));
sprintf( stmp, "%.3f", stats.frameTimeIdle.max * 1e3 );
frameTimeIdle->setText( 4, tr(stmp) );
sprintf(stmp, "%.3f", stats.frameTimeIdle.max * 1e3);
frameTimeIdle->setText(4, tr(stmp));
// Work %
sprintf( stmp, "lt %.1f", 100.0 * stats.frameTimeWork.tgt / stats.frameTimeAbs.tgt );
frameTimeWorkPct->setText( 1, tr(stmp) );
sprintf(stmp, "lt %.1f", 100.0 * stats.frameTimeWork.tgt / stats.frameTimeAbs.tgt);
frameTimeWorkPct->setText(1, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.cur / stats.frameTimeAbs.tgt );
frameTimeWorkPct->setText( 2, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.cur / stats.frameTimeAbs.tgt);
frameTimeWorkPct->setText(2, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.min / stats.frameTimeAbs.tgt );
frameTimeWorkPct->setText( 3, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.min / stats.frameTimeAbs.tgt);
frameTimeWorkPct->setText(3, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.max / stats.frameTimeAbs.tgt );
frameTimeWorkPct->setText( 4, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.max / stats.frameTimeAbs.tgt);
frameTimeWorkPct->setText(4, tr(stmp));
// Idle %
sprintf( stmp, "gt %.1f", 100.0 * stats.frameTimeIdle.tgt / stats.frameTimeAbs.tgt );
frameTimeIdlePct->setText( 1, tr(stmp) );
sprintf(stmp, "gt %.1f", 100.0 * stats.frameTimeIdle.tgt / stats.frameTimeAbs.tgt);
frameTimeIdlePct->setText(1, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.cur / stats.frameTimeAbs.tgt );
frameTimeIdlePct->setText( 2, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.cur / stats.frameTimeAbs.tgt);
frameTimeIdlePct->setText(2, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.min / stats.frameTimeAbs.tgt );
frameTimeIdlePct->setText( 3, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.min / stats.frameTimeAbs.tgt);
frameTimeIdlePct->setText(3, tr(stmp));
sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.max / stats.frameTimeAbs.tgt );
frameTimeIdlePct->setText( 4, tr(stmp) );
sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.max / stats.frameTimeAbs.tgt);
frameTimeIdlePct->setText(4, tr(stmp));
// Late Count
sprintf( stmp, "%u", stats.lateCount );
frameLateCount->setText( 1, tr("0") );
frameLateCount->setText( 2, tr(stmp) );
sprintf(stmp, "%u", stats.lateCount);
frameLateCount->setText(1, tr("0"));
frameLateCount->setText(2, tr(stmp));
statFrame->setEnabled( stats.enabled );
statFrame->setEnabled(stats.enabled);
tree->viewport()->update();
}
@ -276,7 +285,7 @@ void FrameTimingDialog_t::updatePeriodic(void)
//----------------------------------------------------------------------------
void FrameTimingDialog_t::timingEnableChanged(int state)
{
setFrameTimingEnable( state != Qt::Unchecked );
setFrameTimingEnable(state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void FrameTimingDialog_t::resetTimingClicked(void)

View File

@ -21,36 +21,35 @@
class FrameTimingDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
FrameTimingDialog_t(QWidget *parent = 0);
~FrameTimingDialog_t(void);
public:
FrameTimingDialog_t(QWidget *parent = 0);
~FrameTimingDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QTimer *updateTimer;
QCheckBox *timingEnable;
QTreeWidgetItem *frameTimeAbs;
QTreeWidgetItem *frameTimeDel;
QTreeWidgetItem *frameTimeWork;
QTreeWidgetItem *frameTimeWorkPct;
QTreeWidgetItem *frameTimeIdle;
QTreeWidgetItem *frameTimeIdlePct;
QTreeWidgetItem *frameLateCount;
QGroupBox *statFrame;
QTimer *updateTimer;
QCheckBox *timingEnable;
QTreeWidgetItem *frameTimeAbs;
QTreeWidgetItem *frameTimeDel;
QTreeWidgetItem *frameTimeWork;
QTreeWidgetItem *frameTimeWorkPct;
QTreeWidgetItem *frameTimeIdle;
QTreeWidgetItem *frameTimeIdlePct;
QTreeWidgetItem *frameLateCount;
QGroupBox *statFrame;
QTreeWidget *tree;
QTreeWidget *tree;
private:
void updateTimingStats(void);
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void resetTimingClicked(void);
void timingEnableChanged(int state);
private:
void updateTimingStats(void);
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void resetTimingClicked(void);
void timingEnableChanged(int state);
};

File diff suppressed because it is too large Load Diff

View File

@ -19,127 +19,128 @@
#include "Qt/main.h"
class GamePadConfigButton_t : public QPushButton
{
public:
GamePadConfigButton_t(int i);
{
public:
GamePadConfigButton_t(int i);
protected:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
protected:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
int idx;
int idx;
};
class GamePadView_t : public QWidget
{
Q_OBJECT
public:
GamePadView_t( QWidget *parent = 0);
~GamePadView_t(void);
public:
GamePadView_t(QWidget *parent = 0);
~GamePadView_t(void);
void setPort( int port );
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent * event);
//void contextMenuEvent(QContextMenuEvent *event);
void setPort(int port);
void drawLetterOnButton( QPainter &painter, QRect &rect, QColor &color, int ch );
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
//void contextMenuEvent(QContextMenuEvent *event);
int portNum;
int viewWidth;
int viewHeight;
int pxCharWidth;
int pxCharHeight;
void drawLetterOnButton(QPainter &painter, QRect &rect, QColor &color, int ch);
QFont font;
int portNum;
int viewWidth;
int viewHeight;
int pxCharWidth;
int pxCharHeight;
QFont font;
};
class GamePadConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
GamePadConfDialog_t(QWidget *parent = 0);
~GamePadConfDialog_t(void);
public:
GamePadConfDialog_t(QWidget *parent = 0);
~GamePadConfDialog_t(void);
protected:
void resizeEvent(QResizeEvent *event);
protected:
void resizeEvent(QResizeEvent *event);
QWidget *mainWidget;
QTimer *inputTimer;
QComboBox *portSel;
QComboBox *devSel;
QComboBox *mapSel;
QComboBox *profSel;
QCheckBox *efs_chkbox;
QLabel *guidLbl;
QLabel *mapMsg;
QLabel *keyName[GAMEPAD_NUM_BUTTONS];
QLabel *keyState[GAMEPAD_NUM_BUTTONS];
GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS];
GamePadView_t *gpView;
QWidget *mainWidget;
QTimer *inputTimer;
QComboBox *portSel;
QComboBox *devSel;
QComboBox *mapSel;
QComboBox *profSel;
QCheckBox *efs_chkbox;
QLabel *guidLbl;
QLabel *mapMsg;
QLabel *keyName[GAMEPAD_NUM_BUTTONS];
QLabel *keyState[GAMEPAD_NUM_BUTTONS];
GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS];
GamePadView_t *gpView;
int portNum;
int buttonConfigStatus;
int changeSeqStatus; // status of sequentally changing buttons mechanism
// 0 - we can start new change process
// 1-10 - changing in progress
// -1 - changing is aborted
void changeButton( int port, int button );
void clearButton( int port, int button );
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *bar);
private:
void updateCntrlrDpy(void);
void createNewProfile( const char *name );
void loadMapList(void);
void saveConfig(void);
void promptToSave(void);
int portNum;
int buttonConfigStatus;
int changeSeqStatus; // status of sequentally changing buttons mechanism
// 0 - we can start new change process
// 1-10 - changing in progress
// -1 - changing is aborted
public slots:
void closeWindow(void);
private slots:
void changeButton0(void);
void changeButton1(void);
void changeButton2(void);
void changeButton3(void);
void changeButton4(void);
void changeButton5(void);
void changeButton6(void);
void changeButton7(void);
void changeButton8(void);
void changeButton9(void);
void clearButton0(void);
void clearButton1(void);
void clearButton2(void);
void clearButton3(void);
void clearButton4(void);
void clearButton5(void);
void clearButton6(void);
void clearButton7(void);
void clearButton8(void);
void clearButton9(void);
void clearAllCallback(void);
void ena4score(int state);
void oppDirEna(int state);
void portSelect(int index);
void deviceSelect(int index);
void newProfileCallback(void);
void loadProfileCallback(void);
void saveProfileCallback(void);
void deleteProfileCallback(void);
void updatePeriodic(void);
void changeSequentallyCallback(void);
void changeButton(int port, int button);
void clearButton(int port, int button);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *bar);
private:
void updateCntrlrDpy(void);
void createNewProfile(const char *name);
void loadMapList(void);
void saveConfig(void);
void promptToSave(void);
public slots:
void closeWindow(void);
private slots:
void changeButton0(void);
void changeButton1(void);
void changeButton2(void);
void changeButton3(void);
void changeButton4(void);
void changeButton5(void);
void changeButton6(void);
void changeButton7(void);
void changeButton8(void);
void changeButton9(void);
void clearButton0(void);
void clearButton1(void);
void clearButton2(void);
void clearButton3(void);
void clearButton4(void);
void clearButton5(void);
void clearButton6(void);
void clearButton7(void);
void clearButton8(void);
void clearButton9(void);
void clearAllCallback(void);
void ena4score(int state);
void oppDirEna(int state);
void portSelect(int index);
void deviceSelect(int index);
void newProfileCallback(void);
void loadProfileCallback(void);
void saveProfileCallback(void);
void deleteProfileCallback(void);
void updatePeriodic(void);
void changeSequentallyCallback(void);
};
int openGamePadConfWindow( QWidget *parent );
int openGamePadConfWindow(QWidget *parent);
int closeGamePadConfWindow(void);

View File

@ -31,55 +31,67 @@
//----------------------------------------------------
GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
int useNativeFileDialogVal;
int useNativeMenuBarVal;
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
//resize( 512, 600 );
// sync with config
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption ("SDL.UseNativeMenuBar", &useNativeMenuBarVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeMenuBar", &useNativeMenuBarVal);
setWindowTitle( tr("GUI Config") );
setWindowTitle(tr("GUI Config"));
mainLayout = new QVBoxLayout();
useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") );
useNativeMenuBar = new QCheckBox( tr("Use Native OS Menu Bar") );
useNativeFileDialog = new QCheckBox(tr("Use Native OS File Dialog"));
useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar"));
useNativeFileDialog->setChecked( useNativeFileDialogVal );
useNativeMenuBar->setChecked( useNativeMenuBarVal );
useNativeFileDialog->setChecked(useNativeFileDialogVal);
useNativeMenuBar->setChecked(useNativeMenuBarVal);
connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) );
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)) );
connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
connect(useNativeMenuBar, SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
mainLayout->addWidget( useNativeFileDialog );
mainLayout->addWidget( useNativeMenuBar );
mainLayout->addWidget(useNativeFileDialog);
mainLayout->addWidget(useNativeMenuBar);
setLayout( mainLayout );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(3);
hbox->addWidget( closeButton, 3 );
hbox->addStretch(3);
mainLayout->addLayout( hbox );
setLayout(mainLayout);
}
//----------------------------------------------------
GuiConfDialog_t::~GuiConfDialog_t(void)
{
printf("Destroy GUI Config Close Window\n");
printf("Destroy GUI Config Close Window\n");
}
//----------------------------------------------------------------------------
void GuiConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("GUI Config Close Window Event\n");
done(0);
printf("GUI Config Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------
void GuiConfDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------
@ -87,15 +99,15 @@ void GuiConfDialog_t::useNativeFileDialogChanged(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
g_config->setOption ("SDL.UseNativeFileDialog", value);
g_config->setOption("SDL.UseNativeFileDialog", value);
}
//----------------------------------------------------
void GuiConfDialog_t::useNativeMenuBarChanged(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
g_config->setOption ("SDL.UseNativeMenuBar", value);
g_config->setOption("SDL.UseNativeMenuBar", value);
consoleWindow->menuBar()->setNativeMenuBar( value );
consoleWindow->menuBar()->setNativeMenuBar(value);
}
//----------------------------------------------------

View File

@ -19,23 +19,22 @@
class GuiConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
GuiConfDialog_t(QWidget *parent = 0);
~GuiConfDialog_t(void);
public:
GuiConfDialog_t(QWidget *parent = 0);
~GuiConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QCheckBox *useNativeFileDialog;
QCheckBox *useNativeMenuBar;
private:
public slots:
void closeWindow(void);
private slots:
void useNativeFileDialogChanged(int v);
void useNativeMenuBarChanged(int v);
QCheckBox *useNativeFileDialog;
QCheckBox *useNativeMenuBar;
private:
public slots:
void closeWindow(void);
private slots:
void useNativeFileDialogChanged(int v);
void useNativeMenuBarChanged(int v);
};

View File

@ -38,15 +38,17 @@
//----------------------------------------------------------------------------
HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
QTreeWidgetItem *item;
std::string prefix = "SDL.Hotkeys.";
setWindowTitle("Hotkey Configuration");
resize( 512, 512 );
resize(512, 512);
mainLayout = new QVBoxLayout();
@ -55,36 +57,45 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
tree->setColumnCount(2);
item = new QTreeWidgetItem();
item->setText( 0, QString::fromStdString( "Command" ) );
item->setText( 1, QString::fromStdString( "Key" ) );
item->setTextAlignment( 0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignCenter);
item->setText(0, QString::fromStdString("Command"));
item->setText(1, QString::fromStdString("Key"));
item->setTextAlignment(0, Qt::AlignLeft);
item->setTextAlignment(1, Qt::AlignCenter);
tree->setHeaderItem( item );
tree->setHeaderItem(item);
tree->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
for (int i=0; i<HK_MAX; i++)
for (int i = 0; i < HK_MAX; i++)
{
char keyName[128];
std::string optionName = prefix + getHotkeyString(i);
//g_config->getOption (optionName.c_str (), &keycode);
Hotkeys[i].getString( keyName );
Hotkeys[i].getString(keyName);
item = new QTreeWidgetItem();
item->setText( 0, QString::fromStdString( optionName ) );
item->setText( 1, QString::fromStdString( keyName ) );
item->setText(0, QString::fromStdString(optionName));
item->setText(1, QString::fromStdString(keyName));
item->setTextAlignment( 0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignCenter);
item->setTextAlignment(0, Qt::AlignLeft);
item->setTextAlignment(1, Qt::AlignCenter);
tree->addTopLevelItem( item );
tree->addTopLevelItem(item);
}
mainLayout->addWidget( tree );
mainLayout->addWidget(tree);
setLayout( mainLayout );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout(mainLayout);
}
//----------------------------------------------------------------------------
HotKeyConfDialog_t::~HotKeyConfDialog_t(void)
@ -94,94 +105,96 @@ HotKeyConfDialog_t::~HotKeyConfDialog_t(void)
//----------------------------------------------------------------------------
void HotKeyConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("Hot Key Close Window Event\n");
done(0);
printf("Hot Key Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void HotKeyConfDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
{
bool keyIsModifier;
SDL_Keycode k = convQtKey2SDLKeyCode( (Qt::Key)event->key() );
SDL_Keymod m = convQtKey2SDLModifier( event->modifiers() );
keyIsModifier = (k == SDLK_LCTRL ) || (k == SDLK_RCTRL ) ||
(k == SDLK_LSHIFT) || (k == SDLK_RSHIFT) ||
(k == SDLK_LALT ) || (k == SDLK_RALT ) ||
(k == SDLK_LGUI ) || (k == SDLK_RGUI ) ||
(k == SDLK_CAPSLOCK);
SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)event->key());
SDL_Keymod m = convQtKey2SDLModifier(event->modifiers());
if ( (k != SDLK_UNKNOWN) && !keyIsModifier )
keyIsModifier = (k == SDLK_LCTRL) || (k == SDLK_RCTRL) ||
(k == SDLK_LSHIFT) || (k == SDLK_RSHIFT) ||
(k == SDLK_LALT) || (k == SDLK_RALT) ||
(k == SDLK_LGUI) || (k == SDLK_RGUI) ||
(k == SDLK_CAPSLOCK);
if ((k != SDLK_UNKNOWN) && !keyIsModifier)
{
QList <QTreeWidgetItem *> l;
QList<QTreeWidgetItem *> l;
l = tree->selectedItems();
for (size_t i=0; i < l.size(); i++)
for (size_t i = 0; i < l.size(); i++)
{
int j,idx;
int j, idx;
QString qs;
QTreeWidgetItem *item;
std::string keyText;
char keyName[128];
char buf[256];
keyText.assign(" mod=");
j=0;
if ( m & (KMOD_LSHIFT | KMOD_RSHIFT) )
j = 0;
if (m & (KMOD_LSHIFT | KMOD_RSHIFT))
{
if ( j > 0 )
if (j > 0)
{
keyText.append("+");
keyText.append("+");
}
keyText.append("Shift"); j++;
keyText.append("Shift");
j++;
}
if ( m & (KMOD_LALT | KMOD_RALT) )
if (m & (KMOD_LALT | KMOD_RALT))
{
if ( j > 0 )
if (j > 0)
{
keyText.append("+");
keyText.append("+");
}
keyText.append("Alt"); j++;
keyText.append("Alt");
j++;
}
if ( m & (KMOD_LCTRL | KMOD_RCTRL) )
if (m & (KMOD_LCTRL | KMOD_RCTRL))
{
if ( j > 0 )
if (j > 0)
{
keyText.append("+");
keyText.append("+");
}
keyText.append("Ctrl"); j++;
keyText.append("Ctrl");
j++;
}
sprintf( buf, " key=%s", SDL_GetKeyName( k ) );
sprintf(buf, " key=%s", SDL_GetKeyName(k));
keyText.append( buf );
keyText.append(buf);
item = l.at(i);
idx = tree->indexOfTopLevelItem( item );
idx = tree->indexOfTopLevelItem(item);
qs = item->text(0);
g_config->setOption ( qs.toStdString(), keyText );
g_config->setOption(qs.toStdString(), keyText);
setHotKeys();
Hotkeys[idx].getString( keyName );
Hotkeys[idx].getString(keyName);
item->setText( 1, QString::fromStdString( keyName ) );
item->setText(1, QString::fromStdString(keyName));
//printf("Hotkey Window Key Press: 0x%x item:%p\n '%s' : %i\n",
//printf("Hotkey Window Key Press: 0x%x item:%p\n '%s' : %i\n",
// k, item, qs.toStdString().c_str(), idx );
}
}
@ -189,13 +202,13 @@ void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
//----------------------------------------------------------------------------
void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event)
{
//printf("Hotkey Window Key Press: 0x%x \n", event->key() );
assignHotkey( event );
//printf("Hotkey Window Key Press: 0x%x \n", event->key() );
assignHotkey(event);
}
//----------------------------------------------------------------------------
void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event)
{
//printf("Hotkey Window Key Release: 0x%x \n", event->key() );
assignHotkey( event );
//printf("Hotkey Window Key Release: 0x%x \n", event->key() );
assignHotkey(event);
}
//----------------------------------------------------------------------------

View File

@ -20,24 +20,22 @@
class HotKeyConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
HotKeyConfDialog_t(QWidget *parent = 0);
~HotKeyConfDialog_t(void);
public:
HotKeyConfDialog_t(QWidget *parent = 0);
~HotKeyConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void assignHotkey(QKeyEvent *event);
protected:
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void assignHotkey(QKeyEvent *event);
QTreeWidget *tree;
private:
public slots:
void closeWindow(void);
private slots:
QTreeWidget *tree;
private:
public slots:
void closeWindow(void);
private slots:
};

View File

@ -42,9 +42,9 @@
static InputConfDialog_t *win = NULL;
//----------------------------------------------------------------------------
void openInputConfWindow( QWidget *parent )
void openInputConfWindow(QWidget *parent)
{
if ( win != NULL )
if (win != NULL)
{
return;
}
@ -54,194 +54,204 @@ void openInputConfWindow( QWidget *parent )
}
//----------------------------------------------------------------------------
InputConfDialog_t::InputConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout, *vbox1, *vbox;
QHBoxLayout *hbox;
QGroupBox *nesInputFrame, *port1Frame, *port2Frame;
QGroupBox *presetFrame, *expansionPortFrame;
QPalette pal;
QColor color;
QGroupBox *nesInputFrame, *port1Frame, *port2Frame;
QGroupBox *presetFrame, *expansionPortFrame;
QPushButton *closeButton;
QPalette pal;
QColor color;
char stmp[256];
int fourscore, autoInputPreset;
int fourscore, autoInputPreset;
pal = this->palette();
inputTimer = new QTimer( this );
inputTimer = new QTimer(this);
connect( inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic );
connect(inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic);
setWindowTitle("Input Configuration");
mainLayout = new QVBoxLayout();
nesInputFrame = new QGroupBox( tr("NES-Style Input Ports") );
vbox1 = new QVBoxLayout();
hbox = new QHBoxLayout();
fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") );
port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") );
autoPreset = new QCheckBox( tr("Auto Load/Save Presets at ROM Open/Close") );
nesInputFrame = new QGroupBox(tr("NES-Style Input Ports"));
vbox1 = new QVBoxLayout();
hbox = new QHBoxLayout();
fourScoreEna = new QCheckBox(tr("Attach 4-Score (Implies four gamepads)"));
port2Mic = new QCheckBox(tr("Replace Port 2 Start with Microphone"));
autoPreset = new QCheckBox(tr("Auto Load/Save Presets at ROM Open/Close"));
g_config->getOption("SDL.FourScore", &fourscore);
fourScoreEna->setChecked( fourscore );
port2Mic->setChecked( replaceP2StartWithMicrophone );
fourScoreEna->setChecked(fourscore);
port2Mic->setChecked(replaceP2StartWithMicrophone);
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
autoPreset->setChecked( autoInputPreset );
g_config->getOption("SDL.AutoInputPreset", &autoInputPreset);
autoPreset->setChecked(autoInputPreset);
hbox->addWidget( fourScoreEna );
hbox->addWidget( port2Mic );
vbox1->addLayout( hbox );
hbox->addWidget(fourScoreEna);
hbox->addWidget(port2Mic);
vbox1->addLayout(hbox);
hbox = new QHBoxLayout();
port1Frame = new QGroupBox( tr("Port 1:") );
port2Frame = new QGroupBox( tr("Port 2:") );
hbox = new QHBoxLayout();
port1Frame = new QGroupBox(tr("Port 1:"));
port2Frame = new QGroupBox(tr("Port 2:"));
hbox->addWidget( port1Frame );
hbox->addWidget( port2Frame );
vbox1->addLayout( hbox );
hbox->addWidget(port1Frame);
hbox->addWidget(port2Frame);
vbox1->addLayout(hbox);
nesPortComboxBox[0] = new QComboBox();
nesPortComboxBox[1] = new QComboBox();
expPortComboxBox = new QComboBox();
expPortComboxBox = new QComboBox();
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
hbox->addWidget( nesPortLabel[0] = new QLabel( tr("<None>") ) );
hbox->addWidget( nesPortConfButton[0] = new QPushButton( tr("Configure") ) );
vbox->addWidget( nesPortComboxBox[0] );
vbox->addLayout(hbox);
hbox->addWidget(nesPortLabel[0] = new QLabel(tr("<None>")));
hbox->addWidget(nesPortConfButton[0] = new QPushButton(tr("Configure")));
vbox->addWidget(nesPortComboxBox[0]);
port1Frame->setLayout( vbox );
port1Frame->setLayout(vbox);
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
hbox->addWidget( nesPortLabel[1] = new QLabel( tr("<None>") ) );
hbox->addWidget( nesPortConfButton[1] = new QPushButton( tr("Configure") ) );
vbox->addWidget( nesPortComboxBox[1] );
vbox->addLayout(hbox);
hbox->addWidget(nesPortLabel[1] = new QLabel(tr("<None>")));
hbox->addWidget(nesPortConfButton[1] = new QPushButton(tr("Configure")));
vbox->addWidget(nesPortComboxBox[1]);
port2Frame->setLayout( vbox );
port2Frame->setLayout(vbox);
nesInputFrame->setLayout( vbox1 );
nesInputFrame->setLayout(vbox1);
nesPortConfButton[0]->setEnabled(false);
nesPortConfButton[1]->setEnabled(false);
mainLayout->addWidget( nesInputFrame );
mainLayout->addWidget(nesInputFrame);
hbox = new QHBoxLayout();
presetFrame = new QGroupBox( tr("Input Presets:") );
expansionPortFrame = new QGroupBox( tr("Famicom Expansion Port:") );
hbox = new QHBoxLayout();
presetFrame = new QGroupBox(tr("Input Presets:"));
expansionPortFrame = new QGroupBox(tr("Famicom Expansion Port:"));
hbox->addWidget( presetFrame );
hbox->addWidget( expansionPortFrame );
hbox->addWidget(presetFrame);
hbox->addWidget(expansionPortFrame);
mainLayout->addLayout( hbox );
mainLayout->addLayout(hbox);
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
hbox->addWidget( autoPreset );
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox->addLayout(hbox);
hbox->addWidget(autoPreset);
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
hbox->addWidget( loadConfigButton = new QPushButton( tr("Load") ) );
hbox->addWidget( saveConfigButton = new QPushButton( tr("Save") ) );
hbox = new QHBoxLayout();
vbox->addLayout(hbox);
hbox->addWidget(loadConfigButton = new QPushButton(tr("Load")));
hbox->addWidget(saveConfigButton = new QPushButton(tr("Save")));
presetFrame->setLayout( vbox );
presetFrame->setLayout(vbox);
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
hbox->addWidget( expPortLabel = new QLabel( tr("<None>") ) );
hbox->addWidget( expPortConfButton = new QPushButton( tr("Configure") ) );
vbox->addWidget( expPortComboxBox );
vbox->addLayout(hbox);
hbox->addWidget(expPortLabel = new QLabel(tr("<None>")));
hbox->addWidget(expPortConfButton = new QPushButton(tr("Configure")));
vbox->addWidget(expPortComboxBox);
expPortConfButton->setEnabled(false);
expansionPortFrame->setLayout( vbox );
expansionPortFrame->setLayout(vbox);
color = pal.color(QPalette::WindowText);
sprintf( stmp, "border: 2px solid #%02X%02X%02X", color.red(), color.green(), color.blue() );
sprintf(stmp, "border: 2px solid #%02X%02X%02X", color.red(), color.green(), color.blue());
//printf("%s\n", stmp);
nesPortLabel[0]->setAlignment(Qt::AlignCenter);
nesPortLabel[1]->setAlignment(Qt::AlignCenter);
expPortLabel->setAlignment(Qt::AlignCenter);
nesPortLabel[0]->setStyleSheet( stmp );
nesPortLabel[1]->setStyleSheet( stmp );
expPortLabel->setStyleSheet( stmp );
nesPortLabel[0]->setStyleSheet(stmp);
nesPortLabel[1]->setStyleSheet(stmp);
expPortLabel->setStyleSheet(stmp);
setLayout( mainLayout );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
for (int i=0; i<2; i++)
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout(mainLayout);
for (int i = 0; i < 2; i++)
{
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
nesPortComboxBox[i]->addItem( tr("<None>") , SI_NONE );
nesPortComboxBox[i]->addItem( tr("Gamepad") , SI_GAMEPAD );
nesPortComboxBox[i]->addItem( tr("Zapper") , SI_ZAPPER );
nesPortComboxBox[i]->addItem( tr("Power Pad A") , SI_POWERPADA );
nesPortComboxBox[i]->addItem( tr("Power Pad B") , SI_POWERPADB );
nesPortComboxBox[i]->addItem( tr("Arkanoid Paddle") , SI_ARKANOID );
getInputSelection(i, &curNesInput[i], &usrNesInput[i]);
nesPortComboxBox[i]->addItem(tr("<None>"), SI_NONE);
nesPortComboxBox[i]->addItem(tr("Gamepad"), SI_GAMEPAD);
nesPortComboxBox[i]->addItem(tr("Zapper"), SI_ZAPPER);
nesPortComboxBox[i]->addItem(tr("Power Pad A"), SI_POWERPADA);
nesPortComboxBox[i]->addItem(tr("Power Pad B"), SI_POWERPADB);
nesPortComboxBox[i]->addItem(tr("Arkanoid Paddle"), SI_ARKANOID);
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
for (int j = 0; j < nesPortComboxBox[i]->count(); j++)
{
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i])
{
nesPortComboxBox[i]->setCurrentIndex( j );
nesPortComboxBox[i]->setCurrentIndex(j);
}
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i])
{
nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) );
nesPortLabel[i]->setText(nesPortComboxBox[i]->itemText(j));
}
}
}
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
expPortComboxBox->addItem( tr("<None>") , SIFC_NONE );
expPortComboxBox->addItem( tr("Arkanoid Paddle") , SIFC_ARKANOID );
expPortComboxBox->addItem( tr("Shadow") , SIFC_SHADOW );
expPortComboxBox->addItem( tr("Hyper Shot Gun") , SIFC_HYPERSHOT );
expPortComboxBox->addItem( tr("Family Keyboard") , SIFC_FKB );
expPortComboxBox->addItem( tr("Mahjong") , SIFC_MAHJONG );
expPortComboxBox->addItem( tr("Quiz King Buzzers"), SIFC_QUIZKING );
expPortComboxBox->addItem( tr("Family Trainer A") , SIFC_FTRAINERA );
expPortComboxBox->addItem( tr("Family Trainer B") , SIFC_FTRAINERB );
expPortComboxBox->addItem( tr("Oeka Kids Tablet") , SIFC_OEKAKIDS );
expPortComboxBox->addItem( tr("Top Rider") , SIFC_TOPRIDER );
getInputSelection(2, &curNesInput[2], &usrNesInput[2]);
expPortComboxBox->addItem(tr("<None>"), SIFC_NONE);
expPortComboxBox->addItem(tr("Arkanoid Paddle"), SIFC_ARKANOID);
expPortComboxBox->addItem(tr("Shadow"), SIFC_SHADOW);
expPortComboxBox->addItem(tr("Hyper Shot Gun"), SIFC_HYPERSHOT);
expPortComboxBox->addItem(tr("Family Keyboard"), SIFC_FKB);
expPortComboxBox->addItem(tr("Mahjong"), SIFC_MAHJONG);
expPortComboxBox->addItem(tr("Quiz King Buzzers"), SIFC_QUIZKING);
expPortComboxBox->addItem(tr("Family Trainer A"), SIFC_FTRAINERA);
expPortComboxBox->addItem(tr("Family Trainer B"), SIFC_FTRAINERB);
expPortComboxBox->addItem(tr("Oeka Kids Tablet"), SIFC_OEKAKIDS);
expPortComboxBox->addItem(tr("Top Rider"), SIFC_TOPRIDER);
for (int j=0; j<expPortComboxBox->count(); j++)
for (int j = 0; j < expPortComboxBox->count(); j++)
{
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
if (expPortComboxBox->itemData(j).toInt() == curNesInput[2])
{
expPortComboxBox->setCurrentIndex( j );
expPortComboxBox->setCurrentIndex(j);
}
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
if (expPortComboxBox->itemData(j).toInt() == curNesInput[2])
{
expPortLabel->setText( expPortComboxBox->itemText(j) );
expPortLabel->setText(expPortComboxBox->itemText(j));
}
}
connect( fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)) );
connect( port2Mic , SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)) );
connect( autoPreset , SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int)));
connect(fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)));
connect(port2Mic, SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)));
connect(autoPreset, SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int)));
connect( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) );
connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) );
connect( expPortComboxBox , SIGNAL(activated(int)), this, SLOT(expSelect(int)) );
connect(nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)));
connect(nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)));
connect(expPortComboxBox, SIGNAL(activated(int)), this, SLOT(expSelect(int)));
connect( nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)) );
connect( nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)) );
connect(nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)));
connect(nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)));
connect( loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)) );
connect( saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)) );
connect(loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)));
connect(saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)));
connect(closeButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
updatePortLabels();
inputTimer->start( 500 ); // 2hz
inputTimer->start(500); // 2hz
}
//----------------------------------------------------------------------------
InputConfDialog_t::~InputConfDialog_t(void)
@ -249,7 +259,7 @@ InputConfDialog_t::~InputConfDialog_t(void)
printf("Destroy Input Config Window\n");
inputTimer->stop();
if ( win == this )
if (win == this)
{
win = NULL;
}
@ -257,23 +267,23 @@ InputConfDialog_t::~InputConfDialog_t(void)
//----------------------------------------------------------------------------
void InputConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("Input Config Close Window Event\n");
done(0);
printf("Input Config Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void InputConfDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void InputConfDialog_t::setInputs(void)
{
int idx[3];
ESI port[2];
ESI port[2];
ESIFC fcexp;
int fourscore = false, microphone = false;
@ -285,64 +295,64 @@ void InputConfDialog_t::setInputs(void)
idx[1] = nesPortComboxBox[1]->currentIndex();
idx[2] = expPortComboxBox->currentIndex();
port[0] = (ESI)nesPortComboxBox[0]->itemData( idx[0] ).toInt();
port[1] = (ESI)nesPortComboxBox[1]->itemData( idx[1] ).toInt();
fcexp = (ESIFC)expPortComboxBox->itemData( idx[2] ).toInt();
port[0] = (ESI)nesPortComboxBox[0]->itemData(idx[0]).toInt();
port[1] = (ESI)nesPortComboxBox[1]->itemData(idx[1]).toInt();
fcexp = (ESIFC)expPortComboxBox->itemData(idx[2]).toInt();
FCEUD_SetInput( fourscore, microphone, port[0], port[1], fcexp );
FCEUD_SetInput(fourscore, microphone, port[0], port[1], fcexp);
}
//----------------------------------------------------------------------------
void InputConfDialog_t::updatePortLabels(void)
{
for (int i=0; i<2; i++)
for (int i = 0; i < 2; i++)
{
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
getInputSelection(i, &curNesInput[i], &usrNesInput[i]);
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
for (int j = 0; j < nesPortComboxBox[i]->count(); j++)
{
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i])
{
nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) );
nesPortLabel[i]->setText(nesPortComboxBox[i]->itemText(j));
}
}
nesPortConfButton[i]->setEnabled( curNesInput[i] == SI_GAMEPAD );
nesPortConfButton[i]->setEnabled(curNesInput[i] == SI_GAMEPAD);
}
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
getInputSelection(2, &curNesInput[2], &usrNesInput[2]);
for (int j=0; j<expPortComboxBox->count(); j++)
for (int j = 0; j < expPortComboxBox->count(); j++)
{
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
if (expPortComboxBox->itemData(j).toInt() == curNesInput[2])
{
expPortLabel->setText( expPortComboxBox->itemText(j) );
expPortLabel->setText(expPortComboxBox->itemText(j));
}
}
}
//----------------------------------------------------------------------------
void InputConfDialog_t::updatePortComboBoxes(void)
{
for (int i=0; i<2; i++)
for (int i = 0; i < 2; i++)
{
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
getInputSelection(i, &curNesInput[i], &usrNesInput[i]);
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
for (int j = 0; j < nesPortComboxBox[i]->count(); j++)
{
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i])
{
nesPortComboxBox[i]->setCurrentIndex( j );
nesPortComboxBox[i]->setCurrentIndex(j);
}
}
}
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
getInputSelection(2, &curNesInput[2], &usrNesInput[2]);
for (int j=0; j<expPortComboxBox->count(); j++)
for (int j = 0; j < expPortComboxBox->count(); j++)
{
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
if (expPortComboxBox->itemData(j).toInt() == curNesInput[2])
{
expPortComboxBox->setCurrentIndex( j );
expPortComboxBox->setCurrentIndex(j);
}
}
}
@ -395,15 +405,15 @@ void InputConfDialog_t::openPortConfig(int portNum)
{
updatePortLabels();
switch ( curNesInput[portNum] )
switch (curNesInput[portNum])
{
default:
case SI_NONE:
case SI_ZAPPER:
// Do Nothing
default:
case SI_NONE:
case SI_ZAPPER:
// Do Nothing
break;
case SI_GAMEPAD:
consoleWindow->openGamePadConfWin();
case SI_GAMEPAD:
consoleWindow->openGamePadConfWin();
break;
}
}
@ -420,56 +430,56 @@ void InputConfDialog_t::port2Configure(void)
//----------------------------------------------------------------------------
void InputConfDialog_t::openLoadPresetFile(void)
{
int ret, useNativeFileDialogVal;
int ret, useNativeFileDialogVal;
QString filename;
std::string last;
std::string path;
const char *baseDir;
QFileDialog dialog(this, tr("Load Preset From File") );
QFileDialog dialog(this, tr("Load Preset From File"));
QDir dir;
baseDir = FCEUI_GetBaseDirectory();
path = std::string(baseDir) + "/input/presets/";
dir.mkpath( QString::fromStdString(path) );
dir.mkpath(QString::fromStdString(path));
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("Preset File (*.pre *.PRE) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText(QFileDialog::Accept, tr("Load"));
dialog.setDirectory( tr(path.c_str()) );
dialog.setDirectory(tr(path.c_str()));
// Check config option to use native file dialog or not
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec();
if ( ret )
if (ret)
{
QStringList fileList;
fileList = dialog.selectedFiles();
if ( fileList.size() > 0 )
if (fileList.size() > 0)
{
filename = fileList[0];
}
}
if ( filename.isNull() )
if (filename.isNull())
{
return;
return;
}
qDebug() << "selected file path : " << filename.toUtf8();
fceuWrapperLock();
loadInputSettingsFromFile( filename.toStdString().c_str() );
loadInputSettingsFromFile(filename.toStdString().c_str());
fceuWrapperUnLock();
updatePortLabels();
@ -483,64 +493,64 @@ void InputConfDialog_t::openSavePresetFile(void)
QString filename;
std::string path;
const char *baseDir, *romFile;
QFileDialog dialog(this, tr("Save Preset to File") );
QFileDialog dialog(this, tr("Save Preset to File"));
QDir dir;
baseDir = FCEUI_GetBaseDirectory();
path = std::string(baseDir) + "/input/presets/";
dir.mkpath( QString::fromStdString(path) );
dir.mkpath(QString::fromStdString(path));
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter(tr("Preset Files (*.pre *.PRE) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
dialog.setDefaultSuffix( tr(".pre") );
dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText(QFileDialog::Accept, tr("Save"));
dialog.setDefaultSuffix(tr(".pre"));
romFile = getRomFile();
if ( romFile != NULL )
if (romFile != NULL)
{
char dirStr[256], base[256];
parseFilepath( romFile, dirStr, base );
parseFilepath(romFile, dirStr, base);
strcat( base, ".pre");
strcat(base, ".pre");
dialog.selectFile( tr(base) );
dialog.selectFile(tr(base));
}
dialog.setDirectory( tr(path.c_str()) );
dialog.setDirectory(tr(path.c_str()));
// Check config option to use native file dialog or not
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec();
if ( ret )
if (ret)
{
QStringList fileList;
fileList = dialog.selectedFiles();
if ( fileList.size() > 0 )
if (fileList.size() > 0)
{
filename = fileList[0];
}
}
if ( filename.isNull() )
if (filename.isNull())
{
return;
return;
}
qDebug() << "selected file path : " << filename.toUtf8();
saveInputSettingsToFile( filename.toStdString().c_str() );
saveInputSettingsToFile(filename.toStdString().c_str());
}
//----------------------------------------------------------------------------
void InputConfDialog_t::updatePeriodic(void)
@ -549,21 +559,21 @@ void InputConfDialog_t::updatePeriodic(void)
int tmpCurInputType[3], tmpUsrInputType[3];
int fourScoreValue;
for (int i=0; i<3; i++)
for (int i = 0; i < 3; i++)
{
getInputSelection( i, &tmpCurInputType[i], &tmpUsrInputType[i] );
getInputSelection(i, &tmpCurInputType[i], &tmpUsrInputType[i]);
if ( curNesInput[i] != tmpCurInputType[i] )
if (curNesInput[i] != tmpCurInputType[i])
{
updateNeeded = true;
}
if ( usrNesInput[i] != tmpUsrInputType[i] )
if (usrNesInput[i] != tmpUsrInputType[i])
{
updateNeeded = true;
}
}
if ( updateNeeded )
if (updateNeeded)
{
updatePortLabels();
updatePortComboBoxes();
@ -571,9 +581,9 @@ void InputConfDialog_t::updatePeriodic(void)
g_config->getOption("SDL.FourScore", &fourScoreValue);
if ( fourScoreValue != fourScoreEna->isChecked() )
if (fourScoreValue != fourScoreEna->isChecked())
{
fourScoreEna->setChecked( fourScoreValue );
fourScoreEna->setChecked(fourScoreValue);
}
}
//----------------------------------------------------------------------------

View File

@ -22,52 +22,51 @@
class InputConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
InputConfDialog_t(QWidget *parent = 0);
~InputConfDialog_t(void);
public:
InputConfDialog_t(QWidget *parent = 0);
~InputConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QTimer *inputTimer;
QCheckBox *fourScoreEna;
QCheckBox *port2Mic;
QCheckBox *autoPreset;
QLabel *nesPortLabel[2];
QPushButton *nesPortConfButton[2];
QComboBox *nesPortComboxBox[2];
QLabel *expPortLabel;
QPushButton *expPortConfButton;
QComboBox *expPortComboxBox;
QPushButton *loadConfigButton;
QPushButton *saveConfigButton;
QTimer *inputTimer;
QCheckBox *fourScoreEna;
QCheckBox *port2Mic;
QCheckBox *autoPreset;
QLabel *nesPortLabel[2];
QPushButton *nesPortConfButton[2];
QComboBox *nesPortComboxBox[2];
QLabel *expPortLabel;
QPushButton *expPortConfButton;
QComboBox *expPortComboxBox;
QPushButton *loadConfigButton;
QPushButton *saveConfigButton;
int curNesInput[3];
int usrNesInput[3];
int curNesInput[3];
int usrNesInput[3];
private:
void setInputs(void);
void updatePortLabels(void);
void updatePortComboBoxes(void);
void openPortConfig(int portNum);
public slots:
void closeWindow(void);
private slots:
void port1Configure(void);
void port2Configure(void);
void port1Select(int index);
void port2Select(int index);
void expSelect(int index);
void fourScoreChanged(int state);
void port2MicChanged(int state);
void autoPresetChanged(int state);
void openLoadPresetFile(void);
void openSavePresetFile(void);
void updatePeriodic(void);
private:
void setInputs(void);
void updatePortLabels(void);
void updatePortComboBoxes(void);
void openPortConfig(int portNum);
public slots:
void closeWindow(void);
private slots:
void port1Configure(void);
void port2Configure(void);
void port1Select(int index);
void port2Select(int index);
void expSelect(int index);
void fourScoreChanged(int state);
void port2MicChanged(int state);
void autoPresetChanged(int state);
void openLoadPresetFile(void);
void openSavePresetFile(void);
void updatePeriodic(void);
};
void openInputConfWindow( QWidget *parent );
void openInputConfWindow(QWidget *parent);

View File

@ -50,151 +50,161 @@
static bool luaScriptRunning = false;
static bool updateLuaDisplay = false;
static bool openLuaKillMsgBox = false;
static int luaKillMsgBoxRetVal = 0;
static int luaKillMsgBoxRetVal = 0;
struct luaConsoleOutputBuffer
{
int head;
int tail;
int size;
char *buf;
int head;
int tail;
int size;
char *buf;
luaConsoleOutputBuffer(void)
{
tail = head = 0;
size = 4096;
luaConsoleOutputBuffer(void)
{
tail = head = 0;
size = 4096;
buf = (char*)malloc(size);
}
buf = (char *)malloc(size);
}
~luaConsoleOutputBuffer(void)
{
if ( buf )
{
free(buf); buf = NULL;
}
}
void addLine( const char *l )
{
int i=0;
//printf("Adding Line %i: '%s'\n", head, l );
while ( l[i] != 0 )
~luaConsoleOutputBuffer(void)
{
if (buf)
{
buf[head] = l[i]; i++;
free(buf);
buf = NULL;
}
}
head = (head + 1) % size;
void addLine(const char *l)
{
int i = 0;
//printf("Adding Line %i: '%s'\n", head, l );
while (l[i] != 0)
{
buf[head] = l[i];
i++;
if ( head == tail )
{
tail = (tail + 1) % size;
}
}
}
head = (head + 1) % size;
void clear(void)
{
tail = head = 0;
}
if (head == tail)
{
tail = (tail + 1) % size;
}
}
}
void clear(void)
{
tail = head = 0;
}
};
static luaConsoleOutputBuffer outBuf;
static std::list <LuaControlDialog_t*> winList;
static std::list<LuaControlDialog_t *> winList;
static void updateLuaWindows( void );
static void updateLuaWindows(void);
//----------------------------------------------------
LuaControlDialog_t::LuaControlDialog_t(QWidget *parent)
: QDialog( parent, Qt::Window )
: QDialog(parent, Qt::Window)
{
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
QLabel *lbl;
std::string filename;
resize( 512, 512 );
resize(512, 512);
setWindowTitle( tr("Lua Script Control") );
setWindowTitle(tr("Lua Script Control"));
mainLayout = new QVBoxLayout();
lbl = new QLabel( tr("Script File:") );
lbl = new QLabel(tr("Script File:"));
scriptPath = new QLineEdit();
scriptArgs = new QLineEdit();
g_config->getOption ("SDL.LastLoadLua", &filename );
g_config->getOption("SDL.LastLoadLua", &filename);
scriptPath->setText( filename.c_str() );
scriptPath->setText(filename.c_str());
luaOutput = new QTextEdit();
luaOutput->setReadOnly(true);
hbox = new QHBoxLayout();
browseButton = new QPushButton( tr("Browse") );
stopButton = new QPushButton( tr("Stop") );
browseButton = new QPushButton(tr("Browse"));
stopButton = new QPushButton(tr("Stop"));
if ( luaScriptRunning )
if (luaScriptRunning)
{
startButton = new QPushButton( tr("Restart") );
startButton = new QPushButton(tr("Restart"));
}
else
{
startButton = new QPushButton( tr("Start") );
startButton = new QPushButton(tr("Start"));
}
stopButton->setEnabled( luaScriptRunning );
stopButton->setEnabled(luaScriptRunning);
connect(browseButton , SIGNAL(clicked()), this, SLOT(openLuaScriptFile(void)) );
connect(stopButton , SIGNAL(clicked()), this, SLOT(stopLuaScript(void)) );
connect(startButton , SIGNAL(clicked()), this, SLOT(startLuaScript(void)) );
hbox->addWidget( browseButton );
hbox->addWidget( stopButton );
hbox->addWidget( startButton );
connect(browseButton, SIGNAL(clicked()), this, SLOT(openLuaScriptFile(void)));
connect(stopButton, SIGNAL(clicked()), this, SLOT(stopLuaScript(void)));
connect(startButton, SIGNAL(clicked()), this, SLOT(startLuaScript(void)));
mainLayout->addWidget( lbl );
mainLayout->addWidget( scriptPath );
mainLayout->addLayout( hbox );
hbox->addWidget(browseButton);
hbox->addWidget(stopButton);
hbox->addWidget(startButton);
mainLayout->addWidget(lbl);
mainLayout->addWidget(scriptPath);
mainLayout->addLayout(hbox);
hbox = new QHBoxLayout();
lbl = new QLabel( tr("Arguments:") );
lbl = new QLabel(tr("Arguments:"));
hbox->addWidget( lbl );
hbox->addWidget( scriptArgs );
hbox->addWidget(lbl);
hbox->addWidget(scriptArgs);
mainLayout->addLayout(hbox);
lbl = new QLabel(tr("Output Console:"));
mainLayout->addWidget(lbl);
mainLayout->addWidget(luaOutput);
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
lbl = new QLabel( tr("Output Console:") );
mainLayout->addWidget( lbl );
mainLayout->addWidget( luaOutput );
setLayout(mainLayout);
//connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) );
winList.push_back(this);
setLayout( mainLayout );
periodicTimer = new QTimer(this);
winList.push_back( this );
connect(periodicTimer, &QTimer::timeout, this, &LuaControlDialog_t::updatePeriodic);
periodicTimer = new QTimer( this );
connect( periodicTimer, &QTimer::timeout, this, &LuaControlDialog_t::updatePeriodic );
periodicTimer->start( 200 ); // 5hz
periodicTimer->start(200); // 5hz
}
//----------------------------------------------------
LuaControlDialog_t::~LuaControlDialog_t(void)
{
std::list <LuaControlDialog_t*>::iterator it;
std::list<LuaControlDialog_t *>::iterator it;
printf("Destroy Lua Control Window\n");
periodicTimer->stop();
periodicTimer->stop();
for (it = winList.begin(); it != winList.end(); it++)
{
if ( (*it) == this )
if ((*it) == this)
{
winList.erase(it);
//printf("Removing Lua Window\n");
@ -205,29 +215,29 @@ LuaControlDialog_t::~LuaControlDialog_t(void)
//----------------------------------------------------
void LuaControlDialog_t::closeEvent(QCloseEvent *event)
{
printf("Lua Control Close Window Event\n");
done(0);
printf("Lua Control Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------
void LuaControlDialog_t::closeWindow(void)
{
//printf("Lua Control Close Window\n");
done(0);
//printf("Lua Control Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------
void LuaControlDialog_t::updatePeriodic(void)
{
//printf("Update Lua\n");
if ( updateLuaDisplay )
{
updateLuaWindows();
updateLuaDisplay = false;
}
//printf("Update Lua\n");
if (updateLuaDisplay)
{
updateLuaWindows();
updateLuaDisplay = false;
}
if ( openLuaKillMsgBox )
if (openLuaKillMsgBox)
{
openLuaKillMessageBox();
openLuaKillMsgBox = false;
@ -241,15 +251,15 @@ void LuaControlDialog_t::openLuaKillMessageBox(void)
luaKillMsgBoxRetVal = 0;
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr("The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n") );
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n"));
msgBox.setStandardButtons(QMessageBox::Yes);
msgBox.addButton(QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
ret = msgBox.exec();
if ( ret == QMessageBox::Yes )
if (ret == QMessageBox::Yes)
{
luaKillMsgBoxRetVal = 1;
}
@ -264,78 +274,79 @@ void LuaControlDialog_t::openLuaScriptFile(void)
char dir[512];
char exePath[512];
const char *luaPath;
QFileDialog dialog(this, tr("Open LUA Script") );
QFileDialog dialog(this, tr("Open LUA Script"));
QList<QUrl> urls;
QDir d;
QDir d;
fceuExecutablePath( exePath, sizeof(exePath) );
fceuExecutablePath(exePath, sizeof(exePath));
//urls = dialog.sidebarUrls();
urls << QUrl::fromLocalFile( QDir::rootPath() );
urls << QUrl::fromLocalFile(QDir::rootPath());
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
urls << QUrl::fromLocalFile(QDir(FCEUI_GetBaseDirectory()).absolutePath());
if ( exePath[0] != 0 )
if (exePath[0] != 0)
{
d.setPath( QString(exePath) + "/../luaScripts" );
d.setPath(QString(exePath) + "/../luaScripts");
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
}
}
#ifndef WIN32
d.setPath( "/usr/share/fceux/luaScripts" );
d.setPath("/usr/share/fceux/luaScripts");
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
}
#endif
luaPath = getenv("LUA_PATH");
// Parse LUA_PATH and add to urls
if ( luaPath )
if (luaPath)
{
int i,j;
int i, j;
char stmp[1024];
i=j=0;
while ( luaPath[i] != 0 )
i = j = 0;
while (luaPath[i] != 0)
{
if ( luaPath[i] == ';' )
if (luaPath[i] == ';')
{
stmp[j] = 0;
if ( j > 0 )
if (j > 0)
{
d.setPath(stmp);
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
}
}
j=0;
j = 0;
}
else
{
stmp[j] = luaPath[i]; j++;
stmp[j] = luaPath[i];
j++;
}
i++;
}
stmp[j] = 0;
if ( j > 0 )
if (j > 0)
{
d.setPath(stmp);
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
}
}
}
@ -345,52 +356,52 @@ void LuaControlDialog_t::openLuaScriptFile(void)
dialog.setNameFilter(tr("LUA Scripts (*.lua *.LUA) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText(QFileDialog::Accept, tr("Load"));
g_config->getOption ("SDL.LastLoadLua", &last );
g_config->getOption("SDL.LastLoadLua", &last);
if ( last.size() == 0 )
if (last.size() == 0)
{
#ifdef WIN32
last.assign( FCEUI_GetBaseDirectory() );
last.assign(FCEUI_GetBaseDirectory());
#else
last.assign( "/usr/share/fceux/luaScripts" );
last.assign("/usr/share/fceux/luaScripts");
#endif
}
getDirFromFile( last.c_str(), dir );
getDirFromFile(last.c_str(), dir);
dialog.setDirectory( tr(dir) );
dialog.setDirectory(tr(dir));
// Check config option to use native file dialog or not
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
dialog.setSidebarUrls(urls);
ret = dialog.exec();
if ( ret )
if (ret)
{
QStringList fileList;
fileList = dialog.selectedFiles();
if ( fileList.size() > 0 )
if (fileList.size() > 0)
{
filename = fileList[0];
}
}
if ( filename.isNull() )
if (filename.isNull())
{
return;
return;
}
qDebug() << "selected file path : " << filename.toUtf8();
g_config->setOption ("SDL.LastLoadLua", filename.toStdString().c_str() );
g_config->setOption("SDL.LastLoadLua", filename.toStdString().c_str());
scriptPath->setText( filename.toStdString().c_str() );
scriptPath->setText(filename.toStdString().c_str());
#endif
}
@ -400,9 +411,9 @@ void LuaControlDialog_t::startLuaScript(void)
#ifdef _S9XLUA_H
outBuf.clear();
fceuWrapperLock();
if ( 0 == FCEU_LoadLuaCode( scriptPath->text().toStdString().c_str(), scriptArgs->text().toStdString().c_str() ) )
if (0 == FCEU_LoadLuaCode(scriptPath->text().toStdString().c_str(), scriptArgs->text().toStdString().c_str()))
{
printf("Error: Could not open the selected lua script: '%s'\n", scriptPath->text().toStdString().c_str() );
printf("Error: Could not open the selected lua script: '%s'\n", scriptPath->text().toStdString().c_str());
}
fceuWrapperUnLock();
#endif
@ -422,35 +433,35 @@ void LuaControlDialog_t::refreshState(void)
int i;
std::string luaOutputText;
if ( luaScriptRunning )
if (luaScriptRunning)
{
stopButton->setEnabled( true );
startButton->setText( tr("Restart") );
stopButton->setEnabled(true);
startButton->setText(tr("Restart"));
}
else
{
stopButton->setEnabled( false );
startButton->setText( tr("Start") );
stopButton->setEnabled(false);
startButton->setText(tr("Start"));
}
i = outBuf.tail;
while ( i != outBuf.head )
while (i != outBuf.head)
{
luaOutputText.append( 1, outBuf.buf[i] );
i = (i + 1) % outBuf.size;
luaOutputText.append(1, outBuf.buf[i]);
i = (i + 1) % outBuf.size;
}
luaOutput->setText( luaOutputText.c_str() );
luaOutput->setText(luaOutputText.c_str());
luaOutput->moveCursor( QTextCursor::End );
luaOutput->moveCursor(QTextCursor::End);
}
//----------------------------------------------------
static void updateLuaWindows( void )
static void updateLuaWindows(void)
{
std::list <LuaControlDialog_t*>::iterator it;
std::list<LuaControlDialog_t *>::iterator it;
for (it = winList.begin(); it != winList.end(); it++)
{
(*it)->refreshState();
@ -475,35 +486,35 @@ void WinLuaOnStop(intptr_t hDlgAsInt)
updateLuaDisplay = true;
}
//----------------------------------------------------
void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str)
void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str)
{
//printf("%s\n", str );
outBuf.addLine( str );
outBuf.addLine(str);
updateLuaDisplay = true;
}
//----------------------------------------------------
#ifdef WIN32
int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char* format, ...)
#ifdef WIN32
int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char *format, ...)
#else
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw()
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw()
#endif
{
int retval;
va_list args;
int retval;
va_list args;
char msg[2048];
va_start( args, format );
retval = ::vsnprintf( msg, sizeof(msg), format, args );
va_end(args);
va_start(args, format);
retval = ::vsnprintf(msg, sizeof(msg), format, args);
va_end(args);
msg[ sizeof(msg)-1 ] = 0;
msg[sizeof(msg) - 1] = 0;
outBuf.addLine( msg );
outBuf.addLine(msg);
updateLuaDisplay = true;
return(retval);
return (retval);
};
//----------------------------------------------------
int LuaKillMessageBox(void)
@ -513,11 +524,11 @@ int LuaKillMessageBox(void)
openLuaKillMsgBox = true;
while ( openLuaKillMsgBox )
while (openLuaKillMsgBox)
{
msleep(100);
}
return luaKillMsgBoxRetVal;
}
//----------------------------------------------------

View File

@ -23,52 +23,50 @@
class LuaControlDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
LuaControlDialog_t(QWidget *parent = 0);
~LuaControlDialog_t(void);
public:
LuaControlDialog_t(QWidget *parent = 0);
~LuaControlDialog_t(void);
void refreshState(void);
void refreshState(void);
protected:
void closeEvent(QCloseEvent *bar);
void openLuaKillMessageBox(void);
protected:
void closeEvent(QCloseEvent *bar);
void openLuaKillMessageBox(void);
QTimer *periodicTimer;
QLineEdit *scriptPath;
QLineEdit *scriptArgs;
QPushButton *browseButton;
QPushButton *stopButton;
QPushButton *startButton;
QTextEdit *luaOutput;
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void openLuaScriptFile(void);
void startLuaScript(void);
void stopLuaScript(void);
QTimer *periodicTimer;
QLineEdit *scriptPath;
QLineEdit *scriptArgs;
QPushButton *browseButton;
QPushButton *stopButton;
QPushButton *startButton;
QTextEdit *luaOutput;
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void openLuaScriptFile(void);
void startLuaScript(void);
void stopLuaScript(void);
};
// Formatted print
#ifdef WIN32
int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char* format, ...) ;
#elif __linux__
#ifdef __THROWNL
int LuaPrintfToWindowConsole(const char *__restrict format, ...)
__THROWNL __attribute__ ((__format__ (__printf__, 1, 2)));
#else
int LuaPrintfToWindowConsole(const char *__restrict format, ...)
throw() __attribute__ ((__format__ (__printf__, 1, 2)));
#endif
#else
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw();
#ifdef WIN32
int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char *format, ...);
#elif __linux__
#ifdef __THROWNL
int LuaPrintfToWindowConsole(const char *__restrict format, ...)
__THROWNL __attribute__((__format__(__printf__, 1, 2)));
#else
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw() __attribute__((__format__(__printf__, 1, 2)));
#endif
#else
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw();
#endif
void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str);
void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str);
int LuaKillMessageBox(void);

View File

@ -40,56 +40,67 @@
//----------------------------------------------------------------------------
MovieOptionsDialog_t::MovieOptionsDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QLabel *lbl;
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
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:") );
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:"));
lbl = new QLabel( tr("Loading states in record mode will not immediately truncate movie, next frame input will. (VBA-rr and SNES9x style)") );
lbl = new QLabel(tr("Loading states in record mode will not immediately truncate movie, next frame input will. (VBA-rr and SNES9x style)"));
lbl->setWordWrap(true);
mainLayout->addWidget( readOnlyReplay );
mainLayout->addWidget( pauseAfterPlay );
mainLayout->addWidget( closeAfterPlay );
mainLayout->addWidget( bindSaveStates );
mainLayout->addWidget( dpySubTitles );
mainLayout->addWidget( putSubTitlesAvi );
mainLayout->addWidget( autoBackUp );
mainLayout->addWidget( loadFullStates );
mainLayout->addWidget( lbl );
mainLayout->addWidget(readOnlyReplay);
mainLayout->addWidget(pauseAfterPlay);
mainLayout->addWidget(closeAfterPlay);
mainLayout->addWidget(bindSaveStates);
mainLayout->addWidget(dpySubTitles);
mainLayout->addWidget(putSubTitlesAvi);
mainLayout->addWidget(autoBackUp);
mainLayout->addWidget(loadFullStates);
mainLayout->addWidget(lbl);
readOnlyReplay->setChecked( suggestReadOnlyReplay );
pauseAfterPlay->setChecked( pauseAfterPlayback );
closeAfterPlay->setChecked( closeFinishedMovie );
bindSaveStates->setChecked( bindSavestate );
dpySubTitles->setChecked( movieSubtitles );
putSubTitlesAvi->setChecked( subtitlesOnAVI );
autoBackUp->setChecked( autoMovieBackup );
loadFullStates->setChecked( fullSaveStateLoads );
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 );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
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)) );
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
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)
@ -99,57 +110,57 @@ MovieOptionsDialog_t::~MovieOptionsDialog_t(void)
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeEvent(QCloseEvent *event)
{
printf("Movie Options Close Window Event\n");
done(0);
printf("Movie Options Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::readOnlyReplayChanged( int state )
void MovieOptionsDialog_t::readOnlyReplayChanged(int state)
{
suggestReadOnlyReplay = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::pauseAfterPlayChanged( int state )
void MovieOptionsDialog_t::pauseAfterPlayChanged(int state)
{
pauseAfterPlayback = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::closeAfterPlayChanged( int state )
void MovieOptionsDialog_t::closeAfterPlayChanged(int state)
{
closeFinishedMovie = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::bindSaveStatesChanged( int state )
void MovieOptionsDialog_t::bindSaveStatesChanged(int state)
{
bindSavestate = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::dpySubTitlesChanged( int state )
void MovieOptionsDialog_t::dpySubTitlesChanged(int state)
{
movieSubtitles = (state != Qt::Unchecked);
g_config->setOption("SDL.SubtitleDisplay", movieSubtitles);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::putSubTitlesAviChanged( int state )
void MovieOptionsDialog_t::putSubTitlesAviChanged(int state)
{
subtitlesOnAVI = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::autoBackUpChanged( int state )
void MovieOptionsDialog_t::autoBackUpChanged(int state)
{
autoMovieBackup = (state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MovieOptionsDialog_t::loadFullStatesChanged( int state )
void MovieOptionsDialog_t::loadFullStatesChanged(int state)
{
fullSaveStateLoads = (state != Qt::Unchecked);
}

View File

@ -20,36 +20,34 @@
class MovieOptionsDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
MovieOptionsDialog_t(QWidget *parent = 0);
~MovieOptionsDialog_t(void);
public:
MovieOptionsDialog_t(QWidget *parent = 0);
~MovieOptionsDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
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 );
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

@ -44,7 +44,7 @@
//----------------------------------------------------------------------------
MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox;
@ -57,96 +57,99 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
setWindowTitle("Movie Play");
mainLayout = new QVBoxLayout();
hbox = new QHBoxLayout();
hbox = new QHBoxLayout();
lbl = new QLabel( tr("File:") );
movSelBox = new QComboBox();
movBrowseBtn = new QPushButton( tr("Browse") );
lbl = new QLabel(tr("File:"));
movSelBox = new QComboBox();
movBrowseBtn = new QPushButton(tr("Browse"));
hbox->addWidget( lbl, 1 );
hbox->addWidget( movSelBox, 100 );
hbox->addWidget( movBrowseBtn, 1 );
hbox->addWidget(lbl, 1);
hbox->addWidget(movSelBox, 100);
hbox->addWidget(movBrowseBtn, 1);
mainLayout->addLayout( hbox );
mainLayout->addLayout(hbox);
frame = new QGroupBox( tr("Parameters:") );
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
frame = new QGroupBox(tr("Parameters:"));
vbox = new QVBoxLayout();
hbox = new QHBoxLayout();
frame->setLayout( vbox );
frame->setLayout(vbox);
openReadOnly = new QCheckBox( tr("Open Read-Only") );
pauseAtFrame = new QCheckBox( tr("Pause Movie At Frame") );
openReadOnly = new QCheckBox(tr("Open Read-Only"));
pauseAtFrame = new QCheckBox(tr("Pause Movie At Frame"));
validator = new fceuDecIntValidtor( 0, 100000000, this );
validator = new fceuDecIntValidtor(0, 100000000, this);
pauseAtFrameEntry = new QLineEdit();
pauseAtFrameEntry->setValidator( validator );
pauseAtFrameEntry->setValidator(validator);
vbox->addWidget( openReadOnly );
vbox->addLayout( hbox );
hbox->addWidget( pauseAtFrame );
hbox->addWidget( pauseAtFrameEntry );
vbox->addWidget(openReadOnly);
vbox->addLayout(hbox);
hbox->addWidget(pauseAtFrame);
hbox->addWidget(pauseAtFrameEntry);
mainLayout->addWidget( frame );
mainLayout->addWidget(frame);
grid = new QGridLayout();
grid->setColumnStretch( 0, 1 );
grid->setColumnStretch( 1, 10 );
grid->setColumnStretch(0, 1);
grid->setColumnStretch(1, 10);
mainLayout->addLayout( grid );
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();
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(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 );
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);
hbox = new QHBoxLayout();
okButton = new QPushButton( tr("Play") );
cancelButton = new QPushButton( tr("Cancel") );
hbox->addWidget( cancelButton );
hbox->addWidget( okButton );
hbox = new QHBoxLayout();
okButton = new QPushButton(tr("Play"));
cancelButton = new QPushButton(tr("Cancel"));
hbox->addWidget(cancelButton);
hbox->addWidget(okButton);
okButton->setDefault(true);
mainLayout->addLayout( hbox );
mainLayout->addLayout(hbox);
setLayout( mainLayout );
setLayout(mainLayout);
connect( cancelButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) );
connect( okButton , SIGNAL(clicked(void)), this, SLOT(playMovie(void)) );
okButton->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) );
cancelButton->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) );
connect( movBrowseBtn , SIGNAL(clicked(void)) , this, SLOT(openMovie(void)) );
connect( movSelBox , SIGNAL(activated(int)), this, SLOT(movieSelect(int)) );
connect(cancelButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
connect(okButton, SIGNAL(clicked(void)), this, SLOT(playMovie(void)));
connect( pauseAtFrame , SIGNAL(stateChanged(int)), this, SLOT(pauseAtFrameChange(int)) );
connect(movBrowseBtn, SIGNAL(clicked(void)), this, SLOT(openMovie(void)));
connect(movSelBox, SIGNAL(activated(int)), this, SLOT(movieSelect(int)));
connect(pauseAtFrame, SIGNAL(stateChanged(int)), this, SLOT(pauseAtFrameChange(int)));
if (suggestReadOnlyReplay)
{
@ -156,9 +159,9 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
{
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
}
openReadOnly->setChecked( replayReadOnlySetting );
openReadOnly->setChecked(replayReadOnlySetting);
pauseAtFrameEntry->setEnabled( pauseAtFrame->isChecked() );
pauseAtFrameEntry->setEnabled(pauseAtFrame->isChecked());
doScan();
@ -172,16 +175,16 @@ MoviePlayDialog_t::~MoviePlayDialog_t(void)
//----------------------------------------------------------------------------
void MoviePlayDialog_t::closeEvent(QCloseEvent *event)
{
printf("Movie Play Close Window Event\n");
done(0);
printf("Movie Play Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
@ -197,10 +200,10 @@ void MoviePlayDialog_t::movieSelect(int index)
//----------------------------------------------------------------------------
void MoviePlayDialog_t::pauseAtFrameChange(int state)
{
pauseAtFrameEntry->setEnabled( state != Qt::Unchecked );
pauseAtFrameEntry->setEnabled(state != Qt::Unchecked);
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::clearMovieText(void)
void MoviePlayDialog_t::clearMovieText(void)
{
movLenLbl->clear();
movFramesLbl->clear();
@ -215,16 +218,16 @@ void MoviePlayDialog_t::clearMovieText(void)
pauseAtFrameEntry->clear();
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::updateMovieText(void)
void MoviePlayDialog_t::updateMovieText(void)
{
int idx;
std::string path;
FCEUFILE* fp;
FCEUFILE *fp;
MOVIE_INFO info;
bool scanok;
char stmp[256];
if ( movSelBox->count() == 0 )
if (movSelBox->count() == 0)
{
return;
}
@ -232,30 +235,30 @@ void MoviePlayDialog_t::updateMovieText(void)
path = movSelBox->itemText(idx).toStdString();
fp = FCEU_fopen( path.c_str(),0,"rb",0);
fp = FCEU_fopen(path.c_str(), 0, "rb", 0);
if ( fp == NULL )
if (fp == NULL)
{
sprintf( stmp, "Error: Failed to open file '%s'", path.c_str() );
showErrorMsgWindow( stmp );
sprintf(stmp, "Error: Failed to open file '%s'", path.c_str());
showErrorMsgWindow(stmp);
clearMovieText();
return;
}
scanok = FCEUI_MovieGetInfo(fp, info, false);
if ( scanok )
if (scanok)
{
double div;
validator->setMinMax( 0, info.num_frames );
validator->setMinMax(0, info.num_frames);
sprintf(stmp, "%u", (unsigned)info.num_frames);
movFramesLbl->setText( tr(stmp) );
pauseAtFrameEntry->setText( tr(stmp) );
movFramesLbl->setText(tr(stmp));
pauseAtFrameEntry->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
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;
@ -263,56 +266,56 @@ void MoviePlayDialog_t::updateMovieText(void)
int hours = (num_seconds / 60 / 60) % 60;
sprintf(stmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction);
movLenLbl->setText( tr(stmp) );
movLenLbl->setText(tr(stmp));
sprintf(stmp, "%u", (unsigned)info.rerecord_count);
recCountLbl->setText( tr(stmp) );
recCountLbl->setText(tr(stmp));
recFromLbl->setText( tr(info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate") ) );
recFromLbl->setText(tr(info.poweron ? "Power-On" : (info.reset ? "Soft-Reset" : "Savestate")));
romUsedLbl->setText( tr(info.name_of_rom_used.c_str()) );
romUsedLbl->setText(tr(info.name_of_rom_used.c_str()));
romCsumLbl->setText( tr(md5_asciistr(info.md5_of_rom_used)) );
romCsumLbl->setText(tr(md5_asciistr(info.md5_of_rom_used)));
if ( GameInfo )
if (GameInfo)
{
curCsumLbl->setText( tr(md5_asciistr(GameInfo->MD5)) );
curCsumLbl->setText(tr(md5_asciistr(GameInfo->MD5)));
}
else
{
curCsumLbl->clear();
}
if (info.emu_version_used < 20000 )
if (info.emu_version_used < 20000)
{
sprintf( stmp, "FCEU %u.%02u.%02u%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : "");
sprintf(stmp, "FCEU %u.%02u.%02u%s", info.emu_version_used / 10000, (info.emu_version_used / 100) % 100, (info.emu_version_used) % 100, info.emu_version_used < 9813 ? " (blip)" : "");
}
else
else
{
sprintf( stmp, "FCEUX %u.%02u.%02u", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100);
sprintf(stmp, "FCEUX %u.%02u.%02u", info.emu_version_used / 10000, (info.emu_version_used / 100) % 100, (info.emu_version_used) % 100);
}
emuUsedLbl->setText( tr(stmp) );
emuUsedLbl->setText(tr(stmp));
palUsedLbl->setText( tr(info.pal ? "On" : "Off") );
palUsedLbl->setText(tr(info.pal ? "On" : "Off"));
newppuUsedLbl->setText( tr(info.ppuflag ? "On" : "Off") );
newppuUsedLbl->setText(tr(info.ppuflag ? "On" : "Off"));
if ( GameInfo )
if (GameInfo)
{
strcpy( stmp, md5_asciistr(GameInfo->MD5) );
strcpy(stmp, md5_asciistr(GameInfo->MD5));
if ( strcmp( stmp, md5_asciistr(info.md5_of_rom_used) ) != 0 )
if (strcmp(stmp, md5_asciistr(info.md5_of_rom_used)) != 0)
{
sprintf( stmp, "Warning: Selected movie file '%s' may not have been created using the currently loaded ROM.", path.c_str() );
showWarningMsgWindow( stmp );
sprintf(stmp, "Warning: Selected movie file '%s' may not have been created using the currently loaded ROM.", path.c_str());
showWarningMsgWindow(stmp);
}
}
}
else
{
sprintf( stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str() );
showErrorMsgWindow( stmp );
sprintf(stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str());
showErrorMsgWindow(stmp);
clearMovieText();
}
delete fp;
@ -320,27 +323,27 @@ void MoviePlayDialog_t::updateMovieText(void)
return;
}
//----------------------------------------------------------------------------
int MoviePlayDialog_t::addFileToList( const char *file, bool setActive )
int MoviePlayDialog_t::addFileToList(const char *file, bool setActive)
{
int n=0;
int n = 0;
for (int i=0; i<movSelBox->count(); i++)
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;
}
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 );
movSelBox->addItem(tr(file), n);
if ( setActive )
if (setActive)
{
movSelBox->setCurrentIndex(n);
}
@ -348,23 +351,23 @@ int MoviePlayDialog_t::addFileToList( const char *file, bool setActive )
return 0;
}
//----------------------------------------------------------------------------
bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 )
bool MoviePlayDialog_t::checkMD5Sum(const char *path, const char *md5)
{
FCEUFILE* fp;
FCEUFILE *fp;
MOVIE_INFO info;
bool scanok, md5Match = false;
fp = FCEU_fopen( path,0,"rb",0);
if ( fp == NULL )
fp = FCEU_fopen(path, 0, "rb", 0);
if (fp == NULL)
{
return md5Match;
}
scanok = FCEUI_MovieGetInfo(fp, info, true);
if ( scanok )
if (scanok)
{
if ( strcmp( md5, md5_asciistr(info.md5_of_rom_used) ) == 0 )
if (strcmp(md5, md5_asciistr(info.md5_of_rom_used)) == 0)
{
md5Match = true;
}
@ -374,33 +377,32 @@ bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 )
return md5Match;
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::scanDirectory( const char *dirPath, const char *md5 )
void MoviePlayDialog_t::scanDirectory(const char *dirPath, const char *md5)
{
QDir dir;
QFileInfoList list;
std::string path;
const QStringList filters( { "*.fm2" } );
const QStringList filters({"*.fm2"});
path.assign( dirPath );
path.assign(dirPath);
dir.setPath( QString::fromStdString(path) );
dir.setPath(QString::fromStdString(path));
list = dir.entryInfoList( filters, QDir::Files );
list = dir.entryInfoList(filters, QDir::Files);
for (int i = 0; i < list.size(); ++i)
for (int i = 0; i < list.size(); ++i)
{
QFileInfo fileInfo = list.at(i);
path = std::string(dirPath) + fileInfo.fileName().toStdString();
path = std::string(dirPath) + fileInfo.fileName().toStdString();
//printf("File: '%s'\n", path.c_str() );
if ( checkMD5Sum( path.c_str(), md5 ) )
if (checkMD5Sum(path.c_str(), md5))
{
addFileToList( path.c_str() );
addFileToList(path.c_str());
}
}
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::doScan(void)
@ -413,31 +415,31 @@ void MoviePlayDialog_t::doScan(void)
md5[0] = 0;
if ( GameInfo )
if (GameInfo)
{
strcpy( md5, md5_asciistr(GameInfo->MD5) );
strcpy(md5, md5_asciistr(GameInfo->MD5));
}
path = std::string(baseDir) + "/movies/";
scanDirectory( path.c_str(), md5 );
path = std::string(baseDir) + "/movies/";
scanDirectory(path.c_str(), md5);
romFile = getRomFile();
if ( romFile != NULL )
if (romFile != NULL)
{
parseFilepath( romFile, dir, base );
parseFilepath(romFile, dir, base);
path = std::string(dir);
path = std::string(dir);
scanDirectory( path.c_str(), md5 );
scanDirectory(path.c_str(), md5);
}
g_config->getOption ("SDL.LastOpenMovie", &last );
g_config->getOption("SDL.LastOpenMovie", &last);
getDirFromFile( last.c_str(), dir );
getDirFromFile(last.c_str(), dir);
scanDirectory( dir, md5 );
scanDirectory(dir, md5);
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::playMovie(void)
@ -445,7 +447,7 @@ void MoviePlayDialog_t::playMovie(void)
int idx, pauseframe = 0;
bool replayReadOnlySetting, movieLoadError = false;
if ( movSelBox->count() == 0 )
if (movSelBox->count() == 0)
{
return;
}
@ -457,24 +459,24 @@ void MoviePlayDialog_t::playMovie(void)
replayReadOnlySetting = openReadOnly->isChecked();
if ( pauseAtFrame->isChecked() )
if (pauseAtFrame->isChecked())
{
pauseframe = strtol( pauseAtFrameEntry->text().toStdString().c_str(), NULL, 0 );
pauseframe = strtol(pauseAtFrameEntry->text().toStdString().c_str(), NULL, 0);
}
fceuWrapperLock();
if (FCEUI_LoadMovie( path.c_str(),
replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
if (FCEUI_LoadMovie(path.c_str(),
replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
{
movieLoadError = true;
}
fceuWrapperUnLock();
if ( movieLoadError )
if (movieLoadError)
{
char stmp[256];
sprintf( stmp, "Error: Could not load movie file: %s \n", path.c_str() );
showErrorMsgWindow( stmp );
sprintf(stmp, "Error: Could not load movie file: %s \n", path.c_str());
showErrorMsgWindow(stmp);
}
else
{
@ -489,78 +491,78 @@ void MoviePlayDialog_t::openMovie(void)
std::string last;
char dir[512];
char md5Match = 0;
QFileDialog dialog(this, tr("Open FM2 Movie") );
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") );
dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText(QFileDialog::Accept, tr("Open"));
g_config->getOption ("SDL.LastOpenMovie", &last );
g_config->getOption("SDL.LastOpenMovie", &last);
getDirFromFile( last.c_str(), dir );
getDirFromFile(last.c_str(), dir);
dialog.setDirectory( tr(dir) );
dialog.setDirectory(tr(dir));
// Check config option to use native file dialog or not
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec();
if ( ret )
if (ret)
{
QStringList fileList;
fileList = dialog.selectedFiles();
if ( fileList.size() > 0 )
if (fileList.size() > 0)
{
filename = fileList[0];
}
}
if ( filename.isNull() )
{
return;
}
if (filename.isNull())
{
return;
}
qDebug() << "selected file path : " << filename.toUtf8();
if ( GameInfo )
if (GameInfo)
{
char md5[256];
strcpy( md5, md5_asciistr(GameInfo->MD5) );
strcpy(md5, md5_asciistr(GameInfo->MD5));
if ( checkMD5Sum( filename.toStdString().c_str(), md5 ) )
if (checkMD5Sum(filename.toStdString().c_str(), md5))
{
md5Match = 1;
}
if ( !md5Match )
if (!md5Match)
{
printf("Warning MD5 Mismatch\n");
}
}
addFileToList( filename.toStdString().c_str(), true );
addFileToList(filename.toStdString().c_str(), true);
updateMovieText();
g_config->setOption ("SDL.LastOpenMovie", filename.toStdString().c_str() );
return;
g_config->setOption("SDL.LastOpenMovie", filename.toStdString().c_str());
return;
}
//----------------------------------------------------------------------------
void MoviePlayDialog_t::showErrorMsgWindow(const char *str)
{
QMessageBox msgBox(this);
msgBox.setIcon( QMessageBox::Critical );
msgBox.setText( tr(str) );
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr(str));
msgBox.show();
msgBox.exec();
}
@ -569,8 +571,8 @@ void MoviePlayDialog_t::showWarningMsgWindow(const char *str)
{
QMessageBox msgBox(this);
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr(str) );
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr(str));
msgBox.show();
msgBox.exec();
}

View File

@ -20,50 +20,49 @@
class MoviePlayDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
MoviePlayDialog_t(QWidget *parent = 0);
~MoviePlayDialog_t(void);
public:
MoviePlayDialog_t(QWidget *parent = 0);
~MoviePlayDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QComboBox *movSelBox;
QPushButton *movBrowseBtn;
QCheckBox *openReadOnly;
QCheckBox *pauseAtFrame;
QLineEdit *pauseAtFrameEntry;
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;
QLabel *movLenLbl;
QLabel *movFramesLbl;
QLabel *recCountLbl;
QLabel *recFromLbl;
QLabel *romUsedLbl;
QLabel *romCsumLbl;
QLabel *curCsumLbl;
QLabel *emuUsedLbl;
QLabel *palUsedLbl;
QLabel *newppuUsedLbl;
fceuDecIntValidtor *validator;
fceuDecIntValidtor *validator;
private:
void doScan(void);
void clearMovieText(void);
void updateMovieText(void);
int addFileToList( const char *file, bool setActive = false );
bool checkMD5Sum( const char *path, const char *md5 );
void scanDirectory( const char *dirPath, const char *md5 );
void showErrorMsgWindow(const char *str);
void showWarningMsgWindow(const char *str);
public slots:
void closeWindow(void);
private slots:
void openMovie(void);
void playMovie(void);
void movieSelect(int index);
void pauseAtFrameChange(int state);
private:
void doScan(void);
void clearMovieText(void);
void updateMovieText(void);
int addFileToList(const char *file, bool setActive = false);
bool checkMD5Sum(const char *path, const char *md5);
void scanDirectory(const char *dirPath, const char *md5);
void showErrorMsgWindow(const char *str);
void showWarningMsgWindow(const char *str);
public slots:
void closeWindow(void);
private slots:
void openMovie(void);
void playMovie(void);
void movieSelect(int index);
void pauseAtFrameChange(int state);
};

View File

@ -41,40 +41,40 @@
#include "Qt/MsgLogViewer.h"
#include "Qt/ConsoleWindow.h"
#define MSG_LOG_MAX_LINES 256
#define MSG_LOG_MAX_LINES 256
class msgLogBuf_t
{
public:
public:
msgLogBuf_t(void)
{
char filename[512];
#ifdef WIN32
if ( GetTempPathA( sizeof(filename), filename ) > 0 )
#ifdef WIN32
if (GetTempPathA(sizeof(filename), filename) > 0)
{
//printf("PATH: %s \n", filename );
strcat( filename, "fceux.log");
strcat(filename, "fceux.log");
}
else
{
strcpy( filename, "fceux.log" );
strcpy(filename, "fceux.log");
}
#else
strcpy( filename, "/tmp/fceux.log" );
#endif
#else
strcpy(filename, "/tmp/fceux.log");
#endif
fp = ::fopen( filename, "w+");
fp = ::fopen(filename, "w+");
if ( fp == NULL )
if (fp == NULL)
{
printf("Error: Failed to open message log file: '%s'\n", filename);
}
maxLines = MSG_LOG_MAX_LINES;
maxLines = MSG_LOG_MAX_LINES;
totalLines = 0;
head = tail = 0;
for (int i=0; i<MSG_LOG_MAX_LINES; i++)
for (int i = 0; i < MSG_LOG_MAX_LINES; i++)
{
fpOfsList[i] = 0;
}
@ -82,9 +82,10 @@ class msgLogBuf_t
~msgLogBuf_t(void)
{
if ( fp != NULL )
if (fp != NULL)
{
::fclose(fp); fp = NULL;
::fclose(fp);
fp = NULL;
}
}
@ -93,30 +94,31 @@ class msgLogBuf_t
head = tail = 0;
}
void addLine( const char *txt, bool NewLine = false )
void addLine(const char *txt, bool NewLine = false)
{
long ofs;
if ( fp == NULL ) return;
if (fp == NULL)
return;
::fseek( fp, 0L, SEEK_END);
::fseek(fp, 0L, SEEK_END);
ofs = ::ftell(fp);
if ( NewLine )
if (NewLine)
{
::fprintf( fp, "%s\n", txt );
::fprintf(fp, "%s\n", txt);
}
else
{
::fprintf( fp, "%s", txt );
::fprintf(fp, "%s", txt);
}
fpOfsList[head] = ofs;
head = (head + 1) % MSG_LOG_MAX_LINES;
if ( head == tail )
if (head == tail)
{
tail = (tail + 1) % MSG_LOG_MAX_LINES;
}
@ -135,23 +137,23 @@ class msgLogBuf_t
s = head - tail;
if ( s < 0 )
if (s < 0)
{
s += MSG_LOG_MAX_LINES;
}
return s;
}
void loadTextViewer( QPlainTextEdit *viewer )
void loadTextViewer(QPlainTextEdit *viewer)
{
long ofs, nbytes;
if ( fp == NULL )
if (fp == NULL)
{
return;
}
if ( head == tail )
if (head == tail)
{
return;
}
@ -159,32 +161,32 @@ class msgLogBuf_t
ofs = fpOfsList[tail];
::fseek( fp, ofs, SEEK_SET);
::fseek(fp, ofs, SEEK_SET);
//printf("Seek: %li \n", ofs );
if ( (nbytes = ::fread( buf, 1, sizeof(buf), fp )) > 0 )
if ((nbytes = ::fread(buf, 1, sizeof(buf), fp)) > 0)
{
//printf("READ: %li \n", nbytes );
buf[ nbytes ] = 0;
viewer->setPlainText( buf );
buf[nbytes] = 0;
viewer->setPlainText(buf);
}
}
private:
FILE *fp;
size_t maxLines;
size_t totalLines;
size_t head;
size_t tail;
private:
FILE *fp;
size_t maxLines;
size_t totalLines;
size_t head;
size_t tail;
long fpOfsList[MSG_LOG_MAX_LINES];
long fpOfsList[MSG_LOG_MAX_LINES];
};
static msgLogBuf_t msgLog;
//----------------------------------------------------------------------------
MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
@ -192,37 +194,41 @@ MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent)
setWindowTitle("Message Log Viewer");
resize( 512, 512 );
resize(512, 512);
mainLayout = new QVBoxLayout();
txtView = new QPlainTextEdit();
txtView->setReadOnly(true);
mainLayout->addWidget( txtView );
mainLayout->addWidget(txtView);
hbox = new QHBoxLayout();
clearBtn = new QPushButton( tr("Clear") );
closeBtn = new QPushButton( tr("Close") );
hbox->addWidget( clearBtn );
hbox->addWidget( closeBtn );
hbox = new QHBoxLayout();
clearBtn = new QPushButton(tr("Clear"));
closeBtn = new QPushButton(tr("Close"));
hbox->addWidget(clearBtn,1);
hbox->addStretch(5);
hbox->addWidget(closeBtn,1);
connect( clearBtn, SIGNAL(clicked(void)), this, SLOT(clearLog(void)) );
connect( closeBtn, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) );
clearBtn->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
closeBtn->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
mainLayout->addLayout( hbox );
connect(clearBtn, SIGNAL(clicked(void)), this, SLOT(clearLog(void)));
connect(closeBtn, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
setLayout( mainLayout );
mainLayout->addLayout(hbox);
setLayout(mainLayout);
totalLines = 0;
updateTimer = new QTimer( this );
updateTimer = new QTimer(this);
connect( updateTimer, &QTimer::timeout, this, &MsgLogViewDialog_t::updatePeriodic );
connect(updateTimer, &QTimer::timeout, this, &MsgLogViewDialog_t::updatePeriodic);
updateTimer->start( 500 ); // 2hz
updateTimer->start(500); // 2hz
msgLog.loadTextViewer( txtView );
msgLog.loadTextViewer(txtView);
totalLines = msgLog.getTotalLineCount();
@ -237,16 +243,16 @@ MsgLogViewDialog_t::~MsgLogViewDialog_t(void)
//----------------------------------------------------------------------------
void MsgLogViewDialog_t::closeEvent(QCloseEvent *event)
{
printf("Msg Log Key Close Window Event\n");
done(0);
printf("Msg Log Key Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void MsgLogViewDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
@ -263,11 +269,11 @@ void MsgLogViewDialog_t::clearLog(void)
//----------------------------------------------------------------------------
void MsgLogViewDialog_t::updatePeriodic(void)
{
if ( msgLog.getTotalLineCount() != totalLines )
if (msgLog.getTotalLineCount() != totalLines)
{
fceuWrapperLock();
msgLog.loadTextViewer( txtView );
msgLog.loadTextViewer(txtView);
totalLines = msgLog.getTotalLineCount();
@ -289,7 +295,7 @@ void FCEUD_Message(const char *text)
fputs(text, stdout);
//fprintf(stdout, "\n");
//
msgLog.addLine( text, false );
msgLog.addLine(text, false);
}
//----------------------------------------------------------------------------
/**
@ -304,11 +310,11 @@ void FCEUD_PrintError(const char *errormsg)
{
fprintf(stderr, "%s\n", errormsg);
msgLog.addLine( errormsg, true );
msgLog.addLine(errormsg, true);
if ( consoleWindow )
if (consoleWindow)
{
consoleWindow->QueueErrorMsgWindow( errormsg );
consoleWindow->QueueErrorMsgWindow(errormsg);
}
}
//----------------------------------------------------------------------------

View File

@ -20,27 +20,24 @@
class MsgLogViewDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
MsgLogViewDialog_t(QWidget *parent = 0);
~MsgLogViewDialog_t(void);
public:
MsgLogViewDialog_t(QWidget *parent = 0);
~MsgLogViewDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QTimer *updateTimer;
QPlainTextEdit *txtView;
QTimer *updateTimer;
QPlainTextEdit *txtView;
size_t totalLines;
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void clearLog(void);
size_t totalLines;
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void clearLog(void);
};

View File

@ -35,8 +35,8 @@
extern bool force_grayscale;
static const char *commentText =
"Palette Selection uses the 1st Matching Condition:\n\
static const char *commentText =
"Palette Selection uses the 1st Matching Condition:\n\
1. Game type is NSF (always uses fixed palette) \n\
2. Custom User Palette is Available and Enabled \n\
3. NTSC Color Emulation is Enabled \n\
@ -44,150 +44,158 @@ static const char *commentText =
5. Default Built-in Palette ";
//----------------------------------------------------
PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox1;
QGroupBox *frame;
//QPushButton *closebutton;
QHBoxLayout *hbox1, *hbox;
QGroupBox *frame;
QPushButton *closeButton;
QPushButton *button;
QTextEdit *comments;
QStyle *style;
QStyle *style;
int hue, tint;
char stmp[64];
std::string paletteFile;
style = this->style();
resize( 512, 600 );
resize(512, 650);
// sync with config
g_config->getOption ("SDL.Hue", &hue);
g_config->getOption ("SDL.Tint", &tint);
g_config->getOption("SDL.Hue", &hue);
g_config->getOption("SDL.Tint", &tint);
setWindowTitle( tr("Palette Config") );
setWindowTitle(tr("Palette Config"));
mainLayout = new QVBoxLayout();
frame = new QGroupBox( tr("Custom Palette:") );
vbox = new QVBoxLayout();
frame = new QGroupBox(tr("Custom Palette:"));
vbox = new QVBoxLayout();
hbox1 = new QHBoxLayout();
useCustom = new QCheckBox( tr("Use Custom Palette") );
GrayScale = new QCheckBox( tr("Force Grayscale") );
deemphSwap = new QCheckBox( tr("De-emphasis Bit Swap") );
useCustom = new QCheckBox(tr("Use Custom Palette"));
GrayScale = new QCheckBox(tr("Force Grayscale"));
deemphSwap = new QCheckBox(tr("De-emphasis Bit Swap"));
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
GrayScale->setChecked( force_grayscale );
deemphSwap->setChecked( paldeemphswap );
useCustom->setChecked(FCEUI_GetUserPaletteAvail());
GrayScale->setChecked(force_grayscale);
deemphSwap->setChecked(paldeemphswap);
connect(useCustom , SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int)) );
connect(GrayScale , SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)) );
connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)) );
connect(useCustom, SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int)));
connect(GrayScale, SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)));
connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)));
button = new QPushButton( tr("Open Palette") );
button->setIcon( style->standardIcon( QStyle::SP_FileDialogStart ) );
hbox1->addWidget( button );
button = new QPushButton(tr("Open Palette"));
button->setIcon(style->standardIcon(QStyle::SP_FileDialogStart));
hbox1->addWidget(button);
connect( button, SIGNAL(clicked(void)), this, SLOT(openPaletteFile(void)) );
connect(button, SIGNAL(clicked(void)), this, SLOT(openPaletteFile(void)));
g_config->getOption ("SDL.Palette", &paletteFile);
g_config->getOption("SDL.Palette", &paletteFile);
custom_palette_path = new QLineEdit();
custom_palette_path->setReadOnly(true);
custom_palette_path->setText( paletteFile.c_str() );
custom_palette_path->setText(paletteFile.c_str());
vbox->addWidget( useCustom );
vbox->addLayout( hbox1 );
vbox->addWidget( custom_palette_path );
vbox->addWidget( GrayScale );
vbox->addWidget( deemphSwap);
vbox->addWidget(useCustom);
vbox->addLayout(hbox1);
vbox->addWidget(custom_palette_path);
vbox->addWidget(GrayScale);
vbox->addWidget(deemphSwap);
button = new QPushButton(tr("Clear"));
button->setIcon(style->standardIcon(QStyle::SP_LineEditClearButton));
hbox1->addWidget(button);
button = new QPushButton( tr("Clear") );
button->setIcon( style->standardIcon( QStyle::SP_LineEditClearButton ) );
hbox1->addWidget( button );
connect(button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)));
connect( button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)) );
frame->setLayout(vbox);
frame->setLayout( vbox );
mainLayout->addWidget(frame);
mainLayout->addWidget( frame );
frame = new QGroupBox(tr("NTSC Palette Controls:"));
frame = new QGroupBox( tr("NTSC Palette Controls:") );
vbox = new QVBoxLayout();
useNTSC = new QCheckBox( tr("Use NTSC Palette") );
vbox = new QVBoxLayout();
useNTSC = new QCheckBox(tr("Use NTSC Palette"));
int ntscPaletteEnable;
g_config->getOption("SDL.NTSCpalette", &ntscPaletteEnable);
useNTSC->setChecked( ntscPaletteEnable );
useNTSC->setChecked(ntscPaletteEnable);
connect(useNTSC , SIGNAL(stateChanged(int)), this, SLOT(use_NTSC_Changed(int)) );
connect(useNTSC, SIGNAL(stateChanged(int)), this, SLOT(use_NTSC_Changed(int)));
vbox->addWidget( useNTSC );
vbox->addWidget(useNTSC);
sprintf( stmp, "Tint: %3i \n", tint );
tintFrame = new QGroupBox( tr(stmp) );
sprintf(stmp, "Tint: %3i \n", tint);
tintFrame = new QGroupBox(tr(stmp));
hbox1 = new QHBoxLayout();
tintSlider = new QSlider( Qt::Horizontal );
tintSlider->setMinimum( 0);
tintSlider = new QSlider(Qt::Horizontal);
tintSlider->setMinimum(0);
tintSlider->setMaximum(128);
tintSlider->setValue( tint );
tintSlider->setValue(tint);
connect( tintSlider, SIGNAL(valueChanged(int)), this, SLOT(tintChanged(int)) );
connect(tintSlider, SIGNAL(valueChanged(int)), this, SLOT(tintChanged(int)));
hbox1->addWidget( tintSlider );
tintFrame->setLayout( hbox1 );
vbox->addWidget( tintFrame );
hbox1->addWidget(tintSlider);
tintFrame->setLayout(hbox1);
vbox->addWidget(tintFrame);
sprintf( stmp, "Hue: %3i \n", hue );
hueFrame = new QGroupBox( tr(stmp) );
sprintf(stmp, "Hue: %3i \n", hue);
hueFrame = new QGroupBox(tr(stmp));
hbox1 = new QHBoxLayout();
hueSlider = new QSlider( Qt::Horizontal );
hueSlider->setMinimum( 0);
hueSlider = new QSlider(Qt::Horizontal);
hueSlider->setMinimum(0);
hueSlider->setMaximum(128);
hueSlider->setValue( hue );
hueSlider->setValue(hue);
connect( hueSlider, SIGNAL(valueChanged(int)), this, SLOT(hueChanged(int)) );
connect(hueSlider, SIGNAL(valueChanged(int)), this, SLOT(hueChanged(int)));
hbox1->addWidget( hueSlider );
hueFrame->setLayout( hbox1 );
vbox->addWidget( hueFrame );
hbox1->addWidget(hueSlider);
hueFrame->setLayout(hbox1);
vbox->addWidget(hueFrame);
frame->setLayout( vbox );
frame->setLayout(vbox);
mainLayout->addWidget( frame );
mainLayout->addWidget(frame);
comments = new QTextEdit();
comments->setText( commentText );
comments->setText(commentText);
comments->moveCursor(QTextCursor::Start);
comments->setReadOnly(true);
mainLayout->addWidget( comments );
mainLayout->addWidget(comments);
setLayout( mainLayout );
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout(mainLayout);
}
//----------------------------------------------------
PaletteConfDialog_t::~PaletteConfDialog_t(void)
{
printf("Destroy Palette Config Window\n");
printf("Destroy Palette Config Window\n");
}
//----------------------------------------------------------------------------
void PaletteConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("Palette Config Close Window Event\n");
done(0);
printf("Palette Config Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------
void PaletteConfDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------
@ -196,18 +204,18 @@ void PaletteConfDialog_t::hueChanged(int v)
int c, t;
char stmp[64];
sprintf( stmp, "Hue: %3i", v );
sprintf(stmp, "Hue: %3i", v);
hueFrame->setTitle(stmp);
g_config->setOption ("SDL.Hue", v);
g_config->save ();
g_config->getOption ("SDL.Tint", &t);
g_config->getOption ("SDL.NTSCpalette", &c);
g_config->setOption("SDL.Hue", v);
g_config->save();
g_config->getOption("SDL.Tint", &t);
g_config->getOption("SDL.NTSCpalette", &c);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetNTSCTH (c, t, v);
FCEUI_SetNTSCTH(c, t, v);
fceuWrapperUnLock();
}
}
@ -217,18 +225,18 @@ void PaletteConfDialog_t::tintChanged(int v)
int c, h;
char stmp[64];
sprintf( stmp, "Tint: %3i", v );
sprintf(stmp, "Tint: %3i", v);
tintFrame->setTitle(stmp);
g_config->setOption ("SDL.Tint", v);
g_config->save ();
g_config->getOption ("SDL.NTSCpalette", &c);
g_config->getOption ("SDL.Hue", &h);
g_config->setOption("SDL.Tint", v);
g_config->save();
g_config->getOption("SDL.NTSCpalette", &c);
g_config->getOption("SDL.Hue", &h);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetNTSCTH (c, v, h);
FCEUI_SetNTSCTH(c, v, h);
fceuWrapperUnLock();
}
}
@ -240,17 +248,17 @@ void PaletteConfDialog_t::use_Custom_Changed(int state)
//printf("Use Custom:%i \n", state );
g_config->getOption ("SDL.Palette", &filename);
g_config->getOption("SDL.Palette", &filename);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
if ( value && (filename.size() > 0) )
if (value && (filename.size() > 0))
{
LoadCPalette ( filename.c_str() );
LoadCPalette(filename.c_str());
}
else
{
FCEUI_SetUserPalette( NULL, 0);
FCEUI_SetUserPalette(NULL, 0);
}
fceuWrapperUnLock();
}
@ -260,14 +268,14 @@ void PaletteConfDialog_t::force_GrayScale_Changed(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
int e, h, t;
g_config->getOption ("SDL.NTSCpalette", &e);
g_config->getOption ("SDL.Hue", &h);
g_config->getOption ("SDL.Tint", &t);
g_config->getOption("SDL.NTSCpalette", &e);
g_config->getOption("SDL.Hue", &h);
g_config->getOption("SDL.Tint", &t);
force_grayscale = value ? true : false;
FCEUI_SetNTSCTH( e, t, h);
FCEUI_SetNTSCTH(e, t, h);
fceuWrapperUnLock();
}
}
@ -276,14 +284,14 @@ void PaletteConfDialog_t::deemphswap_Changed(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
int e, h, t;
g_config->getOption ("SDL.NTSCpalette", &e);
g_config->getOption ("SDL.Hue", &h);
g_config->getOption ("SDL.Tint", &t);
g_config->getOption("SDL.NTSCpalette", &e);
g_config->getOption("SDL.Hue", &h);
g_config->getOption("SDL.Tint", &t);
paldeemphswap = value ? true : false;
FCEUI_SetNTSCTH( e, t, h);
FCEUI_SetNTSCTH(e, t, h);
fceuWrapperUnLock();
}
}
@ -293,15 +301,15 @@ void PaletteConfDialog_t::use_NTSC_Changed(int state)
int h, t;
int value = (state == Qt::Unchecked) ? 0 : 1;
g_config->setOption ("SDL.NTSCpalette", value);
g_config->save ();
g_config->setOption("SDL.NTSCpalette", value);
g_config->save();
g_config->getOption ("SDL.Hue", &h);
g_config->getOption ("SDL.Tint", &t);
g_config->getOption("SDL.Hue", &h);
g_config->getOption("SDL.Tint", &t);
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetNTSCTH (value, t, h);
FCEUI_SetNTSCTH(value, t, h);
//UpdateEMUCore (g_config);
fceuWrapperUnLock();
}
@ -309,12 +317,12 @@ void PaletteConfDialog_t::use_NTSC_Changed(int state)
//----------------------------------------------------
void PaletteConfDialog_t::clearPalette(void)
{
g_config->setOption ("SDL.Palette", "");
g_config->setOption("SDL.Palette", "");
custom_palette_path->setText("");
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
FCEUI_SetUserPalette( NULL, 0);
FCEUI_SetUserPalette(NULL, 0);
fceuWrapperUnLock();
useCustom->setChecked(false);
}
@ -327,24 +335,24 @@ void PaletteConfDialog_t::openPaletteFile(void)
std::string last, iniPath;
char dir[512];
char exePath[512];
QFileDialog dialog(this, tr("Open NES Palette") );
QFileDialog dialog(this, tr("Open NES Palette"));
QList<QUrl> urls;
QDir d;
QDir d;
fceuExecutablePath( exePath, sizeof(exePath) );
fceuExecutablePath(exePath, sizeof(exePath));
//urls = dialog.sidebarUrls();
urls << QUrl::fromLocalFile( QDir::rootPath() );
urls << QUrl::fromLocalFile(QDir::rootPath());
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
urls << QUrl::fromLocalFile(QDir(FCEUI_GetBaseDirectory()).absolutePath());
if ( exePath[0] != 0 )
if (exePath[0] != 0)
{
d.setPath( QString(exePath) + "/../palettes" );
d.setPath(QString(exePath) + "/../palettes");
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
iniPath = d.absolutePath().toStdString();
}
}
@ -353,9 +361,9 @@ void PaletteConfDialog_t::openPaletteFile(void)
#else
d.setPath("/usr/share/fceux/palettes");
if ( d.exists() )
if (d.exists())
{
urls << QUrl::fromLocalFile( d.absolutePath() );
urls << QUrl::fromLocalFile(d.absolutePath());
iniPath = d.absolutePath().toStdString();
}
#endif
@ -365,62 +373,61 @@ void PaletteConfDialog_t::openPaletteFile(void)
dialog.setNameFilter(tr("NES Palettes (*.pal *.PAL) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText(QFileDialog::Accept, tr("Load"));
g_config->getOption ("SDL.Palette", &last );
g_config->getOption("SDL.Palette", &last);
if ( last.size() == 0 )
if (last.size() == 0)
{
last.assign( iniPath );
last.assign(iniPath);
}
getDirFromFile( last.c_str(), dir );
getDirFromFile(last.c_str(), dir);
dialog.setDirectory( tr(dir) );
dialog.setDirectory(tr(dir));
// Check config option to use native file dialog or not
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
dialog.setSidebarUrls(urls);
ret = dialog.exec();
if ( ret )
if (ret)
{
QStringList fileList;
fileList = dialog.selectedFiles();
if ( fileList.size() > 0 )
if (fileList.size() > 0)
{
filename = fileList[0];
}
}
if ( filename.isNull() )
if (filename.isNull())
{
return;
return;
}
qDebug() << "selected file path : " << filename.toUtf8();
if ( fceuWrapperTryLock() )
if (fceuWrapperTryLock())
{
if ( LoadCPalette ( filename.toStdString().c_str() ) )
if (LoadCPalette(filename.toStdString().c_str()))
{
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
custom_palette_path->setText( filename.toStdString().c_str() );
g_config->setOption("SDL.Palette", filename.toStdString().c_str());
custom_palette_path->setText(filename.toStdString().c_str());
}
else
{
printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str() );
printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str());
}
fceuWrapperUnLock();
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
useCustom->setChecked(FCEUI_GetUserPaletteAvail());
}
return;
return;
}
//----------------------------------------------------

View File

@ -19,36 +19,35 @@
class PaletteConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
PaletteConfDialog_t(QWidget *parent = 0);
~PaletteConfDialog_t(void);
public:
PaletteConfDialog_t(QWidget *parent = 0);
~PaletteConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QLineEdit *custom_palette_path;
QCheckBox *useCustom;
QCheckBox *GrayScale;
QCheckBox *deemphSwap;
QCheckBox *useNTSC;
QSlider *tintSlider;
QSlider *hueSlider;
QGroupBox *tintFrame;
QGroupBox *hueFrame;
private:
public slots:
void closeWindow(void);
private slots:
void hueChanged(int value);
void tintChanged(int value);
void openPaletteFile(void);
void clearPalette(void);
void use_NTSC_Changed(int v);
void use_Custom_Changed(int v);
void force_GrayScale_Changed(int v);
void deemphswap_Changed(int v);
QLineEdit *custom_palette_path;
QCheckBox *useCustom;
QCheckBox *GrayScale;
QCheckBox *deemphSwap;
QCheckBox *useNTSC;
QSlider *tintSlider;
QSlider *hueSlider;
QGroupBox *tintFrame;
QGroupBox *hueFrame;
private:
public slots:
void closeWindow(void);
private slots:
void hueChanged(int value);
void tintChanged(int value);
void openPaletteFile(void);
void clearPalette(void);
void use_NTSC_Changed(int v);
void use_Custom_Changed(int v);
void force_GrayScale_Changed(int v);
void deemphswap_Changed(int v);
};

View File

@ -90,6 +90,16 @@ PaletteEditorDialog_t::PaletteEditorDialog_t(QWidget *parent)
fileMenu->addAction(act);
fileMenu->addSeparator();
// File -> Close
act = new QAction(tr("&Close"), this);
act->setShortcut( QKeySequence::Close );
act->setStatusTip(tr("Close Window"));
connect(act, SIGNAL(triggered()), this, SLOT(closeWindow(void)) );
fileMenu->addAction(act);
// Memory
memMenu = menuBar->addMenu(tr("&Memory"));

View File

@ -148,9 +148,9 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
fileMenu->addSeparator();
// File -> Append
// File -> Close
menuAct = new QAction(tr("&Close"), this);
menuAct->setShortcut( QKeySequence(tr("Alt+F4")) );
menuAct->setShortcut( QKeySequence::Close );
menuAct->setStatusTip(tr("Close Window"));
connect(menuAct, SIGNAL(triggered()), this, SLOT(closeWindow(void)) );

View File

@ -47,7 +47,7 @@
#include "Qt/TimingConf.h"
//----------------------------------------------------------------------------
static bool hasNicePermissions( int val )
static bool hasNicePermissions(int val)
{
#ifndef WIN32
int usrID;
@ -57,18 +57,18 @@ static bool hasNicePermissions( int val )
usrRoot = (usrID == 0);
if ( usrRoot )
if (usrRoot)
{
return true;
}
#ifdef __linux__
struct rlimit r;
if ( getrlimit( RLIMIT_NICE, &r ) == 0 )
if (getrlimit(RLIMIT_NICE, &r) == 0)
{
int ncur = 20 - r.rlim_cur;
if ( val >= ncur )
if (val >= ncur)
{
return true;
}
@ -82,116 +82,126 @@ static bool hasNicePermissions( int val )
}
//----------------------------------------------------------------------------
TimingConfDialog_t::TimingConfDialog_t(QWidget *parent)
: QDialog( parent )
: QDialog(parent)
{
int opt;
QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QGridLayout *grid;
QGroupBox *emuPrioBox, *guiPrioBox;
QPushButton *closeButton;
QGroupBox *emuPrioBox, *guiPrioBox;
setWindowTitle("Timing Configuration");
mainLayout = new QVBoxLayout();
emuPrioCtlEna = new QCheckBox( tr("Set Scheduling Parameters at Startup") );
emuPrioCtlEna = new QCheckBox(tr("Set Scheduling Parameters at Startup"));
emuPrioBox = new QGroupBox( tr("EMU Thread Scheduling Parameters") );
guiPrioBox = new QGroupBox( tr("GUI Thread Scheduling Parameters") );
grid = new QGridLayout();
emuPrioBox->setLayout( grid );
emuPrioBox = new QGroupBox(tr("EMU Thread Scheduling Parameters"));
guiPrioBox = new QGroupBox(tr("GUI Thread Scheduling Parameters"));
grid = new QGridLayout();
emuPrioBox->setLayout(grid);
mainLayout->addWidget( emuPrioCtlEna );
mainLayout->addWidget( emuPrioBox );
mainLayout->addWidget( guiPrioBox );
mainLayout->addWidget(emuPrioCtlEna);
mainLayout->addWidget(emuPrioBox);
mainLayout->addWidget(guiPrioBox);
#ifdef WIN32
emuSchedPrioBox = new QComboBox();
guiSchedPrioBox = new QComboBox();
emuSchedPrioBox = new QComboBox();
guiSchedPrioBox = new QComboBox();
grid->addWidget( emuSchedPrioBox, 0, 0 );
grid->addWidget(emuSchedPrioBox, 0, 0);
grid = new QGridLayout();
guiPrioBox->setLayout( grid );
grid = new QGridLayout();
guiPrioBox->setLayout(grid);
grid->addWidget( guiSchedPrioBox, 0, 0 );
grid->addWidget(guiSchedPrioBox, 0, 0);
emuSchedPrioBox->addItem( tr("Idle" ) , QThread::IdlePriority );
emuSchedPrioBox->addItem( tr("Lowest") , QThread::LowestPriority );
emuSchedPrioBox->addItem( tr("Low" ) , QThread::LowPriority );
emuSchedPrioBox->addItem( tr("Normal") , QThread::NormalPriority );
emuSchedPrioBox->addItem( tr("High") , QThread::HighPriority );
emuSchedPrioBox->addItem( tr("Highest") , QThread::HighestPriority );
emuSchedPrioBox->addItem( tr("Time Critical"), QThread::TimeCriticalPriority );
emuSchedPrioBox->addItem( tr("Inherit") , QThread::InheritPriority );
emuSchedPrioBox->addItem(tr("Idle"), QThread::IdlePriority);
emuSchedPrioBox->addItem(tr("Lowest"), QThread::LowestPriority);
emuSchedPrioBox->addItem(tr("Low"), QThread::LowPriority);
emuSchedPrioBox->addItem(tr("Normal"), QThread::NormalPriority);
emuSchedPrioBox->addItem(tr("High"), QThread::HighPriority);
emuSchedPrioBox->addItem(tr("Highest"), QThread::HighestPriority);
emuSchedPrioBox->addItem(tr("Time Critical"), QThread::TimeCriticalPriority);
emuSchedPrioBox->addItem(tr("Inherit"), QThread::InheritPriority);
guiSchedPrioBox->addItem( tr("Idle" ) , QThread::IdlePriority );
guiSchedPrioBox->addItem( tr("Lowest") , QThread::LowestPriority );
guiSchedPrioBox->addItem( tr("Low" ) , QThread::LowPriority );
guiSchedPrioBox->addItem( tr("Normal") , QThread::NormalPriority );
guiSchedPrioBox->addItem( tr("High") , QThread::HighPriority );
guiSchedPrioBox->addItem( tr("Highest") , QThread::HighestPriority );
guiSchedPrioBox->addItem( tr("Time Critical"), QThread::TimeCriticalPriority );
guiSchedPrioBox->addItem( tr("Inherit") , QThread::InheritPriority );
guiSchedPrioBox->addItem(tr("Idle"), QThread::IdlePriority);
guiSchedPrioBox->addItem(tr("Lowest"), QThread::LowestPriority);
guiSchedPrioBox->addItem(tr("Low"), QThread::LowPriority);
guiSchedPrioBox->addItem(tr("Normal"), QThread::NormalPriority);
guiSchedPrioBox->addItem(tr("High"), QThread::HighPriority);
guiSchedPrioBox->addItem(tr("Highest"), QThread::HighestPriority);
guiSchedPrioBox->addItem(tr("Time Critical"), QThread::TimeCriticalPriority);
guiSchedPrioBox->addItem(tr("Inherit"), QThread::InheritPriority);
#else
emuSchedPolicyBox = new QComboBox();
emuSchedPrioSlider = new QSlider( Qt::Horizontal );
emuSchedNiceSlider = new QSlider( Qt::Horizontal );
emuSchedPrioLabel = new QLabel( tr("Priority (RT)") );
emuSchedNiceLabel = new QLabel( tr("Priority (Nice)") );
emuSchedPolicyBox = new QComboBox();
emuSchedPrioSlider = new QSlider(Qt::Horizontal);
emuSchedNiceSlider = new QSlider(Qt::Horizontal);
emuSchedPrioLabel = new QLabel(tr("Priority (RT)"));
emuSchedNiceLabel = new QLabel(tr("Priority (Nice)"));
emuSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER );
emuSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO );
emuSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR );
emuSchedPolicyBox->addItem(tr("SCHED_OTHER"), SCHED_OTHER);
emuSchedPolicyBox->addItem(tr("SCHED_FIFO"), SCHED_FIFO);
emuSchedPolicyBox->addItem(tr("SCHED_RR"), SCHED_RR);
grid->addWidget( new QLabel( tr("Policy") ), 0, 0 );
grid->addWidget( emuSchedPolicyBox, 0, 1 );
grid->addWidget( emuSchedPrioLabel, 1, 0 );
grid->addWidget( emuSchedPrioSlider, 1, 1 );
grid->addWidget( emuSchedNiceLabel, 2, 0 );
grid->addWidget( emuSchedNiceSlider, 2, 1 );
grid->addWidget(new QLabel(tr("Policy")), 0, 0);
grid->addWidget(emuSchedPolicyBox, 0, 1);
grid->addWidget(emuSchedPrioLabel, 1, 0);
grid->addWidget(emuSchedPrioSlider, 1, 1);
grid->addWidget(emuSchedNiceLabel, 2, 0);
grid->addWidget(emuSchedNiceSlider, 2, 1);
grid = new QGridLayout();
guiPrioBox->setLayout( grid );
grid = new QGridLayout();
guiPrioBox->setLayout(grid);
guiSchedPolicyBox = new QComboBox();
guiSchedPrioSlider = new QSlider( Qt::Horizontal );
guiSchedNiceSlider = new QSlider( Qt::Horizontal );
guiSchedPrioLabel = new QLabel( tr("Priority (RT)") );
guiSchedNiceLabel = new QLabel( tr("Priority (Nice)") );
guiSchedPolicyBox = new QComboBox();
guiSchedPrioSlider = new QSlider(Qt::Horizontal);
guiSchedNiceSlider = new QSlider(Qt::Horizontal);
guiSchedPrioLabel = new QLabel(tr("Priority (RT)"));
guiSchedNiceLabel = new QLabel(tr("Priority (Nice)"));
guiSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER );
guiSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO );
guiSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR );
guiSchedPolicyBox->addItem(tr("SCHED_OTHER"), SCHED_OTHER);
guiSchedPolicyBox->addItem(tr("SCHED_FIFO"), SCHED_FIFO);
guiSchedPolicyBox->addItem(tr("SCHED_RR"), SCHED_RR);
grid->addWidget( new QLabel( tr("Policy") ), 0, 0 );
grid->addWidget( guiSchedPolicyBox, 0, 1 );
grid->addWidget( guiSchedPrioLabel, 1, 0 );
grid->addWidget( guiSchedPrioSlider, 1, 1 );
grid->addWidget( guiSchedNiceLabel, 2, 0 );
grid->addWidget( guiSchedNiceSlider, 2, 1 );
grid->addWidget(new QLabel(tr("Policy")), 0, 0);
grid->addWidget(guiSchedPolicyBox, 0, 1);
grid->addWidget(guiSchedPrioLabel, 1, 0);
grid->addWidget(guiSchedPrioSlider, 1, 1);
grid->addWidget(guiSchedNiceLabel, 2, 0);
grid->addWidget(guiSchedNiceSlider, 2, 1);
#endif
hbox = new QHBoxLayout();
timingDevSelBox = new QComboBox();
#ifdef WIN32
timingDevSelBox->addItem( tr("SDL_Delay") , 0 );
timingDevSelBox->addItem(tr("SDL_Delay"), 0);
#else
timingDevSelBox->addItem( tr("NanoSleep") , 0 );
timingDevSelBox->addItem(tr("NanoSleep"), 0);
#endif
#ifdef __linux__
timingDevSelBox->addItem( tr("Timer FD") , 1 );
timingDevSelBox->addItem(tr("Timer FD"), 1);
#endif
hbox->addWidget( new QLabel( tr("Timing Mechanism:") ) );
hbox->addWidget( timingDevSelBox );
hbox->addWidget(new QLabel(tr("Timing Mechanism:")));
hbox->addWidget(timingDevSelBox);
mainLayout->addLayout(hbox);
closeButton = new QPushButton( tr("Close") );
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
hbox = new QHBoxLayout();
hbox->addStretch(5);
hbox->addWidget( closeButton, 1 );
mainLayout->addLayout( hbox );
setLayout( mainLayout );
setLayout(mainLayout);
g_config->getOption( "SDL.SetSchedParam", &opt );
emuPrioCtlEna->setChecked( opt );
g_config->getOption("SDL.SetSchedParam", &opt);
emuPrioCtlEna->setChecked(opt);
updatePolicyBox();
updateSliderLimits();
@ -199,18 +209,18 @@ TimingConfDialog_t::TimingConfDialog_t(QWidget *parent)
updateTimingMech();
#ifdef WIN32
connect( emuSchedPrioBox , SIGNAL(activated(int)) , this, SLOT(emuSchedPrioChange(int)) );
connect( guiSchedPrioBox , SIGNAL(activated(int)) , this, SLOT(guiSchedPrioChange(int)) );
connect(emuSchedPrioBox, SIGNAL(activated(int)), this, SLOT(emuSchedPrioChange(int)));
connect(guiSchedPrioBox, SIGNAL(activated(int)), this, SLOT(guiSchedPrioChange(int)));
#else
connect( emuSchedPolicyBox , SIGNAL(activated(int)) , this, SLOT(emuSchedPolicyChange(int)) );
connect( emuSchedNiceSlider , SIGNAL(valueChanged(int)), this, SLOT(emuSchedNiceChange(int)) );
connect( emuSchedPrioSlider , SIGNAL(valueChanged(int)), this, SLOT(emuSchedPrioChange(int)) );
connect( guiSchedPolicyBox , SIGNAL(activated(int)) , this, SLOT(guiSchedPolicyChange(int)) );
connect( guiSchedNiceSlider , SIGNAL(valueChanged(int)), this, SLOT(guiSchedNiceChange(int)) );
connect( guiSchedPrioSlider , SIGNAL(valueChanged(int)), this, SLOT(guiSchedPrioChange(int)) );
connect(emuSchedPolicyBox, SIGNAL(activated(int)), this, SLOT(emuSchedPolicyChange(int)));
connect(emuSchedNiceSlider, SIGNAL(valueChanged(int)), this, SLOT(emuSchedNiceChange(int)));
connect(emuSchedPrioSlider, SIGNAL(valueChanged(int)), this, SLOT(emuSchedPrioChange(int)));
connect(guiSchedPolicyBox, SIGNAL(activated(int)), this, SLOT(guiSchedPolicyChange(int)));
connect(guiSchedNiceSlider, SIGNAL(valueChanged(int)), this, SLOT(guiSchedNiceChange(int)));
connect(guiSchedPrioSlider, SIGNAL(valueChanged(int)), this, SLOT(guiSchedPrioChange(int)));
#endif
connect( emuPrioCtlEna , SIGNAL(stateChanged(int)), this, SLOT(emuSchedCtlChange(int)) );
connect( timingDevSelBox , SIGNAL(activated(int)) , this, SLOT(emuTimingMechChange(int)) );
connect(emuPrioCtlEna, SIGNAL(stateChanged(int)), this, SLOT(emuSchedCtlChange(int)));
connect(timingDevSelBox, SIGNAL(activated(int)), this, SLOT(emuTimingMechChange(int)));
}
//----------------------------------------------------------------------------
TimingConfDialog_t::~TimingConfDialog_t(void)
@ -221,22 +231,22 @@ TimingConfDialog_t::~TimingConfDialog_t(void)
//----------------------------------------------------------------------------
void TimingConfDialog_t::closeEvent(QCloseEvent *event)
{
printf("Timing Close Window Event\n");
done(0);
printf("Timing Close Window Event\n");
done(0);
deleteLater();
event->accept();
event->accept();
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::emuSchedCtlChange( int state )
void TimingConfDialog_t::emuSchedCtlChange(int state)
{
g_config->setOption( "SDL.SetSchedParam", (state != Qt::Unchecked) );
g_config->setOption("SDL.SetSchedParam", (state != Qt::Unchecked));
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::saveValues(void)
@ -244,27 +254,27 @@ void TimingConfDialog_t::saveValues(void)
#ifndef WIN32
int policy, prio, nice;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
nice = consoleWindow->emulatorThread->getNicePriority();
consoleWindow->emulatorThread->getSchedParam( policy, prio );
consoleWindow->emulatorThread->getSchedParam(policy, prio);
g_config->setOption( "SDL.EmuSchedPolicy", policy );
g_config->setOption( "SDL.EmuSchedPrioRt", prio );
g_config->setOption( "SDL.EmuSchedNice" , nice );
g_config->setOption("SDL.EmuSchedPolicy", policy);
g_config->setOption("SDL.EmuSchedPrioRt", prio);
g_config->setOption("SDL.EmuSchedNice", nice);
//printf("EMU Sched: %i %i %i\n", policy, prio, nice );
nice = consoleWindow->getNicePriority();
consoleWindow->getSchedParam( policy, prio );
consoleWindow->getSchedParam(policy, prio);
g_config->setOption( "SDL.GuiSchedPolicy", policy );
g_config->setOption( "SDL.GuiSchedPrioRt", prio );
g_config->setOption( "SDL.GuiSchedNice" , nice );
g_config->setOption("SDL.GuiSchedPolicy", policy);
g_config->setOption("SDL.GuiSchedPrioRt", prio);
g_config->setOption("SDL.GuiSchedNice", nice);
//printf("GUI Sched: %i %i %i\n", policy, prio, nice );
@ -275,26 +285,26 @@ void TimingConfDialog_t::saveValues(void)
void TimingConfDialog_t::emuSchedNiceChange(int val)
{
#ifndef WIN32
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
if ( consoleWindow->emulatorThread->setNicePriority( -val ) )
if (consoleWindow->emulatorThread->setNicePriority(-val))
{
char msg[1024];
sprintf( msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
updateSliderValues();
}
fceuWrapperUnLock();
@ -303,71 +313,71 @@ void TimingConfDialog_t::emuSchedNiceChange(int val)
//----------------------------------------------------------------------------
void TimingConfDialog_t::emuSchedPrioChange(int val)
{
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
#ifdef WIN32
printf("Setting EMU Thread to %i\n", val );
printf("Setting EMU Thread to %i\n", val);
fceuWrapperLock();
consoleWindow->emulatorThread->setPriority( (QThread::Priority)val);
consoleWindow->emulatorThread->setPriority((QThread::Priority)val);
fceuWrapperUnLock();
#else
int policy, prio;
fceuWrapperLock();
consoleWindow->emulatorThread->getSchedParam( policy, prio );
consoleWindow->emulatorThread->getSchedParam(policy, prio);
if ( consoleWindow->emulatorThread->setSchedParam( policy, val ) )
if (consoleWindow->emulatorThread->setSchedParam(policy, val))
{
char msg[1024];
sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
updateSliderValues();
}
fceuWrapperUnLock();
#endif
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::emuSchedPolicyChange( int index )
void TimingConfDialog_t::emuSchedPolicyChange(int index)
{
#ifndef WIN32
int policy, prio;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
consoleWindow->emulatorThread->getSchedParam( policy, prio );
consoleWindow->emulatorThread->getSchedParam(policy, prio);
policy = emuSchedPolicyBox->itemData( index ).toInt();
policy = emuSchedPolicyBox->itemData(index).toInt();
if ( consoleWindow->emulatorThread->setSchedParam( policy, prio ) )
if (consoleWindow->emulatorThread->setSchedParam(policy, prio))
{
char msg[1024];
sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
}
updatePolicyBox();
@ -380,26 +390,26 @@ void TimingConfDialog_t::emuSchedPolicyChange( int index )
void TimingConfDialog_t::guiSchedNiceChange(int val)
{
#ifndef WIN32
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
if ( consoleWindow->setNicePriority( -val ) )
if (consoleWindow->setNicePriority(-val))
{
char msg[1024];
sprintf( msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
updateSliderValues();
}
fceuWrapperUnLock();
@ -409,68 +419,68 @@ void TimingConfDialog_t::guiSchedNiceChange(int val)
void TimingConfDialog_t::guiSchedPrioChange(int val)
{
#ifdef WIN32
printf("Setting GUI Thread to %i\n", val );
QThread::currentThread()->setPriority( (QThread::Priority)val);
printf("Setting GUI Thread to %i\n", val);
QThread::currentThread()->setPriority((QThread::Priority)val);
#else
int policy, prio;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
consoleWindow->getSchedParam( policy, prio );
consoleWindow->getSchedParam(policy, prio);
if ( consoleWindow->setSchedParam( policy, val ) )
if (consoleWindow->setSchedParam(policy, val))
{
char msg[1024];
sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
updateSliderValues();
}
fceuWrapperUnLock();
#endif
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::guiSchedPolicyChange( int index )
void TimingConfDialog_t::guiSchedPolicyChange(int index)
{
#ifndef WIN32
int policy, prio;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
consoleWindow->getSchedParam( policy, prio );
consoleWindow->getSchedParam(policy, prio);
policy = guiSchedPolicyBox->itemData( index ).toInt();
policy = guiSchedPolicyBox->itemData(index).toInt();
if ( consoleWindow->setSchedParam( policy, prio ) )
if (consoleWindow->setSchedParam(policy, prio))
{
char msg[1024];
sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) );
sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno));
#ifdef __linux__
strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat( msg, " /etc/security/limits.conf \n\n");
strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat( msg, "* - priority 99 \n");
strcat( msg, "* - rtprio 99 \n");
strcat( msg, "* - nice -20 \n");
strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n");
strcat(msg, " /etc/security/limits.conf \n\n");
strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n");
strcat(msg, "* - priority 99 \n");
strcat(msg, "* - rtprio 99 \n");
strcat(msg, "* - nice -20 \n");
#endif
printf("%s\n", msg );
consoleWindow->QueueErrorMsgWindow( msg );
printf("%s\n", msg);
consoleWindow->QueueErrorMsgWindow(msg);
}
updatePolicyBox();
@ -482,7 +492,7 @@ void TimingConfDialog_t::guiSchedPolicyChange( int index )
//----------------------------------------------------------------------------
void TimingConfDialog_t::updatePolicyBox(void)
{
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
@ -491,48 +501,48 @@ void TimingConfDialog_t::updatePolicyBox(void)
prio = consoleWindow->emulatorThread->priority();
printf("EMU Priority %i\n", prio );
for (int j=0; j<emuSchedPrioBox->count(); j++)
printf("EMU Priority %i\n", prio);
for (int j = 0; j < emuSchedPrioBox->count(); j++)
{
if ( emuSchedPrioBox->itemData(j).toInt() == prio )
if (emuSchedPrioBox->itemData(j).toInt() == prio)
{
printf("EMU Found Priority %i %i\n", j , prio );
emuSchedPrioBox->setCurrentIndex( j );
printf("EMU Found Priority %i %i\n", j, prio);
emuSchedPrioBox->setCurrentIndex(j);
}
}
prio = QThread::currentThread()->priority();
for (int j=0; j<guiSchedPrioBox->count(); j++)
for (int j = 0; j < guiSchedPrioBox->count(); j++)
{
if ( guiSchedPrioBox->itemData(j).toInt() == prio )
if (guiSchedPrioBox->itemData(j).toInt() == prio)
{
printf("GUI Found Priority %i %i\n", j , prio );
guiSchedPrioBox->setCurrentIndex( j );
printf("GUI Found Priority %i %i\n", j, prio);
guiSchedPrioBox->setCurrentIndex(j);
}
}
#else
int policy, prio;
consoleWindow->emulatorThread->getSchedParam( policy, prio );
consoleWindow->emulatorThread->getSchedParam(policy, prio);
for (int j=0; j<emuSchedPolicyBox->count(); j++)
for (int j = 0; j < emuSchedPolicyBox->count(); j++)
{
if ( emuSchedPolicyBox->itemData(j).toInt() == policy )
if (emuSchedPolicyBox->itemData(j).toInt() == policy)
{
//printf("Found Policy %i %i\n", j , policy );
emuSchedPolicyBox->setCurrentIndex( j );
emuSchedPolicyBox->setCurrentIndex(j);
}
}
consoleWindow->getSchedParam( policy, prio );
consoleWindow->getSchedParam(policy, prio);
for (int j=0; j<guiSchedPolicyBox->count(); j++)
for (int j = 0; j < guiSchedPolicyBox->count(); j++)
{
if ( guiSchedPolicyBox->itemData(j).toInt() == policy )
if (guiSchedPolicyBox->itemData(j).toInt() == policy)
{
//printf("Found Policy %i %i\n", j , policy );
guiSchedPolicyBox->setCurrentIndex( j );
guiSchedPolicyBox->setCurrentIndex(j);
}
}
#endif
@ -544,16 +554,16 @@ void TimingConfDialog_t::updateSliderValues(void)
int policy, prio;
bool hasNicePerms;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
consoleWindow->emulatorThread->getSchedParam( policy, prio );
consoleWindow->emulatorThread->getSchedParam(policy, prio);
emuSchedNiceSlider->setValue( -consoleWindow->emulatorThread->getNicePriority() );
emuSchedPrioSlider->setValue( prio );
emuSchedNiceSlider->setValue(-consoleWindow->emulatorThread->getNicePriority());
emuSchedPrioSlider->setValue(prio);
if ( (policy == SCHED_RR) || (policy == SCHED_FIFO) )
if ((policy == SCHED_RR) || (policy == SCHED_FIFO))
{
emuSchedPrioLabel->setEnabled(true);
emuSchedPrioSlider->setEnabled(true);
@ -563,17 +573,17 @@ void TimingConfDialog_t::updateSliderValues(void)
emuSchedPrioLabel->setEnabled(false);
emuSchedPrioSlider->setEnabled(false);
}
hasNicePerms = hasNicePermissions( consoleWindow->emulatorThread->getNicePriority() );
hasNicePerms = hasNicePermissions(consoleWindow->emulatorThread->getNicePriority());
emuSchedNiceLabel->setEnabled( hasNicePerms );
emuSchedNiceSlider->setEnabled( hasNicePerms );
emuSchedNiceLabel->setEnabled(hasNicePerms);
emuSchedNiceSlider->setEnabled(hasNicePerms);
consoleWindow->getSchedParam( policy, prio );
consoleWindow->getSchedParam(policy, prio);
guiSchedNiceSlider->setValue( -consoleWindow->getNicePriority() );
guiSchedPrioSlider->setValue( prio );
guiSchedNiceSlider->setValue(-consoleWindow->getNicePriority());
guiSchedPrioSlider->setValue(prio);
if ( (policy == SCHED_RR) || (policy == SCHED_FIFO) )
if ((policy == SCHED_RR) || (policy == SCHED_FIFO))
{
guiSchedPrioLabel->setEnabled(true);
guiSchedPrioSlider->setEnabled(true);
@ -583,47 +593,46 @@ void TimingConfDialog_t::updateSliderValues(void)
guiSchedPrioLabel->setEnabled(false);
guiSchedPrioSlider->setEnabled(false);
}
hasNicePerms = hasNicePermissions( consoleWindow->getNicePriority() );
hasNicePerms = hasNicePermissions(consoleWindow->getNicePriority());
guiSchedNiceLabel->setEnabled( hasNicePerms );
guiSchedNiceSlider->setEnabled( hasNicePerms );
guiSchedNiceLabel->setEnabled(hasNicePerms);
guiSchedNiceSlider->setEnabled(hasNicePerms);
#endif
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::updateSliderLimits(void)
{
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
#ifndef WIN32
emuSchedNiceSlider->setMinimum( -20 );
emuSchedNiceSlider->setMaximum( 20 );
emuSchedPrioSlider->setMinimum( consoleWindow->emulatorThread->getMinSchedPriority() );
emuSchedPrioSlider->setMaximum( consoleWindow->emulatorThread->getMaxSchedPriority() );
emuSchedNiceSlider->setMinimum(-20);
emuSchedNiceSlider->setMaximum(20);
emuSchedPrioSlider->setMinimum(consoleWindow->emulatorThread->getMinSchedPriority());
emuSchedPrioSlider->setMaximum(consoleWindow->emulatorThread->getMaxSchedPriority());
guiSchedNiceSlider->setMinimum( -20 );
guiSchedNiceSlider->setMaximum( 20 );
guiSchedPrioSlider->setMinimum( consoleWindow->getMinSchedPriority() );
guiSchedPrioSlider->setMaximum( consoleWindow->getMaxSchedPriority() );
guiSchedNiceSlider->setMinimum(-20);
guiSchedNiceSlider->setMaximum(20);
guiSchedPrioSlider->setMinimum(consoleWindow->getMinSchedPriority());
guiSchedPrioSlider->setMaximum(consoleWindow->getMaxSchedPriority());
#endif
}
//----------------------------------------------------------------------------
void TimingConfDialog_t::emuTimingMechChange( int index )
void TimingConfDialog_t::emuTimingMechChange(int index)
{
int mode;
if ( consoleWindow == NULL )
if (consoleWindow == NULL)
{
return;
}
fceuWrapperLock();
mode = timingDevSelBox->itemData( index ).toInt();
mode = timingDevSelBox->itemData(index).toInt();
setTimingMode( mode );
setTimingMode(mode);
RefreshThrottleFPS();
@ -636,11 +645,11 @@ void TimingConfDialog_t::updateTimingMech(void)
{
int mode = getTimingMode();
for (int j=0; j<timingDevSelBox->count(); j++)
for (int j = 0; j < timingDevSelBox->count(); j++)
{
if ( timingDevSelBox->itemData(j).toInt() == mode )
if (timingDevSelBox->itemData(j).toInt() == mode)
{
timingDevSelBox->setCurrentIndex( j );
timingDevSelBox->setCurrentIndex(j);
}
}
}

View File

@ -21,50 +21,49 @@
class TimingConfDialog_t : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
TimingConfDialog_t(QWidget *parent = 0);
~TimingConfDialog_t(void);
public:
TimingConfDialog_t(QWidget *parent = 0);
~TimingConfDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
QCheckBox *emuPrioCtlEna;
QCheckBox *emuPrioCtlEna;
#ifdef WIN32
QComboBox *emuSchedPrioBox;
QComboBox *guiSchedPrioBox;
QComboBox *emuSchedPrioBox;
QComboBox *guiSchedPrioBox;
#else
QComboBox *emuSchedPolicyBox;
QSlider *emuSchedPrioSlider;
QSlider *emuSchedNiceSlider;
QLabel *emuSchedPrioLabel;
QLabel *emuSchedNiceLabel;
QComboBox *guiSchedPolicyBox;
QSlider *guiSchedPrioSlider;
QSlider *guiSchedNiceSlider;
QLabel *guiSchedPrioLabel;
QLabel *guiSchedNiceLabel;
QComboBox *emuSchedPolicyBox;
QSlider *emuSchedPrioSlider;
QSlider *emuSchedNiceSlider;
QLabel *emuSchedPrioLabel;
QLabel *emuSchedNiceLabel;
QComboBox *guiSchedPolicyBox;
QSlider *guiSchedPrioSlider;
QSlider *guiSchedNiceSlider;
QLabel *guiSchedPrioLabel;
QLabel *guiSchedNiceLabel;
#endif
QComboBox *timingDevSelBox;
QComboBox *timingDevSelBox;
private:
void updatePolicyBox(void);
void updateSliderLimits(void);
void updateSliderValues(void);
void updateTimingMech(void);
void saveValues(void);
public slots:
void closeWindow(void);
private slots:
void emuSchedCtlChange( int state );
void emuSchedNiceChange( int val );
void emuSchedPrioChange( int val );
void emuSchedPolicyChange( int index );
void guiSchedNiceChange( int val );
void guiSchedPrioChange( int val );
void guiSchedPolicyChange( int index );
void emuTimingMechChange( int index );
private:
void updatePolicyBox(void);
void updateSliderLimits(void);
void updateSliderValues(void);
void updateTimingMech(void);
void saveValues(void);
public slots:
void closeWindow(void);
private slots:
void emuSchedCtlChange(int state);
void emuSchedNiceChange(int val);
void emuSchedPrioChange(int val);
void emuSchedPolicyChange(int index);
void guiSchedNiceChange(int val);
void guiSchedPrioChange(int val);
void guiSchedPolicyChange(int index);
void emuTimingMechChange(int index);
};