Added a few more options to the palette config window.
This commit is contained in:
parent
2d4451a43c
commit
002481c6b9
|
@ -9,6 +9,9 @@
|
|||
#include "Qt/keyscan.h"
|
||||
#include "Qt/fceuWrapper.h"
|
||||
|
||||
#include "../../ppu.h"
|
||||
|
||||
extern bool force_grayscale;
|
||||
//----------------------------------------------------
|
||||
PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||
: QDialog( parent )
|
||||
|
@ -31,8 +34,25 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
mainLayout = new QVBoxLayout();
|
||||
|
||||
frame = new QGroupBox( tr("Custom Palette:") );
|
||||
vbox = new QVBoxLayout();
|
||||
hbox1 = new QHBoxLayout();
|
||||
|
||||
useCustom = new QCheckBox( tr("Use Custom Palette") );
|
||||
GrayScale = new QCheckBox( tr("Force Grayscale") );
|
||||
deemphSwap = new QCheckBox( tr("De-emphasis Bit Swap") );
|
||||
|
||||
GrayScale->setChecked( force_grayscale );
|
||||
deemphSwap->setChecked( paldeemphswap );
|
||||
|
||||
connect(useCustom , SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int)) );
|
||||
connect(GrayScale , SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)) );
|
||||
connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)) );
|
||||
|
||||
vbox->addWidget( useCustom );
|
||||
vbox->addLayout( hbox1 );
|
||||
vbox->addWidget( GrayScale );
|
||||
vbox->addWidget( deemphSwap);
|
||||
|
||||
button = new QPushButton( tr("Open Palette") );
|
||||
hbox1->addWidget( button );
|
||||
|
||||
|
@ -50,7 +70,7 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
|||
|
||||
connect( button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)) );
|
||||
|
||||
frame->setLayout( hbox1 );
|
||||
frame->setLayout( vbox );
|
||||
|
||||
mainLayout->addWidget( frame );
|
||||
|
||||
|
@ -156,6 +176,59 @@ void PaletteConfDialog_t::tintChanged(int v)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void PaletteConfDialog_t::use_Custom_Changed(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
std::string filename;
|
||||
|
||||
g_config->getOption ("SDL.Palette", &filename);
|
||||
|
||||
if ( fceuWrapperTryLock() )
|
||||
{
|
||||
if ( value && (filename.size() > 0) )
|
||||
{
|
||||
LoadCPalette ( filename.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
FCEUI_SetUserPalette( NULL, 0);
|
||||
}
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void PaletteConfDialog_t::force_GrayScale_Changed(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
|
||||
if ( fceuWrapperTryLock() )
|
||||
{
|
||||
int e, h, t;
|
||||
g_config->getOption ("SDL.NTSCpalette", &e);
|
||||
g_config->getOption ("SDL.Hue", &h);
|
||||
g_config->getOption ("SDL.Tint", &t);
|
||||
force_grayscale = value ? true : false;
|
||||
FCEUI_SetNTSCTH( e, t, h);
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void PaletteConfDialog_t::deemphswap_Changed(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
|
||||
if ( fceuWrapperTryLock() )
|
||||
{
|
||||
int e, h, t;
|
||||
g_config->getOption ("SDL.NTSCpalette", &e);
|
||||
g_config->getOption ("SDL.Hue", &h);
|
||||
g_config->getOption ("SDL.Tint", &t);
|
||||
paldeemphswap = value ? true : false;
|
||||
FCEUI_SetNTSCTH( e, t, h);
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void PaletteConfDialog_t::use_NTSC_Changed(int state)
|
||||
{
|
||||
int h, t;
|
||||
|
|
|
@ -27,6 +27,9 @@ class PaletteConfDialog_t : public QDialog
|
|||
|
||||
protected:
|
||||
QLineEdit *custom_palette_path;
|
||||
QCheckBox *useCustom;
|
||||
QCheckBox *GrayScale;
|
||||
QCheckBox *deemphSwap;
|
||||
QCheckBox *useNTSC;
|
||||
QSlider *tintSlider;
|
||||
QSlider *hueSlider;
|
||||
|
@ -42,5 +45,8 @@ class PaletteConfDialog_t : public QDialog
|
|||
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);
|
||||
|
||||
};
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
// GLOBALS
|
||||
extern Config *g_config;
|
||||
extern bool force_grayscale;
|
||||
|
||||
// STATIC GLOBALS
|
||||
static int s_curbpp = 0;
|
||||
|
@ -269,9 +270,21 @@ FCEUD_SetPalette(uint8 index,
|
|||
uint8 g,
|
||||
uint8 b)
|
||||
{
|
||||
s_psdl[index].r = r;
|
||||
s_psdl[index].g = g;
|
||||
s_psdl[index].b = b;
|
||||
if ( force_grayscale )
|
||||
{
|
||||
// convert the palette entry to grayscale
|
||||
int gray = ((float)r * 0.299 + (float)g * 0.587 + (float)b * 0.114);
|
||||
|
||||
s_psdl[index].r = gray;
|
||||
s_psdl[index].g = gray;
|
||||
s_psdl[index].b = gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_psdl[index].r = r;
|
||||
s_psdl[index].g = g;
|
||||
s_psdl[index].b = b;
|
||||
}
|
||||
|
||||
s_paletterefresh = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue