2022-07-25 08:18:30 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-12-25 11:27:52 -08:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
2022-08-16 14:13:05 -07:00
|
|
|
#include "network/announce_multiplayer_session.h"
|
2021-12-25 11:27:52 -08:00
|
|
|
#include "network/network.h"
|
|
|
|
|
|
|
|
class QStandardItemModel;
|
|
|
|
class Lobby;
|
|
|
|
class HostRoomWindow;
|
|
|
|
class ClientRoomWindow;
|
|
|
|
class DirectConnectWindow;
|
|
|
|
class ClickableLabel;
|
|
|
|
|
2022-08-28 10:31:16 -07:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2021-12-25 11:27:52 -08:00
|
|
|
class MultiplayerState : public QWidget {
|
|
|
|
Q_OBJECT;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MultiplayerState(QWidget* parent, QStandardItemModel* game_list, QAction* leave_room,
|
2022-08-26 18:41:19 -07:00
|
|
|
QAction* show_room, Core::System& system_);
|
2021-12-25 11:27:52 -08:00
|
|
|
~MultiplayerState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close all open multiplayer related dialogs
|
|
|
|
*/
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
ClickableLabel* GetStatusText() const {
|
|
|
|
return status_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClickableLabel* GetStatusIcon() const {
|
|
|
|
return status_icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
void retranslateUi();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether a public room is being hosted or not.
|
|
|
|
* When this is true, Web Services configuration should be disabled.
|
|
|
|
*/
|
|
|
|
bool IsHostingPublicRoom() const;
|
|
|
|
|
|
|
|
void UpdateCredentials();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the multiplayer dialogs with a new game list model.
|
|
|
|
* This model should be the original model of the game list.
|
|
|
|
*/
|
|
|
|
void UpdateGameList(QStandardItemModel* game_list);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
|
|
|
void OnNetworkError(const Network::RoomMember::Error& error);
|
|
|
|
void OnViewLobby();
|
|
|
|
void OnCreateRoom();
|
|
|
|
bool OnCloseRoom();
|
|
|
|
void OnOpenNetworkRoom();
|
|
|
|
void OnDirectConnectToRoom();
|
|
|
|
void OnAnnounceFailed(const WebService::WebResult&);
|
|
|
|
void UpdateThemedIcons();
|
|
|
|
void ShowNotification();
|
|
|
|
void HideNotification();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void NetworkStateChanged(const Network::RoomMember::State&);
|
|
|
|
void NetworkError(const Network::RoomMember::Error&);
|
|
|
|
void AnnounceFailed(const WebService::WebResult&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Lobby* lobby = nullptr;
|
|
|
|
HostRoomWindow* host_room = nullptr;
|
|
|
|
ClientRoomWindow* client_room = nullptr;
|
|
|
|
DirectConnectWindow* direct_connect = nullptr;
|
|
|
|
ClickableLabel* status_icon = nullptr;
|
|
|
|
ClickableLabel* status_text = nullptr;
|
|
|
|
QStandardItemModel* game_list_model = nullptr;
|
|
|
|
QAction* leave_room;
|
|
|
|
QAction* show_room;
|
|
|
|
std::shared_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
|
|
|
Network::RoomMember::State current_state = Network::RoomMember::State::Uninitialized;
|
|
|
|
bool has_mod_perms = false;
|
|
|
|
Network::RoomMember::CallbackHandle<Network::RoomMember::State> state_callback_handle;
|
|
|
|
Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle;
|
|
|
|
|
|
|
|
bool show_notification = false;
|
2022-08-26 18:41:19 -07:00
|
|
|
Core::System& system;
|
2022-07-22 07:31:13 -07:00
|
|
|
Network::RoomNetwork& room_network;
|
2021-12-25 11:27:52 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(WebService::WebResult);
|