summaryrefslogtreecommitdiffstats
path: root/kspaceduel/playerinfo.cpp
blob: 1308feaf9db8253dd203a910f616eb7fec5c2cc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "playerinfo.h"
#include <tqpixmap.h>
#include <tqtooltip.h>
#include <tdelocale.h>
#include <kstandarddirs.h>


PlayerInfo::PlayerInfo(int pnr,TQWidget *parent,const char *name)
      :TQFrame(parent,name),
       lplayer(this),lenergy(this),lwins(this),
       hitpoints(2,this),energy(2,this),wins(2,this)
{
   setFixedWidth(45);
   setFrameStyle(Panel|Raised);
   TQString str;
   int i;
   
   lplayer.setFrameStyle(Panel|Sunken);
   lplayer.setMargin(0);
   TQToolTip::add(&lplayer,i18n("Hit points"));
   lenergy.setFrameStyle(Panel|Sunken);
   lenergy.setMargin(0);
   TQToolTip::add(&lenergy,i18n("Energy"));
   lwins.setFrameStyle(Panel|Sunken);
   lwins.setMargin(0);
   TQToolTip::add(&lwins,i18n("Wins"));

   lplayer.setGeometry(5,5,35,35);
   lplayer.setIndent(0);
   lenergy.setGeometry(5,80,35,35);
   lenergy.setIndent(0);
   lwins.setGeometry(5,155,35,35);
   lwins.setIndent(0);

   for(i=0;i<4;i++)
   {
      str = TQString::fromLatin1("sprites/playerinfo/ship%1%2.pnm")
        .arg(pnr+1)
        .arg(i);
      pix[i]=new TQPixmap(locate("appdata", str));
   }

   lplayer.setPixmap(*pix[0]);
   currentPixmap=0;
   lenergy.setPixmap(TQPixmap(locate("appdata", "sprites/playerinfo/energy.pnm")));
   lwins.setPixmap(TQPixmap(locate("appdata", "sprites/playerinfo/win.pnm")));

   hitpoints.setGeometry(9,45,26,26);
   energy.setGeometry(9,120,26,26);
   wins.setGeometry(9,195,26,26);
   hitpoints.setFrameStyle(NoFrame);
   TQToolTip::add(&hitpoints,i18n("Hit points"));
   energy.setFrameStyle(NoFrame);
   TQToolTip::add(&energy,i18n("Energy"));
   wins.setFrameStyle(NoFrame);
   TQToolTip::add(&wins,i18n("Wins"));
}
       
void PlayerInfo::setHitpoints(int h)
{
   int p=3-h/25;
   hitpoints.display(h);
   if(p!=currentPixmap)
   {
      lplayer.setPixmap(*(pix[p]));
      currentPixmap=p;
   }
}

void PlayerInfo::setEnergy(int e)
{
   energy.display(e);
}

void PlayerInfo::setWins(int w)
{
   wins.display(w);
}

#include "playerinfo.moc"