QTfrontend/team.cpp
changeset 8346 3443e0de2c9d
parent 8098 4efee370e2de
child 8363 0b4ac686fc44
child 8508 f849b7b3af1d
equal deleted inserted replaced
8344:3d18f7f71d65 8346:3443e0de2c9d
    21 #include <QStringList>
    21 #include <QStringList>
    22 #include <QLineEdit>
    22 #include <QLineEdit>
    23 #include <QCryptographicHash>
    23 #include <QCryptographicHash>
    24 #include <QSettings>
    24 #include <QSettings>
    25 #include <QStandardItemModel>
    25 #include <QStandardItemModel>
       
    26 #include <QDebug>
    26 
    27 
    27 #include "team.h"
    28 #include "team.h"
    28 #include "hwform.h"
    29 #include "hwform.h"
    29 #include "DataManager.h"
    30 #include "DataManager.h"
       
    31 #include "gameuiconfig.h"
    30 
    32 
    31 HWTeam::HWTeam(const QString & teamname) :
    33 HWTeam::HWTeam(const QString & teamname) :
    32     QObject(0)
    34     QObject(0)
    33     , m_difficulty(0)
    35     , m_difficulty(0)
    34     , m_numHedgehogs(4)
    36     , m_numHedgehogs(4)
    48     m_flag = "hedgewars";
    50     m_flag = "hedgewars";
    49     for(int i = 0; i < BINDS_NUMBER; i++)
    51     for(int i = 0; i < BINDS_NUMBER; i++)
    50     {
    52     {
    51         m_binds.append(BindAction());
    53         m_binds.append(BindAction());
    52         m_binds[i].action = cbinds[i].action;
    54         m_binds[i].action = cbinds[i].action;
    53         m_binds[i].strbind = cbinds[i].strbind;
    55         m_binds[i].strbind = QString();
    54     }
    56     }
    55     m_rounds = 0;
    57     m_rounds = 0;
    56     m_wins = 0;
    58     m_wins = 0;
    57     m_campaignProgress = 0;
    59     m_campaignProgress = 0;
    58     m_color = 0;
    60     m_color = 0;
   108 
   110 
   109     for(int i = 0; i < BINDS_NUMBER; i++)
   111     for(int i = 0; i < BINDS_NUMBER; i++)
   110     {
   112     {
   111         m_binds.append(BindAction());
   113         m_binds.append(BindAction());
   112         m_binds[i].action = cbinds[i].action;
   114         m_binds[i].action = cbinds[i].action;
   113         m_binds[i].strbind = cbinds[i].strbind;
   115         m_binds[i].strbind = QString();
   114     }
   116     }
   115     m_rounds = 0;
   117     m_rounds = 0;
   116     m_wins = 0;
   118     m_wins = 0;
   117     m_campaignProgress = 0;
   119     m_campaignProgress = 0;
   118     m_color = 0;
   120     m_color = 0;
   189         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
   191         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
   190         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
   192         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
   191         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
   193         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
   192     }
   194     }
   193     for(int i = 0; i < BINDS_NUMBER; i++)
   195     for(int i = 0; i < BINDS_NUMBER; i++)
   194         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
   196         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), QString()).toString();
   195     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   197     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   196         if(achievements[i][0][0])
   198         if(achievements[i][0][0])
   197             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   199             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
   198         else
   200         else
   199             break;
   201             break;
   255             break;
   257             break;
   256 
   258 
   257     return true;
   259     return true;
   258 }
   260 }
   259 
   261 
   260 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const
   262 QStringList HWTeam::teamGameConfig(quint32 InitHealth, GameUIConfig * config) const
   261 {
   263 {
   262     QStringList sl;
   264     QStringList sl;
   263     if (m_isNetTeam)
   265     if (m_isNetTeam)
   264     {
   266     {
   265         sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toUtf8(), QCryptographicHash::Md5).toHex())));
   267         sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toUtf8(), QCryptographicHash::Md5).toHex())));
   271     sl.push_back(QString("efort " + m_fort));
   273     sl.push_back(QString("efort " + m_fort));
   272     sl.push_back(QString("evoicepack " + m_voicepack));
   274     sl.push_back(QString("evoicepack " + m_voicepack));
   273     sl.push_back(QString("eflag " + m_flag));
   275     sl.push_back(QString("eflag " + m_flag));
   274 
   276 
   275     if (!m_isNetTeam)
   277     if (!m_isNetTeam)
       
   278     {
   276         for(int i = 0; i < BINDS_NUMBER; i++)
   279         for(int i = 0; i < BINDS_NUMBER; i++)
   277             if(!m_binds[i].strbind.isEmpty())
   280         {
       
   281             if(m_binds[i].strbind.isEmpty() || m_binds[i].strbind == "default")
       
   282                 sl.push_back(QString("ebind " + config->bind(i) + " " + m_binds[i].action));
       
   283             else
   278                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
   284                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
       
   285         }
       
   286     }
   279 
   287 
   280     for (int t = 0; t < m_numHedgehogs; t++)
   288     for (int t = 0; t < m_numHedgehogs; t++)
   281     {
   289     {
   282         sl.push_back(QString("eaddhh %1 %2 %3")
   290         sl.push_back(QString("eaddhh %1 %2 %3")
   283                      .arg(QString::number(m_difficulty),
   291                      .arg(QString::number(m_difficulty),