QTfrontend/util/namegen.cpp
changeset 6930 d187ea93fc4f
parent 6824 617a861b7750
child 6952 7f70f37bbf08
equal deleted inserted replaced
6929:c305d31642ac 6930:d187ea93fc4f
    21 #include <QTextStream>
    21 #include <QTextStream>
    22 #include <QStringList>
    22 #include <QStringList>
    23 #include <QLineEdit>
    23 #include <QLineEdit>
    24 
    24 
    25 #include "hwform.h"
    25 #include "hwform.h"
    26 #include "HWDataManager.h"
    26 #include "DataManager.h"
    27 
    27 
    28 #include "namegen.h"
    28 #include "namegen.h"
    29 
    29 
    30 HWNamegen::HWNamegen() {}
    30 HWNamegen::HWNamegen() {}
    31 
    31 
   123 QStringList HWNamegen::dictContents(const QString filename)
   123 QStringList HWNamegen::dictContents(const QString filename)
   124 {
   124 {
   125     QStringList list;
   125     QStringList list;
   126 
   126 
   127     // find .txt to load the names from
   127     // find .txt to load the names from
   128     QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString(
   128     QFile * file = new QFile(DataManager::instance().findFileForRead(QString(
   129                                  "Names/%1.txt").arg(filename)));
   129                                  "Names/%1.txt").arg(filename)));
   130 
   130 
   131     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   131     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   132     {
   132     {
   133         QTextStream in(file);
   133         QTextStream in(file);
   152 QStringList HWNamegen::dictsForHat(const QString hatname)
   152 QStringList HWNamegen::dictsForHat(const QString hatname)
   153 {
   153 {
   154     QStringList list;
   154     QStringList list;
   155 
   155 
   156     // find .cfg to load the dicts from
   156     // find .cfg to load the dicts from
   157     QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString(
   157     QFile * file = new QFile(DataManager::instance().findFileForRead(QString(
   158                                  "Names/%1.cfg").arg(hatname)));
   158                                  "Names/%1.cfg").arg(hatname)));
   159 
   159 
   160     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   160     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   161     {
   161     {
   162         QTextStream in(file);
   162         QTextStream in(file);
   182 {
   182 {
   183     typesAvailable = false;
   183     typesAvailable = false;
   184 
   184 
   185     // find .ini to load the names from
   185     // find .ini to load the names from
   186     QFile * file = new QFile(
   186     QFile * file = new QFile(
   187         HWDataManager::instance().findFileForRead(QString("Names/types.ini")));
   187         DataManager::instance().findFileForRead(QString("Names/types.ini")));
   188 
   188 
   189 
   189 
   190     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   190     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   191     {
   191     {
   192 
   192 
   241 QString HWNamegen::getRandomGrave()
   241 QString HWNamegen::getRandomGrave()
   242 {
   242 {
   243     QStringList Graves;
   243     QStringList Graves;
   244 
   244 
   245     //list all available Graves
   245     //list all available Graves
   246     Graves.append(HWDataManager::instance().entryList(
   246     Graves.append(DataManager::instance().entryList(
   247                       "Graphics/Graves",
   247                       "Graphics/Graves",
   248                       QDir::Files,
   248                       QDir::Files,
   249                       QStringList("*.png")
   249                       QStringList("*.png")
   250                   ).replaceInStrings(QRegExp("\\.png$"), "")
   250                   ).replaceInStrings(QRegExp("\\.png$"), "")
   251                  );
   251                  );
   263 QString HWNamegen::getRandomFort()
   263 QString HWNamegen::getRandomFort()
   264 {
   264 {
   265     QStringList Forts;
   265     QStringList Forts;
   266 
   266 
   267     //list all available Forts
   267     //list all available Forts
   268     Forts.append(HWDataManager::instance().entryList(
   268     Forts.append(DataManager::instance().entryList(
   269                      "Forts",
   269                      "Forts",
   270                      QDir::Files,
   270                      QDir::Files,
   271                      QStringList("*L.png")
   271                      QStringList("*L.png")
   272                  ).replaceInStrings(QRegExp("L\\.png$"), "")
   272                  ).replaceInStrings(QRegExp("L\\.png$"), "")
   273                 );
   273                 );