mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
map editor: fix event players after conversion to std::set
This commit is contained in:
parent
8917c753bd
commit
9baccdeeae
@ -63,9 +63,10 @@ TownEventDialog::~TownEventDialog()
|
||||
|
||||
void TownEventDialog::initPlayers()
|
||||
{
|
||||
auto playerList = params.value("players").toList();
|
||||
for (int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
bool isAffected = (1 << i) & params.value("players").toInt();
|
||||
bool isAffected = playerList.contains(QString::fromStdString(PlayerColor(i).toString()));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]));
|
||||
item->setData(MapEditorRoles::PlayerIDRole, QVariant::fromValue(i));
|
||||
item->setCheckState(isAffected ? Qt::Checked : Qt::Unchecked);
|
||||
@ -213,12 +214,12 @@ void TownEventDialog::on_TownEventDialog_finished(int result)
|
||||
|
||||
QVariant TownEventDialog::playersToVariant()
|
||||
{
|
||||
int players = 0;
|
||||
QVariantList players;
|
||||
for (int i = 0; i < ui->playersAffected->count(); ++i)
|
||||
{
|
||||
auto * item = ui->playersAffected->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
players |= 1 << i;
|
||||
players.push_back(QString::fromStdString(PlayerColor(i).toString()));
|
||||
}
|
||||
return QVariant::fromValue(players);
|
||||
}
|
||||
|
@ -30,9 +30,10 @@ TimedEvent::TimedEvent(QListWidgetItem * t, QWidget *parent) :
|
||||
ui->eventFirstOccurrence->setValue(params.value("firstOccurrence").toInt());
|
||||
ui->eventRepeatAfter->setValue(params.value("nextOccurrence").toInt());
|
||||
|
||||
auto playerList = params.value("players").toList();
|
||||
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
bool isAffected = (1 << i) & params.value("players").toInt();
|
||||
bool isAffected = playerList.contains(QString::fromStdString(PlayerColor(i).toString()));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(i));
|
||||
item->setCheckState(isAffected ? Qt::Checked : Qt::Unchecked);
|
||||
@ -69,12 +70,12 @@ void TimedEvent::on_TimedEvent_finished(int result)
|
||||
descriptor["firstOccurrence"] = QVariant::fromValue(ui->eventFirstOccurrence->value());
|
||||
descriptor["nextOccurrence"] = QVariant::fromValue(ui->eventRepeatAfter->value());
|
||||
|
||||
int players = 0;
|
||||
QVariantList players;
|
||||
for(int i = 0; i < ui->playersAffected->count(); ++i)
|
||||
{
|
||||
auto * item = ui->playersAffected->item(i);
|
||||
if(item->checkState() == Qt::Checked)
|
||||
players |= 1 << i;
|
||||
players.push_back(QString::fromStdString(PlayerColor(i).toString()));
|
||||
}
|
||||
descriptor["players"] = QVariant::fromValue(players);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user