mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-24 06:00:05 +00:00
citra_qt: Save ban list for room hosting
This commit is contained in:
parent
15540df140
commit
deb398d190
@ -330,6 +330,21 @@ void Config::ReadValues() {
|
|||||||
UISettings::values.max_player = ReadSetting("max_player", 8).toUInt();
|
UISettings::values.max_player = ReadSetting("max_player", 8).toUInt();
|
||||||
UISettings::values.game_id = ReadSetting("game_id", 0).toULongLong();
|
UISettings::values.game_id = ReadSetting("game_id", 0).toULongLong();
|
||||||
UISettings::values.room_description = ReadSetting("room_description", "").toString();
|
UISettings::values.room_description = ReadSetting("room_description", "").toString();
|
||||||
|
// Read ban list back
|
||||||
|
size = qt_config->beginReadArray("username_ban_list");
|
||||||
|
UISettings::values.ban_list.first.resize(size);
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
qt_config->setArrayIndex(i);
|
||||||
|
UISettings::values.ban_list.first[i] = ReadSetting("username").toString().toStdString();
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
|
size = qt_config->beginReadArray("ip_ban_list");
|
||||||
|
UISettings::values.ban_list.second.resize(size);
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
qt_config->setArrayIndex(i);
|
||||||
|
UISettings::values.ban_list.second[i] = ReadSetting("ip").toString().toStdString();
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
@ -535,6 +550,19 @@ void Config::SaveValues() {
|
|||||||
WriteSetting("max_player", UISettings::values.max_player, 8);
|
WriteSetting("max_player", UISettings::values.max_player, 8);
|
||||||
WriteSetting("game_id", UISettings::values.game_id, 0);
|
WriteSetting("game_id", UISettings::values.game_id, 0);
|
||||||
WriteSetting("room_description", UISettings::values.room_description, "");
|
WriteSetting("room_description", UISettings::values.room_description, "");
|
||||||
|
// Write ban list
|
||||||
|
qt_config->beginWriteArray("username_ban_list");
|
||||||
|
for (std::size_t i = 0; i < UISettings::values.ban_list.first.size(); ++i) {
|
||||||
|
qt_config->setArrayIndex(i);
|
||||||
|
WriteSetting("username", QString::fromStdString(UISettings::values.ban_list.first[i]));
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
|
qt_config->beginWriteArray("ip_ban_list");
|
||||||
|
for (std::size_t i = 0; i < UISettings::values.ban_list.second.size(); ++i) {
|
||||||
|
qt_config->setArrayIndex(i);
|
||||||
|
WriteSetting("ip", QString::fromStdString(UISettings::values.ban_list.second[i]));
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
@ -127,11 +127,16 @@ void HostRoomWindow::Host() {
|
|||||||
auto port = ui->port->isModified() ? ui->port->text().toInt() : Network::DefaultRoomPort;
|
auto port = ui->port->isModified() ? ui->port->text().toInt() : Network::DefaultRoomPort;
|
||||||
auto password = ui->password->text().toStdString();
|
auto password = ui->password->text().toStdString();
|
||||||
const bool is_public = ui->host_type->currentIndex() == 0;
|
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;
|
||||||
|
}
|
||||||
if (auto room = Network::GetRoom().lock()) {
|
if (auto room = Network::GetRoom().lock()) {
|
||||||
bool created = room->Create(ui->room_name->text().toStdString(),
|
bool created = room->Create(ui->room_name->text().toStdString(),
|
||||||
ui->room_description->toPlainText().toStdString(), "", port,
|
ui->room_description->toPlainText().toStdString(), "", port,
|
||||||
password, ui->max_player->value(), game_name.toStdString(),
|
password, ui->max_player->value(),
|
||||||
game_id, CreateVerifyBackend(is_public));
|
Settings::values.citra_username, game_name.toStdString(),
|
||||||
|
game_id, CreateVerifyBackend(is_public), ban_list);
|
||||||
if (!created) {
|
if (!created) {
|
||||||
NetworkMessage::ShowError(NetworkMessage::COULD_NOT_CREATE_ROOM);
|
NetworkMessage::ShowError(NetworkMessage::COULD_NOT_CREATE_ROOM);
|
||||||
LOG_ERROR(Network, "Could not create room!");
|
LOG_ERROR(Network, "Could not create room!");
|
||||||
|
@ -145,6 +145,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="load_ban_list">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load Previous Ban List</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "citra_qt/multiplayer/lobby.h"
|
#include "citra_qt/multiplayer/lobby.h"
|
||||||
#include "citra_qt/multiplayer/message.h"
|
#include "citra_qt/multiplayer/message.h"
|
||||||
#include "citra_qt/multiplayer/state.h"
|
#include "citra_qt/multiplayer/state.h"
|
||||||
|
#include "citra_qt/ui_settings.h"
|
||||||
#include "citra_qt/util/clickable_label.h"
|
#include "citra_qt/util/clickable_label.h"
|
||||||
#include "common/announce_multiplayer_room.h"
|
#include "common/announce_multiplayer_room.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
@ -213,6 +214,10 @@ bool MultiplayerState::OnCloseRoom() {
|
|||||||
if (room->GetState() != Network::Room::State::Open) {
|
if (room->GetState() != Network::Room::State::Open) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Save ban list
|
||||||
|
if (auto room = Network::GetRoom().lock()) {
|
||||||
|
UISettings::values.ban_list = std::move(room->GetBanList());
|
||||||
|
}
|
||||||
room->Destroy();
|
room->Destroy();
|
||||||
announce_multiplayer_session->Stop();
|
announce_multiplayer_session->Stop();
|
||||||
LOG_DEBUG(Frontend, "Closed the room (as a server)");
|
LOG_DEBUG(Frontend, "Closed the room (as a server)");
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
@ -110,6 +112,7 @@ struct Values {
|
|||||||
uint host_type;
|
uint host_type;
|
||||||
qulonglong game_id;
|
qulonglong game_id;
|
||||||
QString room_description;
|
QString room_description;
|
||||||
|
std::pair<std::vector<std::string>, std::vector<std::string>> ban_list;
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
bool show_console;
|
bool show_console;
|
||||||
|
Loading…
Reference in New Issue
Block a user