QTfrontend/teamselect.cpp
author unc0rr
Sun, 16 Jul 2006 08:13:51 +0000
changeset 79 29b477319854
parent 63 27e2b5bb6d4b
child 84 0f6669da2fcb
permissions -rw-r--r--
- New test map - Baseball bat - Flames - Bots can use baseball bat - Many small changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     1
#include <QLabel>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     2
#include <QPixmap>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     3
#include <QPushButton>
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
     4
#include <QFrame>
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     5
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     6
#include <algorithm>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     7
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
     8
#include <vertScrollArea.h>
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     9
#include "teamselect.h"
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    10
#include "teamselhelper.h"
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    11
#include "frameTeam.h"
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    12
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    13
void TeamSelWidget::addTeam(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    14
{
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    15
  frameDontPlaying->addTeam(team);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    16
  curDontPlayingTeams.push_back(team);
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    17
  QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(tmprop)), 
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    18
		   this, SLOT(changeTeamStatus(tmprop)));
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    19
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    20
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    21
void TeamSelWidget::removeTeam(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    22
{
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    23
  //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    24
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    25
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    26
void TeamSelWidget::changeTeamStatus(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    27
{
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    28
  list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    29
  list<tmprop>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    30
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    31
  if(itDontPlay==curDontPlayingTeams.end()) {
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    32
    // playing team => dont playing
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    33
    curDontPlayingTeams.push_back(*itPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    34
    curPlayingTeams.erase(itPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    35
  } else {
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    36
    // dont playing team => playing
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    37
    curPlayingTeams.push_back(*itDontPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    38
    curDontPlayingTeams.erase(itDontPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    39
  }
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    40
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    41
  FrameTeams* pRemoveTeams;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    42
  FrameTeams* pAddTeams;
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    43
  if(itDontPlay==curDontPlayingTeams.end()) {
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    44
    pRemoveTeams=framePlaying;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    45
    pAddTeams=frameDontPlaying;
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    46
  } else {
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    47
    pRemoveTeams=frameDontPlaying;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    48
    pAddTeams=framePlaying;
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    49
  }
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    50
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    51
  pAddTeams->addTeam(team);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    52
  pRemoveTeams->removeTeam(team);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    53
}
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    54
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    55
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    56
{
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    57
  VertScrArea* area=new VertScrArea(color);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    58
  area->setWidget(pfteams);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    59
  mainLayout.addWidget(area, 50);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    60
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    61
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    62
TeamSelWidget::TeamSelWidget(QWidget* parent) :
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    63
  QWidget(parent), mainLayout(this)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    64
{
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    65
  framePlaying=new FrameTeams();
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    66
  frameDontPlaying=new FrameTeams();
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    67
  addScrArea(framePlaying, QColor("DarkTurquoise"));
27e2b5bb6d4b Scroll added to team control widget
displacer
parents: 61
diff changeset
    68
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    69
}