Merge pull request #136 from mjbudd77/master
Qt SDL Port Video Driver and Menu Bar Config Options
This commit is contained in:
commit
3fad48edea
|
@ -391,6 +391,7 @@ set(SRC_DRIVERS_SDL
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/PaletteConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/PaletteConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/GuiConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/GuiConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/LuaControl.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/LuaControl.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleUtilities.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
// ConsoleUtilities.cpp
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "Qt/ConsoleUtilities.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
int getDirFromFile( const char *path, char *dir )
|
||||||
|
{
|
||||||
|
int i, lastSlash = -1, lastPeriod = -1;
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
while ( path[i] != 0 )
|
||||||
|
{
|
||||||
|
if ( path[i] == '/' )
|
||||||
|
{
|
||||||
|
lastSlash = i;
|
||||||
|
}
|
||||||
|
else if ( path[i] == '.' )
|
||||||
|
{
|
||||||
|
lastPeriod = i;
|
||||||
|
}
|
||||||
|
dir[i] = path[i]; i++;
|
||||||
|
}
|
||||||
|
dir[i] = 0;
|
||||||
|
|
||||||
|
if ( lastPeriod >= 0 )
|
||||||
|
{
|
||||||
|
if ( lastPeriod > lastSlash )
|
||||||
|
{
|
||||||
|
dir[lastSlash] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
|
@ -0,0 +1,3 @@
|
||||||
|
// ConsoleUtilities.h
|
||||||
|
|
||||||
|
int getDirFromFile( const char *path, char *dir );
|
|
@ -26,7 +26,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
||||||
driverSelect = new QComboBox();
|
driverSelect = new QComboBox();
|
||||||
|
|
||||||
driverSelect->addItem( tr("OpenGL"), 0 );
|
driverSelect->addItem( tr("OpenGL"), 0 );
|
||||||
//driverSelect->addItem( tr("SDL"), 1 );
|
driverSelect->addItem( tr("SDL"), 1 );
|
||||||
|
|
||||||
hbox1 = new QHBoxLayout();
|
hbox1 = new QHBoxLayout();
|
||||||
|
|
||||||
|
@ -52,8 +52,10 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
||||||
regionSelect->addItem( tr("Dendy"), 2 );
|
regionSelect->addItem( tr("Dendy"), 2 );
|
||||||
|
|
||||||
setComboBoxFromProperty( regionSelect, "SDL.PAL");
|
setComboBoxFromProperty( regionSelect, "SDL.PAL");
|
||||||
|
setComboBoxFromProperty( driverSelect, "SDL.VideoDriver");
|
||||||
|
|
||||||
connect(regionSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(regionChanged(int)) );
|
connect(regionSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(regionChanged(int)) );
|
||||||
|
connect(driverSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(driverChanged(int)) );
|
||||||
|
|
||||||
hbox1 = new QHBoxLayout();
|
hbox1 = new QHBoxLayout();
|
||||||
|
|
||||||
|
@ -199,6 +201,20 @@ void ConsoleVideoConfDialog_t::showFPSChanged( int value )
|
||||||
fceuWrapperUnLock();
|
fceuWrapperUnLock();
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void ConsoleVideoConfDialog_t::driverChanged(int index)
|
||||||
|
{
|
||||||
|
int driver;
|
||||||
|
//printf("Driver: %i : %i \n", index, driverSelect->itemData(index).toInt() );
|
||||||
|
|
||||||
|
driver = driverSelect->itemData(index).toInt();
|
||||||
|
|
||||||
|
g_config->setOption ("SDL.VideoDriver", driver);
|
||||||
|
|
||||||
|
g_config->save ();
|
||||||
|
|
||||||
|
printf("Note: A restart of the application is needed for video driver change to take effect...\n");
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void ConsoleVideoConfDialog_t::regionChanged(int index)
|
void ConsoleVideoConfDialog_t::regionChanged(int index)
|
||||||
{
|
{
|
||||||
int region;
|
int region;
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ConsoleVideoConfDialog_t : public QDialog
|
||||||
void clipSidesChanged( int value );
|
void clipSidesChanged( int value );
|
||||||
void showFPSChanged( int value );
|
void showFPSChanged( int value );
|
||||||
void regionChanged(int index);
|
void regionChanged(int index);
|
||||||
|
void driverChanged(int index);
|
||||||
void applyChanges( void );
|
void applyChanges( void );
|
||||||
void closewindow( void );
|
void closewindow( void );
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,12 @@ extern unsigned int gui_draw_area_height;
|
||||||
ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
{
|
{
|
||||||
|
QPalette pal = palette();
|
||||||
|
|
||||||
|
pal.setColor(QPalette::Background, Qt::black);
|
||||||
|
setAutoFillBackground(true);
|
||||||
|
setPalette(pal);
|
||||||
|
|
||||||
view_width = GL_NES_WIDTH;
|
view_width = GL_NES_WIDTH;
|
||||||
view_height = GL_NES_HEIGHT;
|
view_height = GL_NES_HEIGHT;
|
||||||
|
|
||||||
|
@ -30,11 +36,29 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
||||||
sdlTexture = NULL;
|
sdlTexture = NULL;
|
||||||
|
|
||||||
vsyncEnabled = false;
|
vsyncEnabled = false;
|
||||||
|
|
||||||
|
localBufSize = GL_NES_WIDTH * GL_NES_HEIGHT * sizeof(uint32_t);
|
||||||
|
|
||||||
|
localBuf = (uint32_t*)malloc( localBufSize );
|
||||||
|
|
||||||
|
if ( localBuf )
|
||||||
|
{
|
||||||
|
memset( localBuf, 0, localBufSize );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleViewSDL_t::~ConsoleViewSDL_t(void)
|
ConsoleViewSDL_t::~ConsoleViewSDL_t(void)
|
||||||
{
|
{
|
||||||
|
if ( localBuf )
|
||||||
|
{
|
||||||
|
free( localBuf ); localBuf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleViewSDL_t::transfer2LocalBuffer(void)
|
||||||
|
{
|
||||||
|
memcpy( localBuf, nes_shm->pixbuf, localBufSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConsoleViewSDL_t::init(void)
|
int ConsoleViewSDL_t::init(void)
|
||||||
|
@ -46,10 +70,16 @@ int ConsoleViewSDL_t::init(void)
|
||||||
printf("[SDL] Failed to initialize video subsystem.\n");
|
printf("[SDL] Failed to initialize video subsystem.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
// printf("Initialized SDL Video Subsystem\n");
|
printf("Initialized SDL Video Subsystem\n");
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<SDL_GetNumVideoDrivers(); i++)
|
||||||
|
{
|
||||||
|
printf("SDL Video Driver %i: %s\n", i, SDL_GetVideoDriver(i) );
|
||||||
|
}
|
||||||
|
printf("Using Video Driver: %s \n", SDL_GetCurrentVideoDriver() );
|
||||||
|
|
||||||
windowHandle = this->winId();
|
windowHandle = this->winId();
|
||||||
|
|
||||||
|
@ -132,17 +162,18 @@ void ConsoleViewSDL_t::resizeEvent(QResizeEvent *event)
|
||||||
s = event->size();
|
s = event->size();
|
||||||
view_width = s.width();
|
view_width = s.width();
|
||||||
view_height = s.height();
|
view_height = s.height();
|
||||||
//printf("SDL Resize: %i x %i \n", view_width, view_height);
|
printf("SDL Resize: %i x %i \n", view_width, view_height);
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
sdlViewport.x = sdlRendW - view_width;
|
//sdlViewport.x = sdlRendW - view_width;
|
||||||
sdlViewport.y = sdlRendH - view_height;
|
//sdlViewport.y = sdlRendH - view_height;
|
||||||
sdlViewport.w = view_width;
|
//sdlViewport.w = view_width;
|
||||||
sdlViewport.h = view_height;
|
//sdlViewport.h = view_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleViewSDL_t::paintEvent( QPaintEvent *event )
|
//void ConsoleViewSDL_t::paintEvent( QPaintEvent *event )
|
||||||
|
void ConsoleViewSDL_t::render(void)
|
||||||
{
|
{
|
||||||
int nesWidth = GL_NES_WIDTH;
|
int nesWidth = GL_NES_WIDTH;
|
||||||
int nesHeight = GL_NES_HEIGHT;
|
int nesHeight = GL_NES_HEIGHT;
|
||||||
|
@ -167,8 +198,10 @@ void ConsoleViewSDL_t::paintEvent( QPaintEvent *event )
|
||||||
|
|
||||||
rw=(int)(nesWidth*xscale);
|
rw=(int)(nesWidth*xscale);
|
||||||
rh=(int)(nesHeight*yscale);
|
rh=(int)(nesHeight*yscale);
|
||||||
sx=sdlViewport.x + (view_width-rw)/2;
|
//sx=sdlViewport.x + (view_width-rw)/2;
|
||||||
sy=sdlViewport.y + (view_height-rh)/2;
|
//sy=sdlViewport.y + (view_height-rh)/2;
|
||||||
|
sx=(view_width-rw)/2;
|
||||||
|
sy=(view_height-rh)/2;
|
||||||
|
|
||||||
if ( (sdlRenderer == NULL) || (sdlTexture == NULL) )
|
if ( (sdlRenderer == NULL) || (sdlTexture == NULL) )
|
||||||
{
|
{
|
||||||
|
@ -183,13 +216,13 @@ void ConsoleViewSDL_t::paintEvent( QPaintEvent *event )
|
||||||
int rowPitch;
|
int rowPitch;
|
||||||
SDL_LockTexture( sdlTexture, nullptr, (void**)&textureBuffer, &rowPitch);
|
SDL_LockTexture( sdlTexture, nullptr, (void**)&textureBuffer, &rowPitch);
|
||||||
{
|
{
|
||||||
memcpy( textureBuffer, nes_shm->pixbuf, GL_NES_HEIGHT*GL_NES_WIDTH*sizeof(uint32_t) );
|
memcpy( textureBuffer, localBuf, GL_NES_HEIGHT*GL_NES_WIDTH*sizeof(uint32_t) );
|
||||||
}
|
}
|
||||||
SDL_UnlockTexture(sdlTexture);
|
SDL_UnlockTexture(sdlTexture);
|
||||||
|
|
||||||
SDL_RenderSetViewport( sdlRenderer, &sdlViewport );
|
//SDL_RenderSetViewport( sdlRenderer, &sdlViewport );
|
||||||
|
|
||||||
SDL_Rect source = {0, 0, GL_NES_WIDTH, GL_NES_HEIGHT };
|
SDL_Rect source = {0, 0, nesWidth, nesHeight };
|
||||||
SDL_Rect dest = { sx, sy, rw, rh };
|
SDL_Rect dest = { sx, sy, rw, rh };
|
||||||
SDL_RenderCopy(sdlRenderer, sdlTexture, &source, &dest);
|
SDL_RenderCopy(sdlRenderer, sdlTexture, &source, &dest);
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,13 @@ class ConsoleViewSDL_t : public QWidget
|
||||||
int init(void);
|
int init(void);
|
||||||
void reset(void);
|
void reset(void);
|
||||||
void cleanup(void);
|
void cleanup(void);
|
||||||
|
void render(void);
|
||||||
|
|
||||||
|
void transfer2LocalBuffer(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event);
|
//void paintEvent(QPaintEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
int view_width;
|
int view_width;
|
||||||
int view_height;
|
int view_height;
|
||||||
|
@ -37,10 +40,13 @@ class ConsoleViewSDL_t : public QWidget
|
||||||
|
|
||||||
bool vsyncEnabled;
|
bool vsyncEnabled;
|
||||||
|
|
||||||
|
uint32_t *localBuf;
|
||||||
|
uint32_t localBufSize;
|
||||||
|
|
||||||
SDL_Window *sdlWindow;
|
SDL_Window *sdlWindow;
|
||||||
SDL_Renderer *sdlRenderer;
|
SDL_Renderer *sdlRenderer;
|
||||||
SDL_Texture *sdlTexture;
|
SDL_Texture *sdlTexture;
|
||||||
SDL_Rect sdlViewport;
|
//SDL_Rect sdlViewport;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "Qt/PaletteConf.h"
|
#include "Qt/PaletteConf.h"
|
||||||
#include "Qt/GuiConf.h"
|
#include "Qt/GuiConf.h"
|
||||||
#include "Qt/LuaControl.h"
|
#include "Qt/LuaControl.h"
|
||||||
|
#include "Qt/ConsoleUtilities.h"
|
||||||
#include "Qt/ConsoleSoundConf.h"
|
#include "Qt/ConsoleSoundConf.h"
|
||||||
#include "Qt/ConsoleVideoConf.h"
|
#include "Qt/ConsoleVideoConf.h"
|
||||||
#include "Qt/AboutWindow.h"
|
#include "Qt/AboutWindow.h"
|
||||||
|
@ -32,13 +33,28 @@
|
||||||
consoleWin_t::consoleWin_t(QWidget *parent)
|
consoleWin_t::consoleWin_t(QWidget *parent)
|
||||||
: QMainWindow( parent )
|
: QMainWindow( parent )
|
||||||
{
|
{
|
||||||
|
int use_SDL_video = false;
|
||||||
|
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
|
|
||||||
viewport = new ConsoleViewGL_t(this);
|
g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
|
||||||
//viewport = new ConsoleViewSDL_t(this);
|
|
||||||
|
viewport_GL = NULL;
|
||||||
|
viewport_SDL = NULL;
|
||||||
|
|
||||||
|
if ( use_SDL_video )
|
||||||
|
{
|
||||||
|
viewport_SDL = new ConsoleViewSDL_t(this);
|
||||||
|
|
||||||
|
setCentralWidget(viewport_SDL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewport_GL = new ConsoleViewGL_t(this);
|
||||||
|
|
||||||
|
setCentralWidget(viewport_GL);
|
||||||
|
}
|
||||||
|
|
||||||
setCentralWidget(viewport);
|
|
||||||
setWindowIcon(QIcon(":fceux1.png"));
|
setWindowIcon(QIcon(":fceux1.png"));
|
||||||
|
|
||||||
gameTimer = new QTimer( this );
|
gameTimer = new QTimer( this );
|
||||||
|
@ -74,7 +90,14 @@ consoleWin_t::~consoleWin_t(void)
|
||||||
emulatorThread->quit();
|
emulatorThread->quit();
|
||||||
emulatorThread->wait();
|
emulatorThread->wait();
|
||||||
|
|
||||||
delete viewport;
|
if ( viewport_GL != NULL )
|
||||||
|
{
|
||||||
|
delete viewport_GL; viewport_GL = NULL;
|
||||||
|
}
|
||||||
|
if ( viewport_SDL != NULL )
|
||||||
|
{
|
||||||
|
delete viewport_SDL; viewport_SDL = NULL;
|
||||||
|
}
|
||||||
delete mutex;
|
delete mutex;
|
||||||
|
|
||||||
// LoadGame() checks for an IP and if it finds one begins a network session
|
// LoadGame() checks for an IP and if it finds one begins a network session
|
||||||
|
@ -121,9 +144,12 @@ void consoleWin_t::createMainMenu(void)
|
||||||
{
|
{
|
||||||
QMenu *subMenu;
|
QMenu *subMenu;
|
||||||
QActionGroup *group;
|
QActionGroup *group;
|
||||||
|
int useNativeMenuBar;
|
||||||
|
|
||||||
// This is needed for menu bar to show up on MacOS
|
// This is needed for menu bar to show up on MacOS
|
||||||
menuBar()->setNativeMenuBar(false);
|
g_config->getOption( "SDL.UseNativeMenuBar", &useNativeMenuBar );
|
||||||
|
|
||||||
|
menuBar()->setNativeMenuBar( useNativeMenuBar ? true : false );
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// File
|
// File
|
||||||
|
@ -487,36 +513,6 @@ void consoleWin_t::closeApp(void)
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int consoleWin_t::getDirFromFile( const char *path, char *dir )
|
|
||||||
{
|
|
||||||
int i, lastSlash = -1, lastPeriod = -1;
|
|
||||||
|
|
||||||
i=0;
|
|
||||||
while ( path[i] != 0 )
|
|
||||||
{
|
|
||||||
if ( path[i] == '/' )
|
|
||||||
{
|
|
||||||
lastSlash = i;
|
|
||||||
}
|
|
||||||
else if ( path[i] == '.' )
|
|
||||||
{
|
|
||||||
lastPeriod = i;
|
|
||||||
}
|
|
||||||
dir[i] = path[i]; i++;
|
|
||||||
}
|
|
||||||
dir[i] = 0;
|
|
||||||
|
|
||||||
if ( lastPeriod >= 0 )
|
|
||||||
{
|
|
||||||
if ( lastPeriod > lastSlash )
|
|
||||||
{
|
|
||||||
dir[lastSlash] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void consoleWin_t::openROMFile(void)
|
void consoleWin_t::openROMFile(void)
|
||||||
{
|
{
|
||||||
|
@ -531,6 +527,8 @@ void consoleWin_t::openROMFile(void)
|
||||||
dialog.setNameFilter(tr("NES files (*.nes *.NES) ;; All files (*)"));
|
dialog.setNameFilter(tr("NES files (*.nes *.NES) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenFile", &last );
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
@ -593,6 +591,8 @@ void consoleWin_t::loadNSF(void)
|
||||||
dialog.setNameFilter(tr("NSF Sound Files (*.nsf *.NSF) ;; Zip Files (*.zip *.ZIP) ;; All files (*)"));
|
dialog.setNameFilter(tr("NSF Sound Files (*.nsf *.NSF) ;; Zip Files (*.zip *.ZIP) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenNSF", &last );
|
g_config->getOption ("SDL.LastOpenNSF", &last );
|
||||||
|
|
||||||
|
@ -642,9 +642,11 @@ void consoleWin_t::loadStateFrom(void)
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
|
||||||
dialog.setNameFilter(tr("FCS Files (*.fc? *.FC?) ;; SAV Files (*.sav *.SAV) ;; All files (*)"));
|
dialog.setNameFilter(tr("FCS & SAV Files (*.sav *.SAV *.fc? *.FC?) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastLoadStateFrom", &last );
|
g_config->getOption ("SDL.LastLoadStateFrom", &last );
|
||||||
|
|
||||||
|
@ -697,6 +699,9 @@ void consoleWin_t::saveStateAs(void)
|
||||||
dialog.setNameFilter(tr("SAV Files (*.sav *.SAV) ;; All files (*)"));
|
dialog.setNameFilter(tr("SAV Files (*.sav *.SAV) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||||
|
dialog.setDefaultSuffix( tr(".sav") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastSaveStateAs", &last );
|
g_config->getOption ("SDL.LastSaveStateAs", &last );
|
||||||
|
|
||||||
|
@ -1022,6 +1027,8 @@ void consoleWin_t::loadGameGenieROM(void)
|
||||||
dialog.setNameFilter(tr("GG ROM File (gg.rom *Genie*.nes) ;; All files (*)"));
|
dialog.setNameFilter(tr("GG ROM File (gg.rom *Genie*.nes) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenFile", &last );
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
@ -1103,6 +1110,8 @@ void consoleWin_t::fdsLoadBiosFile(void)
|
||||||
dialog.setNameFilter(tr("ROM files (*.rom *.ROM) ;; All files (*)"));
|
dialog.setNameFilter(tr("ROM files (*.rom *.ROM) ;; All files (*)"));
|
||||||
|
|
||||||
dialog.setViewMode(QFileDialog::List);
|
dialog.setViewMode(QFileDialog::List);
|
||||||
|
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenFile", &last );
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
@ -1168,6 +1177,8 @@ void consoleWin_t::openMovie(void)
|
||||||
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::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenFile", &last );
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
@ -1251,6 +1262,8 @@ void consoleWin_t::recordMovieAs(void)
|
||||||
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::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastOpenFile", &last );
|
g_config->getOption ("SDL.LastOpenFile", &last );
|
||||||
|
|
||||||
|
@ -1345,10 +1358,17 @@ void consoleWin_t::updatePeriodic(void)
|
||||||
{
|
{
|
||||||
nes_shm->blitUpdated = 0;
|
nes_shm->blitUpdated = 0;
|
||||||
|
|
||||||
viewport->transfer2LocalBuffer();
|
if ( viewport_SDL )
|
||||||
|
{
|
||||||
//viewport->repaint();
|
viewport_SDL->transfer2LocalBuffer();
|
||||||
viewport->update();
|
viewport_SDL->render();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewport_GL->transfer2LocalBuffer();
|
||||||
|
//viewport_GL->repaint();
|
||||||
|
viewport_GL->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,8 +39,8 @@ class consoleWin_t : public QMainWindow
|
||||||
consoleWin_t(QWidget *parent = 0);
|
consoleWin_t(QWidget *parent = 0);
|
||||||
~consoleWin_t(void);
|
~consoleWin_t(void);
|
||||||
|
|
||||||
ConsoleViewGL_t *viewport;
|
ConsoleViewGL_t *viewport_GL;
|
||||||
//ConsoleViewSDL_t *viewport;
|
ConsoleViewSDL_t *viewport_SDL;
|
||||||
|
|
||||||
void setCyclePeriodms( int ms );
|
void setCyclePeriodms( int ms );
|
||||||
|
|
||||||
|
@ -99,8 +99,6 @@ class consoleWin_t : public QMainWindow
|
||||||
void keyReleaseEvent(QKeyEvent *event);
|
void keyReleaseEvent(QKeyEvent *event);
|
||||||
void syncActionConfig( QAction *act, const char *property );
|
void syncActionConfig( QAction *act, const char *property );
|
||||||
|
|
||||||
int getDirFromFile( const char *path, char *dir );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMainMenu(void);
|
void createMainMenu(void);
|
||||||
|
|
||||||
|
|
|
@ -8,30 +8,37 @@
|
||||||
#include "Qt/config.h"
|
#include "Qt/config.h"
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
#include "Qt/ConsoleWindow.h"
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
int useNativeFileDialogVal;
|
int useNativeFileDialogVal;
|
||||||
|
int useNativeMenuBarVal;
|
||||||
QVBoxLayout *mainLayout;
|
QVBoxLayout *mainLayout;
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
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") );
|
||||||
|
|
||||||
useNativeFileDialog->setChecked( useNativeFileDialogVal );
|
useNativeFileDialog->setChecked( useNativeFileDialogVal );
|
||||||
|
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)) );
|
||||||
|
|
||||||
mainLayout->addWidget( useNativeFileDialog );
|
mainLayout->addWidget( useNativeFileDialog );
|
||||||
|
mainLayout->addWidget( useNativeMenuBar );
|
||||||
|
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
}
|
}
|
||||||
|
@ -53,6 +60,14 @@ 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)
|
||||||
|
{
|
||||||
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
||||||
|
g_config->setOption ("SDL.UseNativeMenuBar", value);
|
||||||
|
|
||||||
|
consoleWindow->menuBar()->setNativeMenuBar( value );
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
|
@ -27,11 +27,13 @@ class GuiConfDialog_t : public QDialog
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QCheckBox *useNativeFileDialog;
|
QCheckBox *useNativeFileDialog;
|
||||||
|
QCheckBox *useNativeMenuBar;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeWindow(void);
|
void closeWindow(void);
|
||||||
private slots:
|
private slots:
|
||||||
void useNativeFileDialogChanged(int v);
|
void useNativeFileDialogChanged(int v);
|
||||||
|
void useNativeMenuBarChanged(int v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "Qt/config.h"
|
#include "Qt/config.h"
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
#include "Qt/ConsoleUtilities.h"
|
||||||
|
|
||||||
static bool luaScriptRunning = false;
|
static bool luaScriptRunning = false;
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ void LuaControlDialog_t::openLuaScriptFile(void)
|
||||||
int ret, useNativeFileDialogVal;
|
int ret, useNativeFileDialogVal;
|
||||||
QString filename;
|
QString filename;
|
||||||
std::string last;
|
std::string last;
|
||||||
//char dir[512];
|
char dir[512];
|
||||||
QFileDialog dialog(this, tr("Open LUA Script") );
|
QFileDialog dialog(this, tr("Open LUA Script") );
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
@ -132,6 +133,8 @@ 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::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
g_config->getOption ("SDL.LastLoadLua", &last );
|
g_config->getOption ("SDL.LastLoadLua", &last );
|
||||||
|
|
||||||
|
@ -140,9 +143,9 @@ void LuaControlDialog_t::openLuaScriptFile(void)
|
||||||
last.assign( "/usr/share/fceux/luaScripts" );
|
last.assign( "/usr/share/fceux/luaScripts" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//getDirFromFile( last.c_str(), dir );
|
getDirFromFile( last.c_str(), dir );
|
||||||
|
|
||||||
dialog.setDirectory( tr("/usr/share/fceux/luaScripts") );
|
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);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Qt/config.h"
|
#include "Qt/config.h"
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
#include "Qt/ConsoleUtilities.h"
|
||||||
|
|
||||||
#include "../../ppu.h"
|
#include "../../ppu.h"
|
||||||
|
|
||||||
|
@ -289,6 +290,8 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
{
|
{
|
||||||
int ret, useNativeFileDialogVal;
|
int ret, useNativeFileDialogVal;
|
||||||
QString filename;
|
QString filename;
|
||||||
|
std::string last;
|
||||||
|
char dir[512];
|
||||||
QFileDialog dialog(this, tr("Open NES Palette") );
|
QFileDialog dialog(this, tr("Open NES Palette") );
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
@ -296,8 +299,19 @@ 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::Hidden );
|
||||||
|
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||||
|
|
||||||
dialog.setDirectory( tr("/usr/share/fceux/palettes") );
|
g_config->getOption ("SDL.Palette", &last );
|
||||||
|
|
||||||
|
if ( last.size() == 0 )
|
||||||
|
{
|
||||||
|
last.assign( "/usr/share/fceux/palettes" );
|
||||||
|
}
|
||||||
|
|
||||||
|
getDirFromFile( last.c_str(), 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);
|
||||||
|
|
|
@ -199,6 +199,7 @@ InitConfig()
|
||||||
|
|
||||||
// video controls
|
// video controls
|
||||||
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
|
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
|
||||||
|
config->addOption("videoDriver", "SDL.VideoDriver", 0);
|
||||||
|
|
||||||
// set x/y res to 0 for automatic fullscreen resolution detection (no change)
|
// set x/y res to 0 for automatic fullscreen resolution detection (no change)
|
||||||
config->addOption('x', "xres", "SDL.XResolution", 0);
|
config->addOption('x', "xres", "SDL.XResolution", 0);
|
||||||
|
@ -294,6 +295,7 @@ InitConfig()
|
||||||
config->addOption("_lastloadlua", "SDL.LastLoadLua", "");
|
config->addOption("_lastloadlua", "SDL.LastLoadLua", "");
|
||||||
|
|
||||||
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
||||||
|
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
||||||
|
|
||||||
// fcm -> fm2 conversion
|
// fcm -> fm2 conversion
|
||||||
config->addOption("fcmconvert", "SDL.FCMConvert", "");
|
config->addOption("fcmconvert", "SDL.FCMConvert", "");
|
||||||
|
|
|
@ -17,7 +17,14 @@ int main( int argc, char *argv[] )
|
||||||
consoleWindow->resize( 512, 512 );
|
consoleWindow->resize( 512, 512 );
|
||||||
consoleWindow->show();
|
consoleWindow->show();
|
||||||
|
|
||||||
consoleWindow->viewport->init();
|
if ( consoleWindow->viewport_SDL )
|
||||||
|
{
|
||||||
|
consoleWindow->viewport_SDL->init();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
consoleWindow->viewport_GL->init();
|
||||||
|
}
|
||||||
|
|
||||||
retval = app.exec();
|
retval = app.exec();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue