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; int i;
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
QHBoxLayout *hbox1; QHBoxLayout *hbox1, *hbox;
QPixmap pm(":fceux1.png"); QPixmap pm(":fceux1.png");
QPixmap pm2; QPixmap pm2;
QLabel *lbl; QLabel *lbl;
QTextEdit *credits; QTextEdit *credits;
QPushButton *closeButton;
char stmp[256]; char stmp[256];
pm2 = pm.scaled( 64, 64 ); pm2 = pm.scaled( 64, 64 );
setWindowTitle( tr("About fceuX") ); setWindowTitle( tr("About fceuX") );
resize( 512, 512 ); resize( 512, 600 );
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
@ -162,7 +163,19 @@ AboutWindow::AboutWindow(QWidget *parent)
mainLayout->addWidget( credits ); 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 ); setLayout( mainLayout );
closeButton->setFocus();
closeButton->setDefault(true);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
AboutWindow::~AboutWindow(void) 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 <QGroupBox>
#include <QTreeView> #include <QTreeView>
#include <QTreeWidget> #include <QTreeWidget>
#include <QCloseEvent>
#include "Qt/main.h" #include "Qt/main.h"
@ -27,9 +28,11 @@ class AboutWindow : public QDialog
~AboutWindow(void); ~AboutWindow(void);
protected: protected:
void closeEvent(QCloseEvent *event);
private: 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 class GuiCheatsDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiCheatsDialog_t(QWidget *parent = 0); GuiCheatsDialog_t(QWidget *parent = 0);
~GuiCheatsDialog_t(void); ~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: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QGroupBox *actCheatFrame; QGroupBox *actCheatFrame;
QGroupBox *cheatSearchFrame; QGroupBox *cheatSearchFrame;
QGroupBox *cheatResultFrame; QGroupBox *cheatResultFrame;
QPushButton *addCheatBtn; QPushButton *addCheatBtn;
QPushButton *delCheatBtn; QPushButton *delCheatBtn;
QPushButton *modCheatBtn; QPushButton *modCheatBtn;
QPushButton *importCheatFileBtn; QPushButton *importCheatFileBtn;
QPushButton *exportCheatFileBtn; QPushButton *exportCheatFileBtn;
QPushButton *srchResetBtn; QPushButton *srchResetBtn;
QPushButton *knownValBtn; QPushButton *knownValBtn;
QPushButton *eqValBtn; QPushButton *eqValBtn;
QPushButton *neValBtn; QPushButton *neValBtn;
QPushButton *grValBtn; QPushButton *grValBtn;
QPushButton *ltValBtn; QPushButton *ltValBtn;
QCheckBox *useNeVal; QCheckBox *useNeVal;
QCheckBox *useGrVal; QCheckBox *useGrVal;
QCheckBox *useLtVal; QCheckBox *useLtVal;
QCheckBox *enaCheats; QCheckBox *enaCheats;
QCheckBox *autoSave; QCheckBox *autoSave;
QCheckBox *pauseBox; QCheckBox *pauseBox;
QTreeWidget *actvCheatList; QTreeWidget *actvCheatList;
QTreeWidget *srchResults; QTreeWidget *srchResults;
QLineEdit *cheatNameEntry; QLineEdit *cheatNameEntry;
QLineEdit *cheatAddrEntry; QLineEdit *cheatAddrEntry;
QLineEdit *cheatValEntry; QLineEdit *cheatValEntry;
QLineEdit *cheatCmpEntry; QLineEdit *cheatCmpEntry;
QLineEdit *knownValEntry; QLineEdit *knownValEntry;
QLineEdit *neValEntry; QLineEdit *neValEntry;
QLineEdit *grValEntry; QLineEdit *grValEntry;
QLineEdit *ltValEntry; QLineEdit *ltValEntry;
QFont font; QFont font;
int fontCharWidth; int fontCharWidth;
int actvCheatIdx; int actvCheatIdx;
bool actvCheatRedraw; bool actvCheatRedraw;
bool pauseWhileActive; bool pauseWhileActive;
bool wasPausedByCheats; bool wasPausedByCheats;
private: private:
void showCheatSearchResults(void); 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);
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); void openCheatDialog(QWidget *parent);

View File

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

View File

@ -18,48 +18,47 @@
class ConsoleSndConfDialog_t : public QDialog class ConsoleSndConfDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
ConsoleSndConfDialog_t(QWidget *parent = 0); ConsoleSndConfDialog_t(QWidget *parent = 0);
~ConsoleSndConfDialog_t(void); ~ConsoleSndConfDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QCheckBox *enaChkbox; QCheckBox *enaChkbox;
QCheckBox *enaLowPass; QCheckBox *enaLowPass;
QCheckBox *swapDutyChkbox; QCheckBox *swapDutyChkbox;
QComboBox *qualitySelect; QComboBox *qualitySelect;
QComboBox *rateSelect; QComboBox *rateSelect;
QSlider *bufSizeSlider; QSlider *bufSizeSlider;
QLabel *bufSizeLabel; QLabel *bufSizeLabel;
QLabel *volLbl; QLabel *volLbl;
QLabel *triLbl; QLabel *triLbl;
QLabel *sqr1Lbl; QLabel *sqr1Lbl;
QLabel *sqr2Lbl; QLabel *sqr2Lbl;
QLabel *nseLbl; QLabel *nseLbl;
QLabel *pcmLbl; QLabel *pcmLbl;
void setCheckBoxFromProperty( QCheckBox *cbx, const char *property ); void setCheckBoxFromProperty(QCheckBox *cbx, const char *property);
void setComboBoxFromProperty( QComboBox *cbx, const char *property ); void setComboBoxFromProperty(QComboBox *cbx, const char *property);
void setSliderFromProperty( QSlider *slider, QLabel *lbl, 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);
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 #endif

View File

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

View File

@ -21,36 +21,35 @@
class FrameTimingDialog_t : public QDialog class FrameTimingDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
FrameTimingDialog_t(QWidget *parent = 0); FrameTimingDialog_t(QWidget *parent = 0);
~FrameTimingDialog_t(void); ~FrameTimingDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QTimer *updateTimer; QTimer *updateTimer;
QCheckBox *timingEnable; QCheckBox *timingEnable;
QTreeWidgetItem *frameTimeAbs; QTreeWidgetItem *frameTimeAbs;
QTreeWidgetItem *frameTimeDel; QTreeWidgetItem *frameTimeDel;
QTreeWidgetItem *frameTimeWork; QTreeWidgetItem *frameTimeWork;
QTreeWidgetItem *frameTimeWorkPct; QTreeWidgetItem *frameTimeWorkPct;
QTreeWidgetItem *frameTimeIdle; QTreeWidgetItem *frameTimeIdle;
QTreeWidgetItem *frameTimeIdlePct; QTreeWidgetItem *frameTimeIdlePct;
QTreeWidgetItem *frameLateCount; QTreeWidgetItem *frameLateCount;
QGroupBox *statFrame; QGroupBox *statFrame;
QTreeWidget *tree; QTreeWidget *tree;
private: private:
void updateTimingStats(void); void updateTimingStats(void);
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void resetTimingClicked(void);
void timingEnableChanged(int state);
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" #include "Qt/main.h"
class GamePadConfigButton_t : public QPushButton class GamePadConfigButton_t : public QPushButton
{ {
public: public:
GamePadConfigButton_t(int i); GamePadConfigButton_t(int i);
protected: protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
int idx; int idx;
}; };
class GamePadView_t : public QWidget class GamePadView_t : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GamePadView_t( QWidget *parent = 0); GamePadView_t(QWidget *parent = 0);
~GamePadView_t(void); ~GamePadView_t(void);
void setPort( int port ); 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 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; void drawLetterOnButton(QPainter &painter, QRect &rect, QColor &color, int ch);
int viewWidth;
int viewHeight;
int pxCharWidth;
int pxCharHeight;
QFont font; int portNum;
int viewWidth;
int viewHeight;
int pxCharWidth;
int pxCharHeight;
QFont font;
}; };
class GamePadConfDialog_t : public QDialog class GamePadConfDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
GamePadConfDialog_t(QWidget *parent = 0); GamePadConfDialog_t(QWidget *parent = 0);
~GamePadConfDialog_t(void); ~GamePadConfDialog_t(void);
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
QWidget *mainWidget; QWidget *mainWidget;
QTimer *inputTimer; QTimer *inputTimer;
QComboBox *portSel; QComboBox *portSel;
QComboBox *devSel; QComboBox *devSel;
QComboBox *mapSel; QComboBox *mapSel;
QComboBox *profSel; QComboBox *profSel;
QCheckBox *efs_chkbox; QCheckBox *efs_chkbox;
QLabel *guidLbl; QLabel *guidLbl;
QLabel *mapMsg; QLabel *mapMsg;
QLabel *keyName[GAMEPAD_NUM_BUTTONS]; QLabel *keyName[GAMEPAD_NUM_BUTTONS];
QLabel *keyState[GAMEPAD_NUM_BUTTONS]; QLabel *keyState[GAMEPAD_NUM_BUTTONS];
GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS]; GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS];
GamePadView_t *gpView; GamePadView_t *gpView;
int portNum; int portNum;
int buttonConfigStatus; int buttonConfigStatus;
int changeSeqStatus; // status of sequentally changing buttons mechanism int changeSeqStatus; // status of sequentally changing buttons mechanism
// 0 - we can start new change process // 0 - we can start new change process
// 1-10 - changing in progress // 1-10 - changing in progress
// -1 - changing is aborted // -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);
public slots: void changeButton(int port, int button);
void closeWindow(void); void clearButton(int port, int button);
private slots: void keyPressEvent(QKeyEvent *event);
void changeButton0(void); void keyReleaseEvent(QKeyEvent *event);
void changeButton1(void); void closeEvent(QCloseEvent *bar);
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);
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); int closeGamePadConfWindow(void);

View File

@ -31,55 +31,67 @@
//---------------------------------------------------- //----------------------------------------------------
GuiConfDialog_t::GuiConfDialog_t(QWidget *parent) GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog(parent)
{ {
int useNativeFileDialogVal; int useNativeFileDialogVal;
int useNativeMenuBarVal; int useNativeMenuBarVal;
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
//resize( 512, 600 ); //resize( 512, 600 );
// sync with config // sync with config
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
g_config->getOption ("SDL.UseNativeMenuBar", &useNativeMenuBarVal); g_config->getOption("SDL.UseNativeMenuBar", &useNativeMenuBarVal);
setWindowTitle( tr("GUI Config") ); setWindowTitle(tr("GUI Config"));
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") ); useNativeFileDialog = new QCheckBox(tr("Use Native OS File Dialog"));
useNativeMenuBar = new QCheckBox( tr("Use Native OS Menu Bar") ); useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar"));
useNativeFileDialog->setChecked( useNativeFileDialogVal ); useNativeFileDialog->setChecked(useNativeFileDialogVal);
useNativeMenuBar->setChecked( useNativeMenuBarVal ); useNativeMenuBar->setChecked(useNativeMenuBarVal);
connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) ); connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)) ); connect(useNativeMenuBar, SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
mainLayout->addWidget( useNativeFileDialog ); mainLayout->addWidget(useNativeFileDialog);
mainLayout->addWidget( useNativeMenuBar ); 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) 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) void GuiConfDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("GUI Config Close Window Event\n"); printf("GUI Config Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------- //----------------------------------------------------
void GuiConfDialog_t::closeWindow(void) void GuiConfDialog_t::closeWindow(void)
{ {
//printf("Close Window\n"); //printf("Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------- //----------------------------------------------------
@ -87,15 +99,15 @@ void GuiConfDialog_t::useNativeFileDialogChanged(int state)
{ {
int value = (state == Qt::Unchecked) ? 0 : 1; 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) void GuiConfDialog_t::useNativeMenuBarChanged(int state)
{ {
int value = (state == Qt::Unchecked) ? 0 : 1; 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 class GuiConfDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiConfDialog_t(QWidget *parent = 0); GuiConfDialog_t(QWidget *parent = 0);
~GuiConfDialog_t(void); ~GuiConfDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QCheckBox *useNativeFileDialog; QCheckBox *useNativeFileDialog;
QCheckBox *useNativeMenuBar; QCheckBox *useNativeMenuBar;
private:
public slots:
void closeWindow(void);
private slots:
void useNativeFileDialogChanged(int v);
void useNativeMenuBarChanged(int v);
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) HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog(parent)
{ {
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
QHBoxLayout *hbox;
QPushButton *closeButton;
QTreeWidgetItem *item; QTreeWidgetItem *item;
std::string prefix = "SDL.Hotkeys."; std::string prefix = "SDL.Hotkeys.";
setWindowTitle("Hotkey Configuration"); setWindowTitle("Hotkey Configuration");
resize( 512, 512 ); resize(512, 512);
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
@ -55,36 +57,45 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
tree->setColumnCount(2); tree->setColumnCount(2);
item = new QTreeWidgetItem(); item = new QTreeWidgetItem();
item->setText( 0, QString::fromStdString( "Command" ) ); item->setText(0, QString::fromStdString("Command"));
item->setText( 1, QString::fromStdString( "Key" ) ); item->setText(1, QString::fromStdString("Key"));
item->setTextAlignment( 0, Qt::AlignLeft); item->setTextAlignment(0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignCenter); 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]; char keyName[128];
std::string optionName = prefix + getHotkeyString(i); std::string optionName = prefix + getHotkeyString(i);
//g_config->getOption (optionName.c_str (), &keycode); //g_config->getOption (optionName.c_str (), &keycode);
Hotkeys[i].getString( keyName ); Hotkeys[i].getString(keyName);
item = new QTreeWidgetItem(); item = new QTreeWidgetItem();
item->setText( 0, QString::fromStdString( optionName ) ); item->setText(0, QString::fromStdString(optionName));
item->setText( 1, QString::fromStdString( keyName ) ); item->setText(1, QString::fromStdString(keyName));
item->setTextAlignment( 0, Qt::AlignLeft); item->setTextAlignment(0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignCenter); 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) HotKeyConfDialog_t::~HotKeyConfDialog_t(void)
@ -94,94 +105,96 @@ HotKeyConfDialog_t::~HotKeyConfDialog_t(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HotKeyConfDialog_t::closeEvent(QCloseEvent *event) void HotKeyConfDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("Hot Key Close Window Event\n"); printf("Hot Key Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HotKeyConfDialog_t::closeWindow(void) void HotKeyConfDialog_t::closeWindow(void)
{ {
//printf("Close Window\n"); //printf("Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event) void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
{ {
bool keyIsModifier; bool keyIsModifier;
SDL_Keycode k = convQtKey2SDLKeyCode( (Qt::Key)event->key() ); SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)event->key());
SDL_Keymod m = convQtKey2SDLModifier( event->modifiers() ); 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);
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(); 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; QString qs;
QTreeWidgetItem *item; QTreeWidgetItem *item;
std::string keyText; std::string keyText;
char keyName[128]; char keyName[128];
char buf[256]; char buf[256];
keyText.assign(" mod="); keyText.assign(" mod=");
j=0; j = 0;
if ( m & (KMOD_LSHIFT | KMOD_RSHIFT) ) 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); item = l.at(i);
idx = tree->indexOfTopLevelItem( item ); idx = tree->indexOfTopLevelItem(item);
qs = item->text(0); qs = item->text(0);
g_config->setOption ( qs.toStdString(), keyText ); g_config->setOption(qs.toStdString(), keyText);
setHotKeys(); 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 ); // k, item, qs.toStdString().c_str(), idx );
} }
} }
@ -189,13 +202,13 @@ void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event) void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event)
{ {
//printf("Hotkey Window Key Press: 0x%x \n", event->key() ); //printf("Hotkey Window Key Press: 0x%x \n", event->key() );
assignHotkey( event ); assignHotkey(event);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event) void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event)
{ {
//printf("Hotkey Window Key Release: 0x%x \n", event->key() ); //printf("Hotkey Window Key Release: 0x%x \n", event->key() );
assignHotkey( event ); assignHotkey(event);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

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

View File

@ -42,9 +42,9 @@
static InputConfDialog_t *win = NULL; static InputConfDialog_t *win = NULL;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void openInputConfWindow( QWidget *parent ) void openInputConfWindow(QWidget *parent)
{ {
if ( win != NULL ) if (win != NULL)
{ {
return; return;
} }
@ -54,194 +54,204 @@ void openInputConfWindow( QWidget *parent )
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
InputConfDialog_t::InputConfDialog_t(QWidget *parent) InputConfDialog_t::InputConfDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog(parent)
{ {
QVBoxLayout *mainLayout, *vbox1, *vbox; QVBoxLayout *mainLayout, *vbox1, *vbox;
QHBoxLayout *hbox; QHBoxLayout *hbox;
QGroupBox *nesInputFrame, *port1Frame, *port2Frame; QGroupBox *nesInputFrame, *port1Frame, *port2Frame;
QGroupBox *presetFrame, *expansionPortFrame; QGroupBox *presetFrame, *expansionPortFrame;
QPalette pal; QPushButton *closeButton;
QColor color; QPalette pal;
QColor color;
char stmp[256]; char stmp[256];
int fourscore, autoInputPreset; int fourscore, autoInputPreset;
pal = this->palette(); 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"); setWindowTitle("Input Configuration");
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
nesInputFrame = new QGroupBox( tr("NES-Style Input Ports") ); nesInputFrame = new QGroupBox(tr("NES-Style Input Ports"));
vbox1 = new QVBoxLayout(); vbox1 = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") ); fourScoreEna = new QCheckBox(tr("Attach 4-Score (Implies four gamepads)"));
port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") ); port2Mic = new QCheckBox(tr("Replace Port 2 Start with Microphone"));
autoPreset = new QCheckBox( tr("Auto Load/Save Presets at ROM Open/Close") ); autoPreset = new QCheckBox(tr("Auto Load/Save Presets at ROM Open/Close"));
g_config->getOption("SDL.FourScore", &fourscore); g_config->getOption("SDL.FourScore", &fourscore);
fourScoreEna->setChecked( fourscore ); fourScoreEna->setChecked(fourscore);
port2Mic->setChecked( replaceP2StartWithMicrophone ); port2Mic->setChecked(replaceP2StartWithMicrophone);
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset ); g_config->getOption("SDL.AutoInputPreset", &autoInputPreset);
autoPreset->setChecked( autoInputPreset ); autoPreset->setChecked(autoInputPreset);
hbox->addWidget( fourScoreEna ); hbox->addWidget(fourScoreEna);
hbox->addWidget( port2Mic ); hbox->addWidget(port2Mic);
vbox1->addLayout( hbox ); vbox1->addLayout(hbox);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
port1Frame = new QGroupBox( tr("Port 1:") ); port1Frame = new QGroupBox(tr("Port 1:"));
port2Frame = new QGroupBox( tr("Port 2:") ); port2Frame = new QGroupBox(tr("Port 2:"));
hbox->addWidget( port1Frame ); hbox->addWidget(port1Frame);
hbox->addWidget( port2Frame ); hbox->addWidget(port2Frame);
vbox1->addLayout( hbox ); vbox1->addLayout(hbox);
nesPortComboxBox[0] = new QComboBox(); nesPortComboxBox[0] = new QComboBox();
nesPortComboxBox[1] = new QComboBox(); nesPortComboxBox[1] = new QComboBox();
expPortComboxBox = new QComboBox(); expPortComboxBox = new QComboBox();
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( nesPortLabel[0] = new QLabel( tr("<None>") ) ); hbox->addWidget(nesPortLabel[0] = new QLabel(tr("<None>")));
hbox->addWidget( nesPortConfButton[0] = new QPushButton( tr("Configure") ) ); hbox->addWidget(nesPortConfButton[0] = new QPushButton(tr("Configure")));
vbox->addWidget( nesPortComboxBox[0] ); vbox->addWidget(nesPortComboxBox[0]);
port1Frame->setLayout( vbox ); port1Frame->setLayout(vbox);
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( nesPortLabel[1] = new QLabel( tr("<None>") ) ); hbox->addWidget(nesPortLabel[1] = new QLabel(tr("<None>")));
hbox->addWidget( nesPortConfButton[1] = new QPushButton( tr("Configure") ) ); hbox->addWidget(nesPortConfButton[1] = new QPushButton(tr("Configure")));
vbox->addWidget( nesPortComboxBox[1] ); vbox->addWidget(nesPortComboxBox[1]);
port2Frame->setLayout( vbox ); port2Frame->setLayout(vbox);
nesInputFrame->setLayout( vbox1 ); nesInputFrame->setLayout(vbox1);
nesPortConfButton[0]->setEnabled(false); nesPortConfButton[0]->setEnabled(false);
nesPortConfButton[1]->setEnabled(false); nesPortConfButton[1]->setEnabled(false);
mainLayout->addWidget( nesInputFrame ); mainLayout->addWidget(nesInputFrame);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
presetFrame = new QGroupBox( tr("Input Presets:") ); presetFrame = new QGroupBox(tr("Input Presets:"));
expansionPortFrame = new QGroupBox( tr("Famicom Expansion Port:") ); expansionPortFrame = new QGroupBox(tr("Famicom Expansion Port:"));
hbox->addWidget( presetFrame ); hbox->addWidget(presetFrame);
hbox->addWidget( expansionPortFrame ); hbox->addWidget(expansionPortFrame);
mainLayout->addLayout( hbox ); mainLayout->addLayout(hbox);
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( autoPreset ); hbox->addWidget(autoPreset);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( loadConfigButton = new QPushButton( tr("Load") ) ); hbox->addWidget(loadConfigButton = new QPushButton(tr("Load")));
hbox->addWidget( saveConfigButton = new QPushButton( tr("Save") ) ); hbox->addWidget(saveConfigButton = new QPushButton(tr("Save")));
presetFrame->setLayout( vbox ); presetFrame->setLayout(vbox);
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( expPortLabel = new QLabel( tr("<None>") ) ); hbox->addWidget(expPortLabel = new QLabel(tr("<None>")));
hbox->addWidget( expPortConfButton = new QPushButton( tr("Configure") ) ); hbox->addWidget(expPortConfButton = new QPushButton(tr("Configure")));
vbox->addWidget( expPortComboxBox ); vbox->addWidget(expPortComboxBox);
expPortConfButton->setEnabled(false); expPortConfButton->setEnabled(false);
expansionPortFrame->setLayout( vbox ); expansionPortFrame->setLayout(vbox);
color = pal.color(QPalette::WindowText); 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); //printf("%s\n", stmp);
nesPortLabel[0]->setAlignment(Qt::AlignCenter); nesPortLabel[0]->setAlignment(Qt::AlignCenter);
nesPortLabel[1]->setAlignment(Qt::AlignCenter); nesPortLabel[1]->setAlignment(Qt::AlignCenter);
expPortLabel->setAlignment(Qt::AlignCenter); expPortLabel->setAlignment(Qt::AlignCenter);
nesPortLabel[0]->setStyleSheet( stmp ); nesPortLabel[0]->setStyleSheet(stmp);
nesPortLabel[1]->setStyleSheet( stmp ); nesPortLabel[1]->setStyleSheet(stmp);
expPortLabel->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] ); getInputSelection(i, &curNesInput[i], &usrNesInput[i]);
nesPortComboxBox[i]->addItem( tr("<None>") , SI_NONE ); nesPortComboxBox[i]->addItem(tr("<None>"), SI_NONE);
nesPortComboxBox[i]->addItem( tr("Gamepad") , SI_GAMEPAD ); nesPortComboxBox[i]->addItem(tr("Gamepad"), SI_GAMEPAD);
nesPortComboxBox[i]->addItem( tr("Zapper") , SI_ZAPPER ); nesPortComboxBox[i]->addItem(tr("Zapper"), SI_ZAPPER);
nesPortComboxBox[i]->addItem( tr("Power Pad A") , SI_POWERPADA ); nesPortComboxBox[i]->addItem(tr("Power Pad A"), SI_POWERPADA);
nesPortComboxBox[i]->addItem( tr("Power Pad B") , SI_POWERPADB ); nesPortComboxBox[i]->addItem(tr("Power Pad B"), SI_POWERPADB);
nesPortComboxBox[i]->addItem( tr("Arkanoid Paddle") , SI_ARKANOID ); 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] ); getInputSelection(2, &curNesInput[2], &usrNesInput[2]);
expPortComboxBox->addItem( tr("<None>") , SIFC_NONE ); expPortComboxBox->addItem(tr("<None>"), SIFC_NONE);
expPortComboxBox->addItem( tr("Arkanoid Paddle") , SIFC_ARKANOID ); expPortComboxBox->addItem(tr("Arkanoid Paddle"), SIFC_ARKANOID);
expPortComboxBox->addItem( tr("Shadow") , SIFC_SHADOW ); expPortComboxBox->addItem(tr("Shadow"), SIFC_SHADOW);
expPortComboxBox->addItem( tr("Hyper Shot Gun") , SIFC_HYPERSHOT ); expPortComboxBox->addItem(tr("Hyper Shot Gun"), SIFC_HYPERSHOT);
expPortComboxBox->addItem( tr("Family Keyboard") , SIFC_FKB ); expPortComboxBox->addItem(tr("Family Keyboard"), SIFC_FKB);
expPortComboxBox->addItem( tr("Mahjong") , SIFC_MAHJONG ); expPortComboxBox->addItem(tr("Mahjong"), SIFC_MAHJONG);
expPortComboxBox->addItem( tr("Quiz King Buzzers"), SIFC_QUIZKING ); expPortComboxBox->addItem(tr("Quiz King Buzzers"), SIFC_QUIZKING);
expPortComboxBox->addItem( tr("Family Trainer A") , SIFC_FTRAINERA ); expPortComboxBox->addItem(tr("Family Trainer A"), SIFC_FTRAINERA);
expPortComboxBox->addItem( tr("Family Trainer B") , SIFC_FTRAINERB ); expPortComboxBox->addItem(tr("Family Trainer B"), SIFC_FTRAINERB);
expPortComboxBox->addItem( tr("Oeka Kids Tablet") , SIFC_OEKAKIDS ); expPortComboxBox->addItem(tr("Oeka Kids Tablet"), SIFC_OEKAKIDS);
expPortComboxBox->addItem( tr("Top Rider") , SIFC_TOPRIDER ); 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(fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)));
connect( port2Mic , SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)) ); connect(port2Mic, SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)));
connect( autoPreset , SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int))); connect(autoPreset, SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int)));
connect( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) ); connect(nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)));
connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) ); connect(nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)));
connect( expPortComboxBox , SIGNAL(activated(int)), this, SLOT(expSelect(int)) ); connect(expPortComboxBox, SIGNAL(activated(int)), this, SLOT(expSelect(int)));
connect( nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)) ); connect(nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)));
connect( nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)) ); connect(nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)));
connect( loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)) ); connect(loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)));
connect( saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)) ); connect(saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)));
connect(closeButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
updatePortLabels(); updatePortLabels();
inputTimer->start( 500 ); // 2hz inputTimer->start(500); // 2hz
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
InputConfDialog_t::~InputConfDialog_t(void) InputConfDialog_t::~InputConfDialog_t(void)
@ -249,7 +259,7 @@ InputConfDialog_t::~InputConfDialog_t(void)
printf("Destroy Input Config Window\n"); printf("Destroy Input Config Window\n");
inputTimer->stop(); inputTimer->stop();
if ( win == this ) if (win == this)
{ {
win = NULL; win = NULL;
} }
@ -257,23 +267,23 @@ InputConfDialog_t::~InputConfDialog_t(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void InputConfDialog_t::closeEvent(QCloseEvent *event) void InputConfDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("Input Config Close Window Event\n"); printf("Input Config Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void InputConfDialog_t::closeWindow(void) void InputConfDialog_t::closeWindow(void)
{ {
//printf("Close Window\n"); //printf("Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void InputConfDialog_t::setInputs(void) void InputConfDialog_t::setInputs(void)
{ {
int idx[3]; int idx[3];
ESI port[2]; ESI port[2];
ESIFC fcexp; ESIFC fcexp;
int fourscore = false, microphone = false; int fourscore = false, microphone = false;
@ -285,64 +295,64 @@ void InputConfDialog_t::setInputs(void)
idx[1] = nesPortComboxBox[1]->currentIndex(); idx[1] = nesPortComboxBox[1]->currentIndex();
idx[2] = expPortComboxBox->currentIndex(); idx[2] = expPortComboxBox->currentIndex();
port[0] = (ESI)nesPortComboxBox[0]->itemData( idx[0] ).toInt(); port[0] = (ESI)nesPortComboxBox[0]->itemData(idx[0]).toInt();
port[1] = (ESI)nesPortComboxBox[1]->itemData( idx[1] ).toInt(); port[1] = (ESI)nesPortComboxBox[1]->itemData(idx[1]).toInt();
fcexp = (ESIFC)expPortComboxBox->itemData( idx[2] ).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) 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) 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(); updatePortLabels();
switch ( curNesInput[portNum] ) switch (curNesInput[portNum])
{ {
default: default:
case SI_NONE: case SI_NONE:
case SI_ZAPPER: case SI_ZAPPER:
// Do Nothing // Do Nothing
break; break;
case SI_GAMEPAD: case SI_GAMEPAD:
consoleWindow->openGamePadConfWin(); consoleWindow->openGamePadConfWin();
break; break;
} }
} }
@ -420,56 +430,56 @@ void InputConfDialog_t::port2Configure(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void InputConfDialog_t::openLoadPresetFile(void) void InputConfDialog_t::openLoadPresetFile(void)
{ {
int ret, useNativeFileDialogVal; int ret, useNativeFileDialogVal;
QString filename; QString filename;
std::string last; std::string last;
std::string path; std::string path;
const char *baseDir; const char *baseDir;
QFileDialog dialog(this, tr("Load Preset From File") ); QFileDialog dialog(this, tr("Load Preset From File"));
QDir dir; QDir dir;
baseDir = FCEUI_GetBaseDirectory(); baseDir = FCEUI_GetBaseDirectory();
path = std::string(baseDir) + "/input/presets/"; path = std::string(baseDir) + "/input/presets/";
dir.mkpath( QString::fromStdString(path) ); dir.mkpath(QString::fromStdString(path));
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("Preset File (*.pre *.PRE) ;; All files (*)")); dialog.setNameFilter(tr("Preset File (*.pre *.PRE) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List); dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText( QFileDialog::Accept, tr("Load") ); 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 // 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.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec(); ret = dialog.exec();
if ( ret ) if (ret)
{ {
QStringList fileList; QStringList fileList;
fileList = dialog.selectedFiles(); fileList = dialog.selectedFiles();
if ( fileList.size() > 0 ) if (fileList.size() > 0)
{ {
filename = fileList[0]; filename = fileList[0];
} }
} }
if ( filename.isNull() ) if (filename.isNull())
{ {
return; return;
} }
qDebug() << "selected file path : " << filename.toUtf8(); qDebug() << "selected file path : " << filename.toUtf8();
fceuWrapperLock(); fceuWrapperLock();
loadInputSettingsFromFile( filename.toStdString().c_str() ); loadInputSettingsFromFile(filename.toStdString().c_str());
fceuWrapperUnLock(); fceuWrapperUnLock();
updatePortLabels(); updatePortLabels();
@ -483,64 +493,64 @@ void InputConfDialog_t::openSavePresetFile(void)
QString filename; QString filename;
std::string path; std::string path;
const char *baseDir, *romFile; const char *baseDir, *romFile;
QFileDialog dialog(this, tr("Save Preset to File") ); QFileDialog dialog(this, tr("Save Preset to File"));
QDir dir; QDir dir;
baseDir = FCEUI_GetBaseDirectory(); baseDir = FCEUI_GetBaseDirectory();
path = std::string(baseDir) + "/input/presets/"; path = std::string(baseDir) + "/input/presets/";
dir.mkpath( QString::fromStdString(path) ); dir.mkpath(QString::fromStdString(path));
dialog.setFileMode(QFileDialog::AnyFile); dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter(tr("Preset Files (*.pre *.PRE) ;; All files (*)")); dialog.setNameFilter(tr("Preset Files (*.pre *.PRE) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List); dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText( QFileDialog::Accept, tr("Save") ); dialog.setLabelText(QFileDialog::Accept, tr("Save"));
dialog.setDefaultSuffix( tr(".pre") ); dialog.setDefaultSuffix(tr(".pre"));
romFile = getRomFile(); romFile = getRomFile();
if ( romFile != NULL ) if (romFile != NULL)
{ {
char dirStr[256], base[256]; 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 // 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.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec(); ret = dialog.exec();
if ( ret ) if (ret)
{ {
QStringList fileList; QStringList fileList;
fileList = dialog.selectedFiles(); fileList = dialog.selectedFiles();
if ( fileList.size() > 0 ) if (fileList.size() > 0)
{ {
filename = fileList[0]; filename = fileList[0];
} }
} }
if ( filename.isNull() ) if (filename.isNull())
{ {
return; return;
} }
qDebug() << "selected file path : " << filename.toUtf8(); qDebug() << "selected file path : " << filename.toUtf8();
saveInputSettingsToFile( filename.toStdString().c_str() ); saveInputSettingsToFile(filename.toStdString().c_str());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void InputConfDialog_t::updatePeriodic(void) void InputConfDialog_t::updatePeriodic(void)
@ -549,21 +559,21 @@ void InputConfDialog_t::updatePeriodic(void)
int tmpCurInputType[3], tmpUsrInputType[3]; int tmpCurInputType[3], tmpUsrInputType[3];
int fourScoreValue; 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; updateNeeded = true;
} }
if ( usrNesInput[i] != tmpUsrInputType[i] ) if (usrNesInput[i] != tmpUsrInputType[i])
{ {
updateNeeded = true; updateNeeded = true;
} }
} }
if ( updateNeeded ) if (updateNeeded)
{ {
updatePortLabels(); updatePortLabels();
updatePortComboBoxes(); updatePortComboBoxes();
@ -571,9 +581,9 @@ void InputConfDialog_t::updatePeriodic(void)
g_config->getOption("SDL.FourScore", &fourScoreValue); 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 class InputConfDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
InputConfDialog_t(QWidget *parent = 0); InputConfDialog_t(QWidget *parent = 0);
~InputConfDialog_t(void); ~InputConfDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QTimer *inputTimer; QTimer *inputTimer;
QCheckBox *fourScoreEna; QCheckBox *fourScoreEna;
QCheckBox *port2Mic; QCheckBox *port2Mic;
QCheckBox *autoPreset; QCheckBox *autoPreset;
QLabel *nesPortLabel[2]; QLabel *nesPortLabel[2];
QPushButton *nesPortConfButton[2]; QPushButton *nesPortConfButton[2];
QComboBox *nesPortComboxBox[2]; QComboBox *nesPortComboxBox[2];
QLabel *expPortLabel; QLabel *expPortLabel;
QPushButton *expPortConfButton; QPushButton *expPortConfButton;
QComboBox *expPortComboxBox; QComboBox *expPortComboxBox;
QPushButton *loadConfigButton; QPushButton *loadConfigButton;
QPushButton *saveConfigButton; QPushButton *saveConfigButton;
int curNesInput[3]; int curNesInput[3];
int usrNesInput[3]; int usrNesInput[3];
private: private:
void setInputs(void); void setInputs(void);
void updatePortLabels(void); void updatePortLabels(void);
void updatePortComboBoxes(void); void updatePortComboBoxes(void);
void openPortConfig(int portNum); 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);
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 luaScriptRunning = false;
static bool updateLuaDisplay = false; static bool updateLuaDisplay = false;
static bool openLuaKillMsgBox = false; static bool openLuaKillMsgBox = false;
static int luaKillMsgBoxRetVal = 0; static int luaKillMsgBoxRetVal = 0;
struct luaConsoleOutputBuffer struct luaConsoleOutputBuffer
{ {
int head; int head;
int tail; int tail;
int size; int size;
char *buf; char *buf;
luaConsoleOutputBuffer(void) luaConsoleOutputBuffer(void)
{ {
tail = head = 0; tail = head = 0;
size = 4096; size = 4096;
buf = (char*)malloc(size); buf = (char *)malloc(size);
} }
~luaConsoleOutputBuffer(void) ~luaConsoleOutputBuffer(void)
{ {
if ( buf ) 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 )
{ {
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 ) head = (head + 1) % size;
{
tail = (tail + 1) % size;
}
}
}
void clear(void) if (head == tail)
{ {
tail = head = 0; tail = (tail + 1) % size;
} }
}
}
void clear(void)
{
tail = head = 0;
}
}; };
static luaConsoleOutputBuffer outBuf; 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) LuaControlDialog_t::LuaControlDialog_t(QWidget *parent)
: QDialog( parent, Qt::Window ) : QDialog(parent, Qt::Window)
{ {
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
QHBoxLayout *hbox; QHBoxLayout *hbox;
QPushButton *closeButton;
QLabel *lbl; QLabel *lbl;
std::string filename; std::string filename;
resize( 512, 512 ); resize(512, 512);
setWindowTitle( tr("Lua Script Control") ); setWindowTitle(tr("Lua Script Control"));
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
lbl = new QLabel( tr("Script File:") ); lbl = new QLabel(tr("Script File:"));
scriptPath = new QLineEdit(); scriptPath = new QLineEdit();
scriptArgs = 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 = new QTextEdit();
luaOutput->setReadOnly(true); luaOutput->setReadOnly(true);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
browseButton = new QPushButton( tr("Browse") ); browseButton = new QPushButton(tr("Browse"));
stopButton = new QPushButton( tr("Stop") ); stopButton = new QPushButton(tr("Stop"));
if ( luaScriptRunning ) if (luaScriptRunning)
{ {
startButton = new QPushButton( tr("Restart") ); startButton = new QPushButton(tr("Restart"));
} }
else 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(browseButton, SIGNAL(clicked()), this, SLOT(openLuaScriptFile(void)));
connect(stopButton , SIGNAL(clicked()), this, SLOT(stopLuaScript(void)) ); connect(stopButton, SIGNAL(clicked()), this, SLOT(stopLuaScript(void)));
connect(startButton , SIGNAL(clicked()), this, SLOT(startLuaScript(void)) ); connect(startButton, SIGNAL(clicked()), this, SLOT(startLuaScript(void)));
hbox->addWidget( browseButton );
hbox->addWidget( stopButton );
hbox->addWidget( startButton );
mainLayout->addWidget( lbl ); hbox->addWidget(browseButton);
mainLayout->addWidget( scriptPath ); hbox->addWidget(stopButton);
mainLayout->addLayout( hbox ); hbox->addWidget(startButton);
mainLayout->addWidget(lbl);
mainLayout->addWidget(scriptPath);
mainLayout->addLayout(hbox);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
lbl = new QLabel( tr("Arguments:") ); lbl = new QLabel(tr("Arguments:"));
hbox->addWidget( lbl ); hbox->addWidget(lbl);
hbox->addWidget( scriptArgs ); 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 ); mainLayout->addLayout( hbox );
lbl = new QLabel( tr("Output Console:") ); setLayout(mainLayout);
mainLayout->addWidget( lbl );
mainLayout->addWidget( luaOutput );
//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 ); periodicTimer->start(200); // 5hz
connect( periodicTimer, &QTimer::timeout, this, &LuaControlDialog_t::updatePeriodic );
periodicTimer->start( 200 ); // 5hz
} }
//---------------------------------------------------- //----------------------------------------------------
LuaControlDialog_t::~LuaControlDialog_t(void) LuaControlDialog_t::~LuaControlDialog_t(void)
{ {
std::list <LuaControlDialog_t*>::iterator it; std::list<LuaControlDialog_t *>::iterator it;
printf("Destroy Lua Control Window\n"); printf("Destroy Lua Control Window\n");
periodicTimer->stop(); periodicTimer->stop();
for (it = winList.begin(); it != winList.end(); it++) for (it = winList.begin(); it != winList.end(); it++)
{ {
if ( (*it) == this ) if ((*it) == this)
{ {
winList.erase(it); winList.erase(it);
//printf("Removing Lua Window\n"); //printf("Removing Lua Window\n");
@ -205,29 +215,29 @@ LuaControlDialog_t::~LuaControlDialog_t(void)
//---------------------------------------------------- //----------------------------------------------------
void LuaControlDialog_t::closeEvent(QCloseEvent *event) void LuaControlDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("Lua Control Close Window Event\n"); printf("Lua Control Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------- //----------------------------------------------------
void LuaControlDialog_t::closeWindow(void) void LuaControlDialog_t::closeWindow(void)
{ {
//printf("Lua Control Close Window\n"); //printf("Lua Control Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------- //----------------------------------------------------
void LuaControlDialog_t::updatePeriodic(void) void LuaControlDialog_t::updatePeriodic(void)
{ {
//printf("Update Lua\n"); //printf("Update Lua\n");
if ( updateLuaDisplay ) if (updateLuaDisplay)
{ {
updateLuaWindows(); updateLuaWindows();
updateLuaDisplay = false; updateLuaDisplay = false;
} }
if ( openLuaKillMsgBox ) if (openLuaKillMsgBox)
{ {
openLuaKillMessageBox(); openLuaKillMessageBox();
openLuaKillMsgBox = false; openLuaKillMsgBox = false;
@ -241,15 +251,15 @@ void LuaControlDialog_t::openLuaKillMessageBox(void)
luaKillMsgBoxRetVal = 0; luaKillMsgBoxRetVal = 0;
msgBox.setIcon( QMessageBox::Warning ); 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.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.setStandardButtons(QMessageBox::Yes);
msgBox.addButton(QMessageBox::No); msgBox.addButton(QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No);
ret = msgBox.exec(); ret = msgBox.exec();
if ( ret == QMessageBox::Yes ) if (ret == QMessageBox::Yes)
{ {
luaKillMsgBoxRetVal = 1; luaKillMsgBoxRetVal = 1;
} }
@ -264,78 +274,79 @@ void LuaControlDialog_t::openLuaScriptFile(void)
char dir[512]; char dir[512];
char exePath[512]; char exePath[512];
const char *luaPath; const char *luaPath;
QFileDialog dialog(this, tr("Open LUA Script") ); QFileDialog dialog(this, tr("Open LUA Script"));
QList<QUrl> urls; QList<QUrl> urls;
QDir d; QDir d;
fceuExecutablePath( exePath, sizeof(exePath) ); fceuExecutablePath(exePath, sizeof(exePath));
//urls = dialog.sidebarUrls(); //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::HomeLocation).first());
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).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 #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 #endif
luaPath = getenv("LUA_PATH"); luaPath = getenv("LUA_PATH");
// Parse LUA_PATH and add to urls // Parse LUA_PATH and add to urls
if ( luaPath ) if (luaPath)
{ {
int i,j; int i, j;
char stmp[1024]; char stmp[1024];
i=j=0; i = j = 0;
while ( luaPath[i] != 0 ) while (luaPath[i] != 0)
{ {
if ( luaPath[i] == ';' ) if (luaPath[i] == ';')
{ {
stmp[j] = 0; stmp[j] = 0;
if ( j > 0 ) if (j > 0)
{ {
d.setPath(stmp); d.setPath(stmp);
if ( d.exists() ) if (d.exists())
{ {
urls << QUrl::fromLocalFile( d.absolutePath() ); urls << QUrl::fromLocalFile(d.absolutePath());
} }
} }
j=0; j = 0;
} }
else else
{ {
stmp[j] = luaPath[i]; j++; stmp[j] = luaPath[i];
j++;
} }
i++; i++;
} }
stmp[j] = 0; stmp[j] = 0;
if ( j > 0 ) if (j > 0)
{ {
d.setPath(stmp); 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.setNameFilter(tr("LUA Scripts (*.lua *.LUA) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List); dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText( QFileDialog::Accept, tr("Load") ); 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 #ifdef WIN32
last.assign( FCEUI_GetBaseDirectory() ); last.assign(FCEUI_GetBaseDirectory());
#else #else
last.assign( "/usr/share/fceux/luaScripts" ); last.assign("/usr/share/fceux/luaScripts");
#endif #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 // 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.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
dialog.setSidebarUrls(urls); dialog.setSidebarUrls(urls);
ret = dialog.exec(); ret = dialog.exec();
if ( ret ) if (ret)
{ {
QStringList fileList; QStringList fileList;
fileList = dialog.selectedFiles(); fileList = dialog.selectedFiles();
if ( fileList.size() > 0 ) if (fileList.size() > 0)
{ {
filename = fileList[0]; filename = fileList[0];
} }
} }
if ( filename.isNull() ) if (filename.isNull())
{ {
return; return;
} }
qDebug() << "selected file path : " << filename.toUtf8(); 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 #endif
} }
@ -400,9 +411,9 @@ void LuaControlDialog_t::startLuaScript(void)
#ifdef _S9XLUA_H #ifdef _S9XLUA_H
outBuf.clear(); outBuf.clear();
fceuWrapperLock(); 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(); fceuWrapperUnLock();
#endif #endif
@ -422,35 +433,35 @@ void LuaControlDialog_t::refreshState(void)
int i; int i;
std::string luaOutputText; std::string luaOutputText;
if ( luaScriptRunning ) if (luaScriptRunning)
{ {
stopButton->setEnabled( true ); stopButton->setEnabled(true);
startButton->setText( tr("Restart") ); startButton->setText(tr("Restart"));
} }
else else
{ {
stopButton->setEnabled( false ); stopButton->setEnabled(false);
startButton->setText( tr("Start") ); startButton->setText(tr("Start"));
} }
i = outBuf.tail; i = outBuf.tail;
while ( i != outBuf.head ) while (i != outBuf.head)
{ {
luaOutputText.append( 1, outBuf.buf[i] ); luaOutputText.append(1, outBuf.buf[i]);
i = (i + 1) % outBuf.size; 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++) for (it = winList.begin(); it != winList.end(); it++)
{ {
(*it)->refreshState(); (*it)->refreshState();
@ -475,35 +486,35 @@ void WinLuaOnStop(intptr_t hDlgAsInt)
updateLuaDisplay = true; updateLuaDisplay = true;
} }
//---------------------------------------------------- //----------------------------------------------------
void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str) void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str)
{ {
//printf("%s\n", str ); //printf("%s\n", str );
outBuf.addLine( str ); outBuf.addLine(str);
updateLuaDisplay = true; updateLuaDisplay = true;
} }
//---------------------------------------------------- //----------------------------------------------------
#ifdef WIN32 #ifdef WIN32
int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char* format, ...) int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char *format, ...)
#else #else
int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw() int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw()
#endif #endif
{ {
int retval; int retval;
va_list args; va_list args;
char msg[2048]; char msg[2048];
va_start( args, format ); va_start(args, format);
retval = ::vsnprintf( msg, sizeof(msg), format, args ); retval = ::vsnprintf(msg, sizeof(msg), format, args);
va_end(args); va_end(args);
msg[ sizeof(msg)-1 ] = 0; msg[sizeof(msg) - 1] = 0;
outBuf.addLine( msg ); outBuf.addLine(msg);
updateLuaDisplay = true; updateLuaDisplay = true;
return(retval); return (retval);
}; };
//---------------------------------------------------- //----------------------------------------------------
int LuaKillMessageBox(void) int LuaKillMessageBox(void)
@ -513,11 +524,11 @@ int LuaKillMessageBox(void)
openLuaKillMsgBox = true; openLuaKillMsgBox = true;
while ( openLuaKillMsgBox ) while (openLuaKillMsgBox)
{ {
msleep(100); msleep(100);
} }
return luaKillMsgBoxRetVal; return luaKillMsgBoxRetVal;
} }
//---------------------------------------------------- //----------------------------------------------------

View File

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

View File

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

View File

@ -20,36 +20,34 @@
class MovieOptionsDialog_t : public QDialog class MovieOptionsDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
MovieOptionsDialog_t(QWidget *parent = 0); MovieOptionsDialog_t(QWidget *parent = 0);
~MovieOptionsDialog_t(void); ~MovieOptionsDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QCheckBox *readOnlyReplay; QCheckBox *readOnlyReplay;
QCheckBox *pauseAfterPlay; QCheckBox *pauseAfterPlay;
QCheckBox *closeAfterPlay; QCheckBox *closeAfterPlay;
QCheckBox *bindSaveStates; QCheckBox *bindSaveStates;
QCheckBox *dpySubTitles; QCheckBox *dpySubTitles;
QCheckBox *putSubTitlesAvi; QCheckBox *putSubTitlesAvi;
QCheckBox *autoBackUp; QCheckBox *autoBackUp;
QCheckBox *loadFullStates; 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 );
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) MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog(parent)
{ {
QVBoxLayout *mainLayout, *vbox; QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox; QHBoxLayout *hbox;
@ -57,96 +57,99 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
setWindowTitle("Movie Play"); setWindowTitle("Movie Play");
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
lbl = new QLabel( tr("File:") ); lbl = new QLabel(tr("File:"));
movSelBox = new QComboBox(); movSelBox = new QComboBox();
movBrowseBtn = new QPushButton( tr("Browse") ); movBrowseBtn = new QPushButton(tr("Browse"));
hbox->addWidget( lbl, 1 ); hbox->addWidget(lbl, 1);
hbox->addWidget( movSelBox, 100 ); hbox->addWidget(movSelBox, 100);
hbox->addWidget( movBrowseBtn, 1 ); hbox->addWidget(movBrowseBtn, 1);
mainLayout->addLayout( hbox ); mainLayout->addLayout(hbox);
frame = new QGroupBox( tr("Parameters:") ); frame = new QGroupBox(tr("Parameters:"));
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
frame->setLayout( vbox ); frame->setLayout(vbox);
openReadOnly = new QCheckBox( tr("Open Read-Only") ); openReadOnly = new QCheckBox(tr("Open Read-Only"));
pauseAtFrame = new QCheckBox( tr("Pause Movie At Frame") ); pauseAtFrame = new QCheckBox(tr("Pause Movie At Frame"));
validator = new fceuDecIntValidtor( 0, 100000000, this ); validator = new fceuDecIntValidtor(0, 100000000, this);
pauseAtFrameEntry = new QLineEdit(); pauseAtFrameEntry = new QLineEdit();
pauseAtFrameEntry->setValidator( validator ); pauseAtFrameEntry->setValidator(validator);
vbox->addWidget( openReadOnly ); vbox->addWidget(openReadOnly);
vbox->addLayout( hbox ); vbox->addLayout(hbox);
hbox->addWidget( pauseAtFrame ); hbox->addWidget(pauseAtFrame);
hbox->addWidget( pauseAtFrameEntry ); hbox->addWidget(pauseAtFrameEntry);
mainLayout->addWidget( frame ); mainLayout->addWidget(frame);
grid = new QGridLayout(); grid = new QGridLayout();
grid->setColumnStretch( 0, 1 ); grid->setColumnStretch(0, 1);
grid->setColumnStretch( 1, 10 ); grid->setColumnStretch(1, 10);
mainLayout->addLayout( grid ); mainLayout->addLayout(grid);
movLenLbl = new QLabel(); movLenLbl = new QLabel();
movFramesLbl = new QLabel(); movFramesLbl = new QLabel();
recCountLbl = new QLabel(); recCountLbl = new QLabel();
recFromLbl = new QLabel(); recFromLbl = new QLabel();
romUsedLbl = new QLabel(); romUsedLbl = new QLabel();
romCsumLbl = new QLabel(); romCsumLbl = new QLabel();
curCsumLbl = new QLabel(); curCsumLbl = new QLabel();
emuUsedLbl = new QLabel(); emuUsedLbl = new QLabel();
palUsedLbl = new QLabel(); palUsedLbl = new QLabel();
newppuUsedLbl = new QLabel(); newppuUsedLbl = new QLabel();
grid->addWidget( new QLabel( tr("Length:") ) , 0, 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("Frames:")), 1, 0, Qt::AlignRight);
grid->addWidget( new QLabel( tr("Record Count:") ) , 2, 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("Recorded From:")), 3, 0, Qt::AlignRight);
grid->addWidget( new QLabel( tr("ROM Used:") ) , 4, 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("ROM Checksum:")), 5, 0, Qt::AlignRight);
grid->addWidget( new QLabel( tr("Current ROM Sum:") ) , 6, 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("Emulator Used:")), 7, 0, Qt::AlignRight);
grid->addWidget( new QLabel( tr("PAL:") ) , 8, 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("New PPU:")), 9, 0, Qt::AlignRight);
grid->addWidget( movLenLbl , 0, 1, Qt::AlignLeft ); grid->addWidget(movLenLbl, 0, 1, Qt::AlignLeft);
grid->addWidget( movFramesLbl , 1, 1, Qt::AlignLeft ); grid->addWidget(movFramesLbl, 1, 1, Qt::AlignLeft);
grid->addWidget( recCountLbl , 2, 1, Qt::AlignLeft ); grid->addWidget(recCountLbl, 2, 1, Qt::AlignLeft);
grid->addWidget( recFromLbl , 3, 1, Qt::AlignLeft ); grid->addWidget(recFromLbl, 3, 1, Qt::AlignLeft);
grid->addWidget( romUsedLbl , 4, 1, Qt::AlignLeft ); grid->addWidget(romUsedLbl, 4, 1, Qt::AlignLeft);
grid->addWidget( romCsumLbl , 5, 1, Qt::AlignLeft ); grid->addWidget(romCsumLbl, 5, 1, Qt::AlignLeft);
grid->addWidget( curCsumLbl , 6, 1, Qt::AlignLeft ); grid->addWidget(curCsumLbl, 6, 1, Qt::AlignLeft);
grid->addWidget( emuUsedLbl , 7, 1, Qt::AlignLeft ); grid->addWidget(emuUsedLbl, 7, 1, Qt::AlignLeft);
grid->addWidget( palUsedLbl , 8, 1, Qt::AlignLeft ); grid->addWidget(palUsedLbl, 8, 1, Qt::AlignLeft);
grid->addWidget( newppuUsedLbl , 9, 1, Qt::AlignLeft ); grid->addWidget(newppuUsedLbl, 9, 1, Qt::AlignLeft);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
okButton = new QPushButton( tr("Play") ); okButton = new QPushButton(tr("Play"));
cancelButton = new QPushButton( tr("Cancel") ); cancelButton = new QPushButton(tr("Cancel"));
hbox->addWidget( cancelButton ); hbox->addWidget(cancelButton);
hbox->addWidget( okButton ); hbox->addWidget(okButton);
okButton->setDefault(true); okButton->setDefault(true);
mainLayout->addLayout( hbox ); mainLayout->addLayout(hbox);
setLayout( mainLayout ); setLayout(mainLayout);
connect( cancelButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) ); okButton->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) );
connect( okButton , SIGNAL(clicked(void)), this, SLOT(playMovie(void)) ); cancelButton->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) );
connect( movBrowseBtn , SIGNAL(clicked(void)) , this, SLOT(openMovie(void)) ); connect(cancelButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
connect( movSelBox , SIGNAL(activated(int)), this, SLOT(movieSelect(int)) ); 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) if (suggestReadOnlyReplay)
{ {
@ -156,9 +159,9 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent)
{ {
replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly(); replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();
} }
openReadOnly->setChecked( replayReadOnlySetting ); openReadOnly->setChecked(replayReadOnlySetting);
pauseAtFrameEntry->setEnabled( pauseAtFrame->isChecked() ); pauseAtFrameEntry->setEnabled(pauseAtFrame->isChecked());
doScan(); doScan();
@ -172,16 +175,16 @@ MoviePlayDialog_t::~MoviePlayDialog_t(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MoviePlayDialog_t::closeEvent(QCloseEvent *event) void MoviePlayDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("Movie Play Close Window Event\n"); printf("Movie Play Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MoviePlayDialog_t::closeWindow(void) void MoviePlayDialog_t::closeWindow(void)
{ {
//printf("Close Window\n"); //printf("Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -197,10 +200,10 @@ void MoviePlayDialog_t::movieSelect(int index)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MoviePlayDialog_t::pauseAtFrameChange(int state) 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(); movLenLbl->clear();
movFramesLbl->clear(); movFramesLbl->clear();
@ -215,16 +218,16 @@ void MoviePlayDialog_t::clearMovieText(void)
pauseAtFrameEntry->clear(); pauseAtFrameEntry->clear();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MoviePlayDialog_t::updateMovieText(void) void MoviePlayDialog_t::updateMovieText(void)
{ {
int idx; int idx;
std::string path; std::string path;
FCEUFILE* fp; FCEUFILE *fp;
MOVIE_INFO info; MOVIE_INFO info;
bool scanok; bool scanok;
char stmp[256]; char stmp[256];
if ( movSelBox->count() == 0 ) if (movSelBox->count() == 0)
{ {
return; return;
} }
@ -232,30 +235,30 @@ void MoviePlayDialog_t::updateMovieText(void)
path = movSelBox->itemText(idx).toStdString(); 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() ); sprintf(stmp, "Error: Failed to open file '%s'", path.c_str());
showErrorMsgWindow( stmp ); showErrorMsgWindow(stmp);
clearMovieText(); clearMovieText();
return; return;
} }
scanok = FCEUI_MovieGetInfo(fp, info, false); scanok = FCEUI_MovieGetInfo(fp, info, false);
if ( scanok ) if (scanok)
{ {
double div; double div;
validator->setMinMax( 0, info.num_frames ); validator->setMinMax(0, info.num_frames);
sprintf(stmp, "%u", (unsigned)info.num_frames); sprintf(stmp, "%u", (unsigned)info.num_frames);
movFramesLbl->setText( tr(stmp) ); movFramesLbl->setText(tr(stmp));
pauseAtFrameEntry->setText( tr(stmp) ); pauseAtFrameEntry->setText(tr(stmp));
div = (FCEUI_GetCurrentVidSystem(0,0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing div = (FCEUI_GetCurrentVidSystem(0, 0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing
double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding
int num_seconds = (int)tempCount; int num_seconds = (int)tempCount;
int fraction = (int)((tempCount - num_seconds) * 100); int fraction = (int)((tempCount - num_seconds) * 100);
int seconds = num_seconds % 60; int seconds = num_seconds % 60;
@ -263,56 +266,56 @@ void MoviePlayDialog_t::updateMovieText(void)
int hours = (num_seconds / 60 / 60) % 60; int hours = (num_seconds / 60 / 60) % 60;
sprintf(stmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction); 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); 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 else
{ {
curCsumLbl->clear(); 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() ); sprintf(stmp, "Warning: Selected movie file '%s' may not have been created using the currently loaded ROM.", path.c_str());
showWarningMsgWindow( stmp ); showWarningMsgWindow(stmp);
} }
} }
} }
else else
{ {
sprintf( stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str() ); sprintf(stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str());
showErrorMsgWindow( stmp ); showErrorMsgWindow(stmp);
clearMovieText(); clearMovieText();
} }
delete fp; delete fp;
@ -320,27 +323,27 @@ void MoviePlayDialog_t::updateMovieText(void)
return; 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 (strcmp(file, movSelBox->itemText(i).toStdString().c_str()) == 0)
{ {
if ( setActive ) if (setActive)
{ {
movSelBox->setCurrentIndex(i); movSelBox->setCurrentIndex(i);
} }
return -1; return -1;
} }
} }
n = movSelBox->count(); n = movSelBox->count();
movSelBox->addItem( tr(file), n ); movSelBox->addItem(tr(file), n);
if ( setActive ) if (setActive)
{ {
movSelBox->setCurrentIndex(n); movSelBox->setCurrentIndex(n);
} }
@ -348,23 +351,23 @@ int MoviePlayDialog_t::addFileToList( const char *file, bool setActive )
return 0; 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; MOVIE_INFO info;
bool scanok, md5Match = false; 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; return md5Match;
} }
scanok = FCEUI_MovieGetInfo(fp, info, true); 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; md5Match = true;
} }
@ -374,33 +377,32 @@ bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 )
return md5Match; return md5Match;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MoviePlayDialog_t::scanDirectory( const char *dirPath, const char *md5 ) void MoviePlayDialog_t::scanDirectory(const char *dirPath, const char *md5)
{ {
QDir dir; QDir dir;
QFileInfoList list; QFileInfoList list;
std::string path; 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); 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() ); //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) void MoviePlayDialog_t::doScan(void)
@ -413,31 +415,31 @@ void MoviePlayDialog_t::doScan(void)
md5[0] = 0; 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(); 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) void MoviePlayDialog_t::playMovie(void)
@ -445,7 +447,7 @@ void MoviePlayDialog_t::playMovie(void)
int idx, pauseframe = 0; int idx, pauseframe = 0;
bool replayReadOnlySetting, movieLoadError = false; bool replayReadOnlySetting, movieLoadError = false;
if ( movSelBox->count() == 0 ) if (movSelBox->count() == 0)
{ {
return; return;
} }
@ -457,24 +459,24 @@ void MoviePlayDialog_t::playMovie(void)
replayReadOnlySetting = openReadOnly->isChecked(); 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(); fceuWrapperLock();
if (FCEUI_LoadMovie( path.c_str(), if (FCEUI_LoadMovie(path.c_str(),
replayReadOnlySetting, pauseframe ? pauseframe : false) == false) replayReadOnlySetting, pauseframe ? pauseframe : false) == false)
{ {
movieLoadError = true; movieLoadError = true;
} }
fceuWrapperUnLock(); fceuWrapperUnLock();
if ( movieLoadError ) if (movieLoadError)
{ {
char stmp[256]; char stmp[256];
sprintf( stmp, "Error: Could not load movie file: %s \n", path.c_str() ); sprintf(stmp, "Error: Could not load movie file: %s \n", path.c_str());
showErrorMsgWindow( stmp ); showErrorMsgWindow(stmp);
} }
else else
{ {
@ -489,78 +491,78 @@ void MoviePlayDialog_t::openMovie(void)
std::string last; std::string last;
char dir[512]; char dir[512];
char md5Match = 0; char md5Match = 0;
QFileDialog dialog(this, tr("Open FM2 Movie") ); QFileDialog dialog(this, tr("Open FM2 Movie"));
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)")); dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)"));
dialog.setViewMode(QFileDialog::List); dialog.setViewMode(QFileDialog::List);
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden);
dialog.setLabelText( QFileDialog::Accept, tr("Open") ); 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 // 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.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
ret = dialog.exec(); ret = dialog.exec();
if ( ret ) if (ret)
{ {
QStringList fileList; QStringList fileList;
fileList = dialog.selectedFiles(); fileList = dialog.selectedFiles();
if ( fileList.size() > 0 ) if (fileList.size() > 0)
{ {
filename = fileList[0]; filename = fileList[0];
} }
} }
if ( filename.isNull() ) if (filename.isNull())
{ {
return; return;
} }
qDebug() << "selected file path : " << filename.toUtf8(); qDebug() << "selected file path : " << filename.toUtf8();
if ( GameInfo ) if (GameInfo)
{ {
char md5[256]; 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; md5Match = 1;
} }
if ( !md5Match ) if (!md5Match)
{ {
printf("Warning MD5 Mismatch\n"); printf("Warning MD5 Mismatch\n");
} }
} }
addFileToList( filename.toStdString().c_str(), true ); addFileToList(filename.toStdString().c_str(), true);
updateMovieText(); 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) void MoviePlayDialog_t::showErrorMsgWindow(const char *str)
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setIcon( QMessageBox::Critical ); msgBox.setIcon(QMessageBox::Critical);
msgBox.setText( tr(str) ); msgBox.setText(tr(str));
msgBox.show(); msgBox.show();
msgBox.exec(); msgBox.exec();
} }
@ -569,8 +571,8 @@ void MoviePlayDialog_t::showWarningMsgWindow(const char *str)
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setIcon( QMessageBox::Warning ); msgBox.setIcon(QMessageBox::Warning);
msgBox.setText( tr(str) ); msgBox.setText(tr(str));
msgBox.show(); msgBox.show();
msgBox.exec(); msgBox.exec();
} }

View File

@ -20,50 +20,49 @@
class MoviePlayDialog_t : public QDialog class MoviePlayDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
MoviePlayDialog_t(QWidget *parent = 0); MoviePlayDialog_t(QWidget *parent = 0);
~MoviePlayDialog_t(void); ~MoviePlayDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QComboBox *movSelBox; QComboBox *movSelBox;
QPushButton *movBrowseBtn; QPushButton *movBrowseBtn;
QCheckBox *openReadOnly; QCheckBox *openReadOnly;
QCheckBox *pauseAtFrame; QCheckBox *pauseAtFrame;
QLineEdit *pauseAtFrameEntry; QLineEdit *pauseAtFrameEntry;
QLabel *movLenLbl; QLabel *movLenLbl;
QLabel *movFramesLbl; QLabel *movFramesLbl;
QLabel *recCountLbl; QLabel *recCountLbl;
QLabel *recFromLbl; QLabel *recFromLbl;
QLabel *romUsedLbl; QLabel *romUsedLbl;
QLabel *romCsumLbl; QLabel *romCsumLbl;
QLabel *curCsumLbl; QLabel *curCsumLbl;
QLabel *emuUsedLbl; QLabel *emuUsedLbl;
QLabel *palUsedLbl; QLabel *palUsedLbl;
QLabel *newppuUsedLbl; QLabel *newppuUsedLbl;
fceuDecIntValidtor *validator; fceuDecIntValidtor *validator;
private: private:
void doScan(void); void doScan(void);
void clearMovieText(void); void clearMovieText(void);
void updateMovieText(void); void updateMovieText(void);
int addFileToList( const char *file, bool setActive = false ); int addFileToList(const char *file, bool setActive = false);
bool checkMD5Sum( const char *path, const char *md5 ); bool checkMD5Sum(const char *path, const char *md5);
void scanDirectory( const char *dirPath, const char *md5 ); void scanDirectory(const char *dirPath, const char *md5);
void showErrorMsgWindow(const char *str); void showErrorMsgWindow(const char *str);
void showWarningMsgWindow(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);
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/MsgLogViewer.h"
#include "Qt/ConsoleWindow.h" #include "Qt/ConsoleWindow.h"
#define MSG_LOG_MAX_LINES 256 #define MSG_LOG_MAX_LINES 256
class msgLogBuf_t class msgLogBuf_t
{ {
public: public:
msgLogBuf_t(void) msgLogBuf_t(void)
{ {
char filename[512]; char filename[512];
#ifdef WIN32 #ifdef WIN32
if ( GetTempPathA( sizeof(filename), filename ) > 0 ) if (GetTempPathA(sizeof(filename), filename) > 0)
{ {
//printf("PATH: %s \n", filename ); //printf("PATH: %s \n", filename );
strcat( filename, "fceux.log"); strcat(filename, "fceux.log");
} }
else else
{ {
strcpy( filename, "fceux.log" ); strcpy(filename, "fceux.log");
} }
#else #else
strcpy( filename, "/tmp/fceux.log" ); strcpy(filename, "/tmp/fceux.log");
#endif #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); printf("Error: Failed to open message log file: '%s'\n", filename);
} }
maxLines = MSG_LOG_MAX_LINES; maxLines = MSG_LOG_MAX_LINES;
totalLines = 0; totalLines = 0;
head = tail = 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; fpOfsList[i] = 0;
} }
@ -82,9 +82,10 @@ class msgLogBuf_t
~msgLogBuf_t(void) ~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; head = tail = 0;
} }
void addLine( const char *txt, bool NewLine = false ) void addLine(const char *txt, bool NewLine = false)
{ {
long ofs; long ofs;
if ( fp == NULL ) return; if (fp == NULL)
return;
::fseek( fp, 0L, SEEK_END); ::fseek(fp, 0L, SEEK_END);
ofs = ::ftell(fp); ofs = ::ftell(fp);
if ( NewLine ) if (NewLine)
{ {
::fprintf( fp, "%s\n", txt ); ::fprintf(fp, "%s\n", txt);
} }
else else
{ {
::fprintf( fp, "%s", txt ); ::fprintf(fp, "%s", txt);
} }
fpOfsList[head] = ofs; fpOfsList[head] = ofs;
head = (head + 1) % MSG_LOG_MAX_LINES; head = (head + 1) % MSG_LOG_MAX_LINES;
if ( head == tail ) if (head == tail)
{ {
tail = (tail + 1) % MSG_LOG_MAX_LINES; tail = (tail + 1) % MSG_LOG_MAX_LINES;
} }
@ -135,23 +137,23 @@ class msgLogBuf_t
s = head - tail; s = head - tail;
if ( s < 0 ) if (s < 0)
{ {
s += MSG_LOG_MAX_LINES; s += MSG_LOG_MAX_LINES;
} }
return s; return s;
} }
void loadTextViewer( QPlainTextEdit *viewer ) void loadTextViewer(QPlainTextEdit *viewer)
{ {
long ofs, nbytes; long ofs, nbytes;
if ( fp == NULL ) if (fp == NULL)
{ {
return; return;
} }
if ( head == tail ) if (head == tail)
{ {
return; return;
} }
@ -159,32 +161,32 @@ class msgLogBuf_t
ofs = fpOfsList[tail]; ofs = fpOfsList[tail];
::fseek( fp, ofs, SEEK_SET); ::fseek(fp, ofs, SEEK_SET);
//printf("Seek: %li \n", ofs ); //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 ); //printf("READ: %li \n", nbytes );
buf[ nbytes ] = 0; buf[nbytes] = 0;
viewer->setPlainText( buf ); viewer->setPlainText(buf);
} }
} }
private: private:
FILE *fp; FILE *fp;
size_t maxLines; size_t maxLines;
size_t totalLines; size_t totalLines;
size_t head; size_t head;
size_t tail; size_t tail;
long fpOfsList[MSG_LOG_MAX_LINES]; long fpOfsList[MSG_LOG_MAX_LINES];
}; };
static msgLogBuf_t msgLog; static msgLogBuf_t msgLog;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent) MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent)
: QDialog( parent ) : QDialog(parent)
{ {
QVBoxLayout *mainLayout; QVBoxLayout *mainLayout;
QHBoxLayout *hbox; QHBoxLayout *hbox;
@ -192,37 +194,41 @@ MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent)
setWindowTitle("Message Log Viewer"); setWindowTitle("Message Log Viewer");
resize( 512, 512 ); resize(512, 512);
mainLayout = new QVBoxLayout(); mainLayout = new QVBoxLayout();
txtView = new QPlainTextEdit(); txtView = new QPlainTextEdit();
txtView->setReadOnly(true); txtView->setReadOnly(true);
mainLayout->addWidget( txtView ); mainLayout->addWidget(txtView);
hbox = new QHBoxLayout(); hbox = new QHBoxLayout();
clearBtn = new QPushButton( tr("Clear") ); clearBtn = new QPushButton(tr("Clear"));
closeBtn = new QPushButton( tr("Close") ); closeBtn = new QPushButton(tr("Close"));
hbox->addWidget( clearBtn ); hbox->addWidget(clearBtn,1);
hbox->addWidget( closeBtn ); hbox->addStretch(5);
hbox->addWidget(closeBtn,1);
connect( clearBtn, SIGNAL(clicked(void)), this, SLOT(clearLog(void)) ); clearBtn->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
connect( closeBtn, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) ); 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; 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(); totalLines = msgLog.getTotalLineCount();
@ -237,16 +243,16 @@ MsgLogViewDialog_t::~MsgLogViewDialog_t(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MsgLogViewDialog_t::closeEvent(QCloseEvent *event) void MsgLogViewDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("Msg Log Key Close Window Event\n"); printf("Msg Log Key Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MsgLogViewDialog_t::closeWindow(void) void MsgLogViewDialog_t::closeWindow(void)
{ {
//printf("Close Window\n"); //printf("Close Window\n");
done(0); done(0);
deleteLater(); deleteLater();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -263,11 +269,11 @@ void MsgLogViewDialog_t::clearLog(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MsgLogViewDialog_t::updatePeriodic(void) void MsgLogViewDialog_t::updatePeriodic(void)
{ {
if ( msgLog.getTotalLineCount() != totalLines ) if (msgLog.getTotalLineCount() != totalLines)
{ {
fceuWrapperLock(); fceuWrapperLock();
msgLog.loadTextViewer( txtView ); msgLog.loadTextViewer(txtView);
totalLines = msgLog.getTotalLineCount(); totalLines = msgLog.getTotalLineCount();
@ -289,7 +295,7 @@ void FCEUD_Message(const char *text)
fputs(text, stdout); fputs(text, stdout);
//fprintf(stdout, "\n"); //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); 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 class MsgLogViewDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
MsgLogViewDialog_t(QWidget *parent = 0); MsgLogViewDialog_t(QWidget *parent = 0);
~MsgLogViewDialog_t(void); ~MsgLogViewDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QTimer *updateTimer; QTimer *updateTimer;
QPlainTextEdit *txtView; QPlainTextEdit *txtView;
size_t totalLines; size_t totalLines;
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void clearLog(void);
private:
public slots:
void closeWindow(void);
private slots:
void updatePeriodic(void);
void clearLog(void);
}; };

View File

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

View File

@ -19,36 +19,35 @@
class PaletteConfDialog_t : public QDialog class PaletteConfDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
PaletteConfDialog_t(QWidget *parent = 0); PaletteConfDialog_t(QWidget *parent = 0);
~PaletteConfDialog_t(void); ~PaletteConfDialog_t(void);
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QLineEdit *custom_palette_path; QLineEdit *custom_palette_path;
QCheckBox *useCustom; QCheckBox *useCustom;
QCheckBox *GrayScale; QCheckBox *GrayScale;
QCheckBox *deemphSwap; QCheckBox *deemphSwap;
QCheckBox *useNTSC; QCheckBox *useNTSC;
QSlider *tintSlider; QSlider *tintSlider;
QSlider *hueSlider; QSlider *hueSlider;
QGroupBox *tintFrame; QGroupBox *tintFrame;
QGroupBox *hueFrame; 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);
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->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 // Memory
memMenu = menuBar->addMenu(tr("&Memory")); memMenu = menuBar->addMenu(tr("&Memory"));

View File

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

View File

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