For Qt GUI, added option to use palette background color as video background color. This option can be accessed from via main menu -> option submenu.

This commit is contained in:
harry 2022-10-09 21:09:52 -04:00
parent 06467ce73a
commit 900305b587
6 changed files with 56 additions and 5 deletions

View File

@ -894,7 +894,6 @@ void consoleWin_t::createMainMenu(void)
QActionGroup *group;
int useNativeMenuBar;
int customAutofireOnFrames, customAutofireOffFrames;
ColorMenuItem *bgColorItem;
//QShortcut *shortcut;
menubar = new consoleMenuBar(this);
@ -1254,15 +1253,32 @@ void consoleWin_t::createMainMenu(void)
optMenu->addAction(act);
optMenu->addSeparator();
// Options -> Video BG Color
fceuLoadConfigColor( "SDL.VideoBgColor", &videoBgColor );
bgColorItem = new ColorMenuItem( tr("BG Side Panel Color"), "SDL.VideoBgColor", this );
bgColorItem->connectColor( &videoBgColor );
bgColorMenuItem = new ColorMenuItem( tr("BG Side Panel Color"), "SDL.VideoBgColor", this );
bgColorMenuItem->connectColor( &videoBgColor );
optMenu->addAction(bgColorItem);
optMenu->addAction(bgColorMenuItem);
connect( bgColorItem, SIGNAL(colorChanged(QColor&)), this, SLOT(videoBgColorChanged(QColor&)) );
connect( bgColorMenuItem, SIGNAL(colorChanged(QColor&)), this, SLOT(videoBgColorChanged(QColor&)) );
// Options -> Use BG Palette for Video BG Color
g_config->getOption( "SDL.UseBgPaletteForVideo", &usePaletteForVideoBg );
act = new QAction(tr("Use BG Palette for Video BG Color"), this);
//act->setShortcut( QKeySequence(tr("Alt+/")));
act->setCheckable(true);
act->setChecked( usePaletteForVideoBg );
act->setStatusTip(tr("Use BG Palette for Video BG Color"));
//act->setIcon( style()->standardIcon( QStyle::SP_TitleBarMaxButton ) );
connect(act, SIGNAL(triggered(bool)), this, SLOT(toggleUseBgPaletteForVideo(bool)) );
optMenu->addAction(act);
bgColorMenuItem->setEnabled( !usePaletteForVideoBg );
//-----------------------------------------------------------------------
// Emulation
@ -2152,6 +2168,20 @@ void consoleWin_t::toggleMenuAutoHide(bool checked)
g_config->save();
}
//---------------------------------------------------------------------------
void consoleWin_t::toggleUseBgPaletteForVideo(bool checked)
{
usePaletteForVideoBg = checked;
g_config->setOption( "SDL.UseBgPaletteForVideo", usePaletteForVideoBg );
g_config->save();
if ( !usePaletteForVideoBg )
{
fceuLoadConfigColor( "SDL.VideoBgColor", &videoBgColor );
}
bgColorMenuItem->setEnabled( !usePaletteForVideoBg );
}
//---------------------------------------------------------------------------
void consoleWin_t::closeApp(void)
{
nes_shm->runEmulator = 0;

View File

@ -27,6 +27,7 @@
#include <QRecursiveMutex>
#endif
#include "Qt/ColorMenu.h"
#include "Qt/ConsoleViewerGL.h"
#include "Qt/ConsoleViewerSDL.h"
#include "Qt/GamePadConf.h"
@ -259,6 +260,7 @@ class consoleWin_t : public QMainWindow
QTimer *gameTimer;
QColor videoBgColor;
ColorMenuItem *bgColorMenuItem;
std::string errorMsg;
bool errorMsgValid;
@ -453,6 +455,7 @@ class consoleWin_t : public QMainWindow
void winActiveChanged(void);
void emuFrameFinish(void);
void toggleMenuAutoHide(bool);
void toggleUseBgPaletteForVideo(bool);
void videoBgColorChanged( QColor &c );
void loadRomRequestCB( QString s );

View File

@ -535,6 +535,7 @@ InitConfig()
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
config->addOption("videoDriver", "SDL.VideoDriver", 0);
config->addOption("SDL.VideoBgColor", "#000000");
config->addOption("SDL.UseBgPaletteForVideo", false);
config->addOption("SDL.VideoVsync", 1);
// set x/y res to 0 for automatic fullscreen resolution detection (no change)

View File

@ -89,6 +89,7 @@ bool pauseAfterPlayback = false;
bool suggestReadOnlyReplay = true;
bool showStatusIconOpt = true;
bool drawInputAidsEnable = true;
bool usePaletteForVideoBg = false;
unsigned int gui_draw_area_width = 256;
unsigned int gui_draw_area_height = 256;

View File

@ -18,6 +18,7 @@ extern bool suggestReadOnlyReplay;
extern bool emulatorCycleToggle;
extern bool showStatusIconOpt;
extern bool drawInputAidsEnable;
extern bool usePaletteForVideoBg;
extern unsigned int gui_draw_area_width;
extern unsigned int gui_draw_area_height;
extern unsigned int emulatorCycleCount;

View File

@ -37,6 +37,7 @@
#include "Qt/sdl-video.h"
#include "Qt/AviRecord.h"
#include "Qt/fceuWrapper.h"
#include "Qt/ConsoleWindow.h"
#ifdef CREATE_AVI
#include "../videolog/nesvideos-piece.h"
@ -74,6 +75,7 @@ extern bool MaxSpeed;
extern int input_display;
extern int frame_display;
extern int rerecord_display;
extern uint8 PALRAM[0x20];
/**
* Attempts to destroy the graphical video display. Returns 0 on
@ -498,6 +500,19 @@ BlitScreen(uint8 *XBuf)
{
int i = nes_shm->pixBufIdx;
if (usePaletteForVideoBg)
{
unsigned char r, g, b;
FCEUD_GetPalette(0x80 | PALRAM[0], &r, &g, &b);
if (consoleWindow)
{
QColor *bgColor = consoleWindow->getVideoBgColorPtr();
*bgColor = QColor::fromRgb(r,g,b);
}
}
doBlitScreen(XBuf, (uint8_t*)nes_shm->pixbuf[i]);
nes_shm->pixBufIdx = (i+1) % NES_VIDEO_BUFLEN;