Lime3DS/src/citra_qt/multiplayer/lobby.h
GPUCode 88ea66053e
Miscallenious fixes to gl backend and qt frontend (#6834)
* renderer_gl: Make rasterizer normal class member

* It doesn't need to be heap allocated anymore

* gl_rasterizer: Remove default_texture

* It's unused

* gl_rasterizer: General cleanup

* gl_rasterizer: Lower case lambdas

* Match style with review comments from vulkan backend

* rasterizer_cache: Prevent memory leak

* Since the switch from shared_ptr these surfaces were no longer being destroyed properly. Use our garbage collector for that purpose to destroy it safely for both backends

* rasterizer_cache: Make temp copy of old surface

* The custom surface would override the memory region of the old region resulting in garbage data, this ensures the custom surface is constructed correctly

* citra_qt: Manually create dialog tabs

* Allows for custom constructors which is very useful. While at it, global state is now eliminated from configuration

* citra_qt: Eliminate global system usage

* core: Remove global system usage in memory and HIO

* citra_qt: Use qOverload

* tests: Run clang format

* gl_texture_runtime: Fix surface scaling
2023-08-02 01:40:39 +03:00

135 lines
3.7 KiB
C++

// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <QDialog>
#include <QFutureWatcher>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include "citra_qt/multiplayer/validation.h"
#include "common/announce_multiplayer_room.h"
#include "network/announce_multiplayer_session.h"
#include "network/room_member.h"
namespace Ui {
class Lobby;
}
namespace Core {
class System;
}
class LobbyModel;
class LobbyFilterProxyModel;
/**
* Listing of all public games pulled from services. The lobby should be simple enough for users to
* find the game they want to play, and join it.
*/
class Lobby : public QDialog {
Q_OBJECT
public:
explicit Lobby(Core::System& system, QWidget* parent, QStandardItemModel* list,
std::shared_ptr<Network::AnnounceMultiplayerSession> session);
~Lobby() override;
/**
* Updates the lobby with a new game list model.
* This model should be the original model of the game list.
*/
void UpdateGameList(QStandardItemModel* list);
void RetranslateUi();
public slots:
/**
* Begin the process to pull the latest room list from web services. After the listing is
* returned from web services, `LobbyRefreshed` will be signalled
*/
void RefreshLobby();
private slots:
/**
* Pulls the list of rooms from network and fills out the lobby model with the results
*/
void OnRefreshLobby();
/**
* Handler for single clicking on a room in the list. Expands the treeitem to show player
* information for the people in the room
*
* index - The row of the proxy model that the user wants to join.
*/
void OnExpandRoom(const QModelIndex&);
/**
* Handler for double clicking on a room in the list. Gathers the host ip and port and attempts
* to connect. Will also prompt for a password in case one is required.
*
* index - The row of the proxy model that the user wants to join.
*/
void OnJoinRoom(const QModelIndex&);
signals:
void StateChanged(const Network::RoomMember::State&);
private:
/**
* Removes all entries in the Lobby before refreshing.
*/
void ResetModel();
/**
* Prompts for a password. Returns an empty QString if the user either did not provide a
* password or if the user closed the window.
*/
QString PasswordPrompt();
private:
std::unique_ptr<Ui::Lobby> ui;
Core::System& system;
QStandardItemModel* model{};
QStandardItemModel* game_list{};
LobbyFilterProxyModel* proxy{};
QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
std::weak_ptr<Network::AnnounceMultiplayerSession> announce_multiplayer_session;
QFutureWatcher<void>* watcher;
Validation validation;
};
/**
* Proxy Model for filtering the lobby
*/
class LobbyFilterProxyModel : public QSortFilterProxyModel {
Q_OBJECT;
public:
explicit LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list);
/**
* Updates the filter with a new game list model.
* This model should be the processed one created by the Lobby.
*/
void UpdateGameList(QStandardItemModel* list);
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
void sort(int column, Qt::SortOrder order) override;
public slots:
void SetFilterOwned(bool);
void SetFilterEmpty(bool);
void SetFilterFull(bool);
void SetFilterSearch(const QString&);
private:
QStandardItemModel* game_list;
bool filter_owned = false;
bool filter_empty = false;
bool filter_full = false;
QString filter_search;
};