QTfrontend/frameTeam.cpp
author unc0rr
Thu, 20 Jul 2006 20:11:32 +0000
changeset 80 3c3dc6a148ca
parent 63 27e2b5bb6d4b
child 87 ff213e443336
permissions -rw-r--r--
- Fixed bug with hedgehog under water using rope - Add locale support in engine - Bots use ljump and hjump - Fix shotgun rating - Support for theme-dependent sprites - Horizon and sky can have any image size - Many small fixes
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 "frameTeam.h"
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     2
#include "teamselhelper.h"
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 <QResizeEvent>
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     5
#include <QCoreApplication>
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     6
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     7
using namespace std;
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     8
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
     9
FrameTeams::FrameTeams(QWidget* parent) :
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    10
  QWidget(parent), mainLayout(this)
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
}
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    13
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    14
void FrameTeams::addTeam(tmprop team)
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    15
{
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    16
  TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, this);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    17
  int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    18
  teamToWidget.insert(make_pair(team, pTeamShowWidget));
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    19
  mainLayout.addWidget(pTeamShowWidget);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    20
  QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    21
  QCoreApplication::postEvent(parentWidget(), pevent);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    22
}
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    23
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    24
void FrameTeams::removeTeam(tmprop team)
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    25
{
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    26
  tmapTeamToWidget::iterator it=teamToWidget.find(team);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    27
  mainLayout.removeWidget(it->second);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    28
  delete it->second;
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    29
  teamToWidget.erase(team);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    30
}
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    31
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    32
QWidget* FrameTeams::getTeamWidget(tmprop team)
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    33
{
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    34
  tmapTeamToWidget::iterator it=teamToWidget.find(team);
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    35
  QWidget* ret = it!=teamToWidget.end() ? it->second : 0;
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    36
  if(!ret) throw; // FIXME: this is debug exception
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    37
  return ret;
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 63
diff changeset
    38
}