mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
resource and playername translation
This commit is contained in:
parent
3e44dd6a88
commit
4aed816b05
@ -20,6 +20,7 @@
|
||||
#include "../lib/mapObjects/ObjectTemplate.h"
|
||||
#include "../lib/mapping/CMap.h"
|
||||
#include "../lib/constants/StringConstants.h"
|
||||
#include "../lib/texts/CGeneralTextHandler.h"
|
||||
|
||||
#include "townbuildingswidget.h"
|
||||
#include "towneventswidget.h"
|
||||
@ -913,8 +914,10 @@ QTableWidgetItem * Inspector::addProperty(const PlayerColor & value)
|
||||
if(value == PlayerColor::NEUTRAL)
|
||||
str = QObject::tr("neutral");
|
||||
|
||||
MetaString playerStr;
|
||||
playerStr.appendName(value);
|
||||
if(value.isValidPlayer())
|
||||
str = QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[value]);
|
||||
str = QString::fromStdString(playerStr.toString());
|
||||
|
||||
auto * item = new QTableWidgetItem(str);
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
@ -924,7 +927,9 @@ QTableWidgetItem * Inspector::addProperty(const PlayerColor & value)
|
||||
|
||||
QTableWidgetItem * Inspector::addProperty(const GameResID & value)
|
||||
{
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(GameConstants::RESOURCE_NAMES[value.toEnum()]));
|
||||
MetaString str;
|
||||
str.appendName(value);
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(value.getNum()));
|
||||
return item;
|
||||
@ -1003,5 +1008,9 @@ OwnerDelegate::OwnerDelegate(MapController & controller, bool addNeutral)
|
||||
options.push_back({QObject::tr("neutral"), QVariant::fromValue(PlayerColor::NEUTRAL.getNum()) });
|
||||
for(int p = 0; p < controller.map()->players.size(); ++p)
|
||||
if(controller.map()->players[p].canAnyonePlay())
|
||||
options.push_back({QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[p]), QVariant::fromValue(PlayerColor(p).getNum()) });
|
||||
{
|
||||
MetaString str;
|
||||
str.appendName(PlayerColor(p));
|
||||
options.push_back({QString::fromStdString(str.toString()), QVariant::fromValue(PlayerColor(p).getNum()) });
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ QuestWidget::QuestWidget(MapController & _controller, CQuest & _sh, QWidget *par
|
||||
ui->lResources->setRowCount(GameConstants::RESOURCE_QUANTITY - 1);
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY - 1; ++i)
|
||||
{
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(GameConstants::RESOURCE_NAMES[i]));
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(i));
|
||||
ui->lResources->setItem(i, 0, item);
|
||||
auto * spinBox = new QSpinBox;
|
||||
@ -126,7 +128,9 @@ QuestWidget::QuestWidget(MapController & _controller, CQuest & _sh, QWidget *par
|
||||
//fill players
|
||||
for(auto color = PlayerColor(0); color < PlayerColor::PLAYER_LIMIT; ++color)
|
||||
{
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[color.getNum()]));
|
||||
MetaString str;
|
||||
str.appendName(color);
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(color.getNum()));
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
|
@ -55,9 +55,11 @@ RewardsWidget::RewardsWidget(CMap & m, CRewardableObject & p, QWidget *parent) :
|
||||
ui->lResources->setRowCount(GameConstants::RESOURCE_QUANTITY - 1);
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY - 1; ++i)
|
||||
{
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
for(auto * w : {ui->rResources, ui->lResources})
|
||||
{
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(GameConstants::RESOURCE_NAMES[i]));
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(i));
|
||||
w->setItem(i, 0, item);
|
||||
auto * spinBox = new QSpinBox;
|
||||
@ -163,7 +165,9 @@ RewardsWidget::RewardsWidget(CMap & m, CRewardableObject & p, QWidget *parent) :
|
||||
//fill players
|
||||
for(auto color = PlayerColor(0); color < PlayerColor::PLAYER_LIMIT; ++color)
|
||||
{
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[color.getNum()]));
|
||||
MetaString str;
|
||||
str.appendName(color);
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(color.getNum()));
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
|
@ -67,8 +67,10 @@ void TownEventDialog::initPlayers()
|
||||
auto playerList = params.value("players").toList();
|
||||
for (int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
MetaString str;
|
||||
str.appendName(PlayerColor(i));
|
||||
bool isAffected = playerList.contains(toQString(PlayerColor(i)));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(MapEditorRoles::PlayerIDRole, QVariant::fromValue(i));
|
||||
item->setCheckState(isAffected ? Qt::Checked : Qt::Unchecked);
|
||||
ui->playersAffected->addItem(item);
|
||||
@ -81,13 +83,15 @@ void TownEventDialog::initResources()
|
||||
auto resourcesMap = params.value("resources").toMap();
|
||||
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||
{
|
||||
auto name = QString::fromStdString(GameConstants::RESOURCE_NAMES[i]);
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
auto name = QString::fromStdString(str.toString());
|
||||
auto * item = new QTableWidgetItem();
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
||||
item->setText(name);
|
||||
ui->resourcesTable->setItem(i, 0, item);
|
||||
|
||||
int val = resourcesMap.value(name).toInt();
|
||||
int val = resourcesMap.value(QString::fromStdString(GameConstants::RESOURCE_NAMES[i])).toInt();
|
||||
auto * edit = new QSpinBox(ui->resourcesTable);
|
||||
edit->setMaximum(i == GameResID::GOLD ? MAXIMUM_GOLD_CHANGE : MAXIMUM_RESOURCE_CHANGE);
|
||||
edit->setMinimum(i == GameResID::GOLD ? -MAXIMUM_GOLD_CHANGE : -MAXIMUM_RESOURCE_CHANGE);
|
||||
|
@ -37,7 +37,9 @@ TimedEvent::TimedEvent(MapController & c, QListWidgetItem * t, QWidget *parent)
|
||||
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||
{
|
||||
bool isAffected = playerList.contains(toQString(PlayerColor(i)));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]));
|
||||
MetaString str;
|
||||
str.appendName(PlayerColor(i));
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(str.toString()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(i));
|
||||
item->setCheckState(isAffected ? Qt::Checked : Qt::Unchecked);
|
||||
ui->playersAffected->addItem(item);
|
||||
@ -46,8 +48,10 @@ TimedEvent::TimedEvent(MapController & c, QListWidgetItem * t, QWidget *parent)
|
||||
ui->resources->setRowCount(GameConstants::RESOURCE_QUANTITY);
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||
{
|
||||
auto name = QString::fromStdString(GameConstants::RESOURCE_NAMES[i]);
|
||||
int val = params.value("resources").toMap().value(name).toInt();
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
auto name = QString::fromStdString(str.toString());
|
||||
int val = params.value("resources").toMap().value(QString::fromStdString(GameConstants::RESOURCE_NAMES[i])).toInt();
|
||||
ui->resources->setItem(i, 0, new QTableWidgetItem(name));
|
||||
auto nval = new QTableWidgetItem(QString::number(val));
|
||||
nval->setFlags(nval->flags() | Qt::ItemIsEditable);
|
||||
|
@ -407,7 +407,9 @@ void VictoryConditions::on_victoryComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
for(int resType = 0; resType < GameConstants::RESOURCE_QUANTITY; ++resType)
|
||||
{
|
||||
auto resName = QString::fromStdString(GameConstants::RESOURCE_NAMES[resType]);
|
||||
MetaString str;
|
||||
str.appendName(GameResID(resType));
|
||||
auto resName = QString::fromStdString(str.toString());
|
||||
victoryTypeWidget->addItem(resName, QVariant::fromValue(resType));
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,9 @@ PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent)
|
||||
{
|
||||
if(i == playerId || !controller.map()->players[i].canAnyonePlay())
|
||||
{
|
||||
ui->playerColorCombo->addItem(QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[i]), QVariant(i));
|
||||
MetaString str;
|
||||
str.appendName(PlayerColor(i));
|
||||
ui->playerColorCombo->addItem(QString::fromStdString(str.toString()), QVariant(i));
|
||||
if(i == playerId)
|
||||
ui->playerColorCombo->setCurrentIndex(index);
|
||||
++index;
|
||||
|
Loading…
Reference in New Issue
Block a user