// This file is part of c-evo-evo. // // This software is governed by the CeCILL license under French law and // abiding by the rules of distribution of free software. You can use, // modify and/or redistribute the software under the terms of the CeCILL // license as circulated by CEA, CNRS and INRIA at the following URL // "http://www.cecill.info". // // As a counterpart to the access to the source code and rights to copy, // modify and redistribute granted by the license, users are provided only // with a limited warranty and the software's author, the holder of the // economic rights, and the successive licensors have only limited // liability. // // In this respect, the user's attention is drawn to the risks associated // with loading, using, modifying and/or developing or reproducing the // software by the user in light of its specific status of free software, // that may mean that it is complicated to manipulate, and that also // therefore means that it is reserved for developers and experienced // professionals having in-depth computer knowledge. Users are therefore // encouraged to load and test the software's suitability as regards their // requirements in conditions enabling the security of their systems and/or // data to be ensured and, more generally, to use and operate it in the // same conditions as regards security. // // The fact that you are presently reading this means that you have had // knowledge of the CeCILL license and that you accept its terms. #include "Global.h" #include "Cevo/CevoGraphicSet.h" #include "Cevo/CevoScreenTools.h" #include "Cevo/CevoTexture.h" #include namespace Cevo { bool fullScreen = false; bool musicEnabled = true; bool generateNames = true; 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); #else return QString(); #endif } } // namespace QString getGraphicsDir() { const QString dir = resourceDir(); return dir.isEmpty() ? QString() : dir + QStringLiteral("/Graphics"); } QString getMusicDir() { const QString dir = resourceDir(); return dir.isEmpty() ? QString() : dir + QStringLiteral("/Music"); } QString localizedFilePath(const QString &path) { 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