mirror of
https://github.com/simple64/simple64.git
synced 2026-09-11 14:52:44 +02:00
update gui
This commit is contained in:
@@ -10,7 +10,7 @@ endif()
|
||||
|
||||
include_directories(../mupen64plus-core/src/api)
|
||||
|
||||
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x0602ff -DNETPLAY_VER=16)
|
||||
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x0602ff -DNETPLAY_VER=17)
|
||||
|
||||
if(DEFINED ENV{NETPLAY_AUTH_CODE})
|
||||
add_definitions(-DNETPLAY_AUTH_CODE="$ENV{NETPLAY_AUTH_CODE}")
|
||||
|
||||
@@ -116,7 +116,7 @@ CheatsCheckBox::CheatsCheckBox(QString _game, QString _cheat, QWidget *parent)
|
||||
m_group->setExclusive(true);
|
||||
} });
|
||||
|
||||
connect(this, &QCheckBox::stateChanged, [=](int state)
|
||||
connect(this, &QCheckBox::checkStateChanged, [=](Qt::CheckState state)
|
||||
{
|
||||
QString prefix = "Cheats/" + m_game + "/" + m_cheatName + "/";
|
||||
if (m_optionName != "")
|
||||
|
||||
@@ -168,12 +168,13 @@ void CreateRoom::createRoom()
|
||||
{
|
||||
connectionTimer->stop();
|
||||
QJsonObject json;
|
||||
QJsonObject room;
|
||||
room.insert("room_name", nameEdit->text());
|
||||
room.insert("password", passwordEdit->text());
|
||||
room.insert("MD5", QString(rom_settings.MD5));
|
||||
room.insert("game_name", QString(rom_settings.goodname));
|
||||
json.insert("type", "request_create_room");
|
||||
json.insert("room_name", nameEdit->text());
|
||||
json.insert("player_name", playerNameEdit->text());
|
||||
json.insert("password", passwordEdit->text());
|
||||
json.insert("MD5", QString(rom_settings.MD5));
|
||||
json.insert("game_name", QString(rom_settings.goodname));
|
||||
json.insert("client_sha", QStringLiteral(GUI_VERSION));
|
||||
json.insert("netplay_version", NETPLAY_VER);
|
||||
|
||||
@@ -185,9 +186,10 @@ void CreateRoom::createRoom()
|
||||
QJsonDocument cheatsDoc(cheats);
|
||||
QJsonObject features;
|
||||
features.insert("cheats", QString(cheatsDoc.toJson(QJsonDocument::Compact)));
|
||||
json.insert("features", features);
|
||||
room.insert("features", features);
|
||||
}
|
||||
|
||||
json.insert("room", room);
|
||||
addAuthData(webSocket, &json);
|
||||
|
||||
QJsonDocument json_doc(json);
|
||||
|
||||
@@ -171,12 +171,14 @@ void JoinRoom::joinGame()
|
||||
|
||||
joinButton->setEnabled(false);
|
||||
QJsonObject json;
|
||||
QJsonObject room;
|
||||
json.insert("type", "request_join_room");
|
||||
json.insert("player_name", playerNameEdit->text());
|
||||
json.insert("password", passwordEdit->text());
|
||||
json.insert("client_sha", QStringLiteral(GUI_VERSION));
|
||||
json.insert("MD5", QString(rom_settings.MD5));
|
||||
json.insert("port", room_port);
|
||||
room.insert("password", passwordEdit->text());
|
||||
room.insert("MD5", QString(rom_settings.MD5));
|
||||
room.insert("port", room_port);
|
||||
json.insert("room", room);
|
||||
|
||||
QJsonDocument json_doc(json);
|
||||
webSocket->sendTextMessage(json_doc.toJson());
|
||||
@@ -276,34 +278,38 @@ void JoinRoom::processTextMessage(QString message)
|
||||
if (json.value("accept").toInt() == 0)
|
||||
{
|
||||
json.remove("type");
|
||||
rooms << json;
|
||||
QJsonArray room_list = json.value("rooms").toArray();
|
||||
for (int i = 0; i < room_list.size(); ++i)
|
||||
{
|
||||
rooms << room_list.at(i).toObject();
|
||||
|
||||
listWidget->insertRow(row);
|
||||
QTableWidgetItem *newItem = new QTableWidgetItem(json.value("room_name").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 0, newItem);
|
||||
newItem = new QTableWidgetItem(json.value("game_name").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 1, newItem);
|
||||
newItem = new QTableWidgetItem(json.value("MD5").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 2, newItem);
|
||||
listWidget->insertRow(row);
|
||||
QTableWidgetItem *newItem = new QTableWidgetItem(room_list.at(i).toObject().value("room_name").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 0, newItem);
|
||||
newItem = new QTableWidgetItem(room_list.at(i).toObject().value("game_name").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 1, newItem);
|
||||
newItem = new QTableWidgetItem(room_list.at(i).toObject().value("MD5").toString());
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 2, newItem);
|
||||
|
||||
QString protectedValue = "No";
|
||||
if (json.value("protected").toBool())
|
||||
protectedValue = "Yes";
|
||||
newItem = new QTableWidgetItem(protectedValue);
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
listWidget->setItem(row, 3, newItem);
|
||||
QString protectedValue = "No";
|
||||
if (room_list.at(i).toObject().value("protected").toBool())
|
||||
protectedValue = "Yes";
|
||||
newItem = new QTableWidgetItem(protectedValue);
|
||||
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);
|
||||
QString cheatsValue = "No";
|
||||
if (!room_list.at(i).toObject().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;
|
||||
++row;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
#include <QMessageBox>
|
||||
#include <QJsonArray>
|
||||
|
||||
WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidget *parent)
|
||||
WaitRoom::WaitRoom(QString filename, QJsonObject response, QWebSocket *socket, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
this->resize(640, 480);
|
||||
|
||||
QString cheats_string = room.value("features").toObject().value("cheats").toString();
|
||||
QString cheats_string = response.value("room").toObject().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();
|
||||
player_name = response.value("player_name").toString();
|
||||
room_port = response.value("room").toObject().value("port").toInt();
|
||||
room_name = response.value("room").toObject().value("room_name").toString();
|
||||
file_name = filename;
|
||||
started = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
|
||||
|
||||
QLabel *gameLabel = new QLabel("Game Name:", this);
|
||||
layout->addWidget(gameLabel, 1, 0);
|
||||
QLabel *gameName = new QLabel(room.value("game_name").toString(), this);
|
||||
QLabel *gameName = new QLabel(response.value("room").toObject().value("game_name").toString(), this);
|
||||
layout->addWidget(gameName, 1, 1);
|
||||
|
||||
QLabel *pingLabel = new QLabel("Your ping:", this);
|
||||
@@ -89,8 +89,10 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
|
||||
connect(this, &WaitRoom::finished, this, &WaitRoom::onFinished);
|
||||
|
||||
QJsonObject json;
|
||||
QJsonObject room;
|
||||
json.insert("type", "request_players");
|
||||
json.insert("port", room_port);
|
||||
room.insert("port", room_port);
|
||||
json.insert("room", room);
|
||||
QJsonDocument json_doc(json);
|
||||
webSocket->sendTextMessage(json_doc.toJson());
|
||||
|
||||
@@ -105,7 +107,7 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
|
||||
strcpy(assets.large_image, "6205049");
|
||||
strcpy(assets.large_text, "https://simple64.github.io");
|
||||
activity.assets = assets;
|
||||
strncpy(activity.details, room.value("game_name").toString().toUtf8().constData(), 128);
|
||||
strncpy(activity.details, response.value("room").toObject().value("game_name").toString().toUtf8().constData(), 128);
|
||||
strcpy(activity.state, "Netplay waiting room");
|
||||
w->updateDiscordActivity(activity);
|
||||
}
|
||||
@@ -116,7 +118,6 @@ void WaitRoom::sendPing()
|
||||
{
|
||||
QJsonObject json;
|
||||
json.insert("type", "request_motd");
|
||||
json.insert("room_name", room_name);
|
||||
QJsonDocument json_doc(json);
|
||||
webSocket->sendTextMessage(json_doc.toJson());
|
||||
}
|
||||
@@ -134,8 +135,10 @@ void WaitRoom::startGame()
|
||||
{
|
||||
startGameButton->setEnabled(false);
|
||||
QJsonObject json;
|
||||
QJsonObject room;
|
||||
json.insert("type", "request_begin_game");
|
||||
json.insert("port", room_port);
|
||||
room.insert("port", room_port);
|
||||
json.insert("room", room);
|
||||
QJsonDocument json_doc(json);
|
||||
webSocket->sendTextMessage(json_doc.toJson());
|
||||
}
|
||||
@@ -152,9 +155,11 @@ void WaitRoom::sendChat()
|
||||
if (!chatEdit->text().isEmpty())
|
||||
{
|
||||
QJsonObject json;
|
||||
QJsonObject room;
|
||||
json.insert("type", "request_chat_message");
|
||||
json.insert("port", room_port);
|
||||
json.insert("player_name", player_name);
|
||||
room.insert("port", room_port);
|
||||
json.insert("room", room);
|
||||
json.insert("message", chatEdit->text());
|
||||
QJsonDocument json_doc(json);
|
||||
webSocket->sendTextMessage(json_doc.toJson());
|
||||
|
||||
@@ -31,7 +31,7 @@ CustomLineEdit::CustomLineEdit(QWidget *parent)
|
||||
CustomCheckBox::CustomCheckBox(QWidget *parent)
|
||||
: QCheckBox(parent)
|
||||
{
|
||||
connect(this, &QCheckBox::stateChanged, [=](int state)
|
||||
connect(this, &QCheckBox::checkStateChanged, [=](Qt::CheckState state)
|
||||
{
|
||||
int value = state == Qt::Checked ? 1 : 0;
|
||||
(*ConfigSetParameter)(m_CurrentHandle, m_ParamName.toUtf8().constData(), m_ParamType, &value);
|
||||
|
||||
Reference in New Issue
Block a user