QTfrontend/teamselhelper.cpp
author displacer
Fri, 15 Sep 2006 15:45:30 +0000
changeset 147 52a3c431db8a
parent 140 50ccde437ea1
child 152 c558957ef644
permissions -rw-r--r--
maximum number of teams and hedgehogs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     1
#include "teamselhelper.h"
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
     2
#include "hwconsts.h"
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     3
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     4
#include <QPixmap>
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     5
#include <QPushButton>
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
     6
#include <QPainter>
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
     7
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     8
void TeamLabel::teamButtonClicked()
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     9
{
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    10
  emit teamActivated(text());
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    11
}
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    12
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
    13
TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) :
140
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    14
  QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0)
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    15
{
134
3d87d8e58020 spacing reduced, 4 hedgehog per team by default
displacer
parents: 133
diff changeset
    16
  mainLayout.setSpacing(1);
135
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    17
  mainLayout.setMargin(2);
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    18
  this->setMaximumHeight(35);
123
6987769ced3d Various small fixes
unc0rr
parents: 120
diff changeset
    19
  QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40));
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    20
135
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    21
  QPalette newPalette = palette();
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    22
  newPalette.setColor(QPalette::Button, palette().color(backgroundRole()));
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    23
120
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    24
  QPushButton* butt=new QPushButton(*px, "", this);
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    25
  butt->setFlat(true);
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    26
  butt->setGeometry(0, 0, 30, 30);
86
664b536a1c27 Predefined teams, 'simple game' doesn't need to create team
unc0rr
parents: 84
diff changeset
    27
  butt->setMaximumWidth(30);
135
53faa20669de margin reduced (space between commands in teamselect widget)
displacer
parents: 134
diff changeset
    28
  butt->setPalette(newPalette);
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    29
  mainLayout.addWidget(butt);
120
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    30
  butt->setIconSize(butt->size());
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    31
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    32
  QPushButton* bText=new QPushButton(team.TeamName, this);
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    33
  bText->setPalette(newPalette);
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    34
  bText->setFlat(true);
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    35
  mainLayout.addWidget(bText);
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    36
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
    37
  if(m_isPlaying) {
140
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    38
    phhoger=new CHedgehogerWidget(this);
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
    39
    mainLayout.addWidget(phhoger);
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
    40
  }
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 123
diff changeset
    41
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    42
  QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam()));
120
87264c35b09a flat buttons
displacer
parents: 118
diff changeset
    43
  QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam()));
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    44
}
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    45
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    46
void TeamShowWidget::activateTeam()
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    47
{
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    48
  emit teamStatusChanged(m_team);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    49
}
140
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    50
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    51
unsigned char TeamShowWidget::getHedgehogsNum()
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    52
{
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    53
  return phhoger ? phhoger->getHedgehogsNum() : 0;
50ccde437ea1 teams and hedgedogs num selection added to HWgame
displacer
parents: 135
diff changeset
    54
}