Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharry <hrosen2016@gmail.com>2022-10-10 04:09:52 +0300
committerharry <hrosen2016@gmail.com>2022-10-10 04:09:52 +0300
commit900305b58738f66902fd1c743b5017f607f442e3 (patch)
tree9276ec93a85ca6a85bcd9b259f6e7bcaa3bb60c0
parent06467ce73aecf1e96c54dbf6e59a00fd617f2eb4 (diff)
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.
-rw-r--r--src/drivers/Qt/ConsoleWindow.cpp40
-rw-r--r--src/drivers/Qt/ConsoleWindow.h3
-rw-r--r--src/drivers/Qt/config.cpp1
-rw-r--r--src/drivers/Qt/fceuWrapper.cpp1
-rw-r--r--src/drivers/Qt/fceuWrapper.h1
-rw-r--r--src/drivers/Qt/sdl-video.cpp15
6 files changed, 56 insertions, 5 deletions
diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp
index fd5119c4..58cd2eb4 100644
--- a/src/drivers/Qt/ConsoleWindow.cpp
+++ b/src/drivers/Qt/ConsoleWindow.cpp
@@ -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(bgColorMenuItem);
+
+ 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(bgColorItem);
+ optMenu->addAction(act);
- connect( bgColorItem, SIGNAL(colorChanged(QColor&)), this, SLOT(videoBgColorChanged(QColor&)) );
+ 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;
diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h
index d4451965..20460591 100644
--- a/src/drivers/Qt/ConsoleWindow.h
+++ b/src/drivers/Qt/ConsoleWindow.h
@@ -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 );
diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp
index fff49ff4..3f5490cf 100644
--- a/src/drivers/Qt/config.cpp
+++ b/src/drivers/Qt/config.cpp
@@ -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)
diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp
index 12790b69..888d5b2e 100644
--- a/src/drivers/Qt/fceuWrapper.cpp
+++ b/src/drivers/Qt/fceuWrapper.cpp
@@ -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;
diff --git a/src/drivers/Qt/fceuWrapper.h b/src/drivers/Qt/fceuWrapper.h
index 65534ae0..350480a3 100644
--- a/src/drivers/Qt/fceuWrapper.h
+++ b/src/drivers/Qt/fceuWrapper.h
@@ -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;
diff --git a/src/drivers/Qt/sdl-video.cpp b/src/drivers/Qt/sdl-video.cpp
index b3c46434..73bbd8bc 100644
--- a/src/drivers/Qt/sdl-video.cpp
+++ b/src/drivers/Qt/sdl-video.cpp
@@ -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;