Customize colors and teams
This commit is contained in:
1 parent
bd1105e2b7
commit
1899dd97c7
4 files changed
+109
-58
No files matched your search
@@ -12,6 +12,7 @@
|
||||
#include "playerparams.h"
|
||||
#include "ui_playerparams.h"
|
||||
#include "../lib/CTownHandler.h"
|
||||
#include "../lib/StringConstants.h"
|
||||
|
||||
PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -19,10 +20,27 @@ PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent)
|
||||
controller(ctrl)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//set colors and teams
|
||||
ui->teamId->addItem("No team", QVariant(TeamID::NO_TEAM));
|
||||
for(int i = 0, index = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
if(i == playerId || !controller.map()->players[i].canAnyonePlay())
|
||||
{
|
||||
ui->playerColorCombo->addItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]), QVariant(i));
|
||||
if(i == playerId)
|
||||
ui->playerColorCombo->setCurrentIndex(index);
|
||||
++index;
|
||||
}
|
||||
|
||||
//add teams
|
||||
ui->teamId->addItem(QString::number(i + 1), QVariant(i));
|
||||
}
|
||||
|
||||
playerColor = playerId;
|
||||
assert(controller.map()->players.size() > playerColor);
|
||||
playerInfo = controller.map()->players[playerColor];
|
||||
ui->teamId->setCurrentIndex(playerInfo.team == TeamID::NO_TEAM ? 0 : playerInfo.team.getNum() + 1);
|
||||
|
||||
//load factions
|
||||
for(auto idx : VLC->townh->getAllowedFactions())
|
||||
@@ -148,3 +166,21 @@ void PlayerParams::on_mainTown_activated(int index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PlayerParams::on_teamId_activated(int index)
|
||||
{
|
||||
playerInfo.team = ui->teamId->currentData().toInt();
|
||||
}
|
||||
|
||||
|
||||
void PlayerParams::on_playerColorCombo_activated(int index)
|
||||
{
|
||||
int data = ui->playerColorCombo->currentData().toInt();
|
||||
if(data != playerColor)
|
||||
{
|
||||
controller.map()->players[playerColor].canHumanPlay = false;
|
||||
controller.map()->players[playerColor].canComputerPlay = false;
|
||||
playerColor = data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user