QTfrontend/util/namegen.cpp
changeset 6616 f77bb02b669f
parent 6212 a5d95f32e17f
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
   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(HWDataManager::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);
   134         while (!in.atEnd())
   134         while (!in.atEnd())
   141 
   141 
   142     // this QFile isn't needed any further
   142     // this QFile isn't needed any further
   143     delete file;
   143     delete file;
   144 
   144 
   145     if (list.size() == 0)
   145     if (list.size() == 0)
   146          list.append(filename);
   146         list.append(filename);
   147 
   147 
   148     return list;
   148     return list;
   149 }
   149 }
   150 
   150 
   151 
   151 
   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(HWDataManager::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);
   163         while (!in.atEnd())
   163         while (!in.atEnd())
   170 
   170 
   171     // this QFile isn't needed any further
   171     // this QFile isn't needed any further
   172     delete file;
   172     delete file;
   173 
   173 
   174     if (list.size() == 0)
   174     if (list.size() == 0)
   175          list.append(QString("generic"));
   175         list.append(QString("generic"));
   176 
   176 
   177     return list;
   177     return list;
   178 }
   178 }
   179 
   179 
   180 // loades types from ini files. returns true on success.
   180 // loades types from ini files. returns true on success.
   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(HWDataManager::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                  );
   252 
   252 
   253     if(Graves.size()==0)
   253     if(Graves.size()==0)
   254     {
   254     {
   255         // TODO do some serious error handling
   255         // TODO do some serious error handling
   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(HWDataManager::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                 );
   274 
   274 
   275     if(Forts.size()==0)
   275     if(Forts.size()==0)
   276     {
   276     {
   277         // TODO do some serious error handling
   277         // TODO do some serious error handling