tools/MissionsEditor/teamedit.cpp
branch0.9.14
changeset 4273 4035d5b78eeb
parent 4270 d1673536b6e5
parent 4271 3fa9eb4d25b9
child 4278 ac43dfa56baf
equal deleted inserted replaced
4270:d1673536b6e5 4273:4035d5b78eeb
     1 #include "teamedit.h"
       
     2 #include "ui_teamedit.h"
       
     3 
       
     4 TeamEdit::TeamEdit(QWidget *parent) :
       
     5     QWidget(parent),
       
     6     m_ui(new Ui::TeamEdit)
       
     7 {
       
     8     m_ui->setupUi(this);
       
     9 
       
    10     reset();
       
    11 }
       
    12 
       
    13 TeamEdit::~TeamEdit()
       
    14 {
       
    15     delete m_ui;
       
    16 }
       
    17 
       
    18 void TeamEdit::changeEvent(QEvent *e)
       
    19 {
       
    20     QWidget::changeEvent(e);
       
    21     switch (e->type()) {
       
    22     case QEvent::LanguageChange:
       
    23         m_ui->retranslateUi(this);
       
    24         break;
       
    25     default:
       
    26         break;
       
    27     }
       
    28 }
       
    29 
       
    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)
       
    39 {
       
    40     m_ui->leTeamName->setText(teamName);
       
    41 }
       
    42 
       
    43 void TeamEdit::setFort(const QString & name)
       
    44 {
       
    45     m_ui->leFort->setText(name);
       
    46 }
       
    47 
       
    48 void TeamEdit::setGrave(const QString & name)
       
    49 {
       
    50     m_ui->leGrave->setText(name);
       
    51 }
       
    52 
       
    53 void TeamEdit::setVoicepack(const QString & name)
       
    54 {
       
    55     m_ui->leVoicepack->setText(name);
       
    56 }
       
    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