tools/MissionsEditor/teamedit.cpp
changeset 2596 41b46f83d088
parent 2594 0047e16dbacb
equal deleted inserted replaced
2595:d57af3defd56 2596:41b46f83d088
     4 TeamEdit::TeamEdit(QWidget *parent) :
     4 TeamEdit::TeamEdit(QWidget *parent) :
     5     QWidget(parent),
     5     QWidget(parent),
     6     m_ui(new Ui::TeamEdit)
     6     m_ui(new Ui::TeamEdit)
     7 {
     7 {
     8     m_ui->setupUi(this);
     8     m_ui->setupUi(this);
       
     9 
       
    10     reset();
     9 }
    11 }
    10 
    12 
    11 TeamEdit::~TeamEdit()
    13 TeamEdit::~TeamEdit()
    12 {
    14 {
    13     delete m_ui;
    15     delete m_ui;
    23     default:
    25     default:
    24         break;
    26         break;
    25     }
    27     }
    26 }
    28 }
    27 
    29 
    28 void TeamEdit::addTeam(const QString & teamName, quint32 color)
    30 void TeamEdit::reset()
       
    31 {
       
    32    QLayout * l = m_ui->scrollArea->widget()->layout();
       
    33 
       
    34    for(int i = 0; i < 8; ++i)
       
    35        l->itemAt(i)->widget()->setVisible(false);
       
    36 }
       
    37 
       
    38 void TeamEdit::setTeam(const QString & teamName, quint32 color)
    29 {
    39 {
    30     m_ui->leTeamName->setText(teamName);
    40     m_ui->leTeamName->setText(teamName);
    31 }
    41 }
    32 
    42 
    33 void TeamEdit::setFort(const QString & name)
    43 void TeamEdit::setFort(const QString & name)
    43 void TeamEdit::setVoicepack(const QString & name)
    53 void TeamEdit::setVoicepack(const QString & name)
    44 {
    54 {
    45     m_ui->leVoicepack->setText(name);
    55     m_ui->leVoicepack->setText(name);
    46 }
    56 }
    47 
    57 
       
    58 void TeamEdit::addHedgehog(quint32 level, quint32 health, const QString & name)
       
    59 {
       
    60    QLayout * l = m_ui->scrollArea->widget()->layout();
       
    61 
       
    62    int i = 0;
       
    63    while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
       
    64 
       
    65    if(i < 8)
       
    66    {
       
    67        HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
       
    68        he->setHedgehog(level, health, name);
       
    69        l->itemAt(i)->widget()->setVisible(true);
       
    70    }
       
    71 }
       
    72 
       
    73 void TeamEdit::setLastHHHat(const QString & name)
       
    74 {
       
    75    QLayout * l = m_ui->scrollArea->widget()->layout();
       
    76 
       
    77    int i = 0;
       
    78    while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
       
    79 
       
    80    --i;
       
    81 
       
    82    HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
       
    83    he->setHat(name);
       
    84 }
       
    85 
       
    86 void TeamEdit::setLastHHCoords(int x, int y)
       
    87 {
       
    88    QLayout * l = m_ui->scrollArea->widget()->layout();
       
    89 
       
    90    int i = 0;
       
    91    while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
       
    92 
       
    93    --i;
       
    94 
       
    95    HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
       
    96    he->setCoordinates(x ,y);
       
    97 }
       
    98