From e1811ae2327d58d625575e6dccf92f7a279b269f Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Sat, 23 Feb 2019 20:32:11 -0700 Subject: [PATCH] NUI for m64p --- src/CMakeLists.txt | 26 +++++++----- src/Config.h | 17 +++++++- src/DisplayWindow.cpp | 3 ++ src/GLideNUI/ConfigDialog.cpp | 22 +--------- src/GLideNUI/ConfigDialog.h | 2 - src/GLideNUI/GLideNUI.cpp | 11 +---- src/GLideNUI/GLideNUI.pro | 4 +- src/GLideNUI/Settings.cpp | 12 ++---- src/GLideNUI/configDialog.ui | 64 +++++++----------------------- src/mupenplus/GLideN64_mupenplus.h | 2 - src/mupenplus/MupenPlusAPIImpl.cpp | 8 ---- src/windows/Config_windows.cpp | 32 +++++++++++++-- 12 files changed, 87 insertions(+), 116 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1b045590..12f55a5c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,7 +140,7 @@ if(MUPENPLUSAPI) include_directories( . inc ) set(GLideN64_SOURCES_UNIX MupenPlusPluginAPI.cpp - mupenplus/Config_mupenplus.cpp + windows/Config_windows.cpp mupenplus/CommonAPIImpl_mupenplus.cpp mupenplus/MemoryStatus_mupenplus.cpp mupenplus/MupenPlusAPIImpl.cpp @@ -345,6 +345,14 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQ SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCC_STATIC_LINK_FLAGS}" ) endif() +find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED) + +add_library(NUI STATIC IMPORTED) +if(MINGW) + set_target_properties(NUI PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/GLideNUI/build/debug/libGLideNUI.a") +else(MINGW) + set_target_properties(NUI PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/GLideNUI/build/libGLideNUI.a") +endif(MINGW) add_library( ${GLideN64_DLL_NAME} SHARED ${GLideN64_SOURCES}) if( CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -358,15 +366,15 @@ if( CMAKE_BUILD_TYPE STREQUAL "Debug") if(SDL) if (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osald ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osald NUI Qt5::Widgets Qt5::Core Qt5::Gui ) else (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd NUI Qt5::Widgets Qt5::Core Qt5::Gui ) endif (NOHQ) else(SDL) if (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osald ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osald NUI Qt5::Widgets Qt5::Core Qt5::Gui ) else (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd NUI Qt5::Widgets Qt5::Core Qt5::Gui ) endif (NOHQ) endif(SDL) endif( CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -391,15 +399,15 @@ if( CMAKE_BUILD_TYPE STREQUAL "Release") if(SDL) if (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osal ) + target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osal NUI Qt5::Widgets Qt5::Core Qt5::Gui ) else (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ ) + target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ NUI Qt5::Widgets Qt5::Core Qt5::Gui ) endif (NOHQ) else(SDL) if (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osal ) + target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osal NUI Qt5::Widgets Qt5::Core Qt5::Gui ) else (NOHQ) - target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ ) + target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ NUI Qt5::Widgets Qt5::Core Qt5::Gui ) endif (NOHQ) endif(SDL) endif( CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/src/Config.h b/src/Config.h index 157620a2a..db8053fb2 100644 --- a/src/Config.h +++ b/src/Config.h @@ -219,8 +219,21 @@ struct Config extern Config config; void Config_LoadConfig(); -#ifndef MUPENPLUSAPI -void Config_DoConfig(/*HWND hParent*/); + +#ifdef OS_WINDOWS +#define EXPORT __declspec(dllexport) +#define CALL __cdecl +#else +#define EXPORT __attribute__((visibility("default"))) +#define CALL +#endif + +#if defined(__cplusplus) +extern "C" { +#endif +EXPORT void CALL Config_DoConfig(/*HWND hParent*/); +#if defined(__cplusplus) +} #endif bool isHWLightingAllowed(); diff --git a/src/DisplayWindow.cpp b/src/DisplayWindow.cpp index d26e19faa..fc3b0566f 100644 --- a/src/DisplayWindow.cpp +++ b/src/DisplayWindow.cpp @@ -28,6 +28,9 @@ void DisplayWindow::stop() void DisplayWindow::restart() { + //setWindowSize(config.video.windowedWidth, config.video.windowedHeight); + m_resizeWidth = config.video.windowedWidth; + m_resizeHeight = config.video.windowedHeight; m_bResizeWindow = true; } diff --git a/src/GLideNUI/ConfigDialog.cpp b/src/GLideNUI/ConfigDialog.cpp index 66ff91cd0..88af4e539 100644 --- a/src/GLideNUI/ConfigDialog.cpp +++ b/src/GLideNUI/ConfigDialog.cpp @@ -14,7 +14,6 @@ #include "ui_configDialog.h" #include "Settings.h" #include "ConfigDialog.h" -#include "FullscreenResolutions.h" static struct @@ -103,13 +102,7 @@ void ConfigDialog::_init() ui->overscanPalTopSpinBox->setValue(config.frameBufferEmulation.overscanPAL.top); ui->overscanPalBottomSpinBox->setValue(config.frameBufferEmulation.overscanPAL.bottom); - QStringList fullscreenModesList, fullscreenRatesList; - int fullscreenMode, fullscreenRate; - fillFullscreenResolutionsList(fullscreenModesList, fullscreenMode, fullscreenRatesList, fullscreenRate); - ui->fullScreenResolutionComboBox->clear(); - ui->fullScreenResolutionComboBox->insertItems(0, fullscreenModesList); - ui->fullScreenResolutionComboBox->setCurrentIndex(fullscreenMode); - ui->fullScreenRefreshRateComboBox->setCurrentIndex(fullscreenRate); + ui->fullScreenCheckBox->setChecked(config.video.fullscreen != 0); ui->fxaaCheckBox->toggle(); ui->fxaaCheckBox->setChecked(config.video.fxaa != 0); @@ -396,8 +389,7 @@ void ConfigDialog::accept() config.video.windowedHeight = windowedResolutionDimensions[1].trimmed().toInt(); } - getFullscreenResolutions(ui->fullScreenResolutionComboBox->currentIndex(), config.video.fullscreenWidth, config.video.fullscreenHeight); - getFullscreenRefreshRate(ui->fullScreenRefreshRateComboBox->currentIndex(), config.video.fullscreenRefresh); + config.video.fullscreen = ui->fullScreenCheckBox->isChecked() ? 1 : 0; config.video.fxaa = ui->fxaaCheckBox->isChecked() ? 1 : 0; config.video.multisampling = (ui->fxaaCheckBox->isChecked() || ui->n64DepthCompareCheckBox->isChecked()) ? 0 : pow2(ui->aliasingSlider->value()); @@ -612,16 +604,6 @@ void ConfigDialog::on_buttonBox_clicked(QAbstractButton *button) } } -void ConfigDialog::on_fullScreenResolutionComboBox_currentIndexChanged(int index) -{ - QStringList fullscreenRatesList; - int fullscreenRate; - fillFullscreenRefreshRateList(index, fullscreenRatesList, fullscreenRate); - ui->fullScreenRefreshRateComboBox->clear(); - ui->fullScreenRefreshRateComboBox->insertItems(0, fullscreenRatesList); - ui->fullScreenRefreshRateComboBox->setCurrentIndex(fullscreenRate); -} - void ConfigDialog::on_texPackPathButton_clicked() { QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly | QFileDialog::DontUseSheet | QFileDialog::ReadOnly | QFileDialog::HideNameFilterDetails; diff --git a/src/GLideNUI/ConfigDialog.h b/src/GLideNUI/ConfigDialog.h index d1934feff..b5d882580 100644 --- a/src/GLideNUI/ConfigDialog.h +++ b/src/GLideNUI/ConfigDialog.h @@ -30,8 +30,6 @@ private slots: void on_buttonBox_clicked(QAbstractButton *button); - void on_fullScreenResolutionComboBox_currentIndexChanged(int index); - void on_texPackPathButton_clicked(); void on_windowedResolutionComboBox_currentIndexChanged(int index); diff --git a/src/GLideNUI/GLideNUI.cpp b/src/GLideNUI/GLideNUI.cpp index 27d1b387e..608a807df 100644 --- a/src/GLideNUI/GLideNUI.cpp +++ b/src/GLideNUI/GLideNUI.cpp @@ -29,21 +29,12 @@ int openConfigDialog(const wchar_t * _strFileName, const char * _romName, bool & if (config.generalEmulation.enableCustomSettings != 0 && _romName != nullptr && strlen(_romName) != 0) loadCustomRomSettings(strIniFileName, _romName); - int argc = 0; - char * argv = 0; - QApplication a(argc, &argv); - - QTranslator translator; - if (translator.load(getTranslationFile(), strIniFileName)) - a.installTranslator(&translator); - ConfigDialog w(Q_NULLPTR, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); w.setIniPath(strIniFileName); w.setRomName(_romName); w.setTitle(); - w.show(); - const int res = a.exec(); + const int res = w.exec(); _accepted = w.isAccepted(); return res; } diff --git a/src/GLideNUI/GLideNUI.pro b/src/GLideNUI/GLideNUI.pro index 7be53681e..9c3cdf4f5 100644 --- a/src/GLideNUI/GLideNUI.pro +++ b/src/GLideNUI/GLideNUI.pro @@ -14,10 +14,11 @@ TEMPLATE = lib CONFIG += staticlib CONFIG += c++11 +win32:DEFINES += OS_WINDOWS + SOURCES += \ ConfigDialog.cpp \ GLideNUI.cpp \ - FullscreenResolutions_windows.cpp \ Settings.cpp \ ScreenShot.cpp \ AboutDialog.cpp @@ -25,7 +26,6 @@ SOURCES += \ HEADERS += \ ConfigDialog.h \ GLideNUI.h \ - FullscreenResolutions.h \ Settings.h \ AboutDialog.h diff --git a/src/GLideNUI/Settings.cpp b/src/GLideNUI/Settings.cpp index 717876276..9fafa0230 100644 --- a/src/GLideNUI/Settings.cpp +++ b/src/GLideNUI/Settings.cpp @@ -21,11 +21,9 @@ void _loadSettings(QSettings & settings) config.version = settings.value("version").toInt(); settings.beginGroup("video"); - config.video.fullscreenWidth = settings.value("fullscreenWidth", config.video.fullscreenWidth).toInt(); - config.video.fullscreenHeight = settings.value("fullscreenHeight", config.video.fullscreenHeight).toInt(); config.video.windowedWidth = settings.value("windowedWidth", config.video.windowedWidth).toInt(); config.video.windowedHeight = settings.value("windowedHeight", config.video.windowedHeight).toInt(); - config.video.fullscreenRefresh = settings.value("fullscreenRefresh", config.video.fullscreenRefresh).toInt(); + config.video.fullscreen = settings.value("fullscreen", config.video.fullscreen).toInt(); config.video.multisampling = settings.value("multisampling", config.video.multisampling).toInt(); config.video.fxaa= settings.value("fxaa", config.video.fxaa).toInt(); config.video.verticalSync = settings.value("verticalSync", config.video.verticalSync).toInt(); @@ -189,11 +187,9 @@ void writeSettings(const QString & _strIniFolder) settings.setValue("version", config.version); settings.beginGroup("video"); - settings.setValue("fullscreenWidth", config.video.fullscreenWidth); - settings.setValue("fullscreenHeight", config.video.fullscreenHeight); settings.setValue("windowedWidth", config.video.windowedWidth); settings.setValue("windowedHeight", config.video.windowedHeight); - settings.setValue("fullscreenRefresh", config.video.fullscreenRefresh); + settings.setValue("fullscreen", config.video.fullscreen); settings.setValue("multisampling", config.video.multisampling); settings.setValue("fxaa", config.video.fxaa); settings.setValue("verticalSync", config.video.verticalSync); @@ -376,11 +372,9 @@ void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomNa settings.beginGroup(romName); settings.beginGroup("video"); - WriteCustomSetting(video, fullscreenWidth); - WriteCustomSetting(video, fullscreenHeight); WriteCustomSetting(video, windowedWidth); WriteCustomSetting(video, windowedHeight); - WriteCustomSetting(video, fullscreenRefresh); + WriteCustomSetting(video, fullscreen); WriteCustomSetting(video, multisampling); WriteCustomSetting(video, fxaa); WriteCustomSetting(video, verticalSync); diff --git a/src/GLideNUI/configDialog.ui b/src/GLideNUI/configDialog.ui index 4f5b73bca..d880ff41b 100644 --- a/src/GLideNUI/configDialog.ui +++ b/src/GLideNUI/configDialog.ui @@ -57,55 +57,21 @@ 18 - - - <html><head/><body><p>All the resolutions that your video card/monitor supports should be displayed.</p><p>[Recommended:<span style=" font-style:italic;"> Maximum resolution for your monitor unless performance becomes an issue</span>]</p></body></html> - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Full screen resolution: - - - - - - - - - - - - Refresh rate: - - - true - - - - - - - - - - + + + + + Full Screen: + + + true + + + + + + + diff --git a/src/mupenplus/GLideN64_mupenplus.h b/src/mupenplus/GLideN64_mupenplus.h index cb1313db4..82a818534 100644 --- a/src/mupenplus/GLideN64_mupenplus.h +++ b/src/mupenplus/GLideN64_mupenplus.h @@ -56,7 +56,5 @@ extern const unsigned int* rdram_size; extern void(*renderCallback)(int); extern m64p_handle g_configVideoGeneral; -extern m64p_handle g_configVideoGliden64; -bool Config_SetDefault(); #endif // GLIDEN64_MUPENPLUS_H diff --git a/src/mupenplus/MupenPlusAPIImpl.cpp b/src/mupenplus/MupenPlusAPIImpl.cpp index a09055b21..bcc0c6e60 100644 --- a/src/mupenplus/MupenPlusAPIImpl.cpp +++ b/src/mupenplus/MupenPlusAPIImpl.cpp @@ -90,14 +90,6 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle) CoreGetVersion = (ptr_PluginGetVersion) DLSYM(_CoreLibHandle, "PluginGetVersion"); - if (Config_SetDefault()) { - config.version = ConfigGetParamInt(g_configVideoGliden64, "configVersion"); - if (config.version != CONFIG_VERSION_CURRENT) { - ConfigDeleteSection("Video-GLideN64"); - ConfigSaveFile(); - Config_SetDefault(); - } - } return M64ERR_SUCCESS; } diff --git a/src/windows/Config_windows.cpp b/src/windows/Config_windows.cpp index b5255cde0..17975c6f9 100644 --- a/src/windows/Config_windows.cpp +++ b/src/windows/Config_windows.cpp @@ -1,18 +1,43 @@ -#include "GLideN64_Windows.h" #include "../N64.h" #include "../Config.h" #include "../RSP.h" #include "../PluginAPI.h" #include "../GLideNUI/GLideNUI.h" +#include "../mupenplus/GLideN64_mupenplus.h" #include +#include +#include +#include +#include Config config; -void Config_DoConfig(/*HWND hParent*/) +void _copyCustomIni() { wchar_t strIniFolderPath[PLUGIN_PATH_SIZE]; api().FindPluginPath(strIniFolderPath); + QString file_in = QDir(QString::fromWCharArray(strIniFolderPath)).filePath("GLideN64.custom.ini"); + if (!QFile(file_in).exists()) + return; + QString file_out = QDir(QString(ConfigGetUserConfigPath())).filePath("GLideN64.custom.ini"); + if (!QFile(file_out).exists()) { + QFile::copy(file_in, file_out); + return; + } + QSettings settings_in(file_in, QSettings::IniFormat); + QSettings settings_out(file_out, QSettings::IniFormat); + if (settings_in.value("version").toInt() > settings_out.value("version").toInt()) { + QFile(file_out).remove(); + QFile::copy(file_in, file_out); + } +} + +EXPORT void CALL Config_DoConfig(/*HWND hParent*/) +{ + _copyCustomIni(); + wchar_t strIniFolderPath[PLUGIN_PATH_SIZE]; + mbstowcs(&strIniFolderPath[0], ConfigGetUserConfigPath(), PLUGIN_PATH_SIZE); ConfigOpen = true; const bool bRestart = RunConfig(strIniFolderPath, api().isRomOpen() ? RSP.romname : nullptr); @@ -26,8 +51,9 @@ void Config_DoConfig(/*HWND hParent*/) void Config_LoadConfig() { + _copyCustomIni(); wchar_t strIniFolderPath[PLUGIN_PATH_SIZE]; - api().FindPluginPath(strIniFolderPath); + mbstowcs(&strIniFolderPath[0], ConfigGetUserConfigPath(), PLUGIN_PATH_SIZE); LoadConfig(strIniFolderPath); if (config.generalEmulation.enableCustomSettings != 0) LoadCustomRomSettings(strIniFolderPath, RSP.romname);