QTfrontend/team.cpp
changeset 3381 f8800c44b3de
parent 3359 d17b9f6adae5
child 3697 d5b30d6373fc
equal deleted inserted replaced
3380:a46a311097af 3381:f8800c44b3de
    48     for(int i = 0; i < BINDS_NUMBER; i++)
    48     for(int i = 0; i < BINDS_NUMBER; i++)
    49     {
    49     {
    50         binds[i].action = cbinds[i].action;
    50         binds[i].action = cbinds[i].action;
    51         binds[i].strbind = cbinds[i].strbind;
    51         binds[i].strbind = cbinds[i].strbind;
    52     }
    52     }
       
    53     Rounds = 0;
       
    54     Wins = 0;
    53 }
    55 }
    54 
    56 
    55 HWTeam::HWTeam(const QStringList& strLst) :
    57 HWTeam::HWTeam(const QStringList& strLst) :
    56   numHedgehogs(4),
    58   numHedgehogs(4),
    57   m_isNetTeam(true)
    59   m_isNetTeam(true)
    71         Hedgehogs[i].Hat=strLst[i * 2 + 8];
    73         Hedgehogs[i].Hat=strLst[i * 2 + 8];
    72 // Somehow claymore managed an empty hat.  Until we figure out how, this should avoid a repeat
    74 // Somehow claymore managed an empty hat.  Until we figure out how, this should avoid a repeat
    73 // Checking net teams is probably pointless, but can't hurt.
    75 // Checking net teams is probably pointless, but can't hurt.
    74         if (Hedgehogs[i].Hat.length() == 0) Hedgehogs[i].Hat = "NoHat"; 
    76         if (Hedgehogs[i].Hat.length() == 0) Hedgehogs[i].Hat = "NoHat"; 
    75     }
    77     }
       
    78     Rounds = 0;
       
    79     Wins = 0;
    76 }
    80 }
    77 
    81 
    78 HWTeam::HWTeam() :
    82 HWTeam::HWTeam() :
    79   difficulty(0),
    83   difficulty(0),
    80   numHedgehogs(4),
    84   numHedgehogs(4),
    95     for(int i = 0; i < BINDS_NUMBER; i++)
    99     for(int i = 0; i < BINDS_NUMBER; i++)
    96     {
   100     {
    97         binds[i].action = cbinds[i].action;
   101         binds[i].action = cbinds[i].action;
    98         binds[i].strbind = cbinds[i].strbind;
   102         binds[i].strbind = cbinds[i].strbind;
    99     }
   103     }
       
   104     Rounds = 0;
       
   105     Wins = 0;
   100 }
   106 }
   101 
   107 
   102 
   108 
   103 bool HWTeam::LoadFromFile()
   109 bool HWTeam::LoadFromFile()
   104 {
   110 {
   108     Grave = teamfile.value("Team/Grave", "Statue").toString();
   114     Grave = teamfile.value("Team/Grave", "Statue").toString();
   109     Fort = teamfile.value("Team/Fort", "Plane").toString();
   115     Fort = teamfile.value("Team/Fort", "Plane").toString();
   110     Voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   116     Voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   111     Flag = teamfile.value("Team/Flag", "hedgewars").toString();
   117     Flag = teamfile.value("Team/Flag", "hedgewars").toString();
   112     difficulty = teamfile.value("Team/Difficulty", 0).toInt();
   118     difficulty = teamfile.value("Team/Difficulty", 0).toInt();
       
   119     Rounds = teamfile.value("Team/Rounds", 0).toInt();
       
   120     Wins = teamfile.value("Team/Wins", 0).toInt();
   113     for(int i = 0; i < 8; i++)
   121     for(int i = 0; i < 8; i++)
   114     {
   122     {
   115         QString hh = QString("Hedgehog%1/").arg(i);
   123         QString hh = QString("Hedgehog%1/").arg(i);
   116         Hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i)).toString();
   124         Hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i)).toString();
   117         Hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString();
   125         Hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString();
   126         if(achievements[i][0][0])
   134         if(achievements[i][0][0])
   127             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   135             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   128         else
   136         else
   129             break;
   137             break;
   130     return true;
   138     return true;
       
   139 }
       
   140 
       
   141 bool HWTeam::FileExists()
       
   142 {
       
   143     QFile f(cfgdir->absolutePath() + "/Teams/" + TeamName + ".ini");
       
   144     return f.exists();
   131 }
   145 }
   132 
   146 
   133 bool HWTeam::DeleteFile()
   147 bool HWTeam::DeleteFile()
   134 {
   148 {
   135     if(m_isNetTeam)
   149     if(m_isNetTeam)
   153     teamfile.setValue("Team/Grave", Grave);
   167     teamfile.setValue("Team/Grave", Grave);
   154     teamfile.setValue("Team/Fort", Fort);
   168     teamfile.setValue("Team/Fort", Fort);
   155     teamfile.setValue("Team/Voicepack", Voicepack);
   169     teamfile.setValue("Team/Voicepack", Voicepack);
   156     teamfile.setValue("Team/Flag", Flag);
   170     teamfile.setValue("Team/Flag", Flag);
   157     teamfile.setValue("Team/Difficulty", difficulty);
   171     teamfile.setValue("Team/Difficulty", difficulty);
       
   172     teamfile.setValue("Team/Rounds", Rounds);
       
   173     teamfile.setValue("Team/Wins", Wins);
   158     for(int i = 0; i < 8; i++)
   174     for(int i = 0; i < 8; i++)
   159     {
   175     {
   160         QString hh = QString("Hedgehog%1/").arg(i);
   176         QString hh = QString("Hedgehog%1/").arg(i);
   161         teamfile.setValue(hh + "Name", Hedgehogs[i].Name);
   177         teamfile.setValue(hh + "Name", Hedgehogs[i].Name);
   162         teamfile.setValue(hh + "Hat", Hedgehogs[i].Hat);
   178         teamfile.setValue(hh + "Hat", Hedgehogs[i].Hat);