tools/MissionsEditor/teamedit.cpp
author smxx
Wed, 17 Feb 2010 17:38:32 +0000
changeset 2820 389e8b286afe
parent 2596 41b46f83d088
permissions -rw-r--r--
Frontend: * Possible fix to engine window losing it's focus while Xfire is active (too sporadic to test)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2589
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     1
#include "teamedit.h"
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     2
#include "ui_teamedit.h"
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     3
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     4
TeamEdit::TeamEdit(QWidget *parent) :
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     5
    QWidget(parent),
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     6
    m_ui(new Ui::TeamEdit)
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     7
{
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
     8
    m_ui->setupUi(this);
2596
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
     9
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    10
    reset();
2589
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    11
}
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    12
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    13
TeamEdit::~TeamEdit()
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    14
{
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    15
    delete m_ui;
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    16
}
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    17
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    18
void TeamEdit::changeEvent(QEvent *e)
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    19
{
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    20
    QWidget::changeEvent(e);
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    21
    switch (e->type()) {
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    22
    case QEvent::LanguageChange:
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    23
        m_ui->retranslateUi(this);
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    24
        break;
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    25
    default:
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    26
        break;
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    27
    }
4329597c85c8 Further work on missions editor
unc0rr
parents:
diff changeset
    28
}
2594
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    29
2596
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    30
void TeamEdit::reset()
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    31
{
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    32
   QLayout * l = m_ui->scrollArea->widget()->layout();
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    33
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    34
   for(int i = 0; i < 8; ++i)
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    35
       l->itemAt(i)->widget()->setVisible(false);
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    36
}
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    37
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    38
void TeamEdit::setTeam(const QString & teamName, quint32 color)
2594
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    39
{
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    40
    m_ui->leTeamName->setText(teamName);
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    41
}
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    42
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    43
void TeamEdit::setFort(const QString & name)
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    44
{
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    45
    m_ui->leFort->setText(name);
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    46
}
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    47
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    48
void TeamEdit::setGrave(const QString & name)
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    49
{
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    50
    m_ui->leGrave->setText(name);
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    51
}
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    52
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    53
void TeamEdit::setVoicepack(const QString & name)
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    54
{
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    55
    m_ui->leVoicepack->setText(name);
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    56
}
0047e16dbacb Add loading team parameters
unc0rr
parents: 2589
diff changeset
    57
2596
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    58
void TeamEdit::addHedgehog(quint32 level, quint32 health, const QString & name)
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    59
{
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    60
   QLayout * l = m_ui->scrollArea->widget()->layout();
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    61
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    62
   int i = 0;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    63
   while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    64
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    65
   if(i < 8)
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    66
   {
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    67
       HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    68
       he->setHedgehog(level, health, name);
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    69
       l->itemAt(i)->widget()->setVisible(true);
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    70
   }
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    71
}
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    72
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    73
void TeamEdit::setLastHHHat(const QString & name)
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    74
{
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    75
   QLayout * l = m_ui->scrollArea->widget()->layout();
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    76
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    77
   int i = 0;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    78
   while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    79
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    80
   --i;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    81
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    82
   HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    83
   he->setHat(name);
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    84
}
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    85
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    86
void TeamEdit::setLastHHCoords(int x, int y)
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    87
{
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    88
   QLayout * l = m_ui->scrollArea->widget()->layout();
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    89
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    90
   int i = 0;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    91
   while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    92
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    93
   --i;
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    94
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    95
   HedgehogEdit * he = qobject_cast<HedgehogEdit *>(l->itemAt(i)->widget());
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    96
   he->setCoordinates(x ,y);
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    97
}
41b46f83d088 Compete loading teams/hedgehogs part from mission config
unc0rr
parents: 2594
diff changeset
    98