Spell Out Entire Counter Names With First Letter Capitalized (#3997)
This commit is contained in:
parent
dc8603596d
commit
2de863f645
5 changed files with 42 additions and 2 deletions
|
@ -123,6 +123,7 @@ SET(cockatrice_SOURCES
|
||||||
src/carddbparser/cockatricexml4.cpp
|
src/carddbparser/cockatricexml4.cpp
|
||||||
src/filter_string.cpp
|
src/filter_string.cpp
|
||||||
src/customlineedit.cpp
|
src/customlineedit.cpp
|
||||||
|
src/translatecountername.cpp
|
||||||
${VERSION_STRING_CPP}
|
${VERSION_STRING_CPP}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "pb/command_set_counter.pb.h"
|
#include "pb/command_set_counter.pb.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
|
#include "translatecountername.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -32,7 +33,8 @@ AbstractCounter::AbstractCounter(Player *_player,
|
||||||
shortcutActive = false;
|
shortcutActive = false;
|
||||||
|
|
||||||
if (player->getLocalOrJudge()) {
|
if (player->getLocalOrJudge()) {
|
||||||
menu = new TearOffMenu(name);
|
QString displayName = TranslateCounterName::getDisplayName(_name);
|
||||||
|
menu = new TearOffMenu(displayName);
|
||||||
aSet = new QAction(this);
|
aSet = new QAction(this);
|
||||||
connect(aSet, SIGNAL(triggered()), this, SLOT(setCounter()));
|
connect(aSet, SIGNAL(triggered()), this, SLOT(setCounter()));
|
||||||
menu->addAction(aSet);
|
menu->addAction(aSet);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "soundengine.h"
|
#include "soundengine.h"
|
||||||
|
#include "translatecountername.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -681,9 +682,10 @@ void MessageLogWidget::logSetCounter(Player *player, QString counterName, int va
|
||||||
soundEngine->playSound("life_change");
|
soundEngine->playSound("life_change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString counterDisplayName = TranslateCounterName::getDisplayName(counterName);
|
||||||
appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).")
|
appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).")
|
||||||
.arg(sanitizeHtml(player->getName()))
|
.arg(sanitizeHtml(player->getName()))
|
||||||
.arg(QString("<font class=\"blue\">%1</font>").arg(sanitizeHtml(counterName)))
|
.arg(QString("<font class=\"blue\">%1</font>").arg(sanitizeHtml(counterDisplayName)))
|
||||||
.arg(QString("<font class=\"blue\">%1</font>").arg(value))
|
.arg(QString("<font class=\"blue\">%1</font>").arg(value))
|
||||||
.arg(value > oldValue ? "+" : "")
|
.arg(value > oldValue ? "+" : "")
|
||||||
.arg(value - oldValue));
|
.arg(value - oldValue));
|
||||||
|
|
11
cockatrice/src/translatecountername.cpp
Normal file
11
cockatrice/src/translatecountername.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include "translatecountername.h"
|
||||||
|
|
||||||
|
const QMap<QString, QString> TranslateCounterName::translated = {
|
||||||
|
{"life", QT_TRANSLATE_NOOP("TranslateCounterName", "Life")},
|
||||||
|
{"w", QT_TRANSLATE_NOOP("TranslateCounterName", "White")},
|
||||||
|
{"u", QT_TRANSLATE_NOOP("TranslateCounterName", "Blue")},
|
||||||
|
{"b", QT_TRANSLATE_NOOP("TranslateCounterName", "Black")},
|
||||||
|
{"r", QT_TRANSLATE_NOOP("TranslateCounterName", "Red")},
|
||||||
|
{"g", QT_TRANSLATE_NOOP("TranslateCounterName", "Green")},
|
||||||
|
{"x", QT_TRANSLATE_NOOP("TranslateCounterName", "Colorless")},
|
||||||
|
{"storm", QT_TRANSLATE_NOOP("TranslateCounterName", "Other")}};
|
24
cockatrice/src/translatecountername.h
Normal file
24
cockatrice/src/translatecountername.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef TRANSLATECOUNTERNAME_H
|
||||||
|
#define TRANSLATECOUNTERNAME_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QtCore>
|
||||||
|
|
||||||
|
class TranslateCounterName
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(TranslateCounterName)
|
||||||
|
|
||||||
|
static const QMap<QString, QString> translated;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static QString getDisplayName(const QString &name)
|
||||||
|
{
|
||||||
|
if (translated.contains(name)) {
|
||||||
|
return tr(translated[name].toLatin1());
|
||||||
|
} else {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSLATECOUNTERNAME_H
|
Loading…
Reference in a new issue