ManaPlus
targetdebugtab.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
23 
24 #include "being/localplayer.h"
25 
27 #include "gui/widgets/label.h"
29 
30 #include "utils/gettext.h"
31 #include "utils/stringutils.h"
32 
33 #include "debug.h"
34 
36  DebugTab(widget),
37  // TRANSLATORS: debug window label
38  mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))),
39  // TRANSLATORS: debug window label
40  mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))),
41  mTargetTypeLabel(new Label(this, strprintf(
42  // TRANSLATORS: debug window label
43  "%s ? ", _("Target type:")))),
44  // TRANSLATORS: debug window label
45  mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))),
46  // TRANSLATORS: debug window label
47  mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))),
48  // TRANSLATORS: debug window label
49  mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))),
50  // TRANSLATORS: debug window label
51  mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))),
52  // TRANSLATORS: debug window label
53  mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))),
54  // TRANSLATORS: debug window label
55  mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))),
56  // TRANSLATORS: debug window label
57  mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))),
58  // TRANSLATORS: debug window label
59  mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:")))),
60  // TRANSLATORS: debug window label
61  mKarmaLabel(new Label(this, strprintf("%s ?", _("Karma:")))),
62  // TRANSLATORS: debug window label
63  mMannerLabel(new Label(this, strprintf("%s ?", _("Manner:")))),
64  // TRANSLATORS: debug window label
65  mEffectsLabel(new Label(this, strprintf("%s ?", _("Effects:"))))
66 {
67  LayoutHelper h(this);
68  ContainerPlacer place = h.getPlacer(0, 0);
69 
70  place(0, 0, mTargetLabel, 2, 1);
71  place(0, 1, mTargetIdLabel, 2, 1);
72  place(0, 2, mTargetTypeLabel, 2, 1);
73  place(0, 3, mTargetLevelLabel, 2, 1);
74  place(0, 4, mTargetRaceLabel, 2, 1);
75  place(0, 5, mAttackDelayLabel, 2, 1);
76  place(0, 6, mTargetPartyLabel, 2, 1);
77  place(0, 7, mTargetGuildLabel, 2, 1);
78  place(0, 8, mMinHitLabel, 2, 1);
79  place(0, 9, mMaxHitLabel, 2, 1);
80  place(0, 10, mCriticalHitLabel, 2, 1);
81  place(0, 11, mKarmaLabel, 2, 1);
82  place(0, 12, mMannerLabel, 2, 1);
83  place(0, 13, mEffectsLabel, 2, 1);
84 
85  place.getCell().matchColWidth(0, 0);
86  place = h.getPlacer(0, 1);
87  setDimension(Rect(0, 0, 600, 300));
88 }
89 
91 {
92  BLOCK_START("TargetDebugTab::logic")
93  if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
94  {
95  const Being *const target = localPlayer->getTarget();
96 
97  // TRANSLATORS: debug window label
98  mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
99  target->getName().c_str(), target->getTileX(),
100  target->getTileY()));
101 
103  // TRANSLATORS: debug window label
104  _("Target Id:"), toInt(target->getId(), int)));
106  // TRANSLATORS: debug window label
107  _("Target type:"), toInt(target->getSubType(), int)));
108  if (target->getLevel() != 0)
109  {
111  // TRANSLATORS: debug window label
112  _("Target Level:"), target->getLevel()));
113  }
114  else
115  {
117  // TRANSLATORS: debug window label
118  _("Target Level:")));
119  }
120 
122  // TRANSLATORS: debug window label
123  _("Target race:"), target->getRaceName().c_str()));
124 
125  // TRANSLATORS: debug window label
126  mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
127  target->getPartyName().c_str()));
128 
129  // TRANSLATORS: debug window label
130  mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
131  target->getGuildName().c_str()));
132 
134  // TRANSLATORS: debug window label
135  _("Minimal hit:"), target->getMinHit()));
137  // TRANSLATORS: debug window label
138  _("Maximum hit:"), target->getMaxHit()));
140  // TRANSLATORS: debug window label
141  _("Critical hit:"), target->getCriticalHit()));
143  // TRANSLATORS: debug window label
144  _("Karma:"), target->getKarma()));
146  // TRANSLATORS: debug window label
147  _("Manner:"), target->getManner()));
149  // TRANSLATORS: debug window label
150  _("Effects:"), target->getStatusEffectsString().c_str()));
151 
152  const int delay = target->getAttackDelay();
153  if (delay != 0)
154  {
156  // TRANSLATORS: debug window label
157  _("Attack delay:"), delay));
158  }
159  else
160  {
162  // TRANSLATORS: debug window label
163  "%s ?", _("Attack delay:")));
164  }
165  }
166  else
167  {
168  // TRANSLATORS: debug window label
169  mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
170  // TRANSLATORS: debug window label
171  mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
172  // TRANSLATORS: debug window label
173  mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:")));
174  // TRANSLATORS: debug window label
175  mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
176  // TRANSLATORS: debug window label
177  mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
178  // TRANSLATORS: debug window label
179  mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
180  // TRANSLATORS: debug window label
181  mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
182  // TRANSLATORS: debug window label
183  mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
184  // TRANSLATORS: debug window label
185  mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
186  // TRANSLATORS: debug window label
187  mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
188  // TRANSLATORS: debug window label
189  mKarmaLabel->setCaption(strprintf("%s ?", _("Karma:")));
190  // TRANSLATORS: debug window label
191  mMannerLabel->setCaption(strprintf("%s ?", _("Manner:")));
192  // TRANSLATORS: debug window label
193  mEffectsLabel->setCaption(strprintf("%s ?", _("Effects:")));
194  }
195 
209  BLOCK_END("TargetDebugTab::logic")
210 }
BeingId getId() const
Definition: actorsprite.h:64
std::string getStatusEffectsString() const
Definition: being.h:96
int getKarma() const
Definition: being.h:1034
virtual int getLevel() const
Definition: being.h:604
std::string getRaceName() const
Definition: being.h:861
int getTileX() const
Definition: being.h:168
int getMaxHit() const
Definition: being.h:782
BeingTypeId getSubType() const
Definition: being.h:400
int getCriticalHit() const
Definition: being.h:788
const std::string & getPartyName() const
Definition: being.h:255
int getMinHit() const
Definition: being.h:776
int getTileY() const
Definition: being.h:174
int getManner() const
Definition: being.h:1040
const std::string & getName() const
Definition: being.h:232
const std::string & getGuildName() const
Definition: being.h:259
int getAttackDelay() const
Definition: being.h:773
LayoutCell & getCell()
Definition: label.h:91
void adjustSize()
Definition: label.cpp:200
void setCaption(const std::string &caption)
Definition: label.cpp:264
void matchColWidth(const int n1, const int n2)
Definition: layoutcell.cpp:118
ContainerPlacer getPlacer(const int x, const int y)
Being * getTarget() const
Definition: rect.h:74
Label * mCriticalHitLabel
Label * mMannerLabel
Label * mKarmaLabel
Label * mMaxHitLabel
Label * mTargetLabel
Label * mTargetRaceLabel
Label * mEffectsLabel
TargetDebugTab(const Widget2 *const widget)
Label * mAttackDelayLabel
Label * mTargetIdLabel
Label * mTargetGuildLabel
Label * mTargetPartyLabel
Label * mMinHitLabel
Label * mTargetTypeLabel
Label * mTargetLevelLabel
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
#define new
Definition: debug_new.h:147
#define _(s)
Definition: gettext.h:35
#define toInt(val, name)
Definition: intdefines.h:47
LocalPlayer * localPlayer
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
std::string strprintf(const char *const format,...)