QTfrontend/team.cpp
changeset 6024 d38da7c19e43
parent 6015 daffc14a518a
child 6060 fdfc01419815
equal deleted inserted replaced
6022:8ed6e810051a 6024:d38da7c19e43
    44     m_fort = "Plane";
    44     m_fort = "Plane";
    45     m_voicepack = "Default";
    45     m_voicepack = "Default";
    46     m_flag = "hedgewars";
    46     m_flag = "hedgewars";
    47     for(int i = 0; i < BINDS_NUMBER; i++)
    47     for(int i = 0; i < BINDS_NUMBER; i++)
    48     {
    48     {
    49         binds[i].action = cbinds[i].action;
    49         m_binds[i].action = cbinds[i].action;
    50         binds[i].strbind = cbinds[i].strbind;
    50         m_binds[i].strbind = cbinds[i].strbind;
    51     }
    51     }
    52     m_rounds = 0;
    52     m_rounds = 0;
    53     m_wins = 0;
    53     m_wins = 0;
    54     m_campaignProgress = 0;
    54     m_campaignProgress = 0;
    55 }
    55 }
    97     m_voicepack = "Default";
    97     m_voicepack = "Default";
    98     m_flag = "hedgewars";
    98     m_flag = "hedgewars";
    99 
    99 
   100     for(int i = 0; i < BINDS_NUMBER; i++)
   100     for(int i = 0; i < BINDS_NUMBER; i++)
   101     {
   101     {
   102         binds[i].action = cbinds[i].action;
   102         m_binds[i].action = cbinds[i].action;
   103         binds[i].strbind = cbinds[i].strbind;
   103         m_binds[i].strbind = cbinds[i].strbind;
   104     }
   104     }
   105     m_rounds = 0;
   105     m_rounds = 0;
   106     m_wins = 0;
   106     m_wins = 0;
   107     m_campaignProgress = 0;
   107     m_campaignProgress = 0;
   108 }
   108 }
   130         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
   130         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
   131         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
   131         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
   132         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
   132         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
   133     }
   133     }
   134     for(int i = 0; i < BINDS_NUMBER; i++)
   134     for(int i = 0; i < BINDS_NUMBER; i++)
   135         binds[i].strbind = teamfile.value(QString("Binds/%1").arg(binds[i].action), cbinds[i].strbind).toString();
   135         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
   136     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   136     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   137         if(achievements[i][0][0])
   137         if(achievements[i][0][0])
   138             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   138             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   139         else
   139         else
   140             break;
   140             break;
   184         teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills);
   184         teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills);
   185         teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths);
   185         teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths);
   186         teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides);
   186         teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides);
   187     }
   187     }
   188     for(int i = 0; i < BINDS_NUMBER; i++)
   188     for(int i = 0; i < BINDS_NUMBER; i++)
   189         teamfile.setValue(QString("Binds/%1").arg(binds[i].action), binds[i].strbind);
   189         teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind);
   190     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   190     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   191         if(achievements[i][0][0])
   191         if(achievements[i][0][0])
   192             teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]);
   192             teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]);
   193         else
   193         else
   194             break;
   194             break;
   195     return true;
   195     return true;
   196 }
   196 }
   197 
   197 
   198 void HWTeam::SetToPage(HWForm * hwform)
       
   199 {
       
   200     hwform->ui.pageEditTeam->TeamNameEdit->setText(m_name);
       
   201     hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(m_difficulty);
       
   202     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
       
   203     {
       
   204          hwform->ui.pageEditTeam->HHNameEdit[i]->setText(m_hedgehogs[i].Name);
       
   205          if (m_hedgehogs[i].Hat.startsWith("Reserved"))
       
   206             hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+m_hedgehogs[i].Hat.remove(0,40), Qt::DisplayRole));
       
   207          else
       
   208             hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(m_hedgehogs[i].Hat, Qt::DisplayRole));
       
   209     }
       
   210     hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(m_grave));
       
   211     hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findData(m_flag));
       
   212 
       
   213     hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(m_fort));
       
   214     hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(m_voicepack));
       
   215     //hwform->ui.pageEditTeam->CBFort_activated(Fort);
       
   216 
       
   217     for(int i = 0; i < BINDS_NUMBER; i++)
       
   218     {
       
   219         hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind));
       
   220     }
       
   221 }
       
   222 
       
   223 void HWTeam::GetFromPage(HWForm * hwform)
       
   224 {
       
   225     m_name  = hwform->ui.pageEditTeam->TeamNameEdit->text();
       
   226     m_difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex();
       
   227     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
       
   228     {
       
   229         m_hedgehogs[i].Name = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
       
   230         if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved"))
       
   231             m_hedgehogs[i].Hat = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9);
       
   232         else
       
   233             m_hedgehogs[i].Hat = hwform->ui.pageEditTeam->HHHats[i]->currentText();
       
   234     }
       
   235 
       
   236     m_grave = hwform->ui.pageEditTeam->CBGrave->currentText();
       
   237     m_fort = hwform->ui.pageEditTeam->CBFort->currentText();
       
   238     m_voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText();
       
   239     m_flag = hwform->ui.pageEditTeam->CBFlag->itemData(hwform->ui.pageEditTeam->CBFlag->currentIndex()).toString();
       
   240     for(int i = 0; i < BINDS_NUMBER; i++)
       
   241     {
       
   242         binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString();
       
   243     }
       
   244 }
       
   245 
       
   246 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const
   198 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const
   247 {
   199 {
   248     QStringList sl;
   200     QStringList sl;
   249     if (m_isNetTeam)
   201     if (m_isNetTeam)
   250     {
   202     {
   258     sl.push_back(QString("evoicepack " + m_voicepack));
   210     sl.push_back(QString("evoicepack " + m_voicepack));
   259     sl.push_back(QString("eflag " + m_flag));
   211     sl.push_back(QString("eflag " + m_flag));
   260 
   212 
   261     if (!m_isNetTeam)
   213     if (!m_isNetTeam)
   262         for(int i = 0; i < BINDS_NUMBER; i++)
   214         for(int i = 0; i < BINDS_NUMBER; i++)
   263             if(!binds[i].strbind.isEmpty())
   215             if(!m_binds[i].strbind.isEmpty())
   264                 sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));
   216                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
   265 
   217 
   266     for (int t = 0; t < m_numHedgehogs; t++)
   218     for (int t = 0; t < m_numHedgehogs; t++)
   267     {
   219     {
   268       sl.push_back(QString("eaddhh %1 %2 %3")
   220       sl.push_back(QString("eaddhh %1 %2 %3")
   269                .arg(QString::number(m_difficulty),
   221                .arg(QString::number(m_difficulty),
   297 QString HWTeam::name() const { return m_name; }
   249 QString HWTeam::name() const { return m_name; }
   298    void HWTeam::setName(const QString & name) { m_name = name; }
   250    void HWTeam::setName(const QString & name) { m_name = name; }
   299 
   251 
   300 // single hedgehog
   252 // single hedgehog
   301 const HWHog & HWTeam::hedgehog(unsigned int idx) const { return m_hedgehogs[idx]; }
   253 const HWHog & HWTeam::hedgehog(unsigned int idx) const { return m_hedgehogs[idx]; }
   302          void HWTeam::setHedgehog(unsigned int idx, const HWHog & hh) { m_hedgehogs[idx] = hh; }
   254          void HWTeam::setHedgehog(unsigned int idx, HWHog hh) { m_hedgehogs[idx] = hh; }
   303 
   255 
   304 // owner
   256 // owner
   305 QString HWTeam::owner() const { return m_owner; }
   257 QString HWTeam::owner() const { return m_owner; }
   306 
   258 
   307 
   259 
   313 // color
   265 // color
   314 QColor HWTeam::color() const { return m_color; }
   266 QColor HWTeam::color() const { return m_color; }
   315   void HWTeam::setColor(const QColor & color) { m_color = color; }
   267   void HWTeam::setColor(const QColor & color) { m_color = color; }
   316 
   268 
   317 
   269 
       
   270 // binds
       
   271 QString HWTeam::keyBind(unsigned int idx) const { return m_binds[idx].strbind; }
       
   272    void HWTeam::bindKey(unsigned int idx, const QString & key) { m_binds[idx].strbind = key; }
   318 
   273 
   319 // flag
   274 // flag
   320 void    HWTeam::setFlag(const QString & flag) { m_flag = flag; }
   275 void    HWTeam::setFlag(const QString & flag) { m_flag = flag; }
   321 QString HWTeam::flag() const { return m_flag; }
   276 QString HWTeam::flag() const { return m_flag; }
   322 
   277