mirror of
https://github.com/simple64/simple64.git
synced 2026-11-18 07:34:02 +01:00
update gui
This commit is contained in:
1 parent
7a9c1ebb97
commit
d14ed867ac
18 files changed
+365
-42
No files matched your search
@@ -46,6 +46,7 @@ add_executable(simple64-gui
|
||||
vidext.cpp
|
||||
settingsdialog.cpp
|
||||
interface/common.cpp
|
||||
cheats.cpp
|
||||
hotkeydialog.cpp
|
||||
plugindialog.cpp
|
||||
vkwindow.cpp
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
#include "cheats.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QJsonDocument>
|
||||
#include <QtEndian>
|
||||
#include <QScrollArea>
|
||||
#include <QLabel>
|
||||
#include <QJsonArray>
|
||||
#include <cinttypes>
|
||||
|
||||
CheatsDialog::CheatsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QString gameName = getCheatGameName();
|
||||
QJsonObject gameData = loadCheatData(gameName);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
QWidget *cheatsSettings = new QWidget(this);
|
||||
m_layout = new QGridLayout(cheatsSettings);
|
||||
QScrollArea *cheatsScroll = new QScrollArea(this);
|
||||
|
||||
QStringList keys = gameData.keys();
|
||||
int row = 0;
|
||||
for (int i = 0; i < keys.size(); ++i)
|
||||
{
|
||||
QJsonObject cheats = gameData.value(keys.at(i)).toObject();
|
||||
QLabel *name = new QLabel(keys.at(i), this);
|
||||
QString helper = cheats.value("note").toString();
|
||||
if (!helper.isEmpty()) {
|
||||
helper.prepend("<span style=\"color:black;\">");
|
||||
helper.append("</span>");
|
||||
name->setToolTip(helper);
|
||||
}
|
||||
name->setStyleSheet("padding: 10px");
|
||||
m_layout->addWidget(name, row, 0);
|
||||
bool hasOptions = cheats.value("hasOptions").toBool();
|
||||
if (!hasOptions)
|
||||
{
|
||||
CheatsCheckBox *box = new CheatsCheckBox(this);
|
||||
box->setCheatName(keys.at(i));
|
||||
box->setGame(gameName);
|
||||
box->loadState();
|
||||
m_layout->addWidget(box, row++, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
row++;
|
||||
QJsonObject options = cheats.value("options").toObject();
|
||||
QButtonGroup* optionButtons = new QButtonGroup(this);
|
||||
optionButtons->setExclusive(true);
|
||||
QStringList optionsKeys = options.keys();
|
||||
for (int j = 0; j < optionsKeys.size(); ++j)
|
||||
{
|
||||
QString optionName = optionsKeys.at(j);
|
||||
QLabel *optionLabel = new QLabel(" -- " + optionName, this);
|
||||
if (!helper.isEmpty())
|
||||
optionLabel->setToolTip(helper);
|
||||
optionLabel->setStyleSheet("padding: 10px");
|
||||
m_layout->addWidget(optionLabel, row, 0);
|
||||
CheatsCheckBox *box = new CheatsCheckBox(this);
|
||||
box->setCheatName(keys.at(i));
|
||||
box->setOptionName(optionName);
|
||||
box->setGame(gameName);
|
||||
box->setGroup(optionButtons);
|
||||
box->loadState();
|
||||
optionButtons->addButton(box);
|
||||
m_layout->addWidget(box, row++, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
cheatsSettings->setLayout(m_layout);
|
||||
cheatsScroll->setMinimumWidth(cheatsSettings->sizeHint().width() + 20);
|
||||
cheatsScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
cheatsScroll->setWidget(cheatsSettings);
|
||||
QLabel *myLabel = new QLabel("Restart game for cheats to take effect.\n\nHover your mouse over a cheat for a description (if one exists).\n", this);
|
||||
myLabel->setStyleSheet("font-weight: bold");
|
||||
mainLayout->addWidget(myLabel);
|
||||
mainLayout->addWidget(cheatsScroll);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
CheatsCheckBox::CheatsCheckBox(QWidget *parent)
|
||||
: QCheckBox(parent)
|
||||
{
|
||||
connect(this, &QAbstractButton::pressed, [=]{
|
||||
if (m_group != nullptr && checkState() == Qt::Checked)
|
||||
{
|
||||
m_group->setExclusive(false);
|
||||
}
|
||||
});
|
||||
|
||||
connect(this, &QAbstractButton::released, [=]{
|
||||
if (m_group != nullptr)
|
||||
{
|
||||
m_group->setExclusive(true);
|
||||
}
|
||||
});
|
||||
|
||||
connect(this, &QCheckBox::stateChanged, [=](int state){
|
||||
QString prefix = "Cheats/" + m_game + "/" + m_cheatName + "/";
|
||||
if (m_optionName != "")
|
||||
{
|
||||
w->getSettings()->setValue(prefix + "option", m_optionName);
|
||||
}
|
||||
w->getSettings()->setValue(prefix + "enabled", state == Qt::Checked ? true : false);
|
||||
});
|
||||
}
|
||||
|
||||
void CheatsCheckBox::loadState()
|
||||
{
|
||||
QString prefix = "Cheats/" + m_game + "/" + m_cheatName + "/";
|
||||
|
||||
if (w->getSettings()->value(prefix + "option").toString() == m_optionName)
|
||||
{
|
||||
if (w->getSettings()->value(prefix + "enabled").toBool())
|
||||
setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject getCheatsFromSettings(QString gameName, QJsonObject gameData)
|
||||
{
|
||||
QJsonObject data;
|
||||
w->getSettings()->beginGroup("Cheats");
|
||||
w->getSettings()->beginGroup(gameName);
|
||||
QStringList childGroups = w->getSettings()->childGroups();
|
||||
for (int i = 0; i < childGroups.size(); ++i)
|
||||
{
|
||||
w->getSettings()->beginGroup(childGroups.at(i));
|
||||
if (w->getSettings()->value("enabled").toBool())
|
||||
{
|
||||
QJsonArray cheat_codes = gameData.value(childGroups.at(i)).toObject().value("data").toArray();
|
||||
if(w->getSettings()->contains("option"))
|
||||
{
|
||||
for (int j = 0; j < cheat_codes.size(); ++j)
|
||||
{
|
||||
if (cheat_codes.at(j).toString().contains("?"))
|
||||
{
|
||||
QString replacement = gameData.value(childGroups.at(i)).toObject().value("options").toObject().value(w->getSettings()->value("option").toString()).toString();
|
||||
QString code = cheat_codes.at(j).toString().replace(cheat_codes.at(j).toString().indexOf("?"), replacement.size(), replacement);
|
||||
cheat_codes.replace(j, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
data.insert(childGroups.at(i), cheat_codes);
|
||||
}
|
||||
w->getSettings()->endGroup();
|
||||
}
|
||||
w->getSettings()->endGroup();
|
||||
w->getSettings()->endGroup();
|
||||
return data;
|
||||
}
|
||||
|
||||
bool loadCheats(QJsonObject cheatsData)
|
||||
{
|
||||
bool loaded = false;
|
||||
|
||||
for (int i = 0; i < cheatsData.size(); ++i)
|
||||
{
|
||||
QJsonArray cheat_codes = cheatsData.value(cheatsData.keys().at(i)).toArray();
|
||||
QList <m64p_cheat_code> codes;
|
||||
for (int j = 0; j < cheat_codes.size(); ++j)
|
||||
{
|
||||
QStringList data = cheat_codes.at(j).toString().split(" ");
|
||||
m64p_cheat_code code;
|
||||
bool ok;
|
||||
code.address = data[0].toUInt(&ok, 16);
|
||||
code.value = data[1].toInt(&ok, 16);
|
||||
codes.append(code);
|
||||
}
|
||||
m64p_error success = (*CoreAddCheat)(cheatsData.keys().at(i).toUtf8().constData(), codes.data(), codes.size());
|
||||
if (success != M64ERR_SUCCESS)
|
||||
DebugMessage(M64MSG_WARNING, "could not load cheat %s", cheatsData.keys().at(i).toUtf8().constData());
|
||||
else
|
||||
{
|
||||
loaded = true;
|
||||
DebugMessage(M64MSG_INFO, "loaded cheat %s", cheatsData.keys().at(i).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
QString getCheatGameName()
|
||||
{
|
||||
m64p_rom_header rom_header;
|
||||
(*CoreDoCommand)(M64CMD_ROM_GET_HEADER, sizeof(rom_header), &rom_header);
|
||||
return QString("%1-%2-C:%3").arg(qFromBigEndian(rom_header.CRC1), 8, 16, QLatin1Char('0')).arg(qFromBigEndian(rom_header.CRC2), 8, 16, QLatin1Char('0')).arg(rom_header.Country_code, 2, 16).toUpper();
|
||||
}
|
||||
|
||||
QJsonObject loadCheatData(QString gameName)
|
||||
{
|
||||
QString cheats_path = QDir(QCoreApplication::applicationDirPath()).filePath("cheats.json");
|
||||
QFile file(cheats_path);
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
|
||||
QJsonObject data = QJsonDocument::fromJson(file.readAll()).object();
|
||||
file.close();
|
||||
|
||||
return data.value(gameName).toObject();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef CHEATS_H
|
||||
#define CHEATS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QJsonObject>
|
||||
#include <QButtonGroup>
|
||||
|
||||
class CheatsCheckBox : public QCheckBox
|
||||
{
|
||||
public:
|
||||
explicit CheatsCheckBox(QWidget *parent = 0);
|
||||
void loadState();
|
||||
void setGroup(QButtonGroup* group) {
|
||||
m_group = group;
|
||||
}
|
||||
void setCheatName(QString name) {
|
||||
m_cheatName = name;
|
||||
}
|
||||
void setOptionName(QString name) {
|
||||
m_optionName = name;
|
||||
}
|
||||
void setGame(QString name) {
|
||||
m_game = name;
|
||||
}
|
||||
private:
|
||||
QButtonGroup* m_group = nullptr;
|
||||
QString m_cheatName = "";
|
||||
QString m_optionName = "";
|
||||
QString m_game = "";
|
||||
};
|
||||
|
||||
class CheatsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CheatsDialog(QWidget *parent = nullptr);
|
||||
private:
|
||||
QGridLayout *m_layout;
|
||||
};
|
||||
|
||||
QJsonObject getCheatsFromSettings(QString gameName, QJsonObject gameData);
|
||||
bool loadCheats(QJsonObject cheatsData);
|
||||
QString getCheatGameName();
|
||||
QJsonObject loadCheatData(QString gameName);
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@ static void paramListCallback(void *context, const char *ParamName, m64p_type Pa
|
||||
helper.append("</span>");
|
||||
desc->setToolTip(helper);
|
||||
}
|
||||
desc->setStyleSheet("border: 1px solid; padding: 10px");
|
||||
desc->setStyleSheet("padding: 10px");
|
||||
dialog->getLayout()->addWidget(desc, *dialog->getLayoutRow(), 0);
|
||||
CustomButton *my_Widget = new CustomButton(dialog->getLayout()->parentWidget());
|
||||
dialog->getButtonList()->append(my_Widget);
|
||||
@@ -96,7 +96,7 @@ HotkeyDialog::HotkeyDialog(QWidget *parent)
|
||||
mainLayout->addWidget(coreEventsScroll);
|
||||
QPushButton *resetButton = new QPushButton("Reset All Settings", this);
|
||||
resetButton->setAutoDefault(false);
|
||||
connect(resetButton, SIGNAL (released()),this, SLOT (handleResetButton()));
|
||||
connect(resetButton, &QPushButton::released,this, &HotkeyDialog::handleResetButton);
|
||||
mainLayout->addWidget(resetButton);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
@@ -20,3 +20,5 @@ ptr_ConfigOpenSection ConfigOpenSection = nullptr;
|
||||
ptr_ConfigSaveSection ConfigSaveSection = nullptr;
|
||||
ptr_ConfigListParameters ConfigListParameters = nullptr;
|
||||
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = nullptr;
|
||||
|
||||
ptr_CoreAddCheat CoreAddCheat = nullptr;
|
||||
@@ -24,4 +24,6 @@ extern ptr_ConfigOpenSection ConfigOpenSection;
|
||||
extern ptr_ConfigSaveSection ConfigSaveSection;
|
||||
extern ptr_ConfigListParameters ConfigListParameters;
|
||||
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
|
||||
|
||||
extern ptr_CoreAddCheat CoreAddCheat;
|
||||
#endif
|
||||
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
|
||||
if (parser.isSet(testOption))
|
||||
w->setTest(parser.value(testOption).toInt());
|
||||
if (args.size() > 0)
|
||||
w->openROM(args.at(0), "", 0, 0);
|
||||
w->openROM(args.at(0), "", 0, 0, QJsonObject());
|
||||
else
|
||||
w->updateApp();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "plugindialog.h"
|
||||
#include "hotkeydialog.h"
|
||||
#include "cheats.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "interface/common.h"
|
||||
@@ -301,7 +302,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
if (!settings->contains("volume"))
|
||||
settings->setValue("volume", 100);
|
||||
VolumeAction * volumeAction = new VolumeAction(tr("Volume"), this);
|
||||
connect(volumeAction->slider(), SIGNAL(valueChanged(int)), this, SLOT(volumeValueChanged(int)));
|
||||
connect(volumeAction->slider(), &QSlider::valueChanged, this, &MainWindow::volumeValueChanged);
|
||||
volumeAction->slider()->setValue(settings->value("volume").toInt());
|
||||
ui->menuEmulation->insertAction(ui->actionMute, volumeAction);
|
||||
|
||||
@@ -571,7 +572,7 @@ void MainWindow::updateOpenRecent()
|
||||
OpenRecent->addAction(recent[i]);
|
||||
QAction *temp_recent = recent[i];
|
||||
connect(temp_recent, &QAction::triggered,[=](){
|
||||
openROM(temp_recent->text(), "", 0, 0);
|
||||
openROM(temp_recent->text(), "", 0, 0, QJsonObject());
|
||||
});
|
||||
}
|
||||
OpenRecent->addSeparator();
|
||||
@@ -657,7 +658,7 @@ void MainWindow::resetCore()
|
||||
loadPlugins();
|
||||
}
|
||||
|
||||
void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player)
|
||||
void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player, QJsonObject cheats)
|
||||
{
|
||||
stopGame();
|
||||
|
||||
@@ -665,7 +666,7 @@ void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port,
|
||||
|
||||
resetCore();
|
||||
|
||||
workerThread = new WorkerThread(netplay_ip, netplay_port, netplay_player, this);
|
||||
workerThread = new WorkerThread(netplay_ip, netplay_port, netplay_player, cheats, this);
|
||||
workerThread->setFileName(filename);
|
||||
|
||||
QStringList list;
|
||||
@@ -688,7 +689,7 @@ void MainWindow::on_actionOpen_ROM_triggered()
|
||||
if (!filename.isNull()) {
|
||||
QFileInfo info(filename);
|
||||
settings->setValue("ROMdir", info.absoluteDir().absolutePath());
|
||||
openROM(filename, "", 0, 0);
|
||||
openROM(filename, "", 0, 0, QJsonObject());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,6 +776,12 @@ void MainWindow::on_actionToggle_Fullscreen_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCheats_triggered()
|
||||
{
|
||||
CheatsDialog *cheats = new CheatsDialog(this);
|
||||
cheats->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_State_To_triggered()
|
||||
{
|
||||
QString filename = QFileDialog::getSaveFileName(this,
|
||||
@@ -945,6 +952,8 @@ void MainWindow::loadCoreLib()
|
||||
ConfigListParameters = (ptr_ConfigListParameters) osal_dynlib_getproc(coreLib, "ConfigListParameters");
|
||||
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) osal_dynlib_getproc(coreLib, "ConfigGetSharedDataFilepath");
|
||||
|
||||
CoreAddCheat = (ptr_CoreAddCheat) osal_dynlib_getproc(coreLib, "CoreAddCheat");
|
||||
|
||||
QString qtConfigDir = settings->value("configDirPath").toString();
|
||||
|
||||
if (!qtConfigDir.isEmpty())
|
||||
@@ -1145,6 +1154,21 @@ void MainWindow::updateFrameCount()
|
||||
if (run_test)
|
||||
simulateInput();
|
||||
QString FPS = QString("%1 FPS").arg(frame_count);
|
||||
if (m_cheatsEnabled)
|
||||
{
|
||||
FPS.prepend("Cheats Enabled ");
|
||||
}
|
||||
FPSLabel->setText(FPS);
|
||||
frame_count = 0;
|
||||
}
|
||||
|
||||
void MainWindow::setCheats(QJsonObject cheatsData, bool netplay)
|
||||
{
|
||||
if (!netplay)
|
||||
{
|
||||
QString gameName = getCheatGameName();
|
||||
QJsonObject gameData = loadCheatData(gameName);
|
||||
cheatsData = getCheatsFromSettings(gameName, gameData);
|
||||
}
|
||||
m_cheatsEnabled = loadCheats(cheatsData);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ extern "C" {
|
||||
#include <QLabel>
|
||||
#include <QVulkanInstance>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
m64p_dynlib_handle getInputPlugin();
|
||||
m64p_dynlib_handle getGfxPlugin();
|
||||
|
||||
void openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player);
|
||||
void openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player, QJsonObject cheats);
|
||||
void setVerbose();
|
||||
int getVerbose();
|
||||
void setNoGUI();
|
||||
@@ -69,6 +70,7 @@ public slots:
|
||||
void updateDiscordActivity(struct DiscordActivity activity);
|
||||
void clearDiscordActivity();
|
||||
void addFrameCount();
|
||||
void setCheats(QJsonObject cheatsData, bool netplay);
|
||||
|
||||
private slots:
|
||||
void killThread();
|
||||
@@ -109,6 +111,8 @@ private slots:
|
||||
|
||||
void on_actionToggle_Fullscreen_triggered();
|
||||
|
||||
void on_actionCheats_triggered();
|
||||
|
||||
void on_actionSave_State_To_triggered();
|
||||
|
||||
void on_actionLoad_State_From_triggered();
|
||||
@@ -158,6 +162,7 @@ private:
|
||||
QTimer *frame_timer = nullptr;
|
||||
QLabel *FPSLabel = nullptr;
|
||||
QTimer *kill_timer = nullptr;
|
||||
bool m_cheatsEnabled = false;
|
||||
|
||||
m64p_dynlib_handle coreLib;
|
||||
m64p_dynlib_handle rspPlugin;
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
</property>
|
||||
<addaction name="actionToggle_Fullscreen"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCheats"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMute"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPause_Game"/>
|
||||
@@ -172,6 +174,11 @@
|
||||
<string>Toggle Fullscreen (Alt + Return)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCheats">
|
||||
<property name="text">
|
||||
<string>Cheats</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionController_Configuration">
|
||||
<property name="text">
|
||||
<string>Controller Configuration</string>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../mainwindow.h"
|
||||
#include "../cheats.h"
|
||||
#include "createroom.h"
|
||||
#include "waitroom.h"
|
||||
#include "../version.h"
|
||||
@@ -38,7 +39,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||
QLabel *romLabel = new QLabel("ROM", this);
|
||||
layout->addWidget(romLabel, 2, 0);
|
||||
romButton = new QPushButton("ROM Path", this);
|
||||
connect(romButton, SIGNAL (released()), this, SLOT (handleRomButton()));
|
||||
connect(romButton, &QPushButton::released, this, &CreateRoom::handleRomButton);
|
||||
layout->addWidget(romButton, 2, 1);
|
||||
|
||||
QLabel *playerNameLabel = new QLabel("Player Name", this);
|
||||
@@ -55,7 +56,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||
serverChooser = new QComboBox(this);
|
||||
serverChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
layout->addWidget(serverChooser, 6, 1);
|
||||
connect(serverChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(handleServerChanged(int)));
|
||||
connect(serverChooser, &QComboBox::currentIndexChanged, this, &CreateRoom::handleServerChanged);
|
||||
|
||||
QLabel *pingLabel = new QLabel("Your ping:", this);
|
||||
layout->addWidget(pingLabel, 7, 0);
|
||||
@@ -69,15 +70,15 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||
layout->addWidget(lineH1, 8, 0, 1, 2);
|
||||
|
||||
createButton = new QPushButton("Create Game", this);
|
||||
connect(createButton, SIGNAL (released()), this, SLOT (handleCreateButton()));
|
||||
connect(createButton, &QPushButton::released, this, &CreateRoom::handleCreateButton);
|
||||
layout->addWidget(createButton, 9, 0, 1, 2);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
connect(&manager, &QNetworkAccessManager::finished, this,
|
||||
&CreateRoom::downloadFinished);
|
||||
|
||||
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
|
||||
connect(this, &CreateRoom::finished, this, &CreateRoom::onFinished);
|
||||
|
||||
QNetworkRequest request(QUrl(QStringLiteral("https://m64p.s3.amazonaws.com/servers.json")));
|
||||
manager.get(request);
|
||||
@@ -143,7 +144,7 @@ void CreateRoom::handleCreateButton()
|
||||
connectionTimer = new QTimer(this);
|
||||
connectionTimer->setSingleShot(true);
|
||||
connectionTimer->start(5000);
|
||||
connect(connectionTimer, SIGNAL(timeout()), this, SLOT(connectionFailed()));
|
||||
connect(connectionTimer, &QTimer::timeout, this, &CreateRoom::connectionFailed);
|
||||
connect(webSocket, &QWebSocket::disconnected, connectionTimer, &QTimer::stop);
|
||||
connect(webSocket, &QObject::destroyed, connectionTimer, &QTimer::stop);
|
||||
|
||||
@@ -175,6 +176,18 @@ void CreateRoom::createRoom()
|
||||
json.insert("game_name", QString(rom_settings.goodname));
|
||||
json.insert("client_sha", QStringLiteral(GUI_VERSION));
|
||||
json.insert("netplay_version", NETPLAY_VER);
|
||||
|
||||
QString gameName = getCheatGameName();
|
||||
QJsonObject gameData = loadCheatData(gameName);
|
||||
QJsonObject cheats = getCheatsFromSettings(gameName, gameData);
|
||||
if (!cheats.isEmpty())
|
||||
{
|
||||
QJsonDocument cheatsDoc(cheats);
|
||||
QJsonObject features;
|
||||
features.insert("cheats", QString(cheatsDoc.toJson(QJsonDocument::Compact)));
|
||||
json.insert("features", features);
|
||||
}
|
||||
|
||||
addAuthData(webSocket, &json);
|
||||
|
||||
QJsonDocument json_doc(json);
|
||||
|
||||
@@ -38,7 +38,7 @@ JoinRoom::JoinRoom(QWidget *parent)
|
||||
|
||||
serverChooser = new QComboBox(this);
|
||||
serverChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
connect(serverChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(serverChanged(int)));
|
||||
connect(serverChooser, &QComboBox::currentIndexChanged, this, &JoinRoom::serverChanged);
|
||||
|
||||
layout->addWidget(serverChooser, 0, 3);
|
||||
|
||||
@@ -64,10 +64,10 @@ JoinRoom::JoinRoom(QWidget *parent)
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
connect(&manager, &QNetworkAccessManager::finished, this,
|
||||
&JoinRoom::downloadFinished);
|
||||
|
||||
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
|
||||
connect(this, &JoinRoom::finished, this, &JoinRoom::onFinished);
|
||||
|
||||
QNetworkRequest request(QUrl(QStringLiteral("https://m64p.s3.amazonaws.com/servers.json")));
|
||||
manager.get(request);
|
||||
@@ -111,14 +111,14 @@ void JoinRoom::resetList()
|
||||
row = 0;
|
||||
rooms.clear();
|
||||
listWidget->clear();
|
||||
listWidget->setColumnCount(4);
|
||||
listWidget->setColumnCount(5);
|
||||
listWidget->setRowCount(row);
|
||||
QStringList headers;
|
||||
headers.append("Room Name");
|
||||
headers.append("Game Name");
|
||||
headers.append("Game MD5");
|
||||
headers.append("Password Protected");
|
||||
//headers.append("Fixed Input Delay");
|
||||
headers.append("Cheats Enabled");
|
||||
listWidget->setHorizontalHeaderLabels(headers);
|
||||
listWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
}
|
||||
@@ -293,6 +293,13 @@ void JoinRoom::processTextMessage(QString message)
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 3, newItem);
|
||||
|
||||
QString cheatsValue = "No";
|
||||
if (!json.value("features").toObject().value("cheats").toString().isEmpty())
|
||||
cheatsValue = "Yes";
|
||||
newItem = new QTableWidgetItem(cheatsValue);
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 4, newItem);
|
||||
|
||||
++row;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -10,6 +10,10 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
|
||||
{
|
||||
this->resize(640,480);
|
||||
|
||||
QString cheats_string = room.value("features").toObject().value("cheats").toString();
|
||||
QJsonDocument cheats_doc = QJsonDocument::fromJson(cheats_string.toUtf8());
|
||||
cheats = cheats_doc.object();
|
||||
|
||||
player_name = room.value("player_name").toString();
|
||||
room_port = room.value("port").toInt();
|
||||
room_name = room.value("room_name").toString();
|
||||
@@ -82,7 +86,7 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
|
||||
connect(this, &WaitRoom::finished, this, &WaitRoom::onFinished);
|
||||
|
||||
QJsonObject json;
|
||||
json.insert("type", "request_players");
|
||||
@@ -190,7 +194,7 @@ void WaitRoom::processTextMessage(QString message)
|
||||
else if (json.value("type").toString() == "reply_begin_game")
|
||||
{
|
||||
started = 1;
|
||||
w->openROM(file_name, webSocket->peerAddress().toString(), room_port, player_number);
|
||||
w->openROM(file_name, webSocket->peerAddress().toString(), room_port, player_number, cheats);
|
||||
accept();
|
||||
}
|
||||
else if (json.value("type").toString() == "reply_motd")
|
||||
|
||||
@@ -25,6 +25,7 @@ private slots:
|
||||
void updatePing(quint64 elapsedTime, const QByteArray &payload);
|
||||
void sendPing();
|
||||
private:
|
||||
QJsonObject cheats;
|
||||
QWebSocket *webSocket = nullptr;
|
||||
QLabel *pName[4];
|
||||
QPlainTextEdit *chatWindow;
|
||||
|
||||
@@ -46,7 +46,7 @@ static void paramListCallback(void *context, const char *ParamName, m64p_type Pa
|
||||
helper.append("</span>");
|
||||
desc->setToolTip(helper);
|
||||
}
|
||||
desc->setStyleSheet("border: 1px solid; padding: 10px");
|
||||
desc->setStyleSheet("padding: 10px");
|
||||
my_layout->addWidget(desc, *my_row, 0);
|
||||
void *my_Widget = nullptr;
|
||||
switch (ParamType) {
|
||||
@@ -75,7 +75,7 @@ static void paramListCallback(void *context, const char *ParamName, m64p_type Pa
|
||||
((CustomCheckBox*)my_Widget)->setConfigHandle(current_handle);
|
||||
((CustomCheckBox*)my_Widget)->setParamType(ParamType);
|
||||
((CustomCheckBox*)my_Widget)->setParamName(ParamName);
|
||||
((CustomCheckBox*)my_Widget)->setStyleSheet("border: 1px solid; padding: 10px");
|
||||
((CustomCheckBox*)my_Widget)->setStyleSheet("padding: 10px");
|
||||
l_ParamBool = (*ConfigGetParamBool)(current_handle, ParamName);
|
||||
((CustomCheckBox*)my_Widget)->setCheckState(l_ParamBool ? Qt::Checked : Qt::Unchecked);
|
||||
break;
|
||||
@@ -159,7 +159,7 @@ PluginDialog::PluginDialog(QWidget *parent)
|
||||
mainLayout->addWidget(tabWidget);
|
||||
QPushButton *resetButton = new QPushButton("Reset All Settings", this);
|
||||
resetButton->setAutoDefault(false);
|
||||
connect(resetButton, SIGNAL (released()),this, SLOT (handleResetButton()));
|
||||
connect(resetButton, &QPushButton::released,this, &PluginDialog::handleResetButton);
|
||||
mainLayout->addWidget(resetButton);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ void SettingsDialog::initStuff()
|
||||
configPath = new QLineEdit(this);
|
||||
configPath->setText(w->getSettings()->value("configDirPath").toString());
|
||||
QPushButton *configButton = new QPushButton("Set Path", this);
|
||||
connect(configButton, SIGNAL (released()),this, SLOT (handleConfigButton()));
|
||||
connect(configPath, SIGNAL (editingFinished()),this, SLOT (handleConfigEdit()));
|
||||
connect(configButton, &QPushButton::released,this, &SettingsDialog::handleConfigButton);
|
||||
connect(configPath, &QLineEdit::editingFinished,this, &SettingsDialog::handleConfigEdit);
|
||||
QPushButton *appPathButton = new QPushButton("Use Application Path", this);
|
||||
connect(appPathButton, SIGNAL (released()),this, SLOT (handleAppPathButton()));
|
||||
connect(appPathButton, &QPushButton::released,this, &SettingsDialog::handleAppPathButton);
|
||||
QPushButton *clearConfigButton = new QPushButton("Clear", this);
|
||||
connect(clearConfigButton, SIGNAL (released()),this, SLOT (handleClearConfigButton()));
|
||||
connect(clearConfigButton, &QPushButton::released,this, &SettingsDialog::handleClearConfigButton);
|
||||
configPath->setStyleSheet("border: 1px solid; padding: 10px");
|
||||
layout->addWidget(note,0,0,1,-1);
|
||||
layout->addWidget(configLabel,1,0);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QDBusInterface>
|
||||
#endif
|
||||
|
||||
WorkerThread::WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QObject *parent)
|
||||
WorkerThread::WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QJsonObject _cheats, QObject *parent)
|
||||
: QThread(parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -18,19 +18,21 @@ WorkerThread::WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_
|
||||
netplay_ip = _netplay_ip;
|
||||
netplay_port = _netplay_port;
|
||||
netplay_player = _netplay_player;
|
||||
cheats = _cheats;
|
||||
}
|
||||
|
||||
void WorkerThread::run()
|
||||
{
|
||||
connect(this, SIGNAL(resizeMainWindow(int,int)), w, SLOT(resizeMainWindow(int, int)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(toggleFS(int)), w, SLOT(toggleFS(int)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(createVkWindow(QVulkanInstance*)), w, SLOT(createVkWindow(QVulkanInstance*)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(deleteVkWindow()), w, SLOT(deleteVkWindow()), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(showMessage(QString)), w, SLOT(showMessage(QString)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(updateDiscordActivity(struct DiscordActivity)), w, SLOT(updateDiscordActivity(struct DiscordActivity)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(clearDiscordActivity()), w, SLOT(clearDiscordActivity()), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(addLog(QString)), w->getLogViewer(), SLOT(addLog(QString)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(addFrameCount()), w, SLOT(addFrameCount()), Qt::QueuedConnection);
|
||||
connect(this, &WorkerThread::resizeMainWindow, w, &MainWindow::resizeMainWindow, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::toggleFS, w, &MainWindow::toggleFS, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::createVkWindow, w, &MainWindow::createVkWindow, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::deleteVkWindow, w, &MainWindow::deleteVkWindow, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::showMessage, w, &MainWindow::showMessage, Qt::QueuedConnection);
|
||||
connect(this, &WorkerThread::updateDiscordActivity, w, &MainWindow::updateDiscordActivity, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::clearDiscordActivity, w, &MainWindow::clearDiscordActivity, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::setCheats, w, &MainWindow::setCheats, Qt::BlockingQueuedConnection);
|
||||
connect(this, &WorkerThread::addLog, w->getLogViewer(), &LogViewer::addLog, Qt::QueuedConnection);
|
||||
connect(this, &WorkerThread::addFrameCount, w, &MainWindow::addFrameCount, Qt::QueuedConnection);
|
||||
#ifdef _WIN32
|
||||
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||
#else
|
||||
@@ -63,6 +65,8 @@ void WorkerThread::run()
|
||||
strncpy(activity.details, rom_settings.goodname, 128);
|
||||
emit updateDiscordActivity(activity);
|
||||
|
||||
emit setCheats(cheats, netplay_port > 0);
|
||||
|
||||
res = launchGame(netplay_ip, netplay_port, netplay_player);
|
||||
|
||||
emit clearDiscordActivity();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <QVulkanInstance>
|
||||
#include <QJsonObject>
|
||||
#include "interface/common.h"
|
||||
#include "discord/discord_game_sdk.h"
|
||||
|
||||
@@ -14,7 +15,7 @@ class WorkerThread
|
||||
Q_OBJECT
|
||||
void run() Q_DECL_OVERRIDE;
|
||||
public:
|
||||
explicit WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QObject *parent = 0);
|
||||
explicit WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QJsonObject _cheats, QObject *parent = 0);
|
||||
void setFileName(QString filename);
|
||||
signals:
|
||||
void resizeMainWindow(int Width, int Height);
|
||||
@@ -26,10 +27,12 @@ signals:
|
||||
void clearDiscordActivity();
|
||||
void addLog(QString text);
|
||||
void addFrameCount();
|
||||
void setCheats(QJsonObject cheatsData, bool netplay);
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QString netplay_ip;
|
||||
QJsonObject cheats;
|
||||
int netplay_port;
|
||||
int netplay_player;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user