Added a hook in the core palette emulation to allow for the gui to determine if a custom user palette is available and in use.
This commit is contained in:
parent
002481c6b9
commit
c0febe1d3e
|
@ -143,6 +143,7 @@ void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall);
|
|||
//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory.
|
||||
void FCEUI_SetBaseDirectory(std::string const & dir);
|
||||
|
||||
bool FCEUI_GetUserPaletteAvail(void);
|
||||
void FCEUI_SetUserPalette(uint8 *pal, int nEntries);
|
||||
|
||||
//Sets up sound code to render sound at the specified rate, in samples
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// PaletteConf.cpp
|
||||
//
|
||||
#include <QFileDialog>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include "Qt/PaletteConf.h"
|
||||
#include "Qt/main.h"
|
||||
|
@ -12,6 +13,14 @@
|
|||
#include "../../ppu.h"
|
||||
|
||||
extern bool force_grayscale;
|
||||
|
||||
static const char *commentText =
|
||||
"Palette Selection uses the 1st Matching Condition:\n\
|
||||
1. Game type is NSF (always uses fixed palette) \n\
|
||||
2. Custom User Palette is Available and Enabled \n\
|
||||
3. NTSC Color Emulation is Enabled \n\
|
||||
4. Individual Game Palette is Available \n\
|
||||
5. Default Built-in Palette ";
|
||||
//----------------------------------------------------
|
||||
PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||
: QDialog( parent )
|
||||
|
@ -21,10 +30,13 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
QGroupBox *frame;
|
||||
//QPushButton *closebutton;
|
||||
QPushButton *button;
|
||||
QTextEdit *comments;
|
||||
int hue, tint;
|
||||
char stmp[64];
|
||||
std::string paletteFile;
|
||||
|
||||
resize( 512, 600 );
|
||||
|
||||
// sync with config
|
||||
g_config->getOption ("SDL.Hue", &hue);
|
||||
g_config->getOption ("SDL.Tint", &tint);
|
||||
|
@ -41,6 +53,7 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
GrayScale = new QCheckBox( tr("Force Grayscale") );
|
||||
deemphSwap = new QCheckBox( tr("De-emphasis Bit Swap") );
|
||||
|
||||
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
|
||||
GrayScale->setChecked( force_grayscale );
|
||||
deemphSwap->setChecked( paldeemphswap );
|
||||
|
||||
|
@ -48,11 +61,6 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
connect(GrayScale , SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)) );
|
||||
connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)) );
|
||||
|
||||
vbox->addWidget( useCustom );
|
||||
vbox->addLayout( hbox1 );
|
||||
vbox->addWidget( GrayScale );
|
||||
vbox->addWidget( deemphSwap);
|
||||
|
||||
button = new QPushButton( tr("Open Palette") );
|
||||
hbox1->addWidget( button );
|
||||
|
||||
|
@ -63,7 +71,13 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
custom_palette_path = new QLineEdit();
|
||||
custom_palette_path->setReadOnly(true);
|
||||
custom_palette_path->setText( paletteFile.c_str() );
|
||||
hbox1->addWidget( custom_palette_path );
|
||||
|
||||
vbox->addWidget( useCustom );
|
||||
vbox->addLayout( hbox1 );
|
||||
vbox->addWidget( custom_palette_path );
|
||||
vbox->addWidget( GrayScale );
|
||||
vbox->addWidget( deemphSwap);
|
||||
|
||||
|
||||
button = new QPushButton( tr("Clear") );
|
||||
hbox1->addWidget( button );
|
||||
|
@ -119,6 +133,14 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
|
||||
mainLayout->addWidget( frame );
|
||||
|
||||
comments = new QTextEdit();
|
||||
|
||||
comments->setText( commentText );
|
||||
comments->moveCursor(QTextCursor::Start);
|
||||
comments->setReadOnly(true);
|
||||
|
||||
mainLayout->addWidget( comments );
|
||||
|
||||
setLayout( mainLayout );
|
||||
}
|
||||
|
||||
|
@ -181,6 +203,8 @@ void PaletteConfDialog_t::use_Custom_Changed(int state)
|
|||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
std::string filename;
|
||||
|
||||
//printf("Use Custom:%i \n", state );
|
||||
|
||||
g_config->getOption ("SDL.Palette", &filename);
|
||||
|
||||
if ( fceuWrapperTryLock() )
|
||||
|
@ -257,6 +281,7 @@ void PaletteConfDialog_t::clearPalette(void)
|
|||
{
|
||||
FCEUI_SetUserPalette( NULL, 0);
|
||||
fceuWrapperUnLock();
|
||||
useCustom->setChecked(false);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
|
@ -298,18 +323,22 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
|||
}
|
||||
qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
|
||||
g_config->setOption ("SDL.NTSCpalette", 0);
|
||||
|
||||
if ( fceuWrapperTryLock() )
|
||||
{
|
||||
LoadCPalette ( filename.toStdString().c_str() );
|
||||
if ( LoadCPalette ( filename.toStdString().c_str() ) )
|
||||
{
|
||||
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
|
||||
custom_palette_path->setText( filename.toStdString().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str() );
|
||||
}
|
||||
fceuWrapperUnLock();
|
||||
|
||||
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
|
||||
}
|
||||
|
||||
custom_palette_path->setText( filename.toStdString().c_str() );
|
||||
|
||||
useNTSC->setChecked( 0 );
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -289,6 +289,11 @@ static void ApplyDeemphasisComplete(pal* pal512)
|
|||
}
|
||||
}
|
||||
|
||||
bool FCEUI_GetUserPaletteAvail( void )
|
||||
{
|
||||
return palette_user_available;
|
||||
}
|
||||
|
||||
void FCEUI_SetUserPalette(uint8 *pal, int nEntries)
|
||||
{
|
||||
if(!pal)
|
||||
|
|
Loading…
Reference in New Issue