QTfrontend/team.cpp
changeset 13284 b504131f7405
parent 13080 23a498a2b5b8
child 13708 3264a26bbf8b
equal deleted inserted replaced
13283:f816b9e73fcb 13284:b504131f7405
   169     return *this;
   169     return *this;
   170 }
   170 }
   171 
   171 
   172 bool HWTeam::loadFromFile()
   172 bool HWTeam::loadFromFile()
   173 {
   173 {
   174     QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0);
   174     QSettings teamfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0);
   175     teamfile.setIniCodec("UTF-8");
   175     teamfile.setIniCodec("UTF-8");
   176     m_name = teamfile.value("Team/Name", m_name).toString();
   176     m_name = teamfile.value("Team/Name", m_name).toString();
   177     m_grave = teamfile.value("Team/Grave", "Statue").toString();
   177     m_grave = teamfile.value("Team/Grave", "Statue").toString();
   178     m_fort = teamfile.value("Team/Fort", "Plane").toString();
   178     m_fort = teamfile.value("Team/Fort", "Plane").toString();
   179     m_voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   179     m_voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   202     return true;
   202     return true;
   203 }
   203 }
   204 
   204 
   205 bool HWTeam::fileExists()
   205 bool HWTeam::fileExists()
   206 {
   206 {
   207     QFile f(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
   207     QFile f(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
   208     return f.exists();
   208     return f.exists();
   209 }
   209 }
   210 
   210 
   211 // Returns true if the team name has been changed but a file with the same team name already exists.
   211 // Returns true if the team name has been changed but a file with the same team name already exists.
   212 // So if this team would be saved, another team file would be overwritten, which is generally not
   212 // So if this team would be saved, another team file would be overwritten, which is generally not
   218 
   218 
   219 bool HWTeam::deleteFile()
   219 bool HWTeam::deleteFile()
   220 {
   220 {
   221     if(m_isNetTeam)
   221     if(m_isNetTeam)
   222         return false;
   222         return false;
   223     QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
   223     QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
   224     cfgfile.remove();
   224     cfgfile.remove();
   225     return true;
   225     return true;
   226 }
   226 }
   227 
   227 
   228 bool HWTeam::saveToFile()
   228 bool HWTeam::saveToFile()
   229 {
   229 {
   230     if (OldTeamName != m_name)
   230     if (OldTeamName != m_name)
   231     {
   231     {
   232         QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName)));
   232         QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName)));
   233         cfgfile.remove();
   233         cfgfile.remove();
   234         OldTeamName = m_name;
   234         OldTeamName = m_name;
   235     }
   235     }
   236 
   236 
   237     QString fileName = QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name));
   237     QString fileName = QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name));
   238     DataManager::ensureFileExists(fileName);
   238     DataManager::ensureFileExists(fileName);
   239     QSettings teamfile(fileName, QSettings::IniFormat, 0);
   239     QSettings teamfile(fileName, QSettings::IniFormat, 0);
   240     teamfile.setIniCodec("UTF-8");
   240     teamfile.setIniCodec("UTF-8");
   241     teamfile.setValue("Team/Name", m_name);
   241     teamfile.setValue("Team/Name", m_name);
   242     teamfile.setValue("Team/Grave", m_grave);
   242     teamfile.setValue("Team/Grave", m_grave);