Skip to content

Commit 25b1e62

Browse files
committed
UI portion of Spectator button implemented; no functionality yet
1 parent 591661a commit 25b1e62

File tree

9 files changed

+26
-2
lines changed

9 files changed

+26
-2
lines changed

Source/Core/Core/Config/NetplaySettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const Info<u32> NETPLAY_MINIMUM_BUFFER_SIZE{{System::Main, "NetPlay", "MinimumBu
4747
const Info<u32> NETPLAY_PLAYER_BUFFER_SIZE{{System::Main, "NetPlay", "PlayerBufferSize"}, 2};
4848
const Info<u32> NETPLAY_CLIENT_BUFFER_SIZE{{System::Main, "NetPlay", "BufferSizeClient"}, 1};
4949

50+
const Info<bool> NETPLAY_IS_SPECTATOR{{System::Main, "NetPlay", "IsSpectator"}, false};
5051
const Info<bool> NETPLAY_BRAWL_MUSIC_OFF{{System::Main, "NetPlay", "BrawlMusicOff"}, false};
5152

5253
const Info<bool> NETPLAY_SAVEDATA_LOAD{{System::Main, "NetPlay", "SyncSaves"}, true};

Source/Core/Core/Config/NetplaySettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern const Info<u32> NETPLAY_MINIMUM_BUFFER_SIZE;
4343
extern const Info<u32> NETPLAY_PLAYER_BUFFER_SIZE;
4444
extern const Info<u32> NETPLAY_CLIENT_BUFFER_SIZE;
4545

46+
extern const Info<bool> NETPLAY_IS_SPECTATOR;
4647
extern const Info<bool> NETPLAY_BRAWL_MUSIC_OFF;
4748

4849
extern const Info<bool> NETPLAY_SAVEDATA_LOAD;

Source/Core/Core/ConfigManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct SConfig
5050
bool bJITNoBlockLinking = false;
5151

5252
bool bCopyWiiSaveNetplay = true;
53+
bool bIsSpectator = true;
5354
bool bBrawlMusicOff = true;
5455

5556
DiscIO::Region m_region;

Source/Core/Core/NetPlayClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ void NetPlayClient::OnStartGame(sf::Packet& packet)
906906
packet >> m_net_settings.allow_sd_writes;
907907
packet >> m_net_settings.oc_enable;
908908
packet >> m_net_settings.oc_factor;
909+
packet >> m_net_settings.is_spectator;
909910
packet >> m_net_settings.brawlmusic_off;
910911

911912
for (auto slot : ExpansionInterface::SLOTS)

Source/Core/Core/NetPlayClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class NetPlayUI
7676
virtual void OnTtlDetermined(u8 ttl) = 0;
7777

7878
virtual bool IsRecording() = 0;
79+
virtual bool IsSpectator() = 0;
7980
virtual bool IsMusicOff() = 0;
8081
virtual std::shared_ptr<const UICommon::GameFile>
8182
FindGameFile(const SyncIdentifier& sync_identifier,

Source/Core/Core/NetPlayProto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct NetSettings
4747
bool allow_sd_writes = false;
4848
bool oc_enable = false;
4949
float oc_factor = 0;
50+
bool is_spectator = false;
5051
bool brawlmusic_off = false;
5152
Common::EnumMap<ExpansionInterface::EXIDeviceType, ExpansionInterface::MAX_SLOT> exi_device{};
5253
int memcard_size_override = -1;

Source/Core/Core/NetPlayServer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ bool NetPlayServer::SetupNetSettings()
14551455
settings.golf_mode = Config::Get(Config::NETPLAY_NETWORK_MODE) == "golf";
14561456
settings.use_fma = DoAllPlayersHaveHardwareFMA();
14571457
settings.hide_remote_gbas = Config::Get(Config::NETPLAY_HIDE_REMOTE_GBAS);
1458+
settings.is_spectator = Config::Get(Config::NETPLAY_IS_SPECTATOR);
14581459
settings.brawlmusic_off = Config::Get(Config::NETPLAY_BRAWL_MUSIC_OFF);
14591460

14601461
// Unload GameINI to restore things to normal
@@ -1601,6 +1602,7 @@ bool NetPlayServer::StartGame()
16011602
spac << m_settings.allow_sd_writes;
16021603
spac << m_settings.oc_enable;
16031604
spac << m_settings.oc_factor;
1605+
spac << m_settings.is_spectator;
16041606
spac << m_settings.brawlmusic_off;
16051607

16061608
for (auto slot : ExpansionInterface::SLOTS)

Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void NetPlayDialog::CreateMainLayout()
139139
m_player_buffer_size_box = new QSpinBox;
140140
m_player_buffer_label = new QLabel(tr("Player Buffer:"));
141141
m_quit_button = new QPushButton(tr("Quit"));
142+
m_is_spectator = new QCheckBox(tr("Spectator"));
142143
m_brawlmusic_off = new QCheckBox(tr("Client Side Music Off"));
143144
m_splitter = new QSplitter(Qt::Horizontal);
144145
m_menu_bar = new QMenuBar(this);
@@ -266,8 +267,9 @@ void NetPlayDialog::CreateMainLayout()
266267
options_widget->addWidget(m_minimum_buffer_size_box, 0, 2, Qt::AlignVCenter);
267268
options_widget->addWidget(m_player_buffer_label, 0, 3, Qt::AlignVCenter);
268269
options_widget->addWidget(m_player_buffer_size_box, 0, 4, Qt::AlignVCenter);
269-
options_widget->addWidget(m_brawlmusic_off, 0, 6, Qt::AlignVCenter);
270-
options_widget->addWidget(m_quit_button, 0, 7, Qt::AlignVCenter | Qt::AlignRight);
270+
options_widget->addWidget(m_is_spectator, 0, 6, Qt::AlignVCenter);
271+
options_widget->addWidget(m_brawlmusic_off, 0, 7, Qt::AlignVCenter);
272+
options_widget->addWidget(m_quit_button, 0, 8, Qt::AlignVCenter | Qt::AlignRight);
271273
options_widget->setColumnStretch(5, 1000);
272274

273275
m_main_layout->addLayout(options_widget, 2, 0, 1, -1, Qt::AlignRight);
@@ -461,6 +463,14 @@ void NetPlayDialog::SendMessage(const std::string& msg)
461463
"");
462464
}
463465

466+
bool NetPlayDialog::IsSpectator()
467+
{
468+
std::optional<bool> is_spectator = RunOnObject(m_is_spectator, &QCheckBox::isChecked);
469+
if (is_spectator)
470+
return *is_spectator;
471+
return false;
472+
}
473+
464474
bool NetPlayDialog::IsMusicOff()
465475
{
466476
std::optional<bool> brawlmusic_off = RunOnObject(m_brawlmusic_off, &QCheckBox::isChecked);
@@ -903,6 +913,7 @@ void NetPlayDialog::SetOptionsEnabled(bool enabled)
903913
m_host_input_authority_action->setEnabled(enabled);
904914
m_golf_mode_action->setEnabled(enabled);
905915
m_fixed_delay_action->setEnabled(enabled);
916+
m_is_spectator->setEnabled(enabled);
906917
m_brawlmusic_off->setEnabled(enabled);
907918
}
908919

@@ -1190,6 +1201,7 @@ void NetPlayDialog::LoadSettings()
11901201
const bool strict_settings_sync = Config::Get(Config::NETPLAY_STRICT_SETTINGS_SYNC);
11911202
const bool golf_mode_overlay = Config::Get(Config::NETPLAY_GOLF_MODE_OVERLAY);
11921203
const bool hide_remote_gbas = Config::Get(Config::NETPLAY_HIDE_REMOTE_GBAS);
1204+
const bool is_spectator = Config::Get(Config::NETPLAY_IS_SPECTATOR);
11931205
const bool brawlmusic_off = Config::Get(Config::NETPLAY_BRAWL_MUSIC_OFF);
11941206

11951207
m_minimum_buffer_size_box->setValue(minimum_buffer_size);
@@ -1209,6 +1221,7 @@ void NetPlayDialog::LoadSettings()
12091221
m_golf_mode_overlay_action->setChecked(golf_mode_overlay);
12101222
m_hide_remote_gbas_action->setChecked(hide_remote_gbas);
12111223

1224+
m_is_spectator->setChecked(is_spectator);
12121225
m_brawlmusic_off->setChecked(brawlmusic_off);
12131226

12141227
const std::string network_mode = Config::Get(Config::NETPLAY_NETWORK_MODE);
@@ -1253,6 +1266,7 @@ void NetPlayDialog::SaveSettings()
12531266
Config::SetBase(Config::NETPLAY_STRICT_SETTINGS_SYNC, m_strict_settings_sync_action->isChecked());
12541267
Config::SetBase(Config::NETPLAY_GOLF_MODE_OVERLAY, m_golf_mode_overlay_action->isChecked());
12551268
Config::SetBase(Config::NETPLAY_HIDE_REMOTE_GBAS, m_hide_remote_gbas_action->isChecked());
1269+
Config::SetBase(Config::NETPLAY_IS_SPECTATOR, m_is_spectator->isChecked());
12561270
Config::SetBase(Config::NETPLAY_BRAWL_MUSIC_OFF, m_brawlmusic_off->isChecked());
12571271

12581272
std::string network_mode;

Source/Core/DolphinQt/NetPlay/NetPlayDialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
7979
void OnIndexRefreshFailed(const std::string error) override;
8080

8181
bool IsRecording() override;
82+
bool IsSpectator() override;
8283
bool IsMusicOff() override;
8384
std::shared_ptr<const UICommon::GameFile>
8485
FindGameFile(const NetPlay::SyncIdentifier& sync_identifier,
@@ -164,6 +165,7 @@ class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
164165
QAction* m_fixed_delay_action;
165166
QAction* m_hide_remote_gbas_action;
166167
QCheckBox* m_brawlmusic_off;
168+
QCheckBox* m_is_spectator;
167169
QPushButton* m_quit_button;
168170
QSplitter* m_splitter;
169171
QActionGroup* m_network_mode_group;

0 commit comments

Comments
 (0)