2017-07-21 20:48:21 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-07-21 20:48:21 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-11-20 18:59:14 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2017-07-21 20:48:21 +00:00
|
|
|
#include <QDialog>
|
2019-03-01 04:49:03 +00:00
|
|
|
#include <QMenuBar>
|
2017-07-21 20:48:21 +00:00
|
|
|
|
2018-11-15 05:58:07 +00:00
|
|
|
#include "Common/Lazy.h"
|
2017-07-21 20:48:21 +00:00
|
|
|
#include "Core/NetPlayClient.h"
|
2019-01-17 22:28:07 +00:00
|
|
|
#include "DolphinQt/GameList/GameListModel.h"
|
2017-07-21 20:48:21 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
|
|
|
|
2021-11-20 18:59:14 +00:00
|
|
|
class BootSessionData;
|
2018-10-18 08:33:05 +00:00
|
|
|
class ChunkedProgressDialog;
|
2022-07-28 01:43:16 +00:00
|
|
|
class GameDigestDialog;
|
2017-07-21 20:48:21 +00:00
|
|
|
class PadMappingDialog;
|
|
|
|
class QCheckBox;
|
|
|
|
class QComboBox;
|
|
|
|
class QGridLayout;
|
|
|
|
class QGroupBox;
|
|
|
|
class QLabel;
|
|
|
|
class QLineEdit;
|
|
|
|
class QPushButton;
|
|
|
|
class QSpinBox;
|
2018-05-10 17:38:58 +00:00
|
|
|
class QSplitter;
|
2018-05-12 13:13:30 +00:00
|
|
|
class QTableWidget;
|
2017-07-21 20:48:21 +00:00
|
|
|
class QTextEdit;
|
|
|
|
|
2018-07-06 23:39:42 +00:00
|
|
|
class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
|
2017-07-21 20:48:21 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-11-20 18:59:14 +00:00
|
|
|
using StartGameCallback = std::function<void(const std::string& path,
|
|
|
|
std::unique_ptr<BootSessionData> boot_session_data)>;
|
|
|
|
|
|
|
|
explicit NetPlayDialog(const GameListModel& game_list_model,
|
|
|
|
StartGameCallback start_game_callback, QWidget* parent = nullptr);
|
2018-05-10 17:38:58 +00:00
|
|
|
~NetPlayDialog();
|
2017-07-21 20:48:21 +00:00
|
|
|
|
|
|
|
void show(std::string nickname, bool use_traversal);
|
|
|
|
void reject() override;
|
|
|
|
|
|
|
|
// NetPlayUI methods
|
2021-11-20 18:59:14 +00:00
|
|
|
void BootGame(const std::string& filename,
|
|
|
|
std::unique_ptr<BootSessionData> boot_session_data) override;
|
2017-07-21 20:48:21 +00:00
|
|
|
void StopGame() override;
|
2018-07-04 21:01:50 +00:00
|
|
|
bool IsHosting() const override;
|
2017-07-21 20:48:21 +00:00
|
|
|
|
|
|
|
void Update() override;
|
|
|
|
void AppendChat(const std::string& msg) override;
|
|
|
|
|
2020-06-07 20:58:03 +00:00
|
|
|
void OnMsgChangeGame(const NetPlay::SyncIdentifier& sync_identifier,
|
|
|
|
const std::string& netplay_name) override;
|
2021-07-04 11:33:58 +00:00
|
|
|
void OnMsgChangeGBARom(int pad, const NetPlay::GBAConfig& config) override;
|
2017-07-21 20:48:21 +00:00
|
|
|
void OnMsgStartGame() override;
|
|
|
|
void OnMsgStopGame() override;
|
2018-11-11 03:37:49 +00:00
|
|
|
void OnMsgPowerButton() override;
|
2019-07-31 03:14:51 +00:00
|
|
|
void OnPlayerConnect(const std::string& player) override;
|
|
|
|
void OnPlayerDisconnect(const std::string& player) override;
|
2017-07-21 20:48:21 +00:00
|
|
|
void OnPadBufferChanged(u32 buffer) override;
|
NetPlay host input authority mode
Currently, each player buffers their own inputs and sends them to the
host. The host then relays those inputs to everyone else. Every player
waits on inputs from all players to be buffered before continuing. What
this means is all clients run in lockstep, and the total latency of
inputs cannot be lower than the sum of the 2 highest client ping times
in the game (in 3+ player sessions with people across the world, the
latency can be very high).
Host input authority mode changes it so players no longer buffer their
own inputs, and only send them to the host. The host stores only the
most recent input received from a player. The host then sends inputs
for all pads at the SI poll interval, similar to the existing code. If
a player sends inputs to slowly, their last received input is simply
sent again. If they send too quickly, inputs are dropped. This means
that the host has full control over what inputs are actually read by
the game, hence the name of the mode. Also, because the rate at which
inputs are received by SI is decoupled from the rate at which players
are sending inputs, clients are no longer dependent on each other. They
only care what the host is doing. This means that they can set their
buffer individually based on their latency to the host, rather than the
highest latency between any 2 players, allowing someone with lower ping
to the host to have less latency than someone else.
This is a catch to this: as a necessity of how the host's input sending
works, the host has 0 latency. There isn't a good way to fix this, as
input delay is now solely dependent on the real latency to the host's
server. Having differing latency between players would be considered
unfair for competitive play, but for casual play we don't really care.
For this reason though, combined with the potential for a few inputs to
be dropped on a bad connection, the old mode will remain and this new
mode is entirely optional.
2018-08-24 08:17:18 +00:00
|
|
|
void OnHostInputAuthorityChanged(bool enabled) override;
|
2017-07-21 20:48:21 +00:00
|
|
|
void OnDesync(u32 frame, const std::string& player) override;
|
|
|
|
void OnConnectionLost() override;
|
2018-07-02 02:52:43 +00:00
|
|
|
void OnConnectionError(const std::string& message) override;
|
2017-08-10 13:41:01 +00:00
|
|
|
void OnTraversalError(TraversalClient::FailureReason error) override;
|
2018-07-20 22:27:43 +00:00
|
|
|
void OnTraversalStateChanged(TraversalClient::State state) override;
|
2019-03-28 06:32:06 +00:00
|
|
|
void OnGameStartAborted() override;
|
2019-04-02 12:08:27 +00:00
|
|
|
void OnGolferChanged(bool is_golfer, const std::string& golfer_name) override;
|
2018-07-04 21:01:50 +00:00
|
|
|
|
2019-04-10 23:21:40 +00:00
|
|
|
void OnIndexAdded(bool success, const std::string error) override;
|
|
|
|
void OnIndexRefreshFailed(const std::string error) override;
|
|
|
|
|
2017-07-21 20:48:21 +00:00
|
|
|
bool IsRecording() override;
|
2020-06-07 20:58:03 +00:00
|
|
|
std::shared_ptr<const UICommon::GameFile>
|
|
|
|
FindGameFile(const NetPlay::SyncIdentifier& sync_identifier,
|
|
|
|
NetPlay::SyncIdentifierComparison* found = nullptr) override;
|
2021-07-04 11:33:58 +00:00
|
|
|
std::string FindGBARomPath(const std::array<u8, 20>& hash, std::string_view title,
|
|
|
|
int device_number) override;
|
2018-10-09 22:52:19 +00:00
|
|
|
|
2019-05-30 21:44:02 +00:00
|
|
|
void LoadSettings();
|
2018-10-09 22:52:19 +00:00
|
|
|
void SaveSettings();
|
|
|
|
|
2022-07-28 01:43:16 +00:00
|
|
|
void ShowGameDigestDialog(const std::string& title) override;
|
|
|
|
void SetGameDigestProgress(int pid, int progress) override;
|
|
|
|
void SetGameDigestResult(int pid, const std::string& result) override;
|
|
|
|
void AbortGameDigest() override;
|
2018-10-18 08:33:05 +00:00
|
|
|
|
|
|
|
void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
|
|
|
|
const std::vector<int>& players) override;
|
|
|
|
void HideChunkedProgressDialog() override;
|
|
|
|
void SetChunkedProgress(int pid, u64 progress) override;
|
2021-11-20 20:03:34 +00:00
|
|
|
|
2021-11-14 01:22:59 +00:00
|
|
|
void SetHostWiiSyncData(std::vector<u64> titles, std::string redirect_folder) override;
|
2021-11-20 20:03:34 +00:00
|
|
|
|
2017-07-21 20:48:21 +00:00
|
|
|
signals:
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateChatLayout();
|
|
|
|
void CreatePlayersLayout();
|
|
|
|
void CreateMainLayout();
|
|
|
|
void ConnectWidgets();
|
|
|
|
void OnChat();
|
|
|
|
void OnStart();
|
|
|
|
void DisplayMessage(const QString& msg, const std::string& color,
|
|
|
|
int duration = OSD::Duration::NORMAL);
|
2018-11-15 05:58:07 +00:00
|
|
|
void ResetExternalIP();
|
2018-07-20 22:27:43 +00:00
|
|
|
void UpdateDiscordPresence();
|
2017-07-21 20:48:21 +00:00
|
|
|
void UpdateGUI();
|
|
|
|
void GameStatusChanged(bool running);
|
2018-07-04 21:01:50 +00:00
|
|
|
void SetOptionsEnabled(bool enabled);
|
2017-07-21 20:48:21 +00:00
|
|
|
|
2019-03-17 00:09:06 +00:00
|
|
|
void SendMessage(const std::string& message);
|
|
|
|
|
2017-07-21 20:48:21 +00:00
|
|
|
// Chat
|
|
|
|
QGroupBox* m_chat_box;
|
|
|
|
QTextEdit* m_chat_edit;
|
|
|
|
QLineEdit* m_chat_type_edit;
|
|
|
|
QPushButton* m_chat_send_button;
|
|
|
|
|
|
|
|
// Players
|
|
|
|
QGroupBox* m_players_box;
|
|
|
|
QComboBox* m_room_box;
|
|
|
|
QLabel* m_hostcode_label;
|
|
|
|
QPushButton* m_hostcode_action_button;
|
2018-05-12 13:13:30 +00:00
|
|
|
QTableWidget* m_players_list;
|
2017-07-21 20:48:21 +00:00
|
|
|
QPushButton* m_kick_button;
|
|
|
|
QPushButton* m_assign_ports_button;
|
|
|
|
|
|
|
|
// Other
|
2019-03-01 04:49:03 +00:00
|
|
|
QMenuBar* m_menu_bar;
|
|
|
|
QMenu* m_data_menu;
|
|
|
|
QMenu* m_network_menu;
|
2022-07-28 01:43:16 +00:00
|
|
|
QMenu* m_game_digest_menu;
|
2019-03-01 04:49:03 +00:00
|
|
|
QMenu* m_other_menu;
|
2017-07-21 20:48:21 +00:00
|
|
|
QPushButton* m_game_button;
|
|
|
|
QPushButton* m_start_button;
|
|
|
|
QLabel* m_buffer_label;
|
|
|
|
QSpinBox* m_buffer_size_box;
|
2022-09-11 00:35:20 +00:00
|
|
|
|
|
|
|
QActionGroup* m_savedata_style_group;
|
|
|
|
QAction* m_savedata_none_action;
|
|
|
|
QAction* m_savedata_load_only_action;
|
|
|
|
QAction* m_savedata_load_and_write_action;
|
|
|
|
QAction* m_savedata_all_wii_saves_action;
|
|
|
|
|
2019-03-01 04:49:03 +00:00
|
|
|
QAction* m_sync_codes_action;
|
|
|
|
QAction* m_record_input_action;
|
|
|
|
QAction* m_strict_settings_sync_action;
|
|
|
|
QAction* m_host_input_authority_action;
|
2019-04-02 12:08:27 +00:00
|
|
|
QAction* m_golf_mode_action;
|
2019-04-02 21:13:42 +00:00
|
|
|
QAction* m_golf_mode_overlay_action;
|
2019-05-30 21:58:31 +00:00
|
|
|
QAction* m_fixed_delay_action;
|
2021-07-04 11:33:58 +00:00
|
|
|
QAction* m_hide_remote_gbas_action;
|
2017-07-21 20:48:21 +00:00
|
|
|
QPushButton* m_quit_button;
|
2018-05-10 17:38:58 +00:00
|
|
|
QSplitter* m_splitter;
|
2019-05-30 21:58:31 +00:00
|
|
|
QActionGroup* m_network_mode_group;
|
2017-07-21 20:48:21 +00:00
|
|
|
|
|
|
|
QGridLayout* m_main_layout;
|
2022-07-28 01:43:16 +00:00
|
|
|
GameDigestDialog* m_game_digest_dialog;
|
2018-10-18 08:33:05 +00:00
|
|
|
ChunkedProgressDialog* m_chunked_progress_dialog;
|
2017-07-21 20:48:21 +00:00
|
|
|
PadMappingDialog* m_pad_mapping;
|
2020-06-07 20:58:03 +00:00
|
|
|
NetPlay::SyncIdentifier m_current_game_identifier;
|
|
|
|
std::string m_current_game_name;
|
2018-11-15 05:58:07 +00:00
|
|
|
Common::Lazy<std::string> m_external_ip_address;
|
2017-07-21 20:48:21 +00:00
|
|
|
std::string m_nickname;
|
2019-01-17 22:28:07 +00:00
|
|
|
const GameListModel& m_game_list_model;
|
2017-07-21 20:48:21 +00:00
|
|
|
bool m_use_traversal = false;
|
|
|
|
bool m_is_copy_button_retry = false;
|
2018-07-03 23:02:13 +00:00
|
|
|
bool m_got_stop_request = true;
|
2018-05-10 17:26:42 +00:00
|
|
|
int m_buffer_size = 0;
|
2018-07-11 10:45:47 +00:00
|
|
|
int m_player_count = 0;
|
2018-07-20 22:27:43 +00:00
|
|
|
int m_old_player_count = 0;
|
NetPlay host input authority mode
Currently, each player buffers their own inputs and sends them to the
host. The host then relays those inputs to everyone else. Every player
waits on inputs from all players to be buffered before continuing. What
this means is all clients run in lockstep, and the total latency of
inputs cannot be lower than the sum of the 2 highest client ping times
in the game (in 3+ player sessions with people across the world, the
latency can be very high).
Host input authority mode changes it so players no longer buffer their
own inputs, and only send them to the host. The host stores only the
most recent input received from a player. The host then sends inputs
for all pads at the SI poll interval, similar to the existing code. If
a player sends inputs to slowly, their last received input is simply
sent again. If they send too quickly, inputs are dropped. This means
that the host has full control over what inputs are actually read by
the game, hence the name of the mode. Also, because the rate at which
inputs are received by SI is decoupled from the rate at which players
are sending inputs, clients are no longer dependent on each other. They
only care what the host is doing. This means that they can set their
buffer individually based on their latency to the host, rather than the
highest latency between any 2 players, allowing someone with lower ping
to the host to have less latency than someone else.
This is a catch to this: as a necessity of how the host's input sending
works, the host has 0 latency. There isn't a good way to fix this, as
input delay is now solely dependent on the real latency to the host's
server. Having differing latency between players would be considered
unfair for competitive play, but for casual play we don't really care.
For this reason though, combined with the potential for a few inputs to
be dropped on a bad connection, the old mode will remain and this new
mode is entirely optional.
2018-08-24 08:17:18 +00:00
|
|
|
bool m_host_input_authority = false;
|
2021-11-20 18:59:14 +00:00
|
|
|
|
|
|
|
StartGameCallback m_start_game_callback;
|
2017-07-21 20:48:21 +00:00
|
|
|
};
|