QTfrontend/ui/widget/hedgehogerWidget.cpp
changeset 6060 fdfc01419815
parent 4976 088d40d8aba2
child 6616 f77bb02b669f
equal deleted inserted replaced
6059:ddf020d0941a 6060:fdfc01419815
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2008 Ulyanov Igor <iulyanov@gmail.com>
       
     4  * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
       
     5  *
       
     6  * This program is free software; you can redistribute it and/or modify
       
     7  * it under the terms of the GNU General Public License as published by
       
     8  * the Free Software Foundation; version 2 of the License
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    18  */
       
    19 
       
    20 #include "hedgehogerWidget.h"
       
    21 
       
    22 #include "frameTeam.h"
       
    23 
       
    24 CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) :
       
    25     ItemNum(im, img, parent, 1)
       
    26 {
       
    27   // TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now
       
    28   /*if(parent) {
       
    29     pOurFrameTeams = dynamic_cast<FrameTeams*>(parent->parentWidget());
       
    30   }
       
    31   if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
       
    32     numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
       
    33   } else numItems = 4;
       
    34   pOurFrameTeams->overallHedgehogs += numItems;*/
       
    35 }
       
    36 
       
    37 void CHedgehogerWidget::incItems()
       
    38 {
       
    39   //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
       
    40     numItems++;
       
    41     //pOurFrameTeams->overallHedgehogs++;
       
    42     emit hedgehogsNumChanged();
       
    43   //}
       
    44 }
       
    45 
       
    46 void CHedgehogerWidget::decItems()
       
    47 {
       
    48   numItems--;
       
    49   //pOurFrameTeams->overallHedgehogs--;
       
    50   emit hedgehogsNumChanged();
       
    51 }
       
    52 
       
    53 CHedgehogerWidget::~CHedgehogerWidget()
       
    54 {
       
    55   // TODO: not called?
       
    56   //pOurFrameTeams->overallHedgehogs-=numItems;
       
    57 }
       
    58 
       
    59 void CHedgehogerWidget::setNonInteractive()
       
    60 {
       
    61   nonInteractive=true;
       
    62 }
       
    63 
       
    64 void CHedgehogerWidget::setHHNum(unsigned int num)
       
    65 {
       
    66   /*unsigned int diff = num - numItems;
       
    67   numItems += diff;
       
    68   pOurFrameTeams->overallHedgehogs += diff;*/
       
    69   numItems = num;
       
    70   repaint();
       
    71 }
       
    72 
       
    73 unsigned char CHedgehogerWidget::getHedgehogsNum() const
       
    74 {
       
    75   return numItems;
       
    76 }