author | unC0Rr |
Mon, 02 Oct 2023 21:36:13 +0200 | |
changeset 15979 | 1635ce22b214 |
parent 13228 | d23742ccf92b |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2006-2008 Ulyanov Igor <iulyanov@gmail.com> |
11046 | 4 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
184 | 18 |
*/ |
19 |
||
20 |
#include "hedgehogerWidget.h" |
|
21 |
||
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
22 |
#include <QPainter> |
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
23 |
|
184 | 24 |
#include "frameTeam.h" |
25 |
||
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3871
diff
changeset
|
26 |
CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) : |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3871
diff
changeset
|
27 |
ItemNum(im, img, parent, 1) |
184 | 28 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
29 |
// TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
30 |
/*if(parent) { |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
31 |
pOurFrameTeams = dynamic_cast<FrameTeams*>(parent->parentWidget()); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
32 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
33 |
if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) { |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
34 |
numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
35 |
} else numItems = 4; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
36 |
pOurFrameTeams->overallHedgehogs += numItems;*/ |
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
37 |
|
6969
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
38 |
this->setMinimumWidth(48); |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
39 |
} |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
40 |
|
1300 | 41 |
void CHedgehogerWidget::incItems() |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
42 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
43 |
//if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) { |
624 | 44 |
numItems++; |
3871 | 45 |
//pOurFrameTeams->overallHedgehogs++; |
624 | 46 |
emit hedgehogsNumChanged(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
47 |
//} |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
48 |
} |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
49 |
|
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
50 |
void CHedgehogerWidget::decItems() |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
579
diff
changeset
|
51 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
52 |
numItems--; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
53 |
//pOurFrameTeams->overallHedgehogs--; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
54 |
emit hedgehogsNumChanged(); |
184 | 55 |
} |
56 |
||
57 |
CHedgehogerWidget::~CHedgehogerWidget() |
|
58 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
59 |
// TODO: not called? |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
60 |
//pOurFrameTeams->overallHedgehogs-=numItems; |
184 | 61 |
} |
62 |
||
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
352
diff
changeset
|
63 |
void CHedgehogerWidget::setNonInteractive() |
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
352
diff
changeset
|
64 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
65 |
nonInteractive=true; |
13228
d23742ccf92b
Frontend: Properly “gray out” most disabled widgets (a lot of them weren't)
Wuzzy <Wuzzy2@mail.ru>
parents:
11863
diff
changeset
|
66 |
repaint(); |
362
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
352
diff
changeset
|
67 |
} |
b28e0dd48269
hedgehogs num modification now allowed to chief client only
displacer
parents:
352
diff
changeset
|
68 |
|
352 | 69 |
void CHedgehogerWidget::setHHNum(unsigned int num) |
70 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
71 |
/*unsigned int diff = num - numItems; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
72 |
numItems += diff; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
73 |
pOurFrameTeams->overallHedgehogs += diff;*/ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
74 |
numItems = num; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
75 |
repaint(); |
352 | 76 |
} |
77 |
||
207 | 78 |
unsigned char CHedgehogerWidget::getHedgehogsNum() const |
184 | 79 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
80 |
return numItems; |
184 | 81 |
} |
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
82 |
|
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
83 |
void CHedgehogerWidget::paintEvent(QPaintEvent* event) |
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
84 |
{ |
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
85 |
Q_UNUSED(event); |
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
86 |
|
11863 | 87 |
if ((this->width() >= 11 * numItems + 26) || (numItems == 1)) |
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
88 |
ItemNum::paintEvent(event); |
6969
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
89 |
else |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
90 |
{ |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
91 |
int width = this->width() - 38; |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
92 |
QPainter painter(this); |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
93 |
|
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
94 |
for(int i=0; i<numItems; i++) |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
95 |
{ |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
96 |
QRect target((i * width) / (numItems -1), i % 2, 25, 35); |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
97 |
if (enabled) |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
98 |
{ |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
99 |
painter.drawImage(target, m_im); |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
100 |
} |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
101 |
else |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
102 |
{ |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
103 |
painter.drawImage(target, m_img); |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
104 |
} |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
105 |
} |
3273a2b983ca
made the hog count thingy prettier when on low space... have fun squishing hogs!
sheepluva
parents:
6968
diff
changeset
|
106 |
} |
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
107 |
|
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
108 |
QPainter painter(this); |
13228
d23742ccf92b
Frontend: Properly “gray out” most disabled widgets (a lot of them weren't)
Wuzzy <Wuzzy2@mail.ru>
parents:
11863
diff
changeset
|
109 |
if(nonInteractive) |
d23742ccf92b
Frontend: Properly “gray out” most disabled widgets (a lot of them weren't)
Wuzzy <Wuzzy2@mail.ru>
parents:
11863
diff
changeset
|
110 |
painter.setPen(QPen(QColor("#FFA0A0A0"))); |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6969
diff
changeset
|
111 |
painter.setFont(QFont("MS Shell Dlg", 10, QFont::Bold)); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6969
diff
changeset
|
112 |
painter.drawText(this->width() - 12, 23, QString::number(numItems)); |
6968
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
113 |
|
23722ba0f89a
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
sheepluva
parents:
6952
diff
changeset
|
114 |
} |