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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/*
* The ManaPlus Client
* Copyright (C) 2011-2020 The ManaPlus Developers
* Copyright (C) 2020-2023 The ManaVerse Developers
*
* This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gui/widgets/tabs/targetdebugtab.h"
#include "being/localplayer.h"
#include "gui/widgets/containerplacer.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "debug.h"
TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
DebugTab(widget),
// TRANSLATORS: debug window label
mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))),
// TRANSLATORS: debug window label
mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))),
mTargetTypeLabel(new Label(this, strprintf(
// TRANSLATORS: debug window label
"%s ? ", _("Target type:")))),
// TRANSLATORS: debug window label
mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))),
// TRANSLATORS: debug window label
mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))),
// TRANSLATORS: debug window label
mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))),
// TRANSLATORS: debug window label
mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))),
// TRANSLATORS: debug window label
mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))),
// TRANSLATORS: debug window label
mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))),
// TRANSLATORS: debug window label
mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))),
// TRANSLATORS: debug window label
mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:")))),
// TRANSLATORS: debug window label
mKarmaLabel(new Label(this, strprintf("%s ?", _("Karma:")))),
// TRANSLATORS: debug window label
mMannerLabel(new Label(this, strprintf("%s ?", _("Manner:")))),
// TRANSLATORS: debug window label
mEffectsLabel(new Label(this, strprintf("%s ?", _("Effects:"))))
{
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mTargetLabel, 2, 1);
place(0, 1, mTargetIdLabel, 2, 1);
place(0, 2, mTargetTypeLabel, 2, 1);
place(0, 3, mTargetLevelLabel, 2, 1);
place(0, 4, mTargetRaceLabel, 2, 1);
place(0, 5, mAttackDelayLabel, 2, 1);
place(0, 6, mTargetPartyLabel, 2, 1);
place(0, 7, mTargetGuildLabel, 2, 1);
place(0, 8, mMinHitLabel, 2, 1);
place(0, 9, mMaxHitLabel, 2, 1);
place(0, 10, mCriticalHitLabel, 2, 1);
place(0, 11, mKarmaLabel, 2, 1);
place(0, 12, mMannerLabel, 2, 1);
place(0, 13, mEffectsLabel, 2, 1);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
setDimension(Rect(0, 0, 600, 300));
}
void TargetDebugTab::logic()
{
BLOCK_START("TargetDebugTab::logic")
if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
{
const Being *const target = localPlayer->getTarget();
// TRANSLATORS: debug window label
mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
target->getName().c_str(), target->getTileX(),
target->getTileY()));
mTargetIdLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target Id:"), toInt(target->getId(), int)));
mTargetTypeLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target type:"), toInt(target->getSubType(), int)));
if (target->getLevel() != 0)
{
mTargetLevelLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target Level:"), target->getLevel()));
}
else
{
mTargetLevelLabel->setCaption(strprintf("%s ?",
// TRANSLATORS: debug window label
_("Target Level:")));
}
mTargetRaceLabel->setCaption(strprintf("%s %s",
// TRANSLATORS: debug window label
_("Target race:"), target->getRaceName().c_str()));
// TRANSLATORS: debug window label
mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
target->getPartyName().c_str()));
// TRANSLATORS: debug window label
mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
target->getGuildName().c_str()));
mMinHitLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Minimal hit:"), target->getMinHit()));
mMaxHitLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Maximum hit:"), target->getMaxHit()));
mCriticalHitLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Critical hit:"), target->getCriticalHit()));
mKarmaLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Karma:"), target->getKarma()));
mMannerLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Manner:"), target->getManner()));
mEffectsLabel->setCaption(strprintf("%s %s",
// TRANSLATORS: debug window label
_("Effects:"), target->getStatusEffectsString().c_str()));
const int delay = target->getAttackDelay();
if (delay != 0)
{
mAttackDelayLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Attack delay:"), delay));
}
else
{
mAttackDelayLabel->setCaption(strprintf(
// TRANSLATORS: debug window label
"%s ?", _("Attack delay:")));
}
}
else
{
// TRANSLATORS: debug window label
mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
// TRANSLATORS: debug window label
mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
// TRANSLATORS: debug window label
mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:")));
// TRANSLATORS: debug window label
mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
// TRANSLATORS: debug window label
mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
// TRANSLATORS: debug window label
mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
// TRANSLATORS: debug window label
mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
// TRANSLATORS: debug window label
mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
// TRANSLATORS: debug window label
mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
// TRANSLATORS: debug window label
mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
// TRANSLATORS: debug window label
mKarmaLabel->setCaption(strprintf("%s ?", _("Karma:")));
// TRANSLATORS: debug window label
mMannerLabel->setCaption(strprintf("%s ?", _("Manner:")));
// TRANSLATORS: debug window label
mEffectsLabel->setCaption(strprintf("%s ?", _("Effects:")));
}
mTargetLabel->adjustSize();
mTargetIdLabel->adjustSize();
mTargetTypeLabel->adjustSize();
mTargetLevelLabel->adjustSize();
mTargetPartyLabel->adjustSize();
mTargetGuildLabel->adjustSize();
mAttackDelayLabel->adjustSize();
mMinHitLabel->adjustSize();
mMaxHitLabel->adjustSize();
mCriticalHitLabel->adjustSize();
mKarmaLabel->adjustSize();
mMannerLabel->adjustSize();
mEffectsLabel->adjustSize();
BLOCK_END("TargetDebugTab::logic")
}
|