mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-25 19:55:50 +00:00
pull in f84543e623
This commit is contained in:
parent
afd49eb275
commit
ab52be176e
8 changed files with 83 additions and 23 deletions
|
@ -549,7 +549,7 @@ void SConfig::LoadSlippiSettings(IniFile& ini)
|
|||
slippi->Get("PlaybackControls", &m_slippiEnableSeek, true);
|
||||
slippi->Get("OnlineDelay", &m_slippiOnlineDelay, 2);
|
||||
slippi->Get("SaveReplays", &m_slippiSaveReplays, true);
|
||||
slippi->Get("EnableQuickChat", &m_slippiEnableQuickChat, true);
|
||||
slippi->Get("EnableQuickChat", &m_slippiEnableQuickChat, Slippi::Chat::ON);
|
||||
slippi->Get("ReplayMonthFolders", &m_slippiReplayMonthFolders, true);
|
||||
std::string default_replay_dir = File::GetHomeDirectory() + DIR_SEP + "Slippi";
|
||||
slippi->Get("ReplayDir", &m_strSlippiReplayDir, default_replay_dir);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <future>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -58,6 +59,22 @@ enum class Version
|
|||
};
|
||||
}
|
||||
|
||||
namespace Slippi
|
||||
{
|
||||
enum Chat
|
||||
{
|
||||
ON,
|
||||
DIRECT_ONLY,
|
||||
OFF
|
||||
};
|
||||
}
|
||||
|
||||
static std::map<Slippi::Chat, std::string> quickChatOptions = {
|
||||
{Slippi::Chat::ON, "Enabled"},
|
||||
{Slippi::Chat::DIRECT_ONLY, "Direct Only"},
|
||||
{Slippi::Chat::OFF, "Disabled"},
|
||||
};
|
||||
|
||||
struct BootParameters;
|
||||
|
||||
// DSP Backend Types
|
||||
|
@ -169,7 +186,7 @@ struct SConfig
|
|||
int m_slippiOnlineDelay = 2;
|
||||
bool m_slippiEnableSeek = true;
|
||||
bool m_slippiSaveReplays = true;
|
||||
bool m_slippiEnableQuickChat = true;
|
||||
Slippi::Chat m_slippiEnableQuickChat = Slippi::Chat::ON;
|
||||
bool m_slippiReplayMonthFolders = true;
|
||||
std::string m_strSlippiReplayDir;
|
||||
bool m_blockingPipes = false;
|
||||
|
|
|
@ -2347,11 +2347,12 @@ void CEXISlippi::prepareOnlineMatchState()
|
|||
if (slippi_netplay)
|
||||
{
|
||||
auto isSingleMode = matchmaking && matchmaking->RemotePlayerCount() == 1;
|
||||
sentChatMessageId = slippi_netplay->GetSlippiRemoteSentChatMessage();
|
||||
bool isChatEnabled = isSlippiChatEnabled();
|
||||
sentChatMessageId = slippi_netplay->GetSlippiRemoteSentChatMessage(isChatEnabled);
|
||||
// Prevent processing a message in the same frame
|
||||
if (sentChatMessageId <= 0)
|
||||
{
|
||||
auto remoteMessageSelection = slippi_netplay->GetSlippiRemoteChatMessage();
|
||||
auto remoteMessageSelection = slippi_netplay->GetSlippiRemoteChatMessage(isChatEnabled);
|
||||
chatMessageId = remoteMessageSelection.messageId;
|
||||
chatMessagePlayerIdx = remoteMessageSelection.playerIdx;
|
||||
if (chatMessageId == SlippiPremadeText::CHAT_MSG_CHAT_DISABLED && !isSingleMode)
|
||||
|
@ -2858,8 +2859,27 @@ void CEXISlippi::preparePremadeTextLoad(u8* payload)
|
|||
m_read_queue.insert(m_read_queue.end(), premadeTextData.begin(), premadeTextData.end());
|
||||
}
|
||||
|
||||
bool CEXISlippi::isSlippiChatEnabled()
|
||||
{
|
||||
auto chatEnabledChoice = SConfig::GetInstance().m_slippiEnableQuickChat;
|
||||
bool res = true;
|
||||
switch (lastSearch.mode)
|
||||
{
|
||||
case SlippiMatchmaking::DIRECT:
|
||||
res = chatEnabledChoice == Slippi::Chat::ON || chatEnabledChoice == Slippi::Chat::DIRECT_ONLY;
|
||||
break;
|
||||
default:
|
||||
res = chatEnabledChoice == Slippi::Chat::ON;
|
||||
break;
|
||||
}
|
||||
return res; // default is enabled
|
||||
}
|
||||
|
||||
void CEXISlippi::handleChatMessage(u8* payload)
|
||||
{
|
||||
if (!isSlippiChatEnabled())
|
||||
return;
|
||||
|
||||
int messageId = payload[0];
|
||||
INFO_LOG(SLIPPI, "SLIPPI CHAT INPUT: 0x%x", messageId);
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ private:
|
|||
void prepareIsFileReady();
|
||||
|
||||
// misc stuff
|
||||
bool isSlippiChatEnabled();
|
||||
void handleChatMessage(u8* payload);
|
||||
void logMessageFromGame(u8* payload);
|
||||
void prepareFileLength(u8* payload);
|
||||
|
|
|
@ -416,16 +416,7 @@ unsigned int SlippiNetplayClient::OnData(sf::Packet& packet, ENetPeer* peer)
|
|||
auto playerSelection = ReadChatMessageFromPacket(packet);
|
||||
INFO_LOG_FMT(SLIPPI_ONLINE, "[Netplay] Received chat message from opponent {}: {}",
|
||||
playerSelection->playerIdx, playerSelection->messageId);
|
||||
// if chat is not enabled, automatically send back a message saying so
|
||||
if (!SConfig::GetInstance().m_slippiEnableQuickChat)
|
||||
{
|
||||
auto chat_packet = std::make_unique<sf::Packet>();
|
||||
remoteSentChatMessageId = SlippiPremadeText::CHAT_MSG_CHAT_DISABLED;
|
||||
WriteChatMessageToPacket(*chat_packet, remoteSentChatMessageId, LocalPlayerPort());
|
||||
SendAsync(std::move(chat_packet));
|
||||
remoteSentChatMessageId = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!playerSelection->error)
|
||||
{
|
||||
// set message id to netplay instance
|
||||
|
@ -504,6 +495,7 @@ SlippiNetplayClient::ReadChatMessageFromPacket(sf::Packet& packet)
|
|||
case 18:
|
||||
case 20:
|
||||
case 17:
|
||||
case SlippiPremadeText::CHAT_MSG_CHAT_DISABLED: // Opponent Chat Message Disabled
|
||||
{
|
||||
// Good message ID. Do nothing
|
||||
break;
|
||||
|
@ -1077,11 +1069,11 @@ void SlippiNetplayClient::SetMatchSelections(SlippiPlayerSelections& s)
|
|||
SendAsync(std::move(spac));
|
||||
}
|
||||
|
||||
SlippiPlayerSelections SlippiNetplayClient::GetSlippiRemoteChatMessage()
|
||||
SlippiPlayerSelections SlippiNetplayClient::GetSlippiRemoteChatMessage(bool isChatEnabled)
|
||||
{
|
||||
SlippiPlayerSelections copiedSelection = SlippiPlayerSelections();
|
||||
|
||||
if (remoteChatMessageSelection != nullptr && SConfig::GetInstance().m_slippiEnableQuickChat)
|
||||
if (remoteChatMessageSelection != nullptr && isChatEnabled)
|
||||
{
|
||||
copiedSelection.messageId = remoteChatMessageSelection->messageId;
|
||||
copiedSelection.playerIdx = remoteChatMessageSelection->playerIdx;
|
||||
|
@ -1094,13 +1086,30 @@ SlippiPlayerSelections SlippiNetplayClient::GetSlippiRemoteChatMessage()
|
|||
{
|
||||
copiedSelection.messageId = 0;
|
||||
copiedSelection.playerIdx = 0;
|
||||
// if chat is not enabled, automatically send back a message saying so.
|
||||
if (remoteChatMessageSelection != nullptr && !isChatEnabled &&
|
||||
(remoteChatMessageSelection->messageId > 0 &&
|
||||
remoteChatMessageSelection->messageId != SlippiPremadeText::CHAT_MSG_CHAT_DISABLED))
|
||||
{
|
||||
auto packet = std::make_unique<sf::Packet>();
|
||||
remoteSentChatMessageId = SlippiPremadeText::CHAT_MSG_CHAT_DISABLED;
|
||||
WriteChatMessageToPacket(*packet, remoteSentChatMessageId, LocalPlayerPort());
|
||||
SendAsync(std::move(packet));
|
||||
remoteSentChatMessageId = 0;
|
||||
remoteChatMessageSelection = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return copiedSelection;
|
||||
}
|
||||
|
||||
u8 SlippiNetplayClient::GetSlippiRemoteSentChatMessage()
|
||||
u8 SlippiNetplayClient::GetSlippiRemoteSentChatMessage(bool isChatEnabled)
|
||||
{
|
||||
if (!isChatEnabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 copiedMessageId = remoteSentChatMessageId;
|
||||
remoteSentChatMessageId = 0; // Clear it out
|
||||
return copiedMessageId;
|
||||
|
|
|
@ -142,8 +142,8 @@ public:
|
|||
void DropOldRemoteInputs(int32_t finalizedFrame);
|
||||
SlippiMatchInfo* GetMatchInfo();
|
||||
int32_t GetSlippiLatestRemoteFrame(int maxFrameCount);
|
||||
SlippiPlayerSelections GetSlippiRemoteChatMessage();
|
||||
u8 GetSlippiRemoteSentChatMessage();
|
||||
SlippiPlayerSelections GetSlippiRemoteChatMessage(bool isChatEnabled);
|
||||
u8 GetSlippiRemoteSentChatMessage(bool isChatEnabled);
|
||||
s32 CalcTimeOffsetUs();
|
||||
|
||||
void WriteChatMessageToPacket(sf::Packet& packet, int messageId, u8 playerIdx);
|
||||
|
|
|
@ -88,8 +88,7 @@ void ControllersWindow::CreateGamecubeLayout()
|
|||
auto* gc_button = m_gc_buttons[i] = new QPushButton(tr("Configure"));
|
||||
|
||||
for (const auto& item :
|
||||
{tr("None"), tr("Standard Controller"), tr("GameCube Adapter for Wii U"),
|
||||
tr("Steering Wheel"), tr("Dance Mat"), tr("DK Bongos"), tr("GBA"), tr("Keyboard")})
|
||||
{tr("None"), tr("Standard Controller"), tr("GameCube Adapter for Wii U")})
|
||||
{
|
||||
gc_box->addItem(item);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "DolphinQt/Settings/SlippiPane.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
|
@ -82,6 +83,19 @@ void SlippiPane::CreateLayout()
|
|||
connect(delay_spin, qOverload<int>(&QSpinBox::valueChanged), this,
|
||||
[](int delay) { SConfig::GetInstance().m_slippiOnlineDelay = delay; });
|
||||
|
||||
auto* netplay_quick_chat_combo = new QComboBox();
|
||||
for (const auto& item : {tr("Enabled"), tr("Direct Only"), tr("Off")})
|
||||
{
|
||||
netplay_quick_chat_combo->addItem(item);
|
||||
}
|
||||
connect(netplay_quick_chat_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
[](int index) {
|
||||
SConfig::GetInstance().m_slippiEnableQuickChat = static_cast<Slippi::Chat>(index);
|
||||
});
|
||||
netplay_quick_chat_combo->setCurrentIndex(SConfig::GetInstance().m_slippiEnableQuickChat);
|
||||
|
||||
online_settings_layout->addRow(tr("Quick Chat:"), netplay_quick_chat_combo);
|
||||
|
||||
// i'd like to note that I hate everything about how this is organized for the next two sections
|
||||
// and a lot of the Qstring bullshit drives me up the wall.
|
||||
auto* netplay_port_spin = new QSpinBox();
|
||||
|
@ -95,7 +109,7 @@ void SlippiPane::CreateLayout()
|
|||
{
|
||||
netplay_port_spin->hide();
|
||||
}
|
||||
auto* enable_force_netplay_port_checkbox = new QCheckBox(tr("Force Netplay Port:"));
|
||||
auto* enable_force_netplay_port_checkbox = new QCheckBox(tr("Force Netplay Port"));
|
||||
enable_force_netplay_port_checkbox->setToolTip(
|
||||
tr("Enable this to force Slippi to use a specific network port for online peer-to-peer "
|
||||
"connections."));
|
||||
|
@ -130,7 +144,7 @@ void SlippiPane::CreateLayout()
|
|||
{
|
||||
netplay_ip_edit->hide();
|
||||
}
|
||||
auto* enable_force_netplay_ip_checkbox = new QCheckBox(tr("Force Netplay IP:"));
|
||||
auto* enable_force_netplay_ip_checkbox = new QCheckBox(tr("Force Netplay IP"));
|
||||
enable_force_netplay_ip_checkbox->setToolTip(
|
||||
tr("Enable this to force Slippi to use a specific LAN IP when connecting to users with a "
|
||||
"matching WAN IP. Should not be required for most users."));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue