many sparse changes
This commit is contained in:
1 parent
2c26c6f795
commit
7aa4ea4425
23 files changed
+1317
-290
No files matched your search
+81
-12
@@ -28,37 +28,106 @@
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
#include "Cevo/CevoGraphicSet.h"
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/CevoTexture.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
bool fullScreen = false;
|
||||
bool musicEnabled = true;
|
||||
bool generateNames = true;
|
||||
|
||||
QString getGraphicsDir()
|
||||
namespace {
|
||||
// The CEVO_RESOURCE_DIR environment variable overrides the compile-time
|
||||
// install location, to run a build-tree binary against the source resources/.
|
||||
QString resourceDir()
|
||||
{
|
||||
const QByteArray fromEnvironment = qgetenv("CEVO_RESOURCE_DIR");
|
||||
if (!fromEnvironment.isEmpty())
|
||||
return QString::fromLocal8Bit(fromEnvironment);
|
||||
#ifdef CEVO_RESOURCE_DIR
|
||||
return QStringLiteral(CEVO_RESOURCE_DIR "/Graphics");
|
||||
return QStringLiteral(CEVO_RESOURCE_DIR);
|
||||
#else
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
QString getGraphicsDir()
|
||||
{
|
||||
const QString dir = resourceDir();
|
||||
return dir.isEmpty() ? QString() : dir + QStringLiteral("/Graphics");
|
||||
}
|
||||
|
||||
QString getMusicDir()
|
||||
{
|
||||
#ifdef CEVO_RESOURCE_DIR
|
||||
return QStringLiteral(CEVO_RESOURCE_DIR "/Music");
|
||||
#else
|
||||
return QString();
|
||||
#endif
|
||||
const QString dir = resourceDir();
|
||||
return dir.isEmpty() ? QString() : dir + QStringLiteral("/Music");
|
||||
}
|
||||
|
||||
QString localizedFilePath(const QString &path)
|
||||
{
|
||||
#ifdef CEVO_RESOURCE_DIR
|
||||
return QStringLiteral(CEVO_RESOURCE_DIR "/") + path;
|
||||
#else
|
||||
return path;
|
||||
#endif
|
||||
const QString dir = resourceDir();
|
||||
return dir.isEmpty() ? path : dir + QLatin1Char('/') + path;
|
||||
}
|
||||
|
||||
StringTable phrases;
|
||||
StringTable phrases2;
|
||||
bool phrases2FallenBackToEnglish = false;
|
||||
|
||||
void loadPhrases()
|
||||
{
|
||||
phrases2FallenBackToEnglish = false;
|
||||
if (!phrases.loadFromFile(localizedFilePath(QStringLiteral("Language.txt"))))
|
||||
qWarning("Language.txt not found in %s", qPrintable(localizedFilePath(QString())));
|
||||
if (!phrases2.loadFromFile(localizedFilePath(QStringLiteral("Language2.txt"))))
|
||||
qWarning("Language2.txt not found in %s", qPrintable(localizedFilePath(QString())));
|
||||
}
|
||||
|
||||
void loadAssets()
|
||||
{
|
||||
graphicsDir = getGraphicsDir();
|
||||
loadPhrases();
|
||||
loadFonts(localizedFilePath(QStringLiteral("Fonts.txt")));
|
||||
|
||||
Templates = loadGraphicSet(QStringLiteral("Templates") + QLatin1String(PngExt), false);
|
||||
HGrSystem = loadGraphicSet(QStringLiteral("System") + QLatin1String(PngExt));
|
||||
HGrSystem2 = loadGraphicSet(QStringLiteral("System2") + QLatin1String(PngExt));
|
||||
|
||||
static Dpi::Bitmap colorsBitmap;
|
||||
static Dpi::Bitmap bigImpBitmap;
|
||||
static Texture mainTexture;
|
||||
colorsBitmap.loadFromFile(graphicsDir + QStringLiteral("/Colors") + QLatin1String(PngExt));
|
||||
paper.loadFromFile(graphicsDir + QStringLiteral("/Paper") + QLatin1String(JpgExt));
|
||||
bigImpBitmap.loadFromFile(graphicsDir + QStringLiteral("/Icons") + QLatin1String(PngExt));
|
||||
Colors = &colorsBitmap;
|
||||
bigImp = &bigImpBitmap;
|
||||
MainTexture = &mainTexture;
|
||||
}
|
||||
|
||||
QString phraseToQtFormat(const QString &text)
|
||||
{
|
||||
QString converted;
|
||||
int argNumber = 0;
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
if (text.at(i) == QLatin1Char('%') && i + 1 < text.length()) {
|
||||
const QChar next = text.at(i + 1);
|
||||
if (next == QLatin1Char('d') || next == QLatin1Char('s')) {
|
||||
converted += QLatin1Char('%') + QString::number(++argNumber);
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if (next == QLatin1Char('%')) {
|
||||
converted += QLatin1Char('%');
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
converted += text.at(i);
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user