Qt/GamecubeControllersWidget: Disable dropdowns during netplay.

This commit is contained in:
Admiral H. Curtiss 2022-09-20 05:16:29 +02:00
parent 15393f0344
commit 37ae9ab524
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 14 additions and 4 deletions

View File

@ -18,6 +18,7 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/SI/SI.h" #include "Core/HW/SI/SI.h"
#include "Core/HW/SI/SI_Device.h" #include "Core/HW/SI/SI_Device.h"
#include "Core/NetPlayProto.h"
#include "DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.h" #include "DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h" #include "DolphinQt/Config/Mapping/MappingWindow.h"
@ -60,11 +61,13 @@ static SerialInterface::SIDevices FromGCMenuIndex(const int menudevice)
GamecubeControllersWidget::GamecubeControllersWidget(QWidget* parent) : QWidget(parent) GamecubeControllersWidget::GamecubeControllersWidget(QWidget* parent) : QWidget(parent)
{ {
CreateLayout(); CreateLayout();
LoadSettings();
ConnectWidgets(); ConnectWidgets();
connect(&Settings::Instance(), &Settings::ConfigChanged, this, connect(&Settings::Instance(), &Settings::ConfigChanged, this,
&GamecubeControllersWidget::LoadSettings); [this] { LoadSettings(Core::GetState()); });
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[this](Core::State state) { LoadSettings(state); });
LoadSettings(Core::GetState());
} }
void GamecubeControllersWidget::CreateLayout() void GamecubeControllersWidget::CreateLayout()
@ -160,8 +163,9 @@ void GamecubeControllersWidget::OnGCPadConfigure(size_t index)
window->show(); window->show();
} }
void GamecubeControllersWidget::LoadSettings() void GamecubeControllersWidget::LoadSettings(Core::State state)
{ {
const bool running = state != Core::State::Uninitialized;
for (size_t i = 0; i < m_gc_groups.size(); i++) for (size_t i = 0; i < m_gc_groups.size(); i++)
{ {
const SerialInterface::SIDevices si_device = const SerialInterface::SIDevices si_device =
@ -170,6 +174,7 @@ void GamecubeControllersWidget::LoadSettings()
if (gc_index) if (gc_index)
{ {
SignalBlocking(m_gc_controller_boxes[i])->setCurrentIndex(*gc_index); SignalBlocking(m_gc_controller_boxes[i])->setCurrentIndex(*gc_index);
m_gc_controller_boxes[i]->setEnabled(NetPlay::IsNetPlayRunning() ? !running : true);
OnGCTypeChanged(i); OnGCTypeChanged(i);
} }
} }

View File

@ -13,6 +13,11 @@ class QGridLayout;
class QGroupBox; class QGroupBox;
class QPushButton; class QPushButton;
namespace Core
{
enum class State;
}
class GamecubeControllersWidget final : public QWidget class GamecubeControllersWidget final : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,7 +25,7 @@ public:
explicit GamecubeControllersWidget(QWidget* parent); explicit GamecubeControllersWidget(QWidget* parent);
private: private:
void LoadSettings(); void LoadSettings(Core::State state);
void SaveSettings(); void SaveSettings();
void OnGCTypeChanged(size_t index); void OnGCTypeChanged(size_t index);