QTfrontend/teamselect.cpp
author unc0rr
Mon, 04 Jun 2007 21:15:24 +0000
changeset 536 33538aadb4e7
parent 535 a14eaf35cf4b
child 572 302ad5c3836d
permissions -rw-r--r--
- Fix some stupid bugs in collisions detecting code - Add new sprite to the build system
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     2
 * Hedgewars, a worms-like game
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
     3
 * Copyright (c) 2006, 2007 Ulyanov Igor <iulyanov@gmail.com>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     4
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
#include <QLabel>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#include <QPixmap>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
#include <QPushButton>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    22
#include <QFrame>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    23
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    24
#include <vertScrollArea.h>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include "teamselect.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    26
#include "teamselhelper.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    27
#include "frameTeam.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
339
7535ab6c3820 Run game message added, team and config info provided for net game
displacer
parents: 322
diff changeset
    29
void TeamSelWidget::addTeam(HWTeam team)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    30
{
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    31
  if(team.isNetTeam()) {
322
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    32
    framePlaying->addTeam(team, true);
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    33
    curPlayingTeams.push_back(team);
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    34
    connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
347
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
    35
		     this, SLOT(netTeamStatusChanged(const HWTeam&)));
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
    36
    connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)),
356
ca3a5dfcae75 network teams hedgehogs nums modifications now working from chief client
displacer
parents: 352
diff changeset
    37
			    this, SLOT(hhNumChanged(const HWTeam&)));
523
eddcef907b28 num hedgehogs while new team addition (dirty) fixed
displacer
parents: 492
diff changeset
    38
    dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged();
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
    39
    connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)),
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    40
			    this, SLOT(proxyTeamColorChanged(const HWTeam&)));
322
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    41
  } else {
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    42
    frameDontPlaying->addTeam(team, false);
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    43
    curDontPlayingTeams.push_back(team);
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    44
    if(m_acceptOuter) {
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    45
      connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    46
	      this, SLOT(pre_changeTeamStatus(HWTeam)));
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    47
    } else {
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    48
      connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    49
	      this, SLOT(changeTeamStatus(HWTeam)));
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
    50
    }
322
e7175ae57945 first new widgets added to net game
displacer
parents: 311
diff changeset
    51
  }
492
78e80f899b59 disable start game button with teams num < 2
displacer
parents: 486
diff changeset
    52
  emit setEnabledGameStart(curPlayingTeams.size()>1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    53
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    54
362
b28e0dd48269 hedgehogs num modification now allowed to chief client only
displacer
parents: 356
diff changeset
    55
void TeamSelWidget::setNonInteractive()
b28e0dd48269 hedgehogs num modification now allowed to chief client only
displacer
parents: 356
diff changeset
    56
{
b28e0dd48269 hedgehogs num modification now allowed to chief client only
displacer
parents: 356
diff changeset
    57
  framePlaying->setNonInteractive();
b28e0dd48269 hedgehogs num modification now allowed to chief client only
displacer
parents: 356
diff changeset
    58
}
b28e0dd48269 hedgehogs num modification now allowed to chief client only
displacer
parents: 356
diff changeset
    59
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    60
void TeamSelWidget::hhNumChanged(const HWTeam& team)
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    61
{
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    62
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    63
  itPlay->numHedgehogs=team.numHedgehogs;
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    64
  emit hhogsNumChanged(team);
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    65
}
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    66
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    67
void TeamSelWidget::proxyTeamColorChanged(const HWTeam& team)
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    68
{
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    69
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    70
  itPlay->teamColor=team.teamColor;
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    71
  emit teamColorChanged(team);
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    72
}
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    73
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    74
void TeamSelWidget::changeHHNum(const HWTeam& team)
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    75
{
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    76
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    77
  if(itPlay==curPlayingTeams.end()) return;
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    78
  itPlay->numHedgehogs=team.numHedgehogs;
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    79
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    80
  framePlaying->setHHNum(team);
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    81
}
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    82
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    83
void TeamSelWidget::changeTeamColor(const HWTeam& team)
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    84
{
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    85
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    86
  if(itPlay==curPlayingTeams.end()) return;
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    87
  itPlay->teamColor=team.teamColor;
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    88
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    89
  framePlaying->setTeamColor(team);
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    90
}
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
    91
347
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
    92
void TeamSelWidget::removeNetTeam(const HWTeam& team)
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
    93
{
348
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
    94
  for(;;) {
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    95
    QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
348
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
    96
    if(itPlay==curPlayingTeams.end()) break;
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    97
    if(itPlay->isNetTeam()) {
348
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
    98
      QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam)));
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
    99
      framePlaying->removeTeam(team);
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
   100
      curPlayingTeams.erase(itPlay);
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
   101
      break;
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
   102
    }
c91b983de18f equal team names huge bug fixed for multiple clients
displacer
parents: 347
diff changeset
   103
  }
492
78e80f899b59 disable start game button with teams num < 2
displacer
parents: 486
diff changeset
   104
  emit setEnabledGameStart(curPlayingTeams.size()>1);
347
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   105
}
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   106
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   107
void TeamSelWidget::netTeamStatusChanged(const HWTeam& team)
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   108
{
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   109
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
   110
347
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   111
}
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   112
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   113
//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   114
//{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   115
  //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   116
//}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   117
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   118
void TeamSelWidget::changeTeamStatus(HWTeam team)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   119
{
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   120
  QList<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   121
  QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   122
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   123
  bool willBePlaying=itDontPlay!=curDontPlayingTeams.end();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   124
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   125
  if(!willBePlaying) {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
    // playing team => dont playing
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   127
    curDontPlayingTeams.push_back(*itPlay);
347
6521e1b2cd40 more correct remove net teams
displacer
parents: 341
diff changeset
   128
    emit teamNotPlaying(*itPlay);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   129
    curPlayingTeams.erase(itPlay);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   130
  } else {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   131
    // return if max playing teams reached
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   132
    if(framePlaying->isFullTeams()) return;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   133
    // dont playing team => playing
482
61c617f1bec7 correct team info in frames (displaying bots difficulty fixed)
displacer
parents: 387
diff changeset
   134
    team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network)
387
66345e38826d initial colors assign fix
displacer
parents: 384
diff changeset
   135
    itDontPlay->teamColor=framePlaying->getNextColor();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   136
    curPlayingTeams.push_back(*itDontPlay);
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   137
    if(!m_acceptOuter) emit teamWillPlay(*itDontPlay);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   138
    curDontPlayingTeams.erase(itDontPlay);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   139
  }
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   140
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   141
  FrameTeams* pRemoveTeams;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   142
  FrameTeams* pAddTeams;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   143
  if(!willBePlaying) {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   144
    pRemoveTeams=framePlaying;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   145
    pAddTeams=frameDontPlaying;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   146
  } else {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   147
    pRemoveTeams=frameDontPlaying;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   148
    pAddTeams=framePlaying;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   149
  }
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   150
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   151
  pAddTeams->addTeam(team, willBePlaying);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   152
  pRemoveTeams->removeTeam(team);
384
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   153
  if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) {
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   154
    connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   155
	    this, SLOT(pre_changeTeamStatus(HWTeam)));
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   156
  } else {
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   157
    connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   158
	    this, SLOT(changeTeamStatus(HWTeam)));
29299ca39155 adding the same command twice bug fixed for net game
displacer
parents: 383
diff changeset
   159
  }
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
   160
  if(willBePlaying) {
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
   161
    connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)),
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
   162
	    this, SLOT(hhNumChanged(const HWTeam&)));
523
eddcef907b28 num hedgehogs while new team addition (dirty) fixed
displacer
parents: 492
diff changeset
   163
    dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team))->hhNumChanged();
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 482
diff changeset
   164
    connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)),
372
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
   165
	    this, SLOT(proxyTeamColorChanged(const HWTeam&)));
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
   166
    emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam());
4bac77f8cd38 network colors (alpha)
displacer
parents: 362
diff changeset
   167
  }
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   168
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   169
  QSize szh=pAddTeams->sizeHint();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   170
  QSize szh1=pRemoveTeams->sizeHint();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   171
  if(szh.isValid() && szh1.isValid()) {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   172
    pAddTeams->resize(pAddTeams->size().width(), szh.height());
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   173
    pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height());
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   174
  }
492
78e80f899b59 disable start game button with teams num < 2
displacer
parents: 486
diff changeset
   175
78e80f899b59 disable start game button with teams num < 2
displacer
parents: 486
diff changeset
   176
  emit setEnabledGameStart(curPlayingTeams.size()>1);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   177
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   178
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 244
diff changeset
   179
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int maxHeight)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   180
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   181
  VertScrArea* area=new VertScrArea(color);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   182
  area->setWidget(pfteams);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   183
  mainLayout.addWidget(area, 30);
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 244
diff changeset
   184
  if (maxHeight > 0)
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 244
diff changeset
   185
  	area->setMaximumHeight(maxHeight);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   186
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   187
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   188
TeamSelWidget::TeamSelWidget(QWidget* parent) :
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   189
  QGroupBox(parent), mainLayout(this), m_acceptOuter(false)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   190
{
240
c7f0a4f7a54a Better-looking multiplayer page
unc0rr
parents: 231
diff changeset
   191
  setTitle(QGroupBox::tr("Playing teams"));
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   192
  framePlaying=new FrameTeams();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   193
  frameDontPlaying=new FrameTeams();
244
b37ca2295b73 - Fix crosshair position
unc0rr
parents: 240
diff changeset
   194
//  addScrArea(framePlaying, QColor("DarkTurquoise"));
b37ca2295b73 - Fix crosshair position
unc0rr
parents: 240
diff changeset
   195
//  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
b37ca2295b73 - Fix crosshair position
unc0rr
parents: 240
diff changeset
   196
  QPalette p;
311
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 244
diff changeset
   197
  addScrArea(framePlaying, p.color(QPalette::Window).light(105), 200);
b8905423f19f - Limit list of teams in game with 200 px
unc0rr
parents: 244
diff changeset
   198
  addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0);
535
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   199
  QPushButton * btnSetup = new QPushButton(this);
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   200
  btnSetup->setText(QPushButton::tr("Setup"));
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   201
  connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   202
  mainLayout.addWidget(btnSetup);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   203
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   204
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   205
void TeamSelWidget::setAcceptOuter(bool acceptOuter)
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   206
{
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   207
  m_acceptOuter=acceptOuter;
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   208
}
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   209
231
c77b16e48273 bots power icons added
displacer
parents: 207
diff changeset
   210
void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   211
{
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   212
  QList<HWTeam>::iterator it;
383
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   213
  //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) {
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   214
  //framePlaying->removeTeam(*it);
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   215
  //}
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   216
  framePlaying->resetTeams();
207
287077789132 coosing colors added
displacer
parents: 184
diff changeset
   217
  framePlaying->resetColors();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   218
  curPlayingTeams.clear();
383
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   219
  //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) {
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   220
  //frameDontPlaying->removeTeam(*it);
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   221
  //}
09a8795105a4 some disconnect and remove teams bugfixes
displacer
parents: 382
diff changeset
   222
  frameDontPlaying->resetTeams();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   223
  curDontPlayingTeams.clear();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   224
231
c77b16e48273 bots power icons added
displacer
parents: 207
diff changeset
   225
  for (QList<HWTeam>::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   226
    addTeam(*it);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   227
  }
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   228
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   229
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   230
bool TeamSelWidget::isPlaying(HWTeam team) const
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   231
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   232
  return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   233
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   234
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
   235
QList<HWTeam> TeamSelWidget::getPlayingTeams() const
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   236
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   237
  return curPlayingTeams;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   238
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   239
535
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   240
QList<HWTeam> TeamSelWidget::getDontPlayingTeams() const
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   241
{
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   242
  return curDontPlayingTeams;
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   243
}
a14eaf35cf4b "Setup" button instead of "New team", exclude playing teams from setup
displacer
parents: 523
diff changeset
   244
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   245
void TeamSelWidget::pre_changeTeamStatus(HWTeam team)
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   246
{
382
e7220e48ead1 colors changing config fully working (still need disabling in slaves)
displacer
parents: 373
diff changeset
   247
  team.teamColor=framePlaying->getNextColor();
373
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   248
  emit acceptRequested(team);
df912aab6b7e network team add can be denied by server
displacer
parents: 372
diff changeset
   249
}