From 6fbe4c8eccaef85593360132011319280144ffae Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Thu, 17 Sep 2020 20:49:13 +0200 Subject: [PATCH] even more work --- CMakeLists.txt | 3 + Config/stylesheet.qss | 9 + External/CMakeLists.txt | 4 +- Source/RMG/CMakeLists.txt | 14 +- Source/RMG/Config.hpp | 1 + Source/RMG/Globals.cpp | 4 + Source/RMG/Globals.hpp | 10 + Source/RMG/M64P/Api.cpp | 7 + Source/RMG/M64P/Api.hpp | 13 + Source/RMG/M64P/ConfigApi.cpp | 61 ++++ Source/RMG/M64P/ConfigApi.hpp | 59 ++++ Source/RMG/M64P/CoreApi.cpp | 42 +++ Source/RMG/M64P/CoreApi.hpp | 41 +++ Source/RMG/M64P/Macros.hpp | 29 ++ Source/RMG/M64P/PluginApi.cpp | 29 ++ Source/RMG/M64P/PluginApi.hpp | 31 ++ Source/RMG/M64P/Wrapper/Api.cpp | 78 +++++ Source/RMG/M64P/Wrapper/Api.hpp | 39 +++ Source/RMG/M64P/Wrapper/Config.cpp | 48 +++ Source/RMG/M64P/Wrapper/Config.hpp | 33 ++ Source/RMG/M64P/Wrapper/Core.cpp | 299 ++++++++++++++++++ Source/RMG/M64P/Wrapper/Core.hpp | 55 ++++ Source/RMG/M64P/Wrapper/Plugin.cpp | 121 +++++++ Source/RMG/M64P/Wrapper/Plugin.hpp | 51 +++ Source/RMG/M64P/Wrapper/Types.hpp | 40 +++ Source/RMG/{Mupen => M64P}/api/m64p_common.h | 0 Source/RMG/{Mupen => M64P}/api/m64p_config.h | 0 Source/RMG/{Mupen => M64P}/api/m64p_custom.h | 0 .../RMG/{Mupen => M64P}/api/m64p_debugger.h | 0 .../RMG/{Mupen => M64P}/api/m64p_frontend.h | 0 Source/RMG/{Mupen => M64P}/api/m64p_plugin.h | 0 Source/RMG/{Mupen => M64P}/api/m64p_types.h | 0 Source/RMG/{Mupen => M64P}/api/m64p_vidext.h | 0 Source/RMG/{Mupen => M64P}/api/version.h | 0 Source/RMG/Mupen/Mupen.cpp | 296 ----------------- Source/RMG/Mupen/Mupen.hpp | 89 ------ Source/RMG/Mupen/MupenMacros.hpp | 90 ------ Source/RMG/Mupen/VidExt.cpp | 200 ------------ Source/RMG/Mupen/VidExt.hpp | 28 -- Source/RMG/Thread/EmulationThread.cpp | 35 ++ Source/RMG/Thread/EmulationThread.hpp | 35 ++ Source/RMG/Thread/RomSearcherThread.cpp | 34 +- Source/RMG/Thread/RomSearcherThread.hpp | 50 ++- Source/RMG/UserInterface/MainWindow.cpp | 145 ++++++--- Source/RMG/UserInterface/MainWindow.hpp | 138 ++++---- Source/RMG/UserInterface/RomBrowserWidget.cpp | 96 ++++-- Source/RMG/UserInterface/RomBrowserWidget.hpp | 64 ++-- Source/RMG/Util/Logger.cpp | 17 +- Source/RMG/Util/Logger.hpp | 30 +- Source/RMG/main.cpp | 2 +- 50 files changed, 1527 insertions(+), 943 deletions(-) create mode 100644 Config/stylesheet.qss create mode 100644 Source/RMG/Globals.cpp create mode 100644 Source/RMG/Globals.hpp create mode 100644 Source/RMG/M64P/Api.cpp create mode 100644 Source/RMG/M64P/Api.hpp create mode 100644 Source/RMG/M64P/ConfigApi.cpp create mode 100644 Source/RMG/M64P/ConfigApi.hpp create mode 100644 Source/RMG/M64P/CoreApi.cpp create mode 100644 Source/RMG/M64P/CoreApi.hpp create mode 100644 Source/RMG/M64P/Macros.hpp create mode 100644 Source/RMG/M64P/PluginApi.cpp create mode 100644 Source/RMG/M64P/PluginApi.hpp create mode 100644 Source/RMG/M64P/Wrapper/Api.cpp create mode 100644 Source/RMG/M64P/Wrapper/Api.hpp create mode 100644 Source/RMG/M64P/Wrapper/Config.cpp create mode 100644 Source/RMG/M64P/Wrapper/Config.hpp create mode 100644 Source/RMG/M64P/Wrapper/Core.cpp create mode 100644 Source/RMG/M64P/Wrapper/Core.hpp create mode 100644 Source/RMG/M64P/Wrapper/Plugin.cpp create mode 100644 Source/RMG/M64P/Wrapper/Plugin.hpp create mode 100644 Source/RMG/M64P/Wrapper/Types.hpp rename Source/RMG/{Mupen => M64P}/api/m64p_common.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_config.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_custom.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_debugger.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_frontend.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_plugin.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_types.h (100%) rename Source/RMG/{Mupen => M64P}/api/m64p_vidext.h (100%) rename Source/RMG/{Mupen => M64P}/api/version.h (100%) delete mode 100644 Source/RMG/Mupen/Mupen.cpp delete mode 100644 Source/RMG/Mupen/Mupen.hpp delete mode 100644 Source/RMG/Mupen/MupenMacros.hpp delete mode 100644 Source/RMG/Mupen/VidExt.cpp delete mode 100644 Source/RMG/Mupen/VidExt.hpp create mode 100644 Source/RMG/Thread/EmulationThread.cpp create mode 100644 Source/RMG/Thread/EmulationThread.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c66b812c..238e4b59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,9 @@ install(FILES ${MUPEN64PLUSCORE_LIB} install(FILES ${MUPEN64PLUSCORE_INI} ${MUPEN64PLUSCORE_CHT} DESTINATION rmg/Data ) +install(FILES Config/stylesheet.qss + DESTINATION rmg/Config +) install(FILES ${MUPEN64PLUS_PLUGIN_AUDIO} DESTINATION rmg/Plugin/Audio ) diff --git a/Config/stylesheet.qss b/Config/stylesheet.qss new file mode 100644 index 00000000..2a091be0 --- /dev/null +++ b/Config/stylesheet.qss @@ -0,0 +1,9 @@ +/* Rosalie's Mupen GUI Stylesheet */ + +QTableView +{ + border: none; + color: #006600; + selection-color: #FFFFFF; + selection-background-color: #006600; +} diff --git a/External/CMakeLists.txt b/External/CMakeLists.txt index aad5c109..281bd69c 100644 --- a/External/CMakeLists.txt +++ b/External/CMakeLists.txt @@ -88,8 +88,8 @@ ExternalProject_Add(mupen64plus-input-raphnetraw ExternalProject_Add(mupen64plus-video-GLideN64 SOURCE_DIR mupen64plus-video-GLideN64 - GIT_REPOSITORY https://github.com/Rosalie241/GLideN64 - GIT_TAG 2021a8e674dbcd744fd7fddeb1eff9e3beb9deb8 + GIT_REPOSITORY https://github.com/gonetz/GLideN64 + GIT_TAG 229a6bc788fe4601fbe00288fcccdedb9396340f INSTALL_COMMAND "" diff --git a/Source/RMG/CMakeLists.txt b/Source/RMG/CMakeLists.txt index a8cef857..e9295626 100644 --- a/Source/RMG/CMakeLists.txt +++ b/Source/RMG/CMakeLists.txt @@ -11,9 +11,17 @@ add_executable(RMG UserInterface/MainWindow.cpp UserInterface/RomBrowserWidget.cpp Thread/RomSearcherThread.cpp - Mupen/Mupen.cpp - Mupen/VidExt.cpp + Thread/EmulationThread.cpp + M64P/CoreApi.cpp + M64P/ConfigApi.cpp + M64P/PluginApi.cpp + M64P/Api.cpp + M64P/Wrapper/Config.cpp + M64P/Wrapper/Core.cpp + M64P/Wrapper/Plugin.cpp + M64P/Wrapper/Api.cpp Util/Logger.cpp + Globals.cpp main.cpp ) @@ -24,6 +32,4 @@ endif(UNIX) target_link_libraries(RMG ${SDL2_LIBRARIES}) target_include_directories(RMG PRIVATE ${SDL2_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) -message(${CMAKE_SOURCE_DIR}) - target_link_libraries(RMG Qt5::Widgets) diff --git a/Source/RMG/Config.hpp b/Source/RMG/Config.hpp index fe6b0349..0a5ef964 100644 --- a/Source/RMG/Config.hpp +++ b/Source/RMG/Config.hpp @@ -16,6 +16,7 @@ #define APP_SETTINGS_GEOMETRY "geometry" #define APP_ROMSEARCHER_MAX 50 +#define APP_STYLESHEET_FILE "Config/stylesheet.qss" #ifdef _WIN32 #define MUPEN_CORE_FILE "Core\\mupen64plus.dll" diff --git a/Source/RMG/Globals.cpp b/Source/RMG/Globals.cpp new file mode 100644 index 00000000..774471a4 --- /dev/null +++ b/Source/RMG/Globals.cpp @@ -0,0 +1,4 @@ +#include + +Util::Logger g_Logger; +M64P::Wrapper::Api g_MupenApi; diff --git a/Source/RMG/Globals.hpp b/Source/RMG/Globals.hpp new file mode 100644 index 00000000..11ab76e4 --- /dev/null +++ b/Source/RMG/Globals.hpp @@ -0,0 +1,10 @@ +#ifndef GLOBALS_HPP +#define GLOBALS_HPP + +#include "Util/Logger.hpp" +#include "M64P/Wrapper/Api.hpp" + +extern Util::Logger g_Logger; +extern M64P::Wrapper::Api g_MupenApi; + +#endif // GLOBALS_HPP diff --git a/Source/RMG/M64P/Api.cpp b/Source/RMG/M64P/Api.cpp new file mode 100644 index 00000000..e51badb3 --- /dev/null +++ b/Source/RMG/M64P/Api.cpp @@ -0,0 +1,7 @@ +#include + +namespace M64P +{ + M64P::CoreApi Core; + M64P::ConfigApi Config; +} diff --git a/Source/RMG/M64P/Api.hpp b/Source/RMG/M64P/Api.hpp new file mode 100644 index 00000000..7b67eb7d --- /dev/null +++ b/Source/RMG/M64P/Api.hpp @@ -0,0 +1,13 @@ +#ifndef M64P_API_HPP +#define M64P_API_HPP + +#include "CoreApi.hpp" +#include "ConfigApi.hpp" + +namespace M64P +{ + extern M64P::CoreApi Core; + extern M64P::ConfigApi Config; +} // namespace M64P + +#endif // M64P_API_HPP diff --git a/Source/RMG/M64P/ConfigApi.cpp b/Source/RMG/M64P/ConfigApi.cpp new file mode 100644 index 00000000..dceaff96 --- /dev/null +++ b/Source/RMG/M64P/ConfigApi.cpp @@ -0,0 +1,61 @@ +#include "ConfigApi.hpp" +#include "Macros.hpp" + +using namespace M64P; + +ConfigApi::ConfigApi(void) +{ +} + +ConfigApi::~ConfigApi(void) +{ +} + +bool ConfigApi::Hook(m64p_dynlib_handle handle) +{ + this->error_Message = "ConfigApi::Hook Failed: "; + + HOOK_FUNC(handle, Config, ListSections); + HOOK_FUNC(handle, Config, OpenSection); + HOOK_FUNC(handle, Config, ListParameters); + HOOK_FUNC(handle, Config, SaveFile); + HOOK_FUNC(handle, Config, SaveSection); + HOOK_FUNC(handle, Config, HasUnsavedChanges); + HOOK_FUNC(handle, Config, DeleteSection); + HOOK_FUNC(handle, Config, RevertChanges); + HOOK_FUNC(handle, Config, SetParameter); + HOOK_FUNC(handle, Config, SetParameterHelp); + HOOK_FUNC(handle, Config, GetParameter); + HOOK_FUNC(handle, Config, GetParameterType); + HOOK_FUNC(handle, Config, GetParameterHelp); + HOOK_FUNC(handle, Config, SetDefaultInt); + HOOK_FUNC(handle, Config, SetDefaultFloat); + HOOK_FUNC(handle, Config, SetDefaultBool); + HOOK_FUNC(handle, Config, SetDefaultString); + HOOK_FUNC(handle, Config, GetParamInt); + HOOK_FUNC(handle, Config, GetParamFloat); + HOOK_FUNC(handle, Config, GetParamBool); + HOOK_FUNC(handle, Config, GetParamString); + HOOK_FUNC(handle, Config, GetSharedDataFilepath); + HOOK_FUNC(handle, Config, GetUserConfigPath); + HOOK_FUNC(handle, Config, GetUserDataPath); + HOOK_FUNC(handle, Config, GetUserCachePath); + HOOK_FUNC(handle, Config, ExternalOpen); + HOOK_FUNC(handle, Config, ExternalClose); + HOOK_FUNC(handle, Config, ExternalGetParameter); + HOOK_FUNC(handle, Config, SendNetplayConfig); + HOOK_FUNC(handle, Config, ReceiveNetplayConfig); + + this->hooked = true; + return true; +} + +bool ConfigApi::IsHooked(void) +{ + return this->hooked; +} + +QString ConfigApi::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/M64P/ConfigApi.hpp b/Source/RMG/M64P/ConfigApi.hpp new file mode 100644 index 00000000..7b650d4c --- /dev/null +++ b/Source/RMG/M64P/ConfigApi.hpp @@ -0,0 +1,59 @@ +#ifndef M64P_CONFIGAPI_HPP +#define M64P_CONFIGAPI_HPP + +#include "api/m64p_config.h" + +#include + +namespace M64P +{ + class ConfigApi + { + public: + ConfigApi(void); + ~ConfigApi(void); + + bool Hook(m64p_dynlib_handle handle); + bool IsHooked(void); + + QString GetLastError(void); + + ptr_ConfigListSections ListSections; + ptr_ConfigOpenSection OpenSection; + ptr_ConfigListParameters ListParameters; + ptr_ConfigSaveFile SaveFile; + ptr_ConfigSaveSection SaveSection; + ptr_ConfigHasUnsavedChanges HasUnsavedChanges; + ptr_ConfigDeleteSection DeleteSection; + ptr_ConfigRevertChanges RevertChanges; + ptr_ConfigSetParameter SetParameter; + ptr_ConfigSetParameterHelp SetParameterHelp; + ptr_ConfigGetParameter GetParameter; + ptr_ConfigGetParameterType GetParameterType; + ptr_ConfigGetParameterHelp GetParameterHelp; + ptr_ConfigSetDefaultInt SetDefaultInt; + ptr_ConfigSetDefaultFloat SetDefaultFloat; + ptr_ConfigSetDefaultBool SetDefaultBool; + ptr_ConfigSetDefaultString SetDefaultString; + ptr_ConfigGetParamInt GetParamInt; + ptr_ConfigGetParamFloat GetParamFloat; + ptr_ConfigGetParamBool GetParamBool; + ptr_ConfigGetParamString GetParamString; + ptr_ConfigGetSharedDataFilepath GetSharedDataFilepath; + ptr_ConfigGetUserConfigPath GetUserConfigPath; + ptr_ConfigGetUserDataPath GetUserDataPath; + ptr_ConfigGetUserCachePath GetUserCachePath; + ptr_ConfigExternalOpen ExternalOpen; + ptr_ConfigExternalClose ExternalClose; + ptr_ConfigExternalGetParameter ExternalGetParameter; + ptr_ConfigSendNetplayConfig SendNetplayConfig; + ptr_ConfigReceiveNetplayConfig ReceiveNetplayConfig; + + private: + bool hooked = false; + + QString error_Message; + }; +} // namespace M64P + +#endif // M64P_CONFIGAPI_HPP diff --git a/Source/RMG/M64P/CoreApi.cpp b/Source/RMG/M64P/CoreApi.cpp new file mode 100644 index 00000000..0cfe09a0 --- /dev/null +++ b/Source/RMG/M64P/CoreApi.cpp @@ -0,0 +1,42 @@ +#include "CoreApi.hpp" +#include "Macros.hpp" + +using namespace M64P; + +CoreApi::CoreApi(void) +{ +} + +CoreApi::~CoreApi(void) +{ +} + +bool CoreApi::Hook(m64p_dynlib_handle handle) +{ + this->error_Message = "CoreApi::Hook Failed: "; + + HOOK_FUNC(handle, Core, Startup); + HOOK_FUNC(handle, Core, Shutdown); + HOOK_FUNC(handle, Core, AttachPlugin); + HOOK_FUNC(handle, Core, DetachPlugin); + HOOK_FUNC(handle, Core, DoCommand); + HOOK_FUNC(handle, Core, OverrideVidExt); + HOOK_FUNC(handle, Core, AddCheat); + HOOK_FUNC(handle, Core, CheatEnabled); + HOOK_FUNC(handle, Core, GetRomSettings); + HOOK_FUNC(handle, Core, GetAPIVersions); + HOOK_FUNC(handle, Core, ErrorMessage); + + this->hooked = true; + return true; +} + +bool CoreApi::IsHooked(void) +{ + return this->hooked; +} + +QString CoreApi::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/M64P/CoreApi.hpp b/Source/RMG/M64P/CoreApi.hpp new file mode 100644 index 00000000..7de13c7f --- /dev/null +++ b/Source/RMG/M64P/CoreApi.hpp @@ -0,0 +1,41 @@ +#ifndef M64P_COREAPI_HPP +#define M64P_COREAPI_HPP + +#include "api/m64p_frontend.h" +#include "api/m64p_common.h" + +#include + +namespace M64P +{ + class CoreApi + { + public: + CoreApi(); + ~CoreApi(); + + bool Hook(m64p_dynlib_handle handle); + bool IsHooked(void); + + QString GetLastError(void); + + ptr_CoreStartup Startup; + ptr_CoreShutdown Shutdown; + ptr_CoreAttachPlugin AttachPlugin; + ptr_CoreDetachPlugin DetachPlugin; + ptr_CoreDoCommand DoCommand; + ptr_CoreOverrideVidExt OverrideVidExt; + ptr_CoreAddCheat AddCheat; + ptr_CoreCheatEnabled CheatEnabled; + ptr_CoreGetRomSettings GetRomSettings; + ptr_CoreGetAPIVersions GetAPIVersions; + ptr_CoreErrorMessage ErrorMessage; + + private: + bool hooked = false; + + QString error_Message; + }; +} // namespace M64P + +#endif // M64P_COREAPI_HPP diff --git a/Source/RMG/M64P/Macros.hpp b/Source/RMG/M64P/Macros.hpp new file mode 100644 index 00000000..3b22fbb7 --- /dev/null +++ b/Source/RMG/M64P/Macros.hpp @@ -0,0 +1,29 @@ +#ifndef M64P_MACROS_HPP +#define M64P_MACROS_HPP + +#ifdef _WIN32 +#include +#define DLOPEN(lib) LoadLibrary(lib) +#define DLCLOSE(lib) FreeLibrary(lib) +#define DLSYM(lib, func) GetProcAddress(lib, func) +#define DLGETERRSTR() GetLastError() +#else +#include +#define DLOPEN(lib) dlopen(lib, RTLD_LAZY) +#define DLCLOSE(lib) dlclose(lib) +#define DLSYM(lib, func) dlsym(lib, func) +#define DLGETERRSTR() dlerror() +#endif + +#define HOOK_FUNC_OPT(handle, prevar, var) \ + this->var = (ptr_##prevar##var)DLSYM(handle, #prevar#var); + +#define HOOK_FUNC(handle, prevar, var) \ + this->var = (ptr_##prevar##var)DLSYM(handle, #prevar#var); \ + if (this->var == nullptr) \ + { \ + this->error_Message += DLGETERRSTR(); \ + return false; \ + } + +#endif // M64P_MACROS_HPP diff --git a/Source/RMG/M64P/PluginApi.cpp b/Source/RMG/M64P/PluginApi.cpp new file mode 100644 index 00000000..9416a204 --- /dev/null +++ b/Source/RMG/M64P/PluginApi.cpp @@ -0,0 +1,29 @@ +#include "PluginApi.hpp" +#include "Macros.hpp" + +using namespace M64P; + +PluginApi::PluginApi(void) +{ +} + +PluginApi::~PluginApi(void) +{ +} + +bool PluginApi::Hook(m64p_dynlib_handle handle) +{ + this->error_Message = "PluginApi::Hook Failed: "; + + HOOK_FUNC(handle, Plugin, Startup); + HOOK_FUNC(handle, Plugin, Shutdown); + HOOK_FUNC_OPT(handle, Plugin, Config); + HOOK_FUNC(handle, Plugin, GetVersion); + + return true; +} + +QString PluginApi::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/M64P/PluginApi.hpp b/Source/RMG/M64P/PluginApi.hpp new file mode 100644 index 00000000..8b09e064 --- /dev/null +++ b/Source/RMG/M64P/PluginApi.hpp @@ -0,0 +1,31 @@ +#ifndef M64P_PLUGINAPI_HPP +#define M64P_PLUGINAPI_HPP + +#include "api/m64p_common.h" +#include "api/m64p_custom.h" + +#include + +namespace M64P +{ + class PluginApi + { + public: + PluginApi(void); + ~PluginApi(void); + + bool Hook(m64p_dynlib_handle); + + QString GetLastError(void); + + ptr_PluginStartup Startup; + ptr_PluginShutdown Shutdown; + ptr_PluginConfig Config; + ptr_PluginGetVersion GetVersion; + + private: + QString error_Message; + }; +} // namespace M64P + +#endif // M64P_PLUGINAPI_HPP diff --git a/Source/RMG/M64P/Wrapper/Api.cpp b/Source/RMG/M64P/Wrapper/Api.cpp new file mode 100644 index 00000000..b6ba5855 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Api.cpp @@ -0,0 +1,78 @@ +#include "Api.hpp" +#include "../Api.hpp" +#include "../Macros.hpp" + +using namespace M64P::Wrapper; + +Api::Api(void) +{ +} + +Api::~Api(void) +{ + this->core_Handle_Close(); +} + +bool Api::Init(QString file) +{ + this->error_Message = "Api::Init Failed: "; + + if (!this->core_Handle_Open(file)) + return false; + + if (!M64P::Core.Hook(this->core_Handle)) + { + this->error_Message += M64P::Core.GetLastError(); + return false; + } + + if (!M64P::Config.Hook(this->core_Handle)) + { + this->error_Message += M64P::Config.GetLastError(); + return false; + } + + if (!this->Core.Init(this->core_Handle)) + { + this->error_Message += this->Core.GetLastError(); + return false; + } + + if (!this->Config.Init()) + { + this->error_Message += this->Config.GetLastError(); + return false; + } + + return true; +} + +QString Api::GetLastError(void) +{ + return this->error_Message; +} + +bool Api::core_Handle_Open(QString file) +{ + this->core_Handle_Close(); + + this->core_Handle = DLOPEN(file.toStdString().c_str()); + if (this->core_Handle == NULL) + { + this->error_Message += DLGETERRSTR(); + return false; + } + + this->core_Handle_Opened = true; + + return true; +} + +void Api::core_Handle_Close(void) +{ + if (!this->core_Handle_Opened) + return; + + DLCLOSE(this->core_Handle); + this->core_Handle_Opened = false; +} diff --git a/Source/RMG/M64P/Wrapper/Api.hpp b/Source/RMG/M64P/Wrapper/Api.hpp new file mode 100644 index 00000000..9585a1e8 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Api.hpp @@ -0,0 +1,39 @@ +#ifndef M64P_WRAPPER_API +#define M64P_WRAPPER_API + +#include "Core.hpp" +#include "Config.hpp" +#include "Plugin.hpp" +#include "Types.hpp" + +#include + +namespace M64P +{ + namespace Wrapper + { + class Api + { + public: + Api(void); + ~Api(void); + + M64P::Wrapper::Core Core; + M64P::Wrapper::Config Config; + + bool Init(QString); + + QString GetLastError(void); + + private: + QString error_Message; + + m64p_dynlib_handle core_Handle; + bool core_Handle_Opened; + bool core_Handle_Open(QString); + void core_Handle_Close(void); + }; + } // namespace Wrapper +} // namespace M64P + +#endif // M64P_WRAPPER_API diff --git a/Source/RMG/M64P/Wrapper/Config.cpp b/Source/RMG/M64P/Wrapper/Config.cpp new file mode 100644 index 00000000..34de1dd3 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Config.cpp @@ -0,0 +1,48 @@ +#include +#include + +using namespace M64P::Wrapper; + +Config::Config(void) +{ +} + +Config::~Config(void) +{ +} + +bool Config::Init() +{ + if (!M64P::Config.IsHooked()) + { + this->error_Message = "M64P::Config is not hooked!"; + return false; + } + + return true; +} + +bool Config::SetOption(QString section, QString key, int value) +{ + +} + +bool Config::SetOption(QString section, QString key, float value) +{ + +} + +bool Config::SetOption(QString section, QString key, bool value) +{ + +} + +bool Config::SetOption(QString section, QString key, QString value) +{ + +} + +QString Config::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/M64P/Wrapper/Config.hpp b/Source/RMG/M64P/Wrapper/Config.hpp new file mode 100644 index 00000000..31f5cb84 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Config.hpp @@ -0,0 +1,33 @@ +#ifndef M64P_WRAPPER_CONFIG_HPP +#define M64P_WRAPPER_CONFIG_HPP + +#include + +#include + +namespace M64P +{ + namespace Wrapper + { + class Config + { + public: + Config(void); + ~Config(void); + + bool Init(); + + bool SetOption(QString section, QString key, int value); + bool SetOption(QString section, QString key, float value); + bool SetOption(QString section, QString key, bool value); + bool SetOption(QString section, QString key, QString value); + + QString GetLastError(void); + + private: + QString error_Message; + }; + } // namespace Wrapper +} // namespace M64P + +#endif // M64P_WRAPPER_CONFIG_HPP diff --git a/Source/RMG/M64P/Wrapper/Core.cpp b/Source/RMG/M64P/Wrapper/Core.cpp new file mode 100644 index 00000000..324678ac --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Core.cpp @@ -0,0 +1,299 @@ +#include "Core.hpp" +#include "Plugin.hpp" +#include "../Api.hpp" +#include "../api/version.h" +#include "../../Config.hpp" + +using namespace M64P::Wrapper; + +Core::Core(void) +{ +} + +Core::~Core(void) +{ +} +#include +void DebugCallback(void *Context, int level, const char *message) +{ + std::cout << level << ": " << message << std::endl; +} + +void StateCallback(void *Context2, m64p_core_param ParamChanged, int NewValue) +{ + std::cout << ParamChanged << ": " << NewValue << std::endl; +} + +bool Core::Init(m64p_dynlib_handle handle) +{ + m64p_error ret; + if (!M64P::Core.IsHooked()) + { + this->error_Message = "M64P::Core is not hooked!"; + return false; + } + + ret = M64P::Core.Startup(FRONTEND_API_VERSION, MUPEN_CONFIG_DIR, MUPEN_DATA_DIR, NULL, DebugCallback, NULL, StateCallback); + if (ret != M64ERR_SUCCESS) + { + this->error_Message = "Core::Init M64P::Core.Startup() Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + this->handle = handle; + + return true; +} + +#include + +bool Core::HasPluginConfig(PluginType type) +{ + return this->plugin_Get(type)->HasConfig(); +} + +bool Core::OpenPluginConfig(PluginType type) +{ + return this->plugin_Get(type)->OpenConfig(); +} + +M64P::Wrapper::Plugin* Core::plugin_Get(PluginType type) +{ + switch(type) + { + case PluginType::Gfx: + return &this->plugin_Gfx; + case PluginType::Rsp: + return &this->plugin_Rsp; + case PluginType::Audio: + return &this->plugin_Audio; + case PluginType::Input: + return &this->plugin_Input; + default: + return nullptr; + } +} + +#include +QList Core::GetPlugins(PluginType type) +{ + QList plugins; + QString dir; + + switch (type) + { + case PluginType::Gfx: + dir = "Plugin/GFX"; + break; + case PluginType::Rsp: + dir = "Plugin/RSP"; + break; + case PluginType::Audio: + dir = "Plugin/Audio"; + break; + case PluginType::Input: + dir = "Plugin/Input"; + break; + } + + std::cout << dir.toStdString() << std::endl; + + QDir qDir(dir); + QFileInfoList fileList = qDir.entryInfoList(QStringList() << "*.so"); + Plugin p; + Plugin_t pInfo; + + for (const QFileInfo& info : fileList) + { + std::cout << info.absoluteFilePath().toStdString() << std::endl; + if (p.Init(info.absoluteFilePath(), this->handle)) + { + pInfo = p.GetPlugin_t(); + + if (pInfo.Type != type) + continue; + + plugins.append(pInfo); + + } + else + { + std::cout << "Init failed??" << std::endl; + std::cout << p.GetLastError().toStdString() << std::endl; + } + + p.Shutdown(); + } + + + for (const Plugin_t& plugin : plugins) + { + std::cout << "Name: " << plugin.Name.toStdString() << std::endl; + std::cout << "FileName: " << plugin.FileName.toStdString() << std::endl; + std::cout << "Version: " << plugin.Version << std::endl; + this->SetPlugin(plugin); + } + + return plugins; +} + +bool Core::plugin_Attach(Plugin* p) +{ + m64p_error ret; + + ret = M64P::Core.AttachPlugin(p->GetType(), p->GetHandle()); + + if (ret != M64ERR_SUCCESS) + { + this->error_Message = "Core::plugin_Attach Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + } + + return ret == M64ERR_SUCCESS; +} + +bool Core::plugins_Attach(void) +{ + return this->plugin_Attach(&this->plugin_Gfx) && + this->plugin_Attach(&this->plugin_Audio) && + this->plugin_Attach(&this->plugin_Input) && + this->plugin_Attach(&this->plugin_Rsp); +} + +bool Core::plugins_Detach(void) +{ + M64P::Core.DetachPlugin(M64PLUGIN_GFX); + M64P::Core.DetachPlugin(M64PLUGIN_AUDIO); + M64P::Core.DetachPlugin(M64PLUGIN_INPUT); + M64P::Core.DetachPlugin(M64PLUGIN_RSP); + return true; +} + +bool Core::SetPlugin(Plugin_t plugin) +{ + bool ret; + + Plugin* p = this->plugin_Get(plugin.Type); + + ret = p->Init(plugin.FileName, this->handle); + + if (!ret) + { + std::cout << "Init failed?????" << std::endl; + std::cout << p->GetLastError().toStdString() << std::endl; + return false; + } + + return true; +} + + +bool Core::GetRomInfo(QString file, RomInfo_t* info) +{ + m64p_error ret; + + if (!this->rom_Open(file)) + return false; + + ret = M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER, sizeof(m64p_rom_header), &info->Header); + if (ret != M64ERR_SUCCESS) + { + this->rom_Close(); + this->error_Message = "Core::GetRomInfo: M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + ret = M64P::Core.DoCommand(M64CMD_ROM_GET_SETTINGS, sizeof(m64p_rom_settings), &info->Settings); + if (ret != M64ERR_SUCCESS) + { + this->rom_Close(); + this->error_Message = "Core::GetRomInfo: M64P::Core.DoCommand(M64CMD_ROM_GET_SETTINGS) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + if (!this->rom_Close()) + return false; + + return true; +} + +bool Core::LaunchEmulation(QString file) +{ + m64p_error ret; + + if (!this->rom_Open(file)) + return false; + + if (!this->plugins_Attach()) + return false; + + ret = M64P::Core.DoCommand(M64CMD_EXECUTE, 0, NULL); + + this->plugins_Detach(); + + if (ret != M64ERR_SUCCESS) + { + this->rom_Close(); + this->error_Message = "Core::LaunchEmulation M64P::Core.DoCommand(M64CMD_EXECUTE) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + if (!this->rom_Close()) + return false; + + return true; +} + +QString Core::GetLastError(void) +{ + return this->error_Message; +} + +bool Core::rom_Open(QString file) +{ + m64p_error ret; + QByteArray buffer; + QFile qFile(file); + + if (!qFile.open(QIODevice::ReadOnly)) + { + this->error_Message = "Core::rom_Open: QFile::open Failed"; + return false; + } + + buffer = qFile.readAll(); + + if (buffer.data() == NULL) + std::cout << "WARNING" << std::endl; + + ret = M64P::Core.DoCommand(M64CMD_ROM_OPEN, buffer.size(), buffer.data()); + if (ret != M64ERR_SUCCESS) + { + this->error_Message = "Core::rom_Open: M64P::Core.DoCommand(M64CMD_ROM_OPEN) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + } + + buffer.clear(); + qFile.close(); + + return ret == M64ERR_SUCCESS; +} + +bool Core::rom_Close(void) +{ + m64p_error ret; + + ret = M64P::Core.DoCommand(M64CMD_ROM_CLOSE, 0, NULL); + if (ret != M64ERR_SUCCESS) + { + this->error_Message = "Core::rom_Close: M64P::Core.DoCommand(M64CMD_ROM_CLOSE) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + } + + return ret == M64ERR_SUCCESS; +} + diff --git a/Source/RMG/M64P/Wrapper/Core.hpp b/Source/RMG/M64P/Wrapper/Core.hpp new file mode 100644 index 00000000..758b3981 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Core.hpp @@ -0,0 +1,55 @@ +#ifndef M64P_WRAPPER_CORE_HPP +#define M64P_WRAPPER_CORE_HPP + +#include "Types.hpp" +#include "Plugin.hpp" + +#include +#include + +namespace M64P +{ + namespace Wrapper + { + class Core + { + public: + Core(void); + ~Core(void); + + bool Init(m64p_dynlib_handle); + + bool HasPluginConfig(PluginType); + bool OpenPluginConfig(PluginType); + + QList GetPlugins(PluginType); + bool SetPlugin(Plugin_t); + + bool GetRomInfo(QString, RomInfo_t*); + + bool LaunchEmulation(QString); + + QString GetLastError(void); + + private: + QString error_Message; + + m64p_dynlib_handle handle; + + M64P::Wrapper::Plugin plugin_Rsp; + M64P::Wrapper::Plugin plugin_Gfx; + M64P::Wrapper::Plugin plugin_Audio; + M64P::Wrapper::Plugin plugin_Input; + + M64P::Wrapper::Plugin* plugin_Get(PluginType); + bool plugin_Attach(Plugin*); + bool plugins_Attach(void); + bool plugins_Detach(void); + + bool rom_Open(QString); + bool rom_Close(void); + }; + } // namespace Wrapper +} // namespace M64P + +#endif // M64P_WRAPPER_CORE_HPP diff --git a/Source/RMG/M64P/Wrapper/Plugin.cpp b/Source/RMG/M64P/Wrapper/Plugin.cpp new file mode 100644 index 00000000..53a6a4bf --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Plugin.cpp @@ -0,0 +1,121 @@ +#include "Plugin.hpp" +#include "Types.hpp" +#include "../Macros.hpp" +#include "../Api.hpp" + +using namespace M64P::Wrapper; + +Plugin::Plugin(void) +{ +} + +Plugin::~Plugin(void) +{ +} + +bool Plugin::Init(QString file, m64p_dynlib_handle coreHandle) +{ + m64p_error ret; + + this->fileName = file; + this->handle = DLOPEN(file.toStdString().c_str()); + + this->error_Message = "Plugin::Init Failed: "; + + if (this->handle == NULL) + { + this->error_Message += DLGETERRSTR(); + return false; + } + + if (!this->plugin.Hook(this->handle)) + { + this->error_Message += this->plugin.GetLastError(); + return false; + } + + ret = this->plugin.Startup(coreHandle, NULL, NULL); + if (ret != M64ERR_SUCCESS) + { + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + if (!this->plugin_t_Get()) + return false; + + return true; +} + +bool Plugin::Shutdown(void) +{ + return this->plugin.Shutdown() == M64ERR_SUCCESS; +} + +bool Plugin::HasConfig(void) +{ + return this->plugin.Config != NULL; +} + +bool Plugin::OpenConfig(void) +{ + return this->plugin.Config() == M64ERR_SUCCESS; +} + +m64p_dynlib_handle Plugin::GetHandle(void) +{ + return this->handle; +} + +m64p_plugin_type Plugin::GetType(void) +{ + return this->type; +} + +Plugin_t Plugin::GetPlugin_t(void) +{ + return this->plugin_t; +} + +bool Plugin::plugin_t_Get(void) +{ + const char* name; + m64p_error ret; + + ret = this->plugin.GetVersion(&this->type, &this->plugin_t.Version, &this->plugin_t.ApiVersion, &name, &this->plugin_t.Capabilities); + if (ret != M64ERR_SUCCESS) + { + this->error_Message += this->plugin.GetLastError(); + return false; + } + + this->plugin_t.FileName = this->fileName; + this->plugin_t.Name = QString::fromStdString(name); + + // TODO + switch (this->type) + { + case M64PLUGIN_GFX: + this->plugin_t.Type = PluginType::Gfx; + break; + case M64PLUGIN_AUDIO: + this->plugin_t.Type = PluginType::Audio; + break; + case M64PLUGIN_RSP: + this->plugin_t.Type = PluginType::Rsp; + break; + case M64PLUGIN_INPUT: + this->plugin_t.Type = PluginType::Input; + break; + default: + this->plugin_t.Type = PluginType::Invalid; + break; + } + + return true; +} + +QString Plugin::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/M64P/Wrapper/Plugin.hpp b/Source/RMG/M64P/Wrapper/Plugin.hpp new file mode 100644 index 00000000..ffed0a7b --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Plugin.hpp @@ -0,0 +1,51 @@ +#ifndef M64P_WRAPPER_PLUGIN_HPP +#define M64P_WRAPPER_PLUGIN_HPP + +#include "../api/m64p_types.h" +#include "../PluginApi.hpp" +#include "Types.hpp" + +#include + +namespace M64P +{ + namespace Wrapper + { + class Plugin + { + public: + Plugin(void); + ~Plugin(void); + + bool Init(QString, m64p_dynlib_handle); + bool Shutdown(void); + + + bool HasConfig(void); + bool OpenConfig(void); + + m64p_dynlib_handle GetHandle(void); + m64p_plugin_type GetType(void); + + Plugin_t GetPlugin_t(void); + + QString GetLastError(void); + + private: + QString error_Message; + + QString fileName; + + m64p_dynlib_handle handle; + m64p_plugin_type type; + + M64P::PluginApi plugin; + + + Plugin_t plugin_t; + bool plugin_t_Get(void); + }; + } // namespace Wrapper +} // namespace M64P + +#endif // M64P_WRAPPER_PLUGIN_HPP diff --git a/Source/RMG/M64P/Wrapper/Types.hpp b/Source/RMG/M64P/Wrapper/Types.hpp new file mode 100644 index 00000000..35386d07 --- /dev/null +++ b/Source/RMG/M64P/Wrapper/Types.hpp @@ -0,0 +1,40 @@ +#ifndef M64P_WRAPPER_TYPES_HPP +#define M64P_WRAPPER_TYPES_HPP + +#include "../api/m64p_types.h" + +#include + +namespace M64P +{ + namespace Wrapper + { + enum PluginType + { + Rsp, + Gfx, + Audio, + Input, + Invalid + }; + + struct RomInfo_t + { + QString FileName; + m64p_rom_settings Settings; + m64p_rom_header Header; + }; + + struct Plugin_t + { + QString Name; + QString FileName; + PluginType Type; + int Version; + int ApiVersion; + int Capabilities; + }; + } // namespace Wrapper +} // namespace M64P + +#endif // M64P_WRAPPER_TYPES_HPP diff --git a/Source/RMG/Mupen/api/m64p_common.h b/Source/RMG/M64P/api/m64p_common.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_common.h rename to Source/RMG/M64P/api/m64p_common.h diff --git a/Source/RMG/Mupen/api/m64p_config.h b/Source/RMG/M64P/api/m64p_config.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_config.h rename to Source/RMG/M64P/api/m64p_config.h diff --git a/Source/RMG/Mupen/api/m64p_custom.h b/Source/RMG/M64P/api/m64p_custom.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_custom.h rename to Source/RMG/M64P/api/m64p_custom.h diff --git a/Source/RMG/Mupen/api/m64p_debugger.h b/Source/RMG/M64P/api/m64p_debugger.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_debugger.h rename to Source/RMG/M64P/api/m64p_debugger.h diff --git a/Source/RMG/Mupen/api/m64p_frontend.h b/Source/RMG/M64P/api/m64p_frontend.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_frontend.h rename to Source/RMG/M64P/api/m64p_frontend.h diff --git a/Source/RMG/Mupen/api/m64p_plugin.h b/Source/RMG/M64P/api/m64p_plugin.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_plugin.h rename to Source/RMG/M64P/api/m64p_plugin.h diff --git a/Source/RMG/Mupen/api/m64p_types.h b/Source/RMG/M64P/api/m64p_types.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_types.h rename to Source/RMG/M64P/api/m64p_types.h diff --git a/Source/RMG/Mupen/api/m64p_vidext.h b/Source/RMG/M64P/api/m64p_vidext.h similarity index 100% rename from Source/RMG/Mupen/api/m64p_vidext.h rename to Source/RMG/M64P/api/m64p_vidext.h diff --git a/Source/RMG/Mupen/api/version.h b/Source/RMG/M64P/api/version.h similarity index 100% rename from Source/RMG/Mupen/api/version.h rename to Source/RMG/M64P/api/version.h diff --git a/Source/RMG/Mupen/Mupen.cpp b/Source/RMG/Mupen/Mupen.cpp deleted file mode 100644 index 148fef6f..00000000 --- a/Source/RMG/Mupen/Mupen.cpp +++ /dev/null @@ -1,296 +0,0 @@ -#include -#include - -#include - -Mupen g_MupenApi; - -Mupen::Mupen() -{ -} - -Mupen::~Mupen() -{ - if (this->core_Hooked) - { - this->plugin_Unhook(); - this->m64p_CoreShutdown(); - DLCLOSE(this->m64p_handle); - } -} - -bool Mupen::Init(void) -{ - if (!this->core_Hook()) - return false; - - if (!this->core_Init()) - return false; - - return true; -} - -bool Mupen::Setup(void) -{ - return this->plugin_Hook(); -} - -bool Mupen::SetupVidExt(VidExtFuncs funcs) -{ - m64p_error ret; - - m64p_VidExt.VidExt_Register(funcs); - - ret = m64p_CoreOverrideVidExt(m64p_VidExt.VidExt_GetFuncs()); - if (ret != M64ERR_SUCCESS) - { - this->error_message = "Mupen::SetupVidExt Failed: "; - this->error_message += m64p_CoreErrorMessage(ret); - return false; - } - - return true; -} - -bool Mupen::OpenRom(QString file) -{ - m64p_error ret; - - if (!this->rom_Open(file)) - return false; - - if (!this->plugin_Attach()) - return false; - - ret = m64p_CoreDoCommand(M64CMD_EXECUTE, 0, NULL); - - this->rom_Close(); - - if (ret != M64ERR_SUCCESS) - { - this->error_message = "Mupen::OpenRom Failed: "; - this->error_message += m64p_CoreErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Mupen::HasPluginConfig(PluginType type) -{ - ptr_PluginConfig pluginConfig = this->plugin_Config_Get(type); - - return pluginConfig != nullptr; -} - -bool Mupen::OpenPluginConfig(PluginType type) -{ - ptr_PluginConfig pluginConfig = this->plugin_Config_Get(type); - - if (pluginConfig == nullptr) - return false; - - return pluginConfig() == M64ERR_SUCCESS; -} - -bool Mupen::GetRomInfo(QString file, m64p_rom_header* header, m64p_rom_settings* settings) -{ - m64p_error ret; - - if (!this->rom_Open(file)) - return false; - - ret = m64p_CoreDoCommand(M64CMD_ROM_GET_HEADER, sizeof(m64p_rom_header), header); - if (ret != M64ERR_SUCCESS) - { - this->rom_Close(); - this->error_message = "Mupen::GetRomInfo: m64p_CoreDoCommand(M64CMD_ROM_GET_HEADER) Failed: "; - this->error_message += m64p_CoreErrorMessage(ret); - return false; - } - - ret = m64p_CoreDoCommand(M64CMD_ROM_GET_SETTINGS, sizeof(m64p_rom_settings), settings); - if (ret != M64ERR_SUCCESS) - { - this->rom_Close(); - this->error_message = "Mupen::GetRomInfo: m64p_CoreDoCommand(M64CMD_ROM_GET_SETTINGS) Failed: "; - this->error_message += m64p_CoreErrorMessage(ret); - return false; - } - - if (!this->rom_Close()) - return false; - - return true; -} - -QString Mupen::GetLastError(void) -{ - return this->error_message; -} - -bool Mupen::core_Hook(void) -{ - this->m64p_handle = DLOPEN(MUPEN_CORE_FILE); - - if (!this->m64p_handle) - { - this->error_message = "Mupen::core_Hook: DLOPEN Failed: " + QString::fromStdString(DLGETERRSTR()); - return false; - } - - this->core_Hooked = false; - this->error_message = "Mupen::core_Hook: DLSYM Failed: "; - - MUPEN_HOOK_FUNC(CoreStartup); - MUPEN_HOOK_FUNC(CoreShutdown); - MUPEN_HOOK_FUNC(CoreAttachPlugin); - MUPEN_HOOK_FUNC(CoreDetachPlugin); - MUPEN_HOOK_FUNC(CoreDetachPlugin); - MUPEN_HOOK_FUNC(CoreDoCommand); - MUPEN_HOOK_FUNC(CoreOverrideVidExt); - MUPEN_HOOK_FUNC(CoreAddCheat); - MUPEN_HOOK_FUNC(CoreCheatEnabled); - MUPEN_HOOK_FUNC(CoreGetRomSettings); - MUPEN_HOOK_FUNC(CoreErrorMessage); - - this->core_Hooked = true; - return true; -} - -bool Mupen::core_Init(void) -{ - m64p_error ret; - - ret = m64p_CoreStartup(FRONTEND_API_VERSION, MUPEN_CONFIG_DIR, MUPEN_DATA_DIR, NULL, NULL, NULL, NULL); - if (ret != M64ERR_SUCCESS) - { - this->error_message = "Mupen::core_Init: m64p_CoreStartup Failed: "; - this->error_message += this->m64p_CoreErrorMessage(ret); - return false; - } - - return true; -} - -bool Mupen::core_Setup(void) -{ - return true; -} - -ptr_PluginConfig Mupen::plugin_Config_Get(PluginType type) -{ - ptr_PluginConfig pluginConfig; - - switch (type) - { - case PluginType::Rsp: - pluginConfig = this->plugin_Config_Rsp; - break; - case PluginType::Gfx: - pluginConfig = this->plugin_Config_Gfx; - break; - case PluginType::Audio: - pluginConfig = this->plugin_Config_Audio; - break; - case PluginType::Input: - pluginConfig = this->plugin_Config_Input; - break; - default: - pluginConfig = nullptr; - break; - } - - return pluginConfig; -} - -bool Mupen::plugin_Hook(void) -{ - m64p_error ret; - - this->error_message = "Mupen::plugin_Hook Failed: "; - - MUPEN_PLUGIN_HOOK(MUPEN_PLUGIN_RSP, Rsp); - MUPEN_PLUGIN_HOOK(MUPEN_PLUGIN_GFX, Gfx); - MUPEN_PLUGIN_HOOK(MUPEN_PLUGIN_AUDIO, Audio); - MUPEN_PLUGIN_HOOK(MUPEN_PLUGIN_INPUT, Input); - - MUPEN_PLUGIN_CONFIG_HOOK(Rsp); - MUPEN_PLUGIN_CONFIG_HOOK(Gfx); - MUPEN_PLUGIN_CONFIG_HOOK(Audio); - MUPEN_PLUGIN_CONFIG_HOOK(Input); - - return true; -} - -bool Mupen::plugin_Unhook(void) -{ - m64p_error ret; - this->error_message = "Mupen::plugin_Unhook Failed: "; - - MUPEN_PLUGIN_UNHOOK(MUPEN_PLUGIN_RSP, Rsp); - MUPEN_PLUGIN_UNHOOK(MUPEN_PLUGIN_GFX, Gfx); - MUPEN_PLUGIN_UNHOOK(MUPEN_PLUGIN_AUDIO, Audio); - MUPEN_PLUGIN_UNHOOK(MUPEN_PLUGIN_INPUT, Input); - - return true; -} - -bool Mupen::plugin_Attach(void) -{ - m64p_error ret; - - this->error_message = "Mupen::plugin_Attach Failed: "; - - MUPEN_PLUGIN_ATTACH(M64PLUGIN_GFX, Gfx); - MUPEN_PLUGIN_ATTACH(M64PLUGIN_AUDIO, Audio); - MUPEN_PLUGIN_ATTACH(M64PLUGIN_INPUT, Input); - MUPEN_PLUGIN_ATTACH(M64PLUGIN_RSP, Rsp); - - return true; -} - -bool Mupen::plugin_Detach(void) -{ - -} - -bool Mupen::rom_Open(QString file) -{ - m64p_error ret; - QByteArray buffer; - QFile qFile(file); - - if (!qFile.open(QIODevice::ReadOnly)) - { - this->error_message = "Mupen::rom_Open: QFile::open Failed"; - return false; - } - - buffer = qFile.readAll(); - - ret = m64p_CoreDoCommand(M64CMD_ROM_OPEN, buffer.size(), buffer.data()); - if (ret != M64ERR_SUCCESS) - { - this->error_message = "Mupen::rom_Open: m64p_CoreDoCommand(M64CMD_ROM_OPEN) Failed: "; - this->error_message += this->m64p_CoreErrorMessage(ret); - } - - buffer.clear(); - qFile.close(); - - return ret == M64ERR_SUCCESS; -} - -bool Mupen::rom_Close(void) -{ - m64p_error ret; - - ret = m64p_CoreDoCommand(M64CMD_ROM_CLOSE, 0, NULL); - if (ret != M64ERR_SUCCESS) - { - this->error_message = "Mupen::rom_Close: m64p_CoreDoCommand(M64CMD_ROM_CLOSE) Failed: "; - this->error_message += this->m64p_CoreErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} diff --git a/Source/RMG/Mupen/Mupen.hpp b/Source/RMG/Mupen/Mupen.hpp deleted file mode 100644 index bfc4b282..00000000 --- a/Source/RMG/Mupen/Mupen.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef MUPEN_HPP -#define MUPEN_HPP - -#include -#include -#include -#include -#include - -#include - -#include - -enum PluginType -{ - Rsp, - Gfx, - Audio, - Input -}; - -class Mupen -{ -public: - Mupen(); - ~Mupen(); - bool Init(); - bool Setup(); - bool SetupVidExt(VidExtFuncs funcs); - - bool OpenRom(QString); - - bool HasPluginConfig(PluginType); - bool OpenPluginConfig(PluginType); - - bool GetRomInfo(QString, m64p_rom_header*, m64p_rom_settings*); - - QString GetLastError(); - -private: - QString error_message; - - m64p_dynlib_handle m64p_handle; - - ptr_CoreStartup m64p_CoreStartup; - ptr_CoreShutdown m64p_CoreShutdown; - ptr_CoreAttachPlugin m64p_CoreAttachPlugin; - ptr_CoreDetachPlugin m64p_CoreDetachPlugin; - ptr_CoreDoCommand m64p_CoreDoCommand; - ptr_CoreOverrideVidExt m64p_CoreOverrideVidExt; - ptr_CoreAddCheat m64p_CoreAddCheat; - ptr_CoreCheatEnabled m64p_CoreCheatEnabled; - ptr_CoreGetRomSettings m64p_CoreGetRomSettings; - ptr_CoreErrorMessage m64p_CoreErrorMessage; - - bool core_Hooked; - bool core_Hook(void); - bool core_Init(void); - bool core_Setup(void); - - m64p_dynlib_handle plugin_Rsp; - m64p_dynlib_handle plugin_Gfx; - m64p_dynlib_handle plugin_Audio; - m64p_dynlib_handle plugin_Input; - - ptr_PluginConfig plugin_Config_Rsp; - ptr_PluginConfig plugin_Config_Gfx; - ptr_PluginConfig plugin_Config_Audio; - ptr_PluginConfig plugin_Config_Input; - ptr_PluginConfig plugin_Config_Get(PluginType); - - ptr_PluginStartup plugin_PluginStartup; - ptr_PluginShutdown plugin_PluginShutdown; - - bool plugin_Hook(void); - bool plugin_Unhook(void); - bool plugin_Attach(void); - bool plugin_Detach(void); - - - bool rom_Open(QString); - bool rom_Close(void); - - VidExt m64p_VidExt; -}; - -extern Mupen g_MupenApi; - -#endif // MUPEN_HPP diff --git a/Source/RMG/Mupen/MupenMacros.hpp b/Source/RMG/Mupen/MupenMacros.hpp deleted file mode 100644 index b660dfdc..00000000 --- a/Source/RMG/Mupen/MupenMacros.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef MUPENMACROS_HPP -#define MUPENMACROS_HPP - -#ifdef _WIN32 -#include -#define DLOPEN(lib) LoadLibrary(lib) -#define DLCLOSE(lib) FreeLibrary(lib) -#define DLSYM(lib, func) GetProcAddress(lib, func) -#define DLGETERRSTR() GetLastError() -#else -#include -#define DLOPEN(lib) dlopen(lib, RTLD_LAZY) -#define DLCLOSE(lib) dlclose(lib) -#define DLSYM(lib, func) dlsym(lib, func) -#define DLGETERRSTR() dlerror() -#endif - -// -// This macro binds m64p_func from m64p_handle (using DLSYM) -// if it fails, appends DLGETERRSTR() to error_message and return false -// -#define MUPEN_HOOK_FUNC(func) \ - this->m64p_##func = (ptr_##func)DLSYM(this->m64p_handle, #func); \ - if (this->m64p_##func == NULL) \ - { \ - this->error_message += DLGETERRSTR(); \ - return false; \ - } - -// -// This macro binds plugin_name from file (using DLOPEN), -// it also binds "PluginStartup" to plugin_PluginStartup (using DLSYM) and -// executes that function (with m64p_handle), -// if it fails, appends DLGETERRSTR() to error_message and return false -// -#define MUPEN_PLUGIN_HOOK(file, name) \ - this->plugin_##name = DLOPEN(file); \ - if (this->plugin_##name == NULL) \ - { \ - this->error_message += DLGETERRSTR(); \ - return false; \ - }; \ - this->plugin_PluginStartup = (ptr_PluginStartup)DLSYM(this->plugin_##name, "PluginStartup"); \ - if (this->plugin_PluginStartup == NULL) \ - { \ - this->error_message += DLGETERRSTR(); \ - return false; \ - } \ - ret = this->plugin_PluginStartup(this->m64p_handle, NULL, NULL); \ - if (ret != M64ERR_SUCCESS) \ - { \ - this->error_message += this->m64p_CoreErrorMessage(ret); \ - return false; \ - } - -#define MUPEN_PLUGIN_UNHOOK(file, name) \ - this->plugin_PluginShutdown = (ptr_PluginShutdown)DLSYM(this->plugin_##name, "PluginShutdown"); \ - if (this->plugin_PluginShutdown == NULL) \ - { \ - this->error_message += DLGETERRSTR(); \ - return false; \ - } \ - ret = this->plugin_PluginShutdown(); \ - if (ret != M64ERR_SUCCESS) \ - { \ - this->error_message += this->m64p_CoreErrorMessage(ret); \ - return false; \ - } \ - DLCLOSE(this->plugin_##name); \ - - -// -// This macro binds "PluginConfig" to plugin_Config_name (using DLSYM) -// -#define MUPEN_PLUGIN_CONFIG_HOOK(name) \ - this->plugin_Config_##name = (ptr_PluginConfig)DLSYM(this->plugin_##name, "PluginConfig"); - -// -// This macro attachs plugin_name with type to mupen using m64p_CoreAttachPlugin, -// if it fails, appends m64p_CoreErrorMessage(ret) to error_message and return false -// -#define MUPEN_PLUGIN_ATTACH(type, name) \ - ret = this->m64p_CoreAttachPlugin(type, this->plugin_##name); \ - if (ret != M64ERR_SUCCESS) \ - { \ - this->error_message += this->m64p_CoreErrorMessage(ret); \ - return false; \ - } - -#endif // MUPENMACROS_HPP \ No newline at end of file diff --git a/Source/RMG/Mupen/VidExt.cpp b/Source/RMG/Mupen/VidExt.cpp deleted file mode 100644 index 7f423468..00000000 --- a/Source/RMG/Mupen/VidExt.cpp +++ /dev/null @@ -1,200 +0,0 @@ -#include - -#include -#include - -static VidExtFuncs func; - - - -m64p_error VidExtFuncInit(void) -{ - std::cout << "VidExtFuncInit" << std::endl; - // func.VidExtFuncInit(); -} - -m64p_error VidExtFuncQuit(void) -{ - std::cout << "VidExtFuncQuit" << std::endl; - // func.VidExtFuncQuit(); -} - -m64p_error VidExtFuncListModes(m64p_2d_size *SizeArray, int *NumSizes) -{ - SDL_Init(SDL_INIT_VIDEO); - - - std::cout << "VidExtFuncListModes" << std::endl; - - int display = 0; //GetVideoDisplay(); - int modeCount = SDL_GetNumDisplayModes(display); - SDL_DisplayMode displayMode; - - if (modeCount < 1) - { - std::cout << SDL_GetError() << std::endl; - std::cout << "aa" << modeCount << std::endl; - // DebugMessage(M64MSG_ERROR, "SDL_GetNumDisplayModes failed: %s", SDL_GetError()); - return M64ERR_SYSTEM_FAIL; - } - - int displayModeCount = 0; - int duplicateFound = 0; - for (int i = 0; (i < modeCount) && (displayModeCount < *NumSizes); i++) - { - if (SDL_GetDisplayMode(display, i, &displayMode) < 0) - { - std::cout << SDL_GetError() << std::endl; - // DebugMessage(M64MSG_ERROR, "SDL_GetDisplayMode failed: %s", SDL_GetError()); - return M64ERR_SYSTEM_FAIL; - } - - // Check for duplicates - duplicateFound = 0; - for (int x = 0; x <= displayModeCount; x++) - { - if (SizeArray[x].uiHeight == displayMode.h && - SizeArray[x].uiWidth == displayMode.w) - { - duplicateFound = 1; - break; - } - } - - // Skip duplicate - if (duplicateFound == 1) - continue; - - SizeArray[displayModeCount].uiHeight = displayMode.h; - SizeArray[displayModeCount].uiWidth = displayMode.w; - displayModeCount++; - } - - std::cout << displayModeCount << std::endl; - *NumSizes = displayModeCount; - - return M64ERR_SUCCESS; -} - -m64p_error VidExtFuncListRates(m64p_2d_size Size, int *NumRates, int *Rates) -{ - std::cout << "VidExtFuncListRates" << std::endl; - - if (!SDL_WasInit(SDL_INIT_VIDEO)) - return M64ERR_NOT_INIT; - - int display = 0; //GetVideoDisplay(); - int modeCount = SDL_GetNumDisplayModes(display); - SDL_DisplayMode displayMode; - - if (modeCount < 1) - { - // DebugMessage(M64MSG_ERROR, "SDL_GetNumDisplayModes failed: %s", SDL_GetError()); - return M64ERR_SYSTEM_FAIL; - } - - int rateCount = 0; - for (int i = 0; (i < modeCount) && (rateCount < *NumRates); i++) - { - if (SDL_GetDisplayMode(display, i, &displayMode) < 0) - { - // DebugMessage(M64MSG_ERROR, "SDL_GetDisplayMode failed: %s", SDL_GetError()); - return M64ERR_SYSTEM_FAIL; - } - - /* skip when we're not at the right resolution */ - if (displayMode.w != Size.uiWidth || - displayMode.h != Size.uiHeight) - continue; - - Rates[rateCount] = displayMode.refresh_rate; - rateCount++; - } - - *NumRates = rateCount; - - return M64ERR_SUCCESS; -} - -m64p_error VidExtFuncSetMode(int, int, int, int, int) -{ - std::cout << "VidExtFuncSetMode" << std::endl; -} - -m64p_error VidExtFuncSetModeWithRate(int, int, int, int, int, int) -{ - std::cout << "VidExtFuncSetModeWithRate" << std::endl; -} - -m64p_function VidExtFuncGLGetProc(const char *) -{ - std::cout << "VidExtFuncGLGetProc" << std::endl; -} - -m64p_error VidExtFuncGLSetAttr(m64p_GLattr, int) -{ - std::cout << "VidExtFuncGLSetAttr" << std::endl; -} - -m64p_error VidExtFuncGLGetAttr(m64p_GLattr, int *) -{ - std::cout << "VidExtFuncGLGetAttr" << std::endl; -} - -m64p_error VidExtFuncGLSwapBuf(void) -{ - std::cout << "VidExtFuncGLSwapBuf" << std::endl; -} - -m64p_error VidExtFuncSetCaption(const char *) -{ - std::cout << "VidExtFuncSetCaption" << std::endl; -} - -m64p_error VidExtFuncToggleFS(void) -{ - std::cout << "VidExtFuncToggleFS" << std::endl; -} - -m64p_error VidExtFuncResizeWindow(int, int) -{ - std::cout << "VidExtFuncResizeWindow" << std::endl; -} - -uint32_t VidExtFuncGLGetDefaultFramebuffer(void) -{ - std::cout << "VidExtFuncGLGetDefaultFramebuffer" << std::endl; -} - -VidExt::VidExt(void) -{ - this->m64p_vidext_funcs.Functions = 14; - this->m64p_vidext_funcs.VidExtFuncInit = &VidExtFuncInit; - this->m64p_vidext_funcs.VidExtFuncQuit = &VidExtFuncQuit; - this->m64p_vidext_funcs.VidExtFuncListModes = &VidExtFuncListModes; - this->m64p_vidext_funcs.VidExtFuncListRates = &VidExtFuncListRates; - this->m64p_vidext_funcs.VidExtFuncSetMode = &VidExtFuncSetMode; - this->m64p_vidext_funcs.VidExtFuncSetModeWithRate = &VidExtFuncSetModeWithRate; - this->m64p_vidext_funcs.VidExtFuncGLGetProc = &VidExtFuncGLGetProc; - this->m64p_vidext_funcs.VidExtFuncGLSetAttr = &VidExtFuncGLSetAttr; - this->m64p_vidext_funcs.VidExtFuncGLGetAttr = &VidExtFuncGLGetAttr; - this->m64p_vidext_funcs.VidExtFuncGLSwapBuf = &VidExtFuncGLSwapBuf; - this->m64p_vidext_funcs.VidExtFuncSetCaption = &VidExtFuncSetCaption; - this->m64p_vidext_funcs.VidExtFuncToggleFS = &VidExtFuncToggleFS; - this->m64p_vidext_funcs.VidExtFuncResizeWindow = &VidExtFuncResizeWindow; - this->m64p_vidext_funcs.VidExtFuncGLGetDefaultFramebuffer = &VidExtFuncGLGetDefaultFramebuffer; -} - -VidExt::~VidExt(void) -{ -} - -m64p_video_extension_functions *VidExt::VidExt_GetFuncs() -{ - return &this->m64p_vidext_funcs; -} - -void VidExt::VidExt_Register(VidExtFuncs funcs) -{ - func = funcs; -} diff --git a/Source/RMG/Mupen/VidExt.hpp b/Source/RMG/Mupen/VidExt.hpp deleted file mode 100644 index ffcfe501..00000000 --- a/Source/RMG/Mupen/VidExt.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef VIDEXT_HPP -#define VIDEXT_HPP - -#include "api/m64p_types.h" -#include - -struct VidExtFuncs -{ - std::function VidExtFuncInit; - std::function VidExtFuncQuit; -}; - -class VidExt -{ -public: - VidExt(); - ~VidExt(); - - void VidExt_Register(VidExtFuncs funcs); - m64p_video_extension_functions* VidExt_GetFuncs(); - -private: - VidExtFuncs funcs; - m64p_video_extension_functions m64p_vidext_funcs; - -}; - -#endif // VIDEXT_HPP \ No newline at end of file diff --git a/Source/RMG/Thread/EmulationThread.cpp b/Source/RMG/Thread/EmulationThread.cpp new file mode 100644 index 00000000..9ab6bf68 --- /dev/null +++ b/Source/RMG/Thread/EmulationThread.cpp @@ -0,0 +1,35 @@ +#include "EmulationThread.hpp" + +using namespace Thread; + +EmulationThread::EmulationThread(void) +{ +} + +EmulationThread::~EmulationThread(void) +{ +} + +void EmulationThread::SetRomFile(QString file) +{ + this->rom_File = file; +} + +void EmulationThread::run(void) +{ + emit this->on_Emulation_Started(); + + bool ret; + + ret = g_MupenApi.Core.LaunchEmulation(this->rom_File); + + if (!ret) + this->error_Message = g_MupenApi.Core.GetLastError(); + + emit this->on_Emulation_Finished(ret); +} + +QString EmulationThread::GetLastError(void) +{ + return this->error_Message; +} diff --git a/Source/RMG/Thread/EmulationThread.hpp b/Source/RMG/Thread/EmulationThread.hpp new file mode 100644 index 00000000..cd6ee049 --- /dev/null +++ b/Source/RMG/Thread/EmulationThread.hpp @@ -0,0 +1,35 @@ +#ifndef EMULATIONTHREAD_HPP +#define EMULATIONTHREAD_HPP + +#include "../Globals.hpp" + +#include +#include + +namespace Thread +{ + class EmulationThread : public QThread + { + Q_OBJECT + + public: + EmulationThread(void); + ~EmulationThread(void); + + void SetRomFile(QString); + + void run(void) override; + + QString GetLastError(void); + + private: + QString rom_File; + QString error_Message; + + signals: + void on_Emulation_Started(void); + void on_Emulation_Finished(bool); + }; +} // namespace Thread + +#endif // EMULATIONTHREAD_HPP diff --git a/Source/RMG/Thread/RomSearcherThread.cpp b/Source/RMG/Thread/RomSearcherThread.cpp index 5f0d01e2..7c0678a8 100644 --- a/Source/RMG/Thread/RomSearcherThread.cpp +++ b/Source/RMG/Thread/RomSearcherThread.cpp @@ -1,12 +1,17 @@ -#include -#include -#include +#include "RomSearcherThread.hpp" +#include "../Globals.hpp" #include +using namespace Thread; + RomSearcherThread::RomSearcherThread(void) { - qRegisterMetaType("m64p_rom_info"); + qRegisterMetaType("M64P::Wrapper::RomInfo_t"); +} + +RomSearcherThread::~RomSearcherThread(void) +{ } void RomSearcherThread::SetDirectory(QString directory) @@ -24,7 +29,7 @@ void RomSearcherThread::SetMaximumFiles(int value) this->rom_Search_MaxItems = value; } -void RomSearcherThread::run() +void RomSearcherThread::run(void) { this->rom_Search_Count = 0; this->rom_Search(this->rom_Directory); @@ -42,7 +47,7 @@ void RomSearcherThread::rom_Search(QString directory) QFileInfoList fileList = dir.entryInfoList(filter, QDir::Files); QFileInfo fileInfo; - m64p_rom_info romInfo; + M64P::Wrapper::RomInfo_t romInfo; bool ret; for (int i = 0; i < fileList.size(); i++) @@ -72,20 +77,7 @@ void RomSearcherThread::rom_Search(QString directory) } } -bool RomSearcherThread::rom_Get_Info(QString file, m64p_rom_info *info) +bool RomSearcherThread::rom_Get_Info(QString file, M64P::Wrapper::RomInfo_t* info) { - m64p_rom_header header; - m64p_rom_settings settings; - - if (!g_MupenApi.GetRomInfo(file, &header, &settings)) - { - g_Logger.AddText("RomSearcherThread::rom_Get_Info: " + g_MupenApi.GetLastError()); - return false; - } - - info->file = file; - info->m64p_header = header; - info->m64p_settings = settings; - - return true; + return g_MupenApi.Core.GetRomInfo(file, info); } diff --git a/Source/RMG/Thread/RomSearcherThread.hpp b/Source/RMG/Thread/RomSearcherThread.hpp index e993b62a..a484e35b 100644 --- a/Source/RMG/Thread/RomSearcherThread.hpp +++ b/Source/RMG/Thread/RomSearcherThread.hpp @@ -1,43 +1,39 @@ #ifndef ROMSEARCHERTHREAD_HPP #define ROMSEARCHERTHREAD_HPP -#include +#include "../Globals.hpp" #include #include -struct m64p_rom_info +namespace Thread { - QString file; - m64p_rom_settings m64p_settings; - m64p_rom_header m64p_header; -}; + class RomSearcherThread : public QThread + { + Q_OBJECT -class RomSearcherThread : public QThread -{ - Q_OBJECT + public: + RomSearcherThread(void); + ~RomSearcherThread(void); -public: - RomSearcherThread(void); + void SetDirectory(QString); + void SetRecursive(bool); + void SetMaximumFiles(int); - void SetDirectory(QString); - void SetRecursive(bool); - void SetMaximumFiles(int); + void run(void) override; - void run() override; + private: + QString rom_Directory; + bool rom_Search_Recursive; + int rom_Search_MaxItems; + int rom_Search_Count; -private: - QString rom_Directory; - bool rom_Search_Recursive; - int rom_Search_MaxItems; - int rom_Search_Count; - - void rom_Search(QString); - bool rom_Get_Info(QString, m64p_rom_info*); - -signals: - void on_Rom_Found(m64p_rom_info); -}; + void rom_Search(QString); + bool rom_Get_Info(QString, M64P::Wrapper::RomInfo_t*); + signals: + void on_Rom_Found(M64P::Wrapper::RomInfo_t); + }; +} // namespace Thread #endif // ROMSEARCHERTHREAD_HPP diff --git a/Source/RMG/UserInterface/MainWindow.cpp b/Source/RMG/UserInterface/MainWindow.cpp index 941ed50e..c4823300 100644 --- a/Source/RMG/UserInterface/MainWindow.cpp +++ b/Source/RMG/UserInterface/MainWindow.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include "MainWindow.hpp" +#include "../Util/Logger.hpp" +#include "../Config.hpp" #include #include @@ -11,6 +11,8 @@ #include #include +using namespace UserInterface; + MainWindow::MainWindow() : QMainWindow(nullptr) { } @@ -18,13 +20,17 @@ MainWindow::MainWindow() : QMainWindow(nullptr) MainWindow::~MainWindow() { // Delete all UI elements - delete this->menuBar; - delete this->ui_Widget_OpenGL; - delete this->ui_Widget_RomBrowser; - delete this->ui_Settings; + /*if (this->menuBar) + delete this->menuBar; + + if (this->ui_Widgets) + delete this->ui_Widgets; + + if (this->ui_Settings) + delete this->ui_Settings; */ } -bool MainWindow::Init() +bool MainWindow::Init(void) { if (!g_Logger.Init()) { @@ -32,17 +38,16 @@ bool MainWindow::Init() return false; } - if (!g_MupenApi.Init()) + if (!g_MupenApi.Init(MUPEN_CORE_FILE)) { - this->ui_MessageBox("Error", "Mupen::Init Failed", g_MupenApi.GetLastError()); + this->ui_MessageBox("Error", "M64P::Wrapper::Api::Init Failed", g_MupenApi.GetLastError()); return false; } - if (!g_MupenApi.Setup()) - { - this->ui_MessageBox("Error", "Mupen::Setup Failed", g_MupenApi.GetLastError()); - return false; - } + g_MupenApi.Core.GetPlugins(M64P::Wrapper::PluginType::Gfx); + g_MupenApi.Core.GetPlugins(M64P::Wrapper::PluginType::Rsp); + g_MupenApi.Core.GetPlugins(M64P::Wrapper::PluginType::Audio); + g_MupenApi.Core.GetPlugins(M64P::Wrapper::PluginType::Input); this->ui_Init(); this->ui_Setup(); @@ -50,6 +55,9 @@ bool MainWindow::Init() this->menuBar_Init(); this->menuBar_Setup(false); + this->emulationThread_Init(); + this->emulationThread_Connect(); + return true; } @@ -70,6 +78,8 @@ void MainWindow::ui_Init(void) void MainWindow::ui_Setup(void) { + this->ui_Stylesheet_Setup(); + this->setWindowTitle(WINDOW_TITLE); this->setCentralWidget(this->ui_Widgets); this->restoreGeometry(this->ui_Settings->value(APP_SETTINGS_GEOMETRY).toByteArray()); @@ -82,28 +92,56 @@ void MainWindow::ui_Setup(void) this->ui_Widgets->setCurrentIndex(1); } +void MainWindow::ui_Stylesheet_Setup(void) +{ + QFile stylesheet(APP_STYLESHEET_FILE); + + if (!stylesheet.open(QIODevice::ReadOnly)) + return; + + this->setStyleSheet(stylesheet.readAll()); +} + void MainWindow::ui_MessageBox(QString title, QString text, QString details = "") { - g_Logger.AddText("MainWindow::ui_MessageBox: " + title + ", " + text + ", " + details + "\n"); + g_Logger.AddText("MainWindow::ui_MessageBox: " + title + ", " + text + ", " + details); + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Icon::Critical); msgBox.setWindowTitle(title); - msgBox.setText("

" + text + "

"); + msgBox.setText(text); msgBox.setDetailedText(details); msgBox.addButton(QMessageBox::Ok); msgBox.show(); msgBox.exec(); } +void MainWindow::ui_InEmulation(bool inEmulation) +{ + int index; + + if (inEmulation) + index = 0; + else + index = 1; + + this->ui_Widgets->setCurrentIndex(index); + + this->menuBar_Setup(inEmulation); +} + void MainWindow::menuBar_Init(void) { this->menuBar = new QMenuBar(); this->menuBar_Actions_Init(); + this->menuBar_Actions_Connect(); } void MainWindow::menuBar_Setup(bool inEmulation) { this->menuBar_Actions_Setup(inEmulation); - this->menuBar_Actions_Connect(); + + this->menuBar->clear(); this->menuBar_Menu = this->menuBar->addMenu("File"); this->menuBar_Menu->addAction(this->action_File_OpenRom); @@ -115,10 +153,13 @@ void MainWindow::menuBar_Setup(bool inEmulation) this->menuBar_Menu->addSeparator(); this->menuBar_Menu->addAction(this->action_File_Exit); - this->menuBar_Menu = this->menuBar->addMenu("System"); - this->menuBar_Menu->setEnabled(inEmulation); - this->menuBar_Menu->addAction(action_System_Reset); - this->menuBar_Menu->addAction(action_System_Pause); + if (inEmulation) + { + this->menuBar_Menu = this->menuBar->addMenu("System"); + this->menuBar_Menu->setEnabled(inEmulation); + this->menuBar_Menu->addAction(action_System_Reset); + this->menuBar_Menu->addAction(action_System_Pause); + } this->menuBar_Menu = this->menuBar->addMenu("Options"); this->menuBar_Menu->addAction(this->action_Options_FullScreen); @@ -139,6 +180,17 @@ void MainWindow::menuBar_Setup(bool inEmulation) this->setMenuBar(menuBar); } +void MainWindow::emulationThread_Init(void) +{ + this->emulationThread = new Thread::EmulationThread(); +} + +void MainWindow::emulationThread_Connect(void) +{ + connect(this->emulationThread, &Thread::EmulationThread::on_Emulation_Finished, this, &MainWindow::on_Emulation_Finished); + connect(this->emulationThread, &Thread::EmulationThread::on_Emulation_Started, this, &MainWindow::on_Emulation_Started); +} + void MainWindow::menuBar_Actions_Init(void) { this->action_File_OpenRom = new QAction(); @@ -186,13 +238,13 @@ void MainWindow::menuBar_Actions_Setup(bool inEmulation) this->action_Options_FullScreen->setEnabled(inEmulation); this->action_Options_FullScreen->setShortcut(QKeySequence("Alt+Return")); this->action_Options_ConfigGfx->setText("Configure Graphics Plugin..."); - this->action_Options_ConfigGfx->setEnabled(g_MupenApi.HasPluginConfig(PluginType::Gfx)); + this->action_Options_ConfigGfx->setEnabled(g_MupenApi.Core.HasPluginConfig(M64P::Wrapper::PluginType::Gfx)); this->action_Options_ConfigAudio->setText("Configure Audio Plugin..."); - this->action_Options_ConfigAudio->setEnabled(g_MupenApi.HasPluginConfig(PluginType::Audio)); + this->action_Options_ConfigAudio->setEnabled(g_MupenApi.Core.HasPluginConfig(M64P::Wrapper::PluginType::Audio)); this->action_Options_ConfigRsp->setText("Configure RSP..."); - this->action_Options_ConfigRsp->setEnabled(g_MupenApi.HasPluginConfig(PluginType::Rsp)); + this->action_Options_ConfigRsp->setEnabled(g_MupenApi.Core.HasPluginConfig(M64P::Wrapper::PluginType::Rsp)); this->action_Options_ConfigControl->setText("Configure Controller Plugin..."); - this->action_Options_ConfigControl->setEnabled(g_MupenApi.HasPluginConfig(PluginType::Input)); + this->action_Options_ConfigControl->setEnabled(g_MupenApi.Core.HasPluginConfig(M64P::Wrapper::PluginType::Input)); this->action_Options_Settings->setText("Settings..."); this->action_Options_Settings->setShortcut(QKeySequence("Ctrl+T")); @@ -224,34 +276,26 @@ void MainWindow::menuBar_Actions_Connect(void) connect(this->action_Help_About, &QAction::triggered, this, &MainWindow::on_Action_Help_About); } -bool aa = false; +#include void MainWindow::on_Action_File_OpenRom(void) { - if (aa) - this->ui_Widgets->setCurrentIndex(0); - else - this->ui_Widgets->setCurrentIndex(1); - - aa = !aa; - /*if (!m64p.OpenRom("/home/rosalie/Downloads/Resident Evil 2 (USA) (Rev A).n64")) - { - this->ui_MessageBox("Error", "Mupen::OpenRom Failed", m64p.GetLastError()); - }*/ + if (this->emulationThread->isRunning()) + return; + + this->emulationThread->SetRomFile("/home/rosalie/Downloads/n64_roms/Super Mario 64 (U) [!].z64"); + this->emulationThread->start(); } void MainWindow::on_Action_File_OpenCombo(void) { - } void MainWindow::on_Action_File_EndEmulation(void) { - } void MainWindow::on_Action_File_ChooseDirectory(void) { - } void MainWindow::on_Action_File_RefreshRomList(void) @@ -278,22 +322,22 @@ void MainWindow::on_Action_Options_FullScreen(void) void MainWindow::on_Action_Options_ConfigGfx(void) { - g_MupenApi.OpenPluginConfig(PluginType::Gfx); + g_MupenApi.Core.OpenPluginConfig(M64P::Wrapper::PluginType::Gfx); } void MainWindow::on_Action_Options_ConfigAudio(void) { - g_MupenApi.OpenPluginConfig(PluginType::Audio); + g_MupenApi.Core.OpenPluginConfig(M64P::Wrapper::PluginType::Audio); } void MainWindow::on_Action_Options_ConfigRsp(void) { - g_MupenApi.OpenPluginConfig(PluginType::Rsp); + g_MupenApi.Core.OpenPluginConfig(M64P::Wrapper::PluginType::Rsp); } void MainWindow::on_Action_Options_ConfigControl(void) { - g_MupenApi.OpenPluginConfig(PluginType::Input); + g_MupenApi.Core.OpenPluginConfig(M64P::Wrapper::PluginType::Input); } void MainWindow::on_Action_Options_Settings(void) @@ -313,3 +357,16 @@ void MainWindow::on_Action_Help_HomePage(void) void MainWindow::on_Action_Help_About(void) { } + +void MainWindow::on_Emulation_Started(void) +{ + this->ui_InEmulation(true); +} + +void MainWindow::on_Emulation_Finished(bool ret) +{ + if (!ret) + this->ui_MessageBox("Error", "EmulationThread::run Failed", this->emulationThread->GetLastError()); + + this->ui_InEmulation(false); +} diff --git a/Source/RMG/UserInterface/MainWindow.hpp b/Source/RMG/UserInterface/MainWindow.hpp index 56f7a5c2..002299ba 100644 --- a/Source/RMG/UserInterface/MainWindow.hpp +++ b/Source/RMG/UserInterface/MainWindow.hpp @@ -1,9 +1,9 @@ #ifndef MAINWINDOW_HPP #define MAINWINDOW_HPP -#include -#include -#include +#include "../Thread/EmulationThread.hpp" +#include "RomBrowserWidget.hpp" +#include "../Globals.hpp" #include #include @@ -12,75 +12,89 @@ #include #include -class MainWindow : public QMainWindow +namespace UserInterface { - Q_OBJECT + class MainWindow : public QMainWindow + { + Q_OBJECT -public: - MainWindow(); - ~MainWindow(); - bool Init(); + public: + MainWindow(void); + ~MainWindow(void); -private: - QOpenGLWidget* ui_Widget_OpenGL; - RomBrowserWidget* ui_Widget_RomBrowser; - QStackedWidget* ui_Widgets; + bool Init(void); - QMenuBar* menuBar; - QMenu* menuBar_Menu; - QAction* action_File_OpenRom; - QAction* action_File_OpenCombo; - QAction* action_File_EndEmulation; - QAction* action_File_ChooseDirectory; - QAction* action_File_RefreshRomList; - QAction* action_File_Exit; - QAction* action_System_Reset; - QAction* action_System_Pause; - QAction* action_Options_FullScreen; - QAction* action_Options_ConfigGfx; - QAction* action_Options_ConfigAudio; - QAction* action_Options_ConfigRsp; - QAction* action_Options_ConfigControl; - QAction* action_Options_Settings; - QAction* action_Help_Support; - QAction* action_Help_HomePage; - QAction* action_Help_About; + private: + Thread::EmulationThread* emulationThread; + + QOpenGLWidget *ui_Widget_OpenGL; + RomBrowserWidget *ui_Widget_RomBrowser; + QStackedWidget *ui_Widgets; - QSettings* ui_Settings; + QMenuBar *menuBar; + QMenu *menuBar_Menu; + QAction *action_File_OpenRom; + QAction *action_File_OpenCombo; + QAction *action_File_EndEmulation; + QAction *action_File_ChooseDirectory; + QAction *action_File_RefreshRomList; + QAction *action_File_Exit; + QAction *action_System_Reset; + QAction *action_System_Pause; + QAction *action_Options_FullScreen; + QAction *action_Options_ConfigGfx; + QAction *action_Options_ConfigAudio; + QAction *action_Options_ConfigRsp; + QAction *action_Options_ConfigControl; + QAction *action_Options_Settings; + QAction *action_Help_Support; + QAction *action_Help_HomePage; + QAction *action_Help_About; - void closeEvent(QCloseEvent*); + QSettings *ui_Settings; - void ui_Init(); - void ui_Setup(); - void ui_MessageBox(QString, QString, QString); + void closeEvent(QCloseEvent *); - void menuBar_Init(void); - void menuBar_Setup(bool); + void ui_Init(); + void ui_Setup(); + void ui_Stylesheet_Setup(); + void ui_MessageBox(QString, QString, QString); + void ui_InEmulation(bool); - void menuBar_Actions_Init(void); - void menuBar_Actions_Setup(bool); - void menuBar_Actions_Connect(void); + void menuBar_Init(void); + void menuBar_Setup(bool); - void on_VidExt_Quit(void); + void emulationThread_Init(void); + void emulationThread_Connect(void); -public slots: - void on_Action_File_OpenRom(void); - void on_Action_File_OpenCombo(void); - void on_Action_File_EndEmulation(void); - void on_Action_File_ChooseDirectory(void); - void on_Action_File_RefreshRomList(void); - void on_Action_File_Exit(void); - void on_Action_System_Reset(void); - void on_Action_System_Pause(void); - void on_Action_Options_FullScreen(void); - void on_Action_Options_ConfigGfx(void); - void on_Action_Options_ConfigAudio(void); - void on_Action_Options_ConfigRsp(void); - void on_Action_Options_ConfigControl(void); - void on_Action_Options_Settings(void); - void on_Action_Help_Support(void); - void on_Action_Help_HomePage(void); - void on_Action_Help_About(void); -}; + void menuBar_Actions_Init(void); + void menuBar_Actions_Setup(bool); + void menuBar_Actions_Connect(void); + + void on_VidExt_Quit(void); + + public slots: + void on_Action_File_OpenRom(void); + void on_Action_File_OpenCombo(void); + void on_Action_File_EndEmulation(void); + void on_Action_File_ChooseDirectory(void); + void on_Action_File_RefreshRomList(void); + void on_Action_File_Exit(void); + void on_Action_System_Reset(void); + void on_Action_System_Pause(void); + void on_Action_Options_FullScreen(void); + void on_Action_Options_ConfigGfx(void); + void on_Action_Options_ConfigAudio(void); + void on_Action_Options_ConfigRsp(void); + void on_Action_Options_ConfigControl(void); + void on_Action_Options_Settings(void); + void on_Action_Help_Support(void); + void on_Action_Help_HomePage(void); + void on_Action_Help_About(void); + + void on_Emulation_Started(void); + void on_Emulation_Finished(bool); + }; +} // namespace UserInterface #endif // MAINWINDOW_HPP diff --git a/Source/RMG/UserInterface/RomBrowserWidget.cpp b/Source/RMG/UserInterface/RomBrowserWidget.cpp index 1768876e..9ca88f28 100644 --- a/Source/RMG/UserInterface/RomBrowserWidget.cpp +++ b/Source/RMG/UserInterface/RomBrowserWidget.cpp @@ -1,15 +1,16 @@ -#include -#include -#include +#include "RomBrowserWidget.hpp" +#include "../Globals.hpp" +#include "../Config.hpp" #include +using namespace UserInterface; + RomBrowserWidget::RomBrowserWidget(void) : QTableView(nullptr) { this->model_Init(); this->model_Setup(); this->widget_Init(); - } RomBrowserWidget::~RomBrowserWidget() @@ -37,20 +38,22 @@ void RomBrowserWidget::model_Setup(void) this->rom_List_Fill("/home/rosalie/Downloads/n64_roms/"); - QStringList list; - list.append("Name"); - list.append("Internal Name"); - list.append("MD5"); + this->model_LabelList_Setup(); - // this->model_Model->setRowCount(this->rom_List_Index); - this->model_Model->setColumnCount(list.size()); - this->model_Model->setHorizontalHeaderLabels(list); + this->model_Model->setColumnCount(this->model_LabelList.size()); + this->model_Model->setHorizontalHeaderLabels(this->model_LabelList); +} + +void RomBrowserWidget::model_LabelList_Setup(void) +{ + this->model_LabelList.clear(); + this->model_LabelList.append("Name"); + this->model_LabelList.append("Internal Name"); + this->model_LabelList.append("MD5"); } -#include void RomBrowserWidget::widget_Init(void) { - this->setModel(this->model_Model); this->setShowGrid(false); this->setSelectionBehavior(QTableView::SelectRows); @@ -58,34 +61,42 @@ void RomBrowserWidget::widget_Init(void) this->verticalHeader()->hide(); - this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + this->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); this->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); this->horizontalHeader()->setSortIndicatorShown(false); this->horizontalHeader()->setHighlightSections(false); - this->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + + this->verticalHeader()->setSectionResizeMode(QHeaderView::Interactive); this->verticalHeader()->setMaximumSectionSize(20); + + this->column_SetSize(); QFont f = this->font(); f.setPixelSize(11); this->setFont(f); } -void RomBrowserWidget::rom_List_Init() +void RomBrowserWidget::rom_Searcher_Init(void) { - this->rom_Searcher_Thread = new RomSearcherThread(); + this->rom_Searcher_Thread = new Thread::RomSearcherThread(); this->rom_Searcher_Thread->SetMaximumFiles(APP_ROMSEARCHER_MAX); // TODO this->rom_Searcher_Thread->SetRecursive(true); - connect(rom_Searcher_Thread, &RomSearcherThread::on_Rom_Found, this, &RomBrowserWidget::on_RomBrowserThread_Received); - connect(rom_Searcher_Thread, &RomSearcherThread::finished, this, &RomBrowserWidget::on_RomBrowserThread_Finished); + connect(rom_Searcher_Thread, &Thread::RomSearcherThread::on_Rom_Found, this, &RomBrowserWidget::on_RomBrowserThread_Received); + connect(rom_Searcher_Thread, &Thread::RomSearcherThread::finished, this, &RomBrowserWidget::on_RomBrowserThread_Finished); } +bool init = false; + void RomBrowserWidget::rom_List_Fill(QString directory) { - if (!this->rom_List_Fill_Thread_Init) - this->rom_List_Init(); + if (!init) + { + this->rom_Searcher_Init(); + init = true; + } if (this->rom_List_Fill_Thread_Running) return; @@ -95,18 +106,49 @@ void RomBrowserWidget::rom_List_Fill(QString directory) this->rom_Searcher_Thread->start(); } -void RomBrowserWidget::on_RomBrowserThread_Received(m64p_rom_info romInfo) +void RomBrowserWidget::column_SetSize(void) +{ + for (int i = 0; i < this->model_LabelList.size(); i++) + { + QString label = this->model_LabelList.at(i); + + int oldSize = this->columnWidth(i); + int newSize = 0; + if (label == "Name") + { + newSize = 150; + } else if (label == "Internal Name") + { + newSize = 100; + } else if (label == "MD5") + { + newSize = 100; + } + + if (oldSize != newSize) + { + this->setColumnWidth(i, oldSize); + } + else + { + this->setColumnWidth(i, newSize); + } + } +} + +void RomBrowserWidget::on_RomBrowserThread_Received(M64P::Wrapper::RomInfo_t romInfo) { QList list; - list.append(new QStandardItem(romInfo.m64p_settings.goodname)); - list.append(new QStandardItem(QString((char*)romInfo.m64p_header.Name))); - list.append(new QStandardItem(romInfo.m64p_settings.MD5)); + list.append(new QStandardItem(romInfo.Settings.goodname)); + list.append(new QStandardItem(QString((char*)romInfo.Header.Name))); + list.append(new QStandardItem(romInfo.Settings.MD5)); this->model_Model->appendRow(list); - this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + this->column_SetSize(); + + this->horizontalHeader()->setStretchLastSection(true); } void RomBrowserWidget::on_RomBrowserThread_Finished(void) diff --git a/Source/RMG/UserInterface/RomBrowserWidget.hpp b/Source/RMG/UserInterface/RomBrowserWidget.hpp index aba588c9..2df0d598 100644 --- a/Source/RMG/UserInterface/RomBrowserWidget.hpp +++ b/Source/RMG/UserInterface/RomBrowserWidget.hpp @@ -1,10 +1,10 @@ #ifndef ROMBROWSERWIDGET_HPP #define ROMBROWSERWIDGET_HPP -#include -#include +#include "../Thread/RomSearcherThread.hpp" +#include "../Globals.hpp" -#include +#include #include #include #include @@ -12,42 +12,48 @@ #define MAX_ROM_INFO 50 -class RomBrowserWidget: public QTableView +namespace UserInterface { - Q_OBJECT + class RomBrowserWidget : public QTableView + { + Q_OBJECT -public: - RomBrowserWidget(void); - ~RomBrowserWidget(void); + public: + RomBrowserWidget(void); + ~RomBrowserWidget(void); - void RefreshRomList(void); + void RefreshRomList(void); -private: - QStandardItemModel* model_Model; - void model_Init(void); - void model_Setup(void); + private: + QStandardItemModel *model_Model; + QStringList model_LabelList; + void model_Init(void); + void model_Setup(void); + void model_LabelList_Setup(void); - void widget_Init(void); + void widget_Init(void); - RomSearcherThread* rom_Searcher_Thread; - bool rom_Searcher_Recursive; - bool rom_Searcher_MaxItems; - bool rom_Searcher_Running; + Thread::RomSearcherThread *rom_Searcher_Thread; + bool rom_Searcher_Recursive; + bool rom_Searcher_MaxItems; + bool rom_Searcher_Running; - m64p_rom_info rom_List[MAX_ROM_INFO]; - int rom_List_Index = 0; + void rom_Searcher_Init(void); - bool rom_List_Recursive; - bool rom_List_Fill_Thread_Init; - bool rom_List_Fill_Thread_Running; - void rom_List_Init(); - void rom_List_Fill(QString); + M64P::Wrapper::RomInfo_t rom_List[MAX_ROM_INFO]; + int rom_List_Index = 0; + bool rom_List_Recursive; + bool rom_List_Fill_Thread_Running; + void rom_List_Init(); + void rom_List_Fill(QString); + void column_SetSize(); -public slots: - void on_RomBrowserThread_Received(m64p_rom_info info); - void on_RomBrowserThread_Finished(void); -}; + public slots: + void on_RomBrowserThread_Received(M64P::Wrapper::RomInfo_t info); + void on_RomBrowserThread_Finished(void); + }; +} // namespace UserInterface #endif // ROMBROWSERWIDGET_HPP diff --git a/Source/RMG/Util/Logger.cpp b/Source/RMG/Util/Logger.cpp index 1a459b9a..4583a590 100644 --- a/Source/RMG/Util/Logger.cpp +++ b/Source/RMG/Util/Logger.cpp @@ -2,28 +2,27 @@ #include -Logger g_Logger; +using namespace Util; -Logger::Logger() +Logger::Logger(void) { } -Logger::~Logger() +Logger::~Logger(void) { - if (this->init) + if (!this->init_Failed) { this->logfile.flush(); this->logfile.close(); } } -bool Logger::Init() +bool Logger::Init(void) { if (!QDir().exists(APP_LOG_DIR)) { if (!QDir().mkdir(APP_LOG_DIR)) { - this->init = false; this->error_message = "QDir::mkdir Failed"; return false; } @@ -33,19 +32,17 @@ bool Logger::Init() if (!this->logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { - this->init = false; this->error_message = "QFile::Open Failed"; return false; } - this->init = true; + this->init_Failed = false; return true; } -#include void Logger::AddText(QString text) { - if (!this->init) + if (this->init_Failed) return; if (text[text.size() - 1] != "\n") diff --git a/Source/RMG/Util/Logger.hpp b/Source/RMG/Util/Logger.hpp index 41748efc..a8941706 100644 --- a/Source/RMG/Util/Logger.hpp +++ b/Source/RMG/Util/Logger.hpp @@ -6,25 +6,29 @@ #include #include -class Logger +namespace Util { -public: - Logger(); - ~Logger(); + class Logger + { + public: + Logger(void); + ~Logger(void); - bool Init(void); + bool Init(void); - void AddText(QString text); + void AddText(QString); - QString GetLastError(void); + QString GetLastError(void); -private: - bool init; + private: + bool init_Failed = true; - QString error_message; - QFile logfile; -}; + QString error_message; + QFile logfile; + }; -extern Logger g_Logger; +} // namespace Util + +extern Util::Logger g_Logger; #endif // LOGGER_HPP \ No newline at end of file diff --git a/Source/RMG/main.cpp b/Source/RMG/main.cpp index 061c5b99..39dd0dd9 100644 --- a/Source/RMG/main.cpp +++ b/Source/RMG/main.cpp @@ -8,7 +8,7 @@ int main(int argc, char** argv) { QApplication app(argc, argv); - MainWindow window; + UserInterface::MainWindow window; QDir::setCurrent(app.applicationDirPath());