| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <functional> |
| 7 |
#include <memory> |
| 8 |
#include <string> |
| 9 |
|
| 10 |
#include <QDialog> |
| 11 |
#include <QMenuBar> |
| 12 |
|
| 13 |
#include "Common/Lazy.h" |
| 14 |
#include "Core/NetPlayClient.h" |
| 15 |
#include "DolphinQt/GameList/GameListModel.h" |
| 16 |
#include "DolphinQt/NetPlay/ClickBlurLabel.h" |
| 17 |
#include "VideoCommon/OnScreenDisplay.h" |
| 18 |
|
| 19 |
class BootSessionData; |
| 20 |
class ChunkedProgressDialog; |
| 21 |
class GameDigestDialog; |
| 22 |
class PadMappingDialog; |
| 23 |
class QCheckBox; |
| 24 |
class QComboBox; |
| 25 |
class QGridLayout; |
| 26 |
class QGroupBox; |
| 27 |
class QLabel; |
| 28 |
class QLineEdit; |
| 29 |
class QPushButton; |
| 30 |
class QSpinBox; |
| 31 |
class QSplitter; |
| 32 |
class QTableWidget; |
| 33 |
class QTextEdit; |
| 34 |
|
| 35 |
class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI |
| 36 |
{ |
| 37 |
Q_OBJECT |
| 38 |
public: |
| 39 |
using StartGameCallback = std::function<void(const std::string& path, |
| 40 |
std::unique_ptr<BootSessionData> boot_session_data)>; |
| 41 |
|
| 42 |
explicit NetPlayDialog(const GameListModel& game_list_model, |
| 43 |
StartGameCallback start_game_callback, QWidget* parent = nullptr); |
| 44 |
~NetPlayDialog() override; |
| 45 |
|
| 46 |
void show(std::string nickname, bool use_traversal); |
| 47 |
void reject() override; |
| 48 |
|
| 49 |
|
| 50 |
void BootGame(const std::string& filename, |
| 51 |
std::unique_ptr<BootSessionData> boot_session_data) override; |
| 52 |
void StopGame() override; |
| 53 |
bool IsHosting() const override; |
| 54 |
|
| 55 |
void Update() override; |
| 56 |
void AppendChat(const std::string& msg) override; |
| 57 |
|
| 58 |
void OnMsgChangeGame(const NetPlay::SyncIdentifier& sync_identifier, |
| 59 |
const std::string& netplay_name) override; |
| 60 |
void OnMsgChangeGBARom(int pad, const NetPlay::GBAConfig& config) override; |
| 61 |
void OnMsgStartGame() override; |
| 62 |
void OnMsgStopGame() override; |
| 63 |
void OnMsgPowerButton() override; |
| 64 |
void OnPlayerConnect(const std::string& player) override; |
| 65 |
void OnPlayerDisconnect(const std::string& player) override; |
| 66 |
void OnPadBufferChanged(u32 buffer) override; |
| 67 |
void OnHostInputAuthorityChanged(bool enabled) override; |
| 68 |
void OnDesync(u32 frame, const std::string& player) override; |
| 69 |
void OnConnectionLost() override; |
| 70 |
void OnConnectionError(const std::string& message) override; |
| 71 |
void OnTraversalError(Common::TraversalClient::FailureReason error) override; |
| 72 |
void OnTraversalStateChanged(Common::TraversalClient::State state) override; |
| 73 |
void OnGameStartAborted() override; |
| 74 |
void OnGolferChanged(bool is_golfer, const std::string& golfer_name) override; |
| 75 |
void OnTtlDetermined(u8 ttl) override; |
| 76 |
|
| 77 |
void OnIndexAdded(bool success, const std::string error) override; |
| 78 |
void OnIndexRefreshFailed(const std::string error) override; |
| 79 |
|
| 80 |
bool IsRecording() override; |
| 81 |
std::shared_ptr<const UICommon::GameFile> |
| 82 |
FindGameFile(const NetPlay::SyncIdentifier& sync_identifier, |
| 83 |
NetPlay::SyncIdentifierComparison* found = nullptr) override; |
| 84 |
std::string FindGBARomPath(const std::array<u8, 20>& hash, std::string_view title, |
| 85 |
int device_number) override; |
| 86 |
|
| 87 |
void LoadSettings(); |
| 88 |
void SaveSettings(); |
| 89 |
|
| 90 |
void ShowGameDigestDialog(const std::string& title) override; |
| 91 |
void SetGameDigestProgress(int pid, int progress) override; |
| 92 |
void SetGameDigestResult(int pid, const std::string& result) override; |
| 93 |
void AbortGameDigest() override; |
| 94 |
|
| 95 |
void ShowChunkedProgressDialog(const std::string& title, u64 data_size, |
| 96 |
std::span<const int> players) override; |
| 97 |
void HideChunkedProgressDialog() override; |
| 98 |
void SetChunkedProgress(int pid, u64 progress) override; |
| 99 |
|
| 100 |
void SetHostWiiSyncData(std::vector<u64> titles, std::string redirect_folder) override; |
| 101 |
|
| 102 |
signals: |
| 103 |
void Stop(); |
| 104 |
|
| 105 |
private: |
| 106 |
void CreateChatLayout(); |
| 107 |
void CreatePlayersLayout(); |
| 108 |
void CreateMainLayout(); |
| 109 |
void ConnectWidgets(); |
| 110 |
void OnChat(); |
| 111 |
void OnStart(); |
| 112 |
void DisplayMessage(const QString& msg, const std::string& color, |
| 113 |
int duration = OSD::Duration::NORMAL); |
| 114 |
void ResetExternalIP(); |
| 115 |
void UpdateDiscordPresence(); |
| 116 |
void UpdateGUI(); |
| 117 |
void GameStatusChanged(bool running); |
| 118 |
void SetOptionsEnabled(bool enabled); |
| 119 |
|
| 120 |
void SendMessage(const std::string& message); |
| 121 |
|
| 122 |
|
| 123 |
QGroupBox* m_chat_box; |
| 124 |
QTextEdit* m_chat_edit; |
| 125 |
QLineEdit* m_chat_type_edit; |
| 126 |
QPushButton* m_chat_send_button; |
| 127 |
|
| 128 |
|
| 129 |
QGroupBox* m_players_box; |
| 130 |
QComboBox* m_room_box; |
| 131 |
ClickBlurLabel* m_hostcode_label; |
| 132 |
QPushButton* m_hostcode_action_button; |
| 133 |
QTableWidget* m_players_list; |
| 134 |
QPushButton* m_kick_button; |
| 135 |
QPushButton* m_assign_ports_button; |
| 136 |
|
| 137 |
|
| 138 |
QMenuBar* m_menu_bar; |
| 139 |
QMenu* m_data_menu; |
| 140 |
QMenu* m_network_menu; |
| 141 |
QMenu* m_game_digest_menu; |
| 142 |
QMenu* m_other_menu; |
| 143 |
QPushButton* m_game_button; |
| 144 |
QPushButton* m_start_button; |
| 145 |
QLabel* m_buffer_label; |
| 146 |
QSpinBox* m_buffer_size_box; |
| 147 |
|
| 148 |
QActionGroup* m_savedata_style_group; |
| 149 |
QAction* m_savedata_none_action; |
| 150 |
QAction* m_savedata_load_only_action; |
| 151 |
QAction* m_savedata_load_and_write_action; |
| 152 |
QAction* m_savedata_all_wii_saves_action; |
| 153 |
|
| 154 |
QAction* m_sync_codes_action; |
| 155 |
QAction* m_record_input_action; |
| 156 |
QAction* m_strict_settings_sync_action; |
| 157 |
QAction* m_host_input_authority_action; |
| 158 |
QAction* m_golf_mode_action; |
| 159 |
QAction* m_golf_mode_overlay_action; |
| 160 |
QAction* m_fixed_delay_action; |
| 161 |
QAction* m_hide_remote_gbas_action; |
| 162 |
QPushButton* m_quit_button; |
| 163 |
QSplitter* m_splitter; |
| 164 |
QActionGroup* m_network_mode_group; |
| 165 |
|
| 166 |
QGridLayout* m_main_layout; |
| 167 |
GameDigestDialog* m_game_digest_dialog; |
| 168 |
ChunkedProgressDialog* m_chunked_progress_dialog; |
| 169 |
PadMappingDialog* m_pad_mapping; |
| 170 |
NetPlay::SyncIdentifier m_current_game_identifier; |
| 171 |
std::string m_current_game_name; |
| 172 |
Common::Lazy<std::string> m_external_ip_address; |
| 173 |
std::string m_nickname; |
| 174 |
const GameListModel& m_game_list_model; |
| 175 |
bool m_use_traversal = false; |
| 176 |
bool m_is_copy_button_retry = false; |
| 177 |
bool m_got_stop_request = true; |
| 178 |
int m_buffer_size = 0; |
| 179 |
int m_player_count = 0; |
| 180 |
int m_old_player_count = 0; |
| 181 |
bool m_host_input_authority = false; |
| 182 |
|
| 183 |
StartGameCallback m_start_game_callback; |
| 184 |
}; |