more work

This commit is contained in:
Rosalie Wanders
2020-09-18 23:06:55 +02:00
parent 2bd8eaced1
commit 227e4fd915
16 changed files with 273 additions and 28 deletions
+1
View File
@@ -1,2 +1,3 @@
# CMake build directory
Build/
Bin/
+12 -9
View File
@@ -3,7 +3,10 @@
#
include(ExternalProject)
set(M64P_CORE_DIR ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-core)
set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/Source/3rdParty)
set(M64P_CORE_DIR ${THIRDPARTY_DIR}/mupen64plus-core)
if(WIN32)
set(SO_EXT "dll")
set(CORE_FILE "mupen64plus.dll")
@@ -43,9 +46,9 @@ ExternalProject_Add(mupen64plus-audio-sdl
BUILD_COMMAND make all APIDIR=${APIDIR}
BUILD_IN_SOURCE False
BINARY_DIR ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-audio-sdl/projects/unix
BINARY_DIR ${THIRDPARTY_DIR}/mupen64plus-audio-sdl/projects/unix
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-audio-sdl/projects/unix/mupen64plus-audio-sdl.${SO_EXT}
BUILD_BYPRODUCTS ${THIRDPARTY_DIR}/mupen64plus-audio-sdl/projects/unix/mupen64plus-audio-sdl.${SO_EXT}
DEPENDS mupen64plus-core
)
@@ -61,9 +64,9 @@ ExternalProject_Add(mupen64plus-rsp-hle
BUILD_COMMAND make all APIDIR=${APIDIR}
BUILD_IN_SOURCE False
BINARY_DIR ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-rsp-hle/projects/unix
BINARY_DIR ${THIRDPARTY_DIR}/mupen64plus-rsp-hle/projects/unix
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-rsp-hle/projects/unix/mupen64plus-rsp-hle.${SO_EXT}
BUILD_BYPRODUCTS ${THIRDPARTY_DIR}/mupen64plus-rsp-hle/projects/unix/mupen64plus-rsp-hle.${SO_EXT}
DEPENDS mupen64plus-core
)
@@ -79,9 +82,9 @@ ExternalProject_Add(mupen64plus-input-raphnetraw
BUILD_COMMAND make all APIDIR=${APIDIR}
BUILD_IN_SOURCE False
BINARY_DIR ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-input-raphnetraw/projects/unix
BINARY_DIR ${THIRDPARTY_DIR}/mupen64plus-input-raphnetraw/projects/unix
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-input-raphnetraw/projects/unix/mupen64plus-input-raphnetraw.${SO_EXT}
BUILD_BYPRODUCTS ${THIRDPARTY_DIR}/mupen64plus-input-raphnetraw/projects/unix/mupen64plus-input-raphnetraw.${SO_EXT}
DEPENDS mupen64plus-core
)
@@ -97,7 +100,8 @@ ExternalProject_Add(mupen64plus-video-GLideN64
CMAKE_ARGS -DMUPENPLUSAPI=1 -DMUPENPLUSAPI_GLIDENUI=1 -Wno-dev
SOURCE_SUBDIR ./src
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/Source/3rdParty/mupen64plus-video-GLideN64/src/plugin/Release/mupen64plus-video-GLideN64.${SO_EXT}
BUILD_BYPRODUCTS ${THIRDPARTY_DIR}/mupen64plus-video-GLideN64/src/plugin/Release/mupen64plus-video-GLideN64.${SO_EXT}
BUILD_BYPRODUCTS ${THIRDPARTY_DIR}/mupen64plus-video-GLideN64/ini/GLideN64.custom.ini
)
ExternalProject_Get_property(mupen64plus-core BUILD_BYPRODUCTS)
@@ -105,7 +109,6 @@ set(MUPEN64PLUSCORE_LIB ${BUILD_BYPRODUCTS} PARENT_SCOPE)
set(MUPEN64PLUSCORE_INI ${M64P_CORE_DIR}/data/mupen64plus.ini PARENT_SCOPE)
set(MUPEN64PLUSCORE_CHT ${M64P_CORE_DIR}/data/mupencheat.txt PARENT_SCOPE)
ExternalProject_Get_property(mupen64plus-audio-sdl BUILD_BYPRODUCTS)
set(MUPEN64PLUS_PLUGIN_AUDIO ${BUILD_BYPRODUCTS} PARENT_SCOPE)
+2 -1
View File
@@ -24,7 +24,8 @@ add_executable(RMG
M64P/Wrapper/Core.cpp
M64P/Wrapper/Plugin.cpp
M64P/Wrapper/Api.cpp
Util/Logger.cpp
Utilities/Logger.cpp
Utilities/Settings.cpp
Globals.cpp
main.cpp
)
+2 -1
View File
@@ -1,4 +1,5 @@
#include <Globals.hpp>
Util::Logger g_Logger;
Utilities::Logger g_Logger;
Utilities::Settings g_Settings;
M64P::Wrapper::Api g_MupenApi;
+4 -2
View File
@@ -1,10 +1,12 @@
#ifndef GLOBALS_HPP
#define GLOBALS_HPP
#include "Util/Logger.hpp"
#include "Utilities/Logger.hpp"
#include "Utilities/Settings.hpp"
#include "M64P/Wrapper/Api.hpp"
extern Util::Logger g_Logger;
extern Utilities::Logger g_Logger;
extern Utilities::Settings g_Settings;
extern M64P::Wrapper::Api g_MupenApi;
#endif // GLOBALS_HPP
+114 -3
View File
@@ -22,33 +22,144 @@ Config::~Config(void)
bool Config::Init()
{
m64p_error ret;
if (!M64P::Config.IsHooked())
{
this->error_Message = "M64P::Config is not hooked!";
return false;
}
/*ret = M64P::Config.ExternalOpen("Config/RMG.ini", &this->handle);
if (ret != M64ERR_SUCCESS)
{
this->error_Message = "Config::Init M64P::Config.ExternalOpen Failed: ";
this->error_Message += M64P::Core.ErrorMessage(ret);
return false;
}*/
return true;
}
bool Config::SetOption(QString section, QString key, int value)
{
return this->section_Open(section) &&
this->value_Set(key, M64TYPE_INT, (void *)&value);
}
bool Config::SetOption(QString section, QString key, float value)
{
return this->section_Open(section) &&
this->value_Set(key, M64TYPE_FLOAT, (void *)&value);
}
bool Config::SetOption(QString section, QString key, bool value)
{
return this->section_Open(section) &&
this->value_Set(key, M64TYPE_BOOL, (void *)&value);
}
bool Config::SetOption(QString section, QString key, QString value)
{
const char *a = value.toStdString().c_str();
return this->section_Open(section) &&
this->value_Set(key, M64TYPE_STRING, (void *)a);
}
bool Config::SetOption(QString section, QString key, char *value)
{
return this->section_Open(section) &&
this->value_Set(key, M64TYPE_STRING, (void *)value);
}
bool Config::GetOption(QString section, QString key, int *value)
{
return this->section_Open(section) &&
this->value_Get(key, M64TYPE_INT, value, sizeof(*value));
}
bool Config::GetOption(QString section, QString key, float *value)
{
return this->section_Open(section) &&
this->value_Get(key, M64TYPE_INT, value, sizeof(*value));
}
bool Config::GetOption(QString section, QString key, bool *value)
{
return this->section_Open(section) &&
this->value_Get(key, M64TYPE_BOOL, value, sizeof(*value));
}
bool Config::GetOption(QString section, QString key, QString *value)
{
char data[300];
std::string str;
if (!this->section_Open(section))
return false;
if (!this->value_Get(key, M64TYPE_STRING, data, sizeof(data)))
return false;
str = std::string(data);
*value = QString::fromStdString(str);
return true;
}
bool Config::section_Open(QString section)
{
m64p_error ret;
ret = M64P::Config.OpenSection(section.toStdString().c_str(), &this->section_Handle);
if (ret != M64ERR_SUCCESS)
{
this->error_Message = "Config::section_Open Failed: ";
this->error_Message = M64P::Core.ErrorMessage(ret);
return false;
}
return true;
}
bool Config::value_Set(QString key, m64p_type type, void *value)
{
m64p_error ret;
ret = M64P::Config.SetParameter(this->section_Handle, key.toStdString().c_str(), type, value);
if (ret != M64ERR_SUCCESS)
{
this->error_Message = "Config::value_Set M64P::Config.SetParameter Failed: ";
this->error_Message += M64P::Core.ErrorMessage(ret);
return false;
}
ret = M64P::Config.SaveFile();
if (ret != M64ERR_SUCCESS)
{
this->error_Message = "Config::value_Set M64P::Config.SaveFile Failed: ";
this->error_Message += M64P::Core.ErrorMessage(ret);
return false;
}
return true;
}
bool Config::value_Get(QString key, m64p_type type, void *data, int maxSize)
{
m64p_error ret;
ret = M64P::Config.GetParameter(this->section_Handle, key.toStdString().c_str(), type, data, maxSize);
if (ret != M64ERR_SUCCESS)
{
this->error_Message = "Config::value_Get M64P::Config.GetParameter Failed: ";
this->error_Message += M64P::Core.ErrorMessage(ret);
return false;
}
return true;
}
QString Config::GetLastError(void)
+13
View File
@@ -30,11 +30,24 @@ namespace M64P
bool SetOption(QString section, QString key, float value);
bool SetOption(QString section, QString key, bool value);
bool SetOption(QString section, QString key, QString value);
bool SetOption(QString section, QString key, char* value);
bool GetOption(QString section, QString key, int* value);
bool GetOption(QString section, QString key, float* value);
bool GetOption(QString section, QString key, bool* value);
bool GetOption(QString section, QString key, QString* value);
QString GetLastError(void);
private:
QString error_Message;
m64p_handle handle;
m64p_handle section_Handle;
bool section_Open(QString);
bool value_Set(QString, m64p_type, void*);
bool value_Get(QString, m64p_type, void*, int);
};
} // namespace Wrapper
} // namespace M64P
+32 -3
View File
@@ -8,7 +8,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "MainWindow.hpp"
#include "../Util/Logger.hpp"
#include "../Config.hpp"
#include <QMenuBar>
@@ -19,6 +18,7 @@
#include <QMessageBox>
#include <QString>
#include <QSettings>
#include <QFileDialog>
using namespace UserInterface;
@@ -38,7 +38,7 @@ MainWindow::~MainWindow()
if (this->ui_Settings)
delete this->ui_Settings; */
}
#include <iostream>
bool MainWindow::Init(void)
{
if (!g_Logger.Init())
@@ -47,6 +47,12 @@ bool MainWindow::Init(void)
return false;
}
if (!g_Settings.Init())
{
this->ui_MessageBox("Error", "Settings::Init Failed", g_Settings.GetLastError());
return false;
}
if (!g_MupenApi.Init(MUPEN_CORE_FILE))
{
this->ui_MessageBox("Error", "M64P::Wrapper::Api::Init Failed", g_MupenApi.GetLastError());
@@ -79,17 +85,21 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::ui_Init(void)
{
this->ui_Icon = QIcon(":Icons/RMG.png");
this->ui_Widget_OpenGL = new QOpenGLWidget();
this->ui_Widget_RomBrowser = new RomBrowserWidget();
this->ui_Widgets = new QStackedWidget();
this->ui_Settings = new QSettings(APP_SETTINGS_ORG, APP_SETTINGS_NAME);
this->ui_Widget_RomBrowser->SetDirectory(g_Settings.GetValue("tmp", "directory").toString());
this->ui_Widget_RomBrowser->RefreshRomList();
}
void MainWindow::ui_Setup(void)
{
this->ui_Stylesheet_Setup();
this->setWindowIcon(QIcon(":Icons/RMG.png"));
this->setWindowIcon(this->ui_Icon);
this->setWindowTitle(WINDOW_TITLE);
this->setCentralWidget(this->ui_Widgets);
this->restoreGeometry(this->ui_Settings->value(APP_SETTINGS_GEOMETRY).toByteArray());
@@ -118,6 +128,7 @@ void MainWindow::ui_MessageBox(QString title, QString text, QString details = ""
g_Logger.AddText("MainWindow::ui_MessageBox: " + title + ", " + text + ", " + details);
QMessageBox msgBox;
msgBox.setWindowIcon(this->ui_Icon);
msgBox.setIcon(QMessageBox::Icon::Critical);
msgBox.setWindowTitle(title);
msgBox.setText(text);
@@ -307,6 +318,24 @@ void MainWindow::on_Action_File_EndEmulation(void)
void MainWindow::on_Action_File_ChooseDirectory(void)
{
QFileDialog dialog;
int ret;
QString dir;
dialog.setParent(this);
dialog.setFileMode(QFileDialog::Directory);
dialog.setOption(QFileDialog::ShowDirsOnly, true);
dialog.setWindowIcon(this->ui_Icon);
dialog.show();
ret = dialog.exec();
if (ret)
{
dir = dialog.selectedFiles().first();
g_Settings.SetValue("tmp", "directory", dir);
this->ui_Widget_RomBrowser->SetDirectory(dir);
this->ui_Widget_RomBrowser->RefreshRomList();
}
}
void MainWindow::on_Action_File_RefreshRomList(void)
+1
View File
@@ -36,6 +36,7 @@ namespace UserInterface
private:
Thread::EmulationThread* emulationThread;
QIcon ui_Icon;
QOpenGLWidget *ui_Widget_OpenGL;
RomBrowserWidget *ui_Widget_RomBrowser;
QStackedWidget *ui_Widgets;
@@ -31,6 +31,11 @@ void RomBrowserWidget::RefreshRomList(void)
this->model_Setup();
}
void RomBrowserWidget::SetDirectory(QString directory)
{
this->directory = directory;
}
void RomBrowserWidget::model_Init(void)
{
this->model_Model = new QStandardItemModel(this);
@@ -45,7 +50,8 @@ void RomBrowserWidget::model_Setup(void)
this->rom_List_Recursive = false;
this->model_Model->clear();
this->rom_List_Fill("/home/rosalie/Downloads/n64_roms/");
if (!this->directory.isEmpty())
this->rom_List_Fill(this->directory);
this->model_LabelList_Setup();
@@ -34,7 +34,10 @@ namespace UserInterface
void RefreshRomList(void);
void SetDirectory(QString);
private:
QString directory;
QStandardItemModel *model_Model;
QStringList model_LabelList;
void model_Init(void);
@@ -7,11 +7,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Util/Logger.hpp>
#include "Logger.hpp"
#include <QDir>
using namespace Util;
using namespace Utilities;
Logger::Logger(void)
{
@@ -10,12 +10,12 @@
#ifndef LOGGER_HPP
#define LOGGER_HPP
#include <Config.hpp>
#include "../Config.hpp"
#include <QString>
#include <QFile>
namespace Util
namespace Utilities
{
class Logger
{
@@ -39,6 +39,4 @@ namespace Util
} // namespace Util
extern Util::Logger g_Logger;
#endif // LOGGER_HPP
#endif // LOGGER_HPP
+50
View File
@@ -0,0 +1,50 @@
#include "Settings.hpp"
using namespace Utilities;
Settings::Settings(void)
{
}
Settings::~Settings(void)
{
delete this->settings;
}
bool Settings::Init(void)
{
this->settings = new QSettings("Config/RMG.ini", QSettings::IniFormat);
if (!this->settings->isWritable())
{
this->error_Message = "Settings::Init Failed: ";
this->error_Message += "QSettings is not writable!";
return false;
}
return true;
}
void Settings::SetValue(QString section, QString key, QVariant value)
{
this->settings->beginGroup(section);
this->settings->setValue(key, value);
this->settings->endGroup();
}
QVariant Settings::GetValue(QString section, QString key)
{
QVariant ret;
this->settings->beginGroup(section);
ret = this->settings->value(key);
this->settings->endGroup();
return ret;
}
QString Settings::GetLastError(void)
{
return this->error_Message;
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef SETTINGS_HPP
#define SETTINGS_HPP
#include <QSettings>
namespace Utilities
{
class Settings
{
public:
Settings(void);
~Settings(void);
bool Init(void);
void SetValue(QString, QString, QVariant);
QVariant GetValue(QString, QString);
QString GetLastError(void);
private:
QString error_Message;
QSettings* settings;
};
} // namespace Utilities
#endif // SETTINGS_HPP
-1
View File
@@ -1,5 +1,4 @@
#include <UserInterface/MainWindow.hpp>
#include <Util/Logger.hpp>
#include <QApplication>
#include <QDir>