mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2025-08-05 05:12:33 -07:00
Address first part of review comments
This commit is contained in:
@@ -390,7 +390,7 @@ void ChatRoom::SetPlayerList(const Network::RoomMember::MemberList& member_list)
|
||||
return;
|
||||
QPixmap pixmap;
|
||||
if (!pixmap.loadFromData(reinterpret_cast<const u8*>(result.data()),
|
||||
result.size()))
|
||||
static_cast<uint>(result.size())))
|
||||
return;
|
||||
icon_cache[avatar_url] =
|
||||
pixmap.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
|
@@ -32,15 +32,15 @@ DirectConnectWindow::DirectConnectWindow(QWidget* parent)
|
||||
connect(watcher, &QFutureWatcher<void>::finished, this, &DirectConnectWindow::OnConnection);
|
||||
|
||||
ui->nickname->setValidator(validation.GetNickname());
|
||||
ui->nickname->setText(UISettings::values.nickname);
|
||||
ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue());
|
||||
if (ui->nickname->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) {
|
||||
// Use yuzu Web Service user name as nickname by default
|
||||
ui->nickname->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue()));
|
||||
}
|
||||
ui->ip->setValidator(validation.GetIP());
|
||||
ui->ip->setText(UISettings::values.ip);
|
||||
ui->ip->setText(UISettings::values.multiplayer_ip.GetValue());
|
||||
ui->port->setValidator(validation.GetPort());
|
||||
ui->port->setText(UISettings::values.port);
|
||||
ui->port->setText(QString::number(UISettings::values.multiplayer_port.GetValue()));
|
||||
|
||||
// TODO(jroweboy): Show or hide the connection options based on the current value of the combo
|
||||
// box. Add this back in when the traversal server support is added.
|
||||
@@ -86,16 +86,18 @@ void DirectConnectWindow::Connect() {
|
||||
}
|
||||
|
||||
// Store settings
|
||||
UISettings::values.nickname = ui->nickname->text();
|
||||
UISettings::values.ip = ui->ip->text();
|
||||
UISettings::values.port = (ui->port->isModified() && !ui->port->text().isEmpty())
|
||||
? ui->port->text()
|
||||
: UISettings::values.port;
|
||||
UISettings::values.multiplayer_nickname = ui->nickname->text();
|
||||
UISettings::values.multiplayer_ip = ui->ip->text();
|
||||
if (ui->port->isModified() && !ui->port->text().isEmpty()) {
|
||||
UISettings::values.multiplayer_port = ui->port->text().toInt();
|
||||
} else {
|
||||
UISettings::values.multiplayer_port = UISettings::values.multiplayer_port.GetDefault();
|
||||
}
|
||||
|
||||
// attempt to connect in a different thread
|
||||
QFuture<void> f = QtConcurrent::run([&] {
|
||||
if (auto room_member = Network::GetRoomMember().lock()) {
|
||||
auto port = UISettings::values.port.toUInt();
|
||||
auto port = UISettings::values.multiplayer_port.GetValue();
|
||||
room_member->Join(ui->nickname->text().toStdString(), "",
|
||||
ui->ip->text().toStdString().c_str(), port, 0,
|
||||
Network::NoPreferredMac, ui->password->text().toStdString().c_str());
|
||||
|
@@ -51,23 +51,24 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||
connect(ui->host, &QPushButton::clicked, this, &HostRoomWindow::Host);
|
||||
|
||||
// Restore the settings:
|
||||
ui->username->setText(UISettings::values.room_nickname);
|
||||
ui->username->setText(UISettings::values.multiplayer_room_nickname.GetValue());
|
||||
if (ui->username->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) {
|
||||
// Use yuzu Web Service user name as nickname by default
|
||||
ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue()));
|
||||
}
|
||||
ui->room_name->setText(UISettings::values.room_name);
|
||||
ui->port->setText(UISettings::values.room_port);
|
||||
ui->max_player->setValue(UISettings::values.max_player);
|
||||
int index = UISettings::values.host_type;
|
||||
ui->room_name->setText(UISettings::values.multiplayer_room_name.GetValue());
|
||||
ui->port->setText(QString::number(UISettings::values.multiplayer_room_port.GetValue()));
|
||||
ui->max_player->setValue(UISettings::values.multiplayer_max_player.GetValue());
|
||||
int index = UISettings::values.multiplayer_host_type.GetValue();
|
||||
if (index < ui->host_type->count()) {
|
||||
ui->host_type->setCurrentIndex(index);
|
||||
}
|
||||
index = ui->game_list->findData(UISettings::values.game_id, GameListItemPath::ProgramIdRole);
|
||||
index = ui->game_list->findData(UISettings::values.multiplayer_game_id.GetValue(),
|
||||
GameListItemPath::ProgramIdRole);
|
||||
if (index != -1) {
|
||||
ui->game_list->setCurrentIndex(index);
|
||||
}
|
||||
ui->room_description->setText(UISettings::values.room_description);
|
||||
ui->room_description->setText(UISettings::values.multiplayer_room_description.GetValue());
|
||||
}
|
||||
|
||||
HostRoomWindow::~HostRoomWindow() = default;
|
||||
@@ -91,7 +92,8 @@ std::unique_ptr<Network::VerifyUser::Backend> HostRoomWindow::CreateVerifyBacken
|
||||
std::unique_ptr<Network::VerifyUser::Backend> verify_backend;
|
||||
if (use_validation) {
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
verify_backend = std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url);
|
||||
verify_backend =
|
||||
std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url.GetValue());
|
||||
#else
|
||||
verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
|
||||
#endif
|
||||
@@ -137,7 +139,7 @@ void HostRoomWindow::Host() {
|
||||
const bool is_public = ui->host_type->currentIndex() == 0;
|
||||
Network::Room::BanList ban_list{};
|
||||
if (ui->load_ban_list->isChecked()) {
|
||||
ban_list = UISettings::values.ban_list;
|
||||
ban_list = UISettings::values.multiplayer_ban_list;
|
||||
}
|
||||
if (auto room = Network::GetRoom().lock()) {
|
||||
bool created = room->Create(
|
||||
@@ -181,8 +183,9 @@ void HostRoomWindow::Host() {
|
||||
std::string token;
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
if (is_public) {
|
||||
WebService::Client client(Settings::values.web_api_url, Settings::values.yuzu_username,
|
||||
Settings::values.yuzu_token);
|
||||
WebService::Client client(Settings::values.web_api_url.GetValue(),
|
||||
Settings::values.yuzu_username.GetValue(),
|
||||
Settings::values.yuzu_token.GetValue());
|
||||
if (auto room = Network::GetRoom().lock()) {
|
||||
token = client.GetExternalJWT(room->GetVerifyUID()).returned_data;
|
||||
}
|
||||
@@ -198,17 +201,19 @@ void HostRoomWindow::Host() {
|
||||
Network::NoPreferredMac, password, token);
|
||||
|
||||
// Store settings
|
||||
UISettings::values.room_nickname = ui->username->text();
|
||||
UISettings::values.room_name = ui->room_name->text();
|
||||
UISettings::values.game_id =
|
||||
UISettings::values.multiplayer_room_nickname = ui->username->text();
|
||||
UISettings::values.multiplayer_room_name = ui->room_name->text();
|
||||
UISettings::values.multiplayer_game_id =
|
||||
ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong();
|
||||
UISettings::values.max_player = ui->max_player->value();
|
||||
UISettings::values.multiplayer_max_player = ui->max_player->value();
|
||||
|
||||
UISettings::values.host_type = ui->host_type->currentIndex();
|
||||
UISettings::values.room_port = (ui->port->isModified() && !ui->port->text().isEmpty())
|
||||
? ui->port->text()
|
||||
: QString::number(Network::DefaultRoomPort);
|
||||
UISettings::values.room_description = ui->room_description->toPlainText();
|
||||
UISettings::values.multiplayer_host_type = ui->host_type->currentIndex();
|
||||
if (ui->port->isModified() && !ui->port->text().isEmpty()) {
|
||||
UISettings::values.multiplayer_room_port = ui->port->text().toInt();
|
||||
} else {
|
||||
UISettings::values.multiplayer_room_port = Network::DefaultRoomPort;
|
||||
}
|
||||
UISettings::values.multiplayer_room_description = ui->room_description->toPlainText();
|
||||
ui->host->setEnabled(true);
|
||||
close();
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
ui->room_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
ui->nickname->setValidator(validation.GetNickname());
|
||||
ui->nickname->setText(UISettings::values.nickname);
|
||||
ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue());
|
||||
if (ui->nickname->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) {
|
||||
// Use yuzu Web Service user name as nickname by default
|
||||
ui->nickname->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue()));
|
||||
@@ -154,9 +154,11 @@ void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||
QFuture<void> f = QtConcurrent::run([nickname, ip, port, password, verify_UID] {
|
||||
std::string token;
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
if (!Settings::values.yuzu_username.empty() && !Settings::values.yuzu_token.empty()) {
|
||||
WebService::Client client(Settings::values.web_api_url, Settings::values.yuzu_username,
|
||||
Settings::values.yuzu_token);
|
||||
if (!Settings::values.yuzu_username.GetValue().empty() &&
|
||||
!Settings::values.yuzu_token.GetValue().empty()) {
|
||||
WebService::Client client(Settings::values.web_api_url.GetValue(),
|
||||
Settings::values.yuzu_username.GetValue(),
|
||||
Settings::values.yuzu_token.GetValue());
|
||||
token = client.GetExternalJWT(verify_UID).returned_data;
|
||||
if (token.empty()) {
|
||||
LOG_ERROR(WebService, "Could not get external JWT, verification may fail");
|
||||
@@ -175,9 +177,11 @@ void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||
// TODO(jroweboy): disable widgets and display a connecting while we wait
|
||||
|
||||
// Save settings
|
||||
UISettings::values.nickname = ui->nickname->text();
|
||||
UISettings::values.ip = proxy->data(connection_index, LobbyItemHost::HostIPRole).toString();
|
||||
UISettings::values.port = proxy->data(connection_index, LobbyItemHost::HostPortRole).toString();
|
||||
UISettings::values.multiplayer_nickname = ui->nickname->text();
|
||||
UISettings::values.multiplayer_ip =
|
||||
proxy->data(connection_index, LobbyItemHost::HostIPRole).toString();
|
||||
UISettings::values.multiplayer_port =
|
||||
proxy->data(connection_index, LobbyItemHost::HostPortRole).toInt();
|
||||
}
|
||||
|
||||
void Lobby::ResetModel() {
|
||||
|
@@ -232,7 +232,7 @@ bool MultiplayerState::OnCloseRoom() {
|
||||
return true;
|
||||
}
|
||||
// Save ban list
|
||||
UISettings::values.ban_list = std::move(room->GetBanList());
|
||||
UISettings::values.multiplayer_ban_list = std::move(room->GetBanList());
|
||||
|
||||
room->Destroy();
|
||||
announce_multiplayer_session->Stop();
|
||||
|
Reference in New Issue
Block a user