2018-04-01 08:06:48 +02:00
|
|
|
// Copyright 2018 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
2018-04-20 08:39:01 +02:00
|
|
|
#include "core/announce_multiplayer_session.h"
|
2018-04-01 08:06:48 +02:00
|
|
|
#include "network/network.h"
|
|
|
|
|
|
|
|
class QStandardItemModel;
|
|
|
|
class Lobby;
|
|
|
|
class HostRoomWindow;
|
|
|
|
class ClientRoomWindow;
|
|
|
|
class DirectConnectWindow;
|
|
|
|
class ClickableLabel;
|
|
|
|
|
|
|
|
class MultiplayerState : public QWidget {
|
|
|
|
Q_OBJECT;
|
|
|
|
|
|
|
|
public:
|
2018-04-17 20:01:14 +02:00
|
|
|
explicit MultiplayerState(QWidget* parent, QStandardItemModel* game_list, QAction* leave_room,
|
|
|
|
QAction* show_room);
|
2018-04-01 08:06:48 +02:00
|
|
|
~MultiplayerState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close all open multiplayer related dialogs
|
|
|
|
*/
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
ClickableLabel* GetStatusText() const {
|
|
|
|
return status_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClickableLabel* GetStatusIcon() const {
|
|
|
|
return status_icon;
|
|
|
|
}
|
|
|
|
|
2018-07-24 12:57:45 +02:00
|
|
|
void retranslateUi();
|
|
|
|
|
2018-04-01 08:06:48 +02:00
|
|
|
public slots:
|
|
|
|
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
2018-11-24 09:13:46 +01:00
|
|
|
void OnNetworkError(const Network::RoomMember::Error& error);
|
2018-04-01 08:06:48 +02:00
|
|
|
void OnViewLobby();
|
|
|
|
void OnCreateRoom();
|
2018-04-18 19:04:32 +02:00
|
|
|
bool OnCloseRoom();
|
2018-04-01 08:06:48 +02:00
|
|
|
void OnOpenNetworkRoom();
|
|
|
|
void OnDirectConnectToRoom();
|
|
|
|
void OnAnnounceFailed(const Common::WebResult&);
|
2018-07-27 04:51:33 +02:00
|
|
|
void UpdateThemedIcons();
|
2018-12-01 02:28:55 +01:00
|
|
|
void ShowNotification();
|
|
|
|
void HideNotification();
|
2018-04-01 08:06:48 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void NetworkStateChanged(const Network::RoomMember::State&);
|
2018-11-24 09:13:46 +01:00
|
|
|
void NetworkError(const Network::RoomMember::Error&);
|
2018-04-01 08:06:48 +02:00
|
|
|
void AnnounceFailed(const Common::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;
|
2018-04-17 20:01:14 +02:00
|
|
|
QAction* leave_room;
|
|
|
|
QAction* show_room;
|
2018-04-01 08:06:48 +02:00
|
|
|
std::shared_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
2018-07-24 12:57:45 +02:00
|
|
|
Network::RoomMember::State current_state = Network::RoomMember::State::Uninitialized;
|
2018-11-24 09:22:14 +01:00
|
|
|
bool has_mod_perms = false;
|
2018-04-01 08:06:48 +02:00
|
|
|
Network::RoomMember::CallbackHandle<Network::RoomMember::State> state_callback_handle;
|
2018-11-24 09:13:46 +01:00
|
|
|
Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle;
|
2018-12-01 02:28:55 +01:00
|
|
|
|
|
|
|
bool show_notification = false;
|
2018-04-01 08:06:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Common::WebResult);
|