ManaPlus
equipmentwindow.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2017 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
24 
25 #include "configuration.h"
26 #include "dragdrop.h"
27 
28 #include "being/localplayer.h"
29 #include "being/playerinfo.h"
30 
31 #include "gui/fonts/font.h"
32 
33 #include "gui/popups/popupmenu.h"
34 #include "gui/popups/itempopup.h"
35 
37 
38 #include "gui/widgets/button.h"
41 #include "gui/widgets/playerbox.h"
42 #include "gui/widgets/tabstrip.h"
43 
45 
46 #include "resources/imageset.h"
47 
48 #include "utils/checkutils.h"
49 #include "utils/delete2.h"
50 #include "utils/dtor.h"
51 #include "utils/foreach.h"
52 #include "utils/gettext.h"
53 
54 #include "net/inventoryhandler.h"
55 
56 #include "debug.h"
57 
60 static const int BOX_COUNT = 27;
62 
64  Being *const being,
65  const bool foring) :
66  // TRANSLATORS: equipment window name
67  Window(_("Equipment"), Modal_false, nullptr, "equipment.xml"),
69  mEquipment(equipment),
70  mPlayerBox(new PlayerBox(this,
71  "equipment_playerbox.xml",
72  "equipment_selectedplayerbox.xml")),
73  // TRANSLATORS: equipment window button
74  mUnequip(new Button(this, _("Unequip"), "unequip", this)),
75  mImageSet(nullptr),
76  mBeing(being),
77  mSlotBackground(),
78  mSlotHighlightedBackground(),
79  mVertexes(new ImageCollection),
80  mPages(),
81  mTabs(nullptr),
82  mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
83  mBorderColor(getThemeColor(ThemeColorId::BORDER)),
84  mLabelsColor(getThemeColor(ThemeColorId::LABEL)),
85  mLabelsColor2(getThemeColor(ThemeColorId::LABEL_OUTLINE)),
86  mSelected(-1),
87  mItemPadding(getOption("itemPadding")),
88  mBoxSize(getOption("boxSize")),
89  mButtonPadding(getOption("buttonPadding", 5)),
90  mMinX(180),
91  mMinY(345),
92  mMaxX(0),
93  mMaxY(0),
94  mYPadding(0),
95  mSelectedTab(0),
96  mForing(foring),
97  mHaveDefaultPage(false)
98 {
99  const int size = config.getIntValue("fontSize")
100  + getOption("tabHeightAdjust", 16);
101  mTabs = new TabStrip(this, "equipment", size);
102  mTabs->addActionListener(this);
103  mTabs->setActionEventId("tab_");
104  mTabs->setSelectable(false);
105 
106  mYPadding = mTabs->getHeight() + getOption("tabPadding", 2);
107 
108  if (setupWindow != nullptr)
110 
111  if (mBoxSize == 0)
112  mBoxSize = 36;
113 
114  // Control that shows the Player
115  mPlayerBox->setDimension(Rect(50, 80 + mYPadding, 74, 168));
116  mPlayerBox->setPlayer(being);
117  mPlayerBox->setSelectable(false);
118 
119  if (foring)
120  setWindowName("Being equipment");
121  else
122  setWindowName("Equipment");
123 
124  setCloseButton(true);
125  setSaveVisible(true);
126  setStickyButtonLock(true);
127 
128  fillBoxes();
129  recalcSize();
130  updatePage();
131  loadWindowState();
132 }
133 
135 {
137  const Rect &area = getChildrenArea();
140  mUnequip->setEnabled(false);
141 
142  ImageRect rect;
143  theme->loadRect(rect, "equipment_background.xml", "", 0, 1);
144  mSlotBackground = rect.grid[0];
146  add(mTabs);
147  add(mPlayerBox);
148  add(mUnequip);
149  enableVisibleSound(true);
150  mPlayerBox->setActionEventId("playerbox");
152 }
153 
155 {
156  if (this == beingEquipmentWindow)
157  {
158  if (mEquipment != nullptr)
159  delete mEquipment->getBackend();
161  }
162  FOR_EACH (STD_VECTOR<EquipmentPage*>::iterator, it, mPages)
163  {
164  STD_VECTOR<EquipmentBox*> &boxes = (*it)->boxes;
165  delete_all(boxes);
166  boxes.clear();
167  delete *it;
168  }
169  if (mImageSet != nullptr)
170  {
171  mImageSet->decRef();
172  mImageSet = nullptr;
173  }
174  if (mSlotBackground != nullptr)
176  if (mSlotHighlightedBackground != nullptr)
179 }
180 
181 void EquipmentWindow::draw(Graphics *const graphics)
182 {
183  BLOCK_START("EquipmentWindow::draw")
184  // Draw window graphics
185  Window::draw(graphics);
186 
187  int i = 0;
188  Font *const font = getFont();
189  const int fontHeight = font->getHeight();
190  const STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
191 
192  if (mLastRedraw)
193  {
194  mVertexes->clear();
195  FOR_EACH (STD_VECTOR<EquipmentBox*>::const_iterator, it, boxes)
196  {
197  const EquipmentBox *const box = *it;
198  if (box == nullptr)
199  {
200  i ++;
201  continue;
202  }
203  if (i == mSelected)
204  {
205  graphics->calcTileCollection(mVertexes,
207  box->x, box->y);
208  }
209  else
210  {
211  graphics->calcTileCollection(mVertexes,
213  box->x, box->y);
214  }
215  i ++;
216  }
217  graphics->finalize(mVertexes);
218  }
219  graphics->drawTileCollection(mVertexes);
220 
221  if (mEquipment == nullptr)
222  {
223  BLOCK_END("EquipmentWindow::draw")
224  return;
225  }
226 
227  i = 0;
228  const int projSlot = inventoryHandler->getProjectileSlot();
229  for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
230  it_end = boxes.end(); it != it_end; ++ it, ++ i)
231  {
232  const EquipmentBox *const box = *it;
233  if (box == nullptr)
234  continue;
235  const Item *const item = mEquipment->getEquipment(i);
236  if (item != nullptr)
237  {
238  // Draw Item.
239  Image *const image = item->getImage();
240  if (image != nullptr)
241  {
242  image->setAlpha(1.0F); // Ensure the image is drawn
243  // with maximum opacity
244  graphics->drawImage(image, box->x + mItemPadding,
245  box->y + mItemPadding);
246  if (i == projSlot)
247  {
248  const std::string str = toString(item->getQuantity());
249  font->drawString(graphics,
250  mLabelsColor,
252  str,
253  box->x + (mBoxSize - font->getWidth(str)) / 2,
254  box->y - fontHeight);
255  }
256  }
257  }
258  else if (box->image != nullptr)
259  {
260  graphics->drawImage(box->image,
261  box->x + mItemPadding,
262  box->y + mItemPadding);
263  }
264  }
265  BLOCK_END("EquipmentWindow::draw")
266 }
267 
268 void EquipmentWindow::safeDraw(Graphics *const graphics)
269 {
270  BLOCK_START("EquipmentWindow::draw")
271  // Draw window graphics
272  Window::safeDraw(graphics);
273 
274  int i = 0;
275  Font *const font = getFont();
276  const int fontHeight = font->getHeight();
277  const STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
278 
279  for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
280  it_end = boxes.end(); it != it_end; ++ it, ++ i)
281  {
282  const EquipmentBox *const box = *it;
283  if (box == nullptr)
284  continue;
285  if (i == mSelected)
286  {
288  box->x, box->y);
289  }
290  else
291  {
292  graphics->drawImage(mSlotBackground, box->x, box->y);
293  }
294  }
295 
296  if (mEquipment == nullptr)
297  {
298  BLOCK_END("EquipmentWindow::draw")
299  return;
300  }
301 
302  i = 0;
303  const int projSlot = inventoryHandler->getProjectileSlot();
304  for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
305  it_end = boxes.end(); it != it_end; ++ it, ++ i)
306  {
307  const EquipmentBox *const box = *it;
308  if (box == nullptr)
309  continue;
310  const Item *const item = mEquipment->getEquipment(i);
311  if (item != nullptr)
312  {
313  // Draw Item.
314  Image *const image = item->getImage();
315  if (image != nullptr)
316  {
317  image->setAlpha(1.0F); // Ensure the image is drawn
318  // with maximum opacity
319  graphics->drawImage(image, box->x + mItemPadding,
320  box->y + mItemPadding);
321  if (i == projSlot)
322  {
323  const std::string str = toString(item->getQuantity());
324  font->drawString(graphics,
325  mLabelsColor,
327  str,
328  box->x + (mBoxSize - font->getWidth(str)) / 2,
329  box->y - fontHeight);
330  }
331  }
332  }
333  else if (box->image != nullptr)
334  {
335  graphics->drawImage(box->image,
336  box->x + mItemPadding,
337  box->y + mItemPadding);
338  }
339  }
340  BLOCK_END("EquipmentWindow::draw")
341 }
342 
344 {
345  const std::string &eventId = event.getId();
346  if (eventId == "unequip")
347  {
348  if ((mEquipment == nullptr) || mSelected == -1)
349  return;
350 
351  const Item *const item = mEquipment->getEquipment(mSelected);
353  setSelected(-1);
354  }
355  else if (eventId.find("tab_") == 0u)
356  {
357  Button *const button = dynamic_cast<Button*>(event.getSource());
358  if (button == nullptr)
359  return;
360  mSelectedTab = button->getTag();
361  updatePage();
362  }
363  else if (eventId == "playerbox")
364  {
365  const DragDropSourceT src = dragDrop.getSource();
367  && src != DragDropSource::Equipment))
368  {
369  return;
370  }
371  Inventory *const inventory = localPlayer != nullptr
372  ? PlayerInfo::getInventory() : nullptr;
373  if (inventory == nullptr)
374  return;
375  Item *const item = inventory->findItem(dragDrop.getItem(),
377  if (item == nullptr)
378  return;
379 
381  {
382  if (item->isEquipment() == Equipm_true)
383  {
384  if (item->isEquipped() == Equipped_false)
386  }
387  }
388  }
389 }
390 
392 {
393  EquipmentPage *const page = mPages[mSelectedTab];
394  const Visible visible = fromBool(page->showPlayerBox, Visible);
395  mPlayerBox->setVisible(visible);
396  if (visible == Visible_true)
397  {
398  mPlayerBox->setDimension(Rect(page->x, page->y,
399  page->width, page->height));
400  }
401  mRedraw = true;
402 }
403 
404 const Item *EquipmentWindow::getItem(const int x, const int y) const
405 {
406  if (mEquipment == nullptr)
407  return nullptr;
408 
409  int i = 0;
410 
411  STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
412  for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
413  it_end = boxes.end(); it != it_end; ++ it, ++ i)
414  {
415  const EquipmentBox *const box = *it;
416  if (box == nullptr)
417  continue;
418  const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
419 
420  if (tRect.isPointInRect(x, y))
421  return mEquipment->getEquipment(i);
422  }
423  return nullptr;
424 }
425 
427 {
428  if (mEquipment == nullptr)
429  {
430  Window::mousePressed(event);
431  return;
432  }
433 
434  const int x = event.getX();
435  const int y = event.getY();
436 
437  if (event.getButton() == MouseButton::LEFT)
438  {
439  if (mForing)
440  {
441  Window::mousePressed(event);
442  return;
443  }
444  // Checks if any of the presses were in the equip boxes.
445  int i = 0;
446 
447  bool inBox(false);
448 
449  STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
450  for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
451  it_end = boxes.end(); it != it_end; ++ it, ++ i)
452  {
453  const EquipmentBox *const box = *it;
454  if (box == nullptr)
455  continue;
456  const Item *const item = mEquipment->getEquipment(i);
457  const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
458 
459  if (tRect.isPointInRect(x, y))
460  {
461  inBox = true;
462  if (item != nullptr)
463  {
464  event.consume();
465  setSelected(i);
467  return;
468  }
469  }
470  if (inBox)
471  return;
472  }
473  }
474  else if (event.getButton() == MouseButton::RIGHT)
475  {
476  if (const Item *const item = getItem(x, y))
477  {
478  if (itemPopup != nullptr)
480 
481  /* Convert relative to the window coordinates to absolute screen
482  * coordinates.
483  */
484  const int mx = x + getX();
485  const int my = y + getY();
486  if (popupMenu != nullptr)
487  {
488  event.consume();
489  if (mForing)
490  {
492  }
493  else
494  {
495  popupMenu->showPopup(this, mx, my, item,
497  }
498  return;
499  }
500  }
501  }
502  Window::mousePressed(event);
503 }
504 
506 {
507  Window::mouseReleased(event);
508  const DragDropSourceT src = dragDrop.getSource();
510  && src != DragDropSource::Equipment))
511  {
512  return;
513  }
514  Inventory *const inventory = localPlayer != nullptr
515  ? PlayerInfo::getInventory() : nullptr;
516  if (inventory == nullptr)
517  return;
518 
519  Item *const item = inventory->findItem(dragDrop.getItem(),
521  if (item == nullptr)
522  return;
523 
525  {
526  if (item->isEquipment() == Equipm_true)
527  {
528  if (item->isEquipped() == Equipped_false)
530  }
531  }
533  {
534  if (item->isEquipment() == Equipm_true)
535  {
536  const int x = event.getX();
537  const int y = event.getY();
538  STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
539  for (STD_VECTOR<EquipmentBox*>::const_iterator
540  it = boxes.begin(), it_end = boxes.end();
541  it != it_end; ++ it)
542  {
543  const EquipmentBox *const box = *it;
544  if (box == nullptr)
545  continue;
546  const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
547 
548  if (tRect.isPointInRect(x, y))
549  return;
550  }
551 
552  if (item->isEquipped() == Equipped_true)
554  }
555  }
556  dragDrop.clear();
557  dragDrop.deselect();
558 }
559 
560 // Show ItemTooltip
562 {
563  Window::mouseMoved(event);
564 
565  if (itemPopup == nullptr)
566  return;
567 
568  const int x = event.getX();
569  const int y = event.getY();
570 
571  const Item *const item = getItem(x, y);
572 
573  if (item != nullptr)
574  {
575  itemPopup->setItem(item, false);
576  itemPopup->position(x + getX(), y + getY());
577  }
578  else
579  {
581  }
582 }
583 
584 // Hide ItemTooltip
586 {
587  if (itemPopup != nullptr)
589 }
590 
591 void EquipmentWindow::setSelected(const int index)
592 {
593  mSelected = index;
594  mRedraw = true;
595  if (mUnequip != nullptr)
596  mUnequip->setEnabled(mSelected != -1);
597  if (itemPopup != nullptr)
599 }
600 
602 {
603  mPlayerBox->setPlayer(being);
604  mBeing = being;
605  if (mEquipment != nullptr)
606  delete mEquipment->getBackend();
607  delete mEquipment;
608  if (being == nullptr)
609  {
610  mEquipment = nullptr;
611  return;
612  }
613  mEquipment = being->getEquipment();
614 }
615 
617 {
618  if (being == mBeing)
619  setBeing(being);
620 }
621 
622 void EquipmentWindow::resetBeing(const Being *const being)
623 {
624  if (being == mBeing)
625  setBeing(nullptr);
626 }
627 
629 {
630  XML::Document *const doc = new XML::Document(
631  paths.getStringValue("equipmentWindowFile"),
634  XmlNodeConstPtr root = doc->rootNode();
635  if (root == nullptr)
636  {
637  delete doc;
638  fillDefault();
639  return;
640  }
641 
642  if (mImageSet != nullptr)
643  mImageSet->decRef();
644 
646  root, "image", "equipmentbox.png"), 32, 32);
647 
648  for_each_xml_child_node(node, root)
649  {
650  if (xmlNameEqual(node, "page"))
651  {
652  loadPage(node);
653  }
654  }
655  delete doc;
656  if (reportTrue(mPages.empty()))
657  fillDefault();
658 }
659 
661 {
662  if (!mHaveDefaultPage)
663  {
664  mHaveDefaultPage = true;
665  // TRANSLATORS: equipment window tab
666  addPage(_("default"));
667  }
668 }
669 
670 void EquipmentWindow::loadPage(XmlNodeConstPtr node)
671 {
672  if (node == nullptr)
673  return;
674  // TRANSLATORS: unknown equipment page name
675  const std::string &name = XML::langProperty(node, "name", _("Unknown"));
676  const int page = addPage(name);
677  for_each_xml_child_node(childNode, node)
678  {
679  if (xmlNameEqual(childNode, "playerbox"))
680  loadPlayerBox(childNode, page);
681  else if (xmlNameEqual(childNode, "slot"))
682  loadSlot(childNode, mImageSet, page);
683  }
684 }
685 
686 void EquipmentWindow::loadPlayerBox(XmlNodeConstPtr playerBoxNode,
687  const int page)
688 {
689  EquipmentPage *const data = mPages[page];
690  data->x = XML::getProperty(playerBoxNode, "x", 50);
691  data->y = XML::getProperty(playerBoxNode, "y", 80) + mYPadding;
692  data->width = XML::getProperty(playerBoxNode, "width", 74);
693  data->height = XML::getProperty(playerBoxNode, "height", 168);
694 }
695 
696 void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
697  const ImageSet *const imageset,
698  const int page)
699 {
700  if (imageset == nullptr)
701  return;
702  const int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
703  if (slot < 0)
704  return;
705 
706  const int x = XML::getProperty(slotNode, "x", 0) + getPadding();
707  const int y = XML::getProperty(slotNode, "y", 0)
709  const int imageIndex = XML::getProperty(slotNode, "image", -1);
710  Image *image = nullptr;
711 
712  if (imageIndex >= 0 && imageIndex < CAST_S32(imageset->size()))
713  image = imageset->get(imageIndex);
714 
715  STD_VECTOR<EquipmentBox*> &boxes = mPages[page]->boxes;
716  if (boxes[slot] != nullptr)
717  {
718  EquipmentBox *const box = boxes[slot];
719  box->x = x;
720  box->y = y;
721  box->image = image;
722  }
723  else
724  {
725  boxes[slot] = new EquipmentBox(x, y, image);
726  }
727  if (x < mMinX)
728  mMinX = x;
729  if (y < mMinY)
730  mMinY = y;
731  if (x + mBoxSize > mMaxX)
732  mMaxX = x + mBoxSize;
733  if (y + mBoxSize > mMaxY)
734  mMaxY = y + mBoxSize;
735 }
736 
738 {
739  mSlotNames.clear();
740  XML::Document doc(paths.getStringValue("equipmentSlotsFile"),
743  XmlNodeConstPtrConst root = doc.rootNode();
744  if (root == nullptr)
745  return;
746 
747  for_each_xml_child_node(slotNode, root)
748  {
749  if (!xmlNameEqual(slotNode, "slot"))
750  continue;
751  const std::string name = XML::getProperty(slotNode, "name", "");
752  if (name.empty())
753  {
754  reportAlways("Empty slot name detected.");
755  continue;
756  }
757 
758  const int slot = XML::getProperty(slotNode, "slot", -1);
759  if (slot < 0 || slot >= BOX_COUNT)
760  {
761  reportAlways("Wrong slot id '%d' for slot with name '%s'",
762  slot,
763  name.c_str());
764  continue;
765  }
766  mSlotNames[name] = slot;
767  }
768 }
769 
770 int EquipmentWindow::parseSlotName(const std::string &name)
771 {
772  StringIntMapCIter it = mSlotNames.find(name);
773  if (it != mSlotNames.end())
774  return (*it).second;
775  return -1;
776 }
777 
779 {
780  if (mImageSet != nullptr)
781  mImageSet->decRef();
782 
783  addDefaultPage();
785  "equipmentbox.png", 32, 32);
786 
787  addBox(0, 90, 40, 0); // torso
788  addBox(1, 8, 78, 1); // gloves
789  addBox(2, 70, 0, 2); // hat
790  addBox(3, 50, 253, 3); // pants
791  addBox(4, 90, 253, 4); // boots
792  addBox(5, 8, 213, 5); // FREE
793  addBox(6, 129, 213, 6); // wings
794  addBox(7, 50, 40, 5); // scarf
795  addBox(8, 8, 168, 7); // weapon
796  addBox(9, 129, 168, 8); // shield
797  addBox(10, 129, 78, 9); // ammo
798  addBox(11, 8, 123, 5); // amulet
799  addBox(12, 129, 123, 5); // ring
800 }
801 
802 void EquipmentWindow::addBox(const int idx, int x, int y, const int imageIndex)
803 {
804  Image *image = nullptr;
805 
806  if ((mImageSet != nullptr) && imageIndex >= 0 && imageIndex
807  < CAST_S32(mImageSet->size()))
808  {
809  image = mImageSet->get(imageIndex);
810  }
811 
812  x += getPadding();
813  y += getTitleBarHeight() + mYPadding;
814  STD_VECTOR<EquipmentBox*> &boxes = mPages[0]->boxes;
815  boxes[idx] = new EquipmentBox(x, y, image);
816 
817  if (x < mMinX)
818  mMinX = x;
819  if (y < mMinY)
820  mMinY = y;
821  if (x + mBoxSize > mMaxX)
822  mMaxX = x + mBoxSize;
823  if (y + mBoxSize > mMaxY)
824  mMaxY = y + mBoxSize;
825 }
826 
828 {
829  mMaxX += mMinX;
830  mMaxY += mMinY;
831  mTabs->setWidth(mMaxX);
834 }
835 
836 int EquipmentWindow::addPage(const std::string &name)
837 {
838  EquipmentPage *const page = new EquipmentPage;
839  mPages.push_back(page);
840  STD_VECTOR<EquipmentBox*> &boxes = page->boxes;
841 
842  boxes.reserve(BOX_COUNT);
843  for (int f = 0; f < BOX_COUNT; f ++)
844  boxes.push_back(nullptr);
845 
846  mTabs->addButton(name, name, false);
847  return CAST_S32(mPages.size()) - 1;
848 }
Font * getFont() const
Definition: widget.cpp:330
void setPlayer(Being *being)
Definition: playerbox.h:73
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setDefaultSize()
Definition: window.cpp:1186
unsigned int getTitleBarHeight() const
Definition: window.h:514
std::string getStringValue(const std::string &key) const
#define _(s)
Definition: gettext.h:34
int width
Definition: rect.h:218
void dragItem(const Item *const item, const DragDropSourceT source, const int tag=0)
Definition: dragdrop.h:86
const bool SkipError_false
Definition: skiperror.h:29
int getWidth() const
Definition: widget.h:220
std::map< std::string, int > StringIntMap
Definition: stringmap.h:27
void setBeing(Being *const being)
Image * get(const size_type i) const
Definition: imageset.cpp:66
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
void setWidth(const int width)
Definition: widget.cpp:132
DragDropSource ::T DragDropSourceT
Definition: font.h:88
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:250
const bool Visible_true
Definition: visible.h:29
ImageSet * mImageSet
void loadWindowState()
Definition: window.cpp:1075
virtual void addButton(const std::string &text, const std::string &tag, const bool pressed)
Definition: widgetgroup.cpp:41
int getY() const
Definition: widget.h:287
void safeDraw(Graphics *const graphics)
virtual void decRef()
Definition: resource.cpp:49
void clear()
Definition: dragdrop.h:182
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:93
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
Rect getChildrenArea()
Definition: window.cpp:1461
void setVisible(Visible visible)
Definition: widget.cpp:224
Equipped isEquipped() const
Definition: item.h:128
void showUndressPopup(const int x, const int y, const Being *const being, const Item *const item)
Definition: popupmenu.cpp:2120
void mousePressed(MouseEvent &event)
MouseButtonT getButton() const
Definition: mouseevent.h:113
Definition: rect.h:72
Inventory * getInventory()
Definition: playerinfo.cpp:207
const Item * getItem(const int x, const int y) const
ImageCollection * mVertexes
Definition: window.h:98
#define BLOCK_START(name)
Definition: perfomance.h:78
Definition: button.h:94
Configuration config
const bool Sfx_true
Definition: sfx.h:29
void loadPlayerBox(const xmlNodePtr playerBoxNode, const int page)
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:171
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
static void prepareSlotNames()
void mouseMoved(MouseEvent &event)
Definition: window.cpp:955
DragDrop dragDrop
#define BLOCK_END(name)
Definition: perfomance.h:79
void mouseReleased(MouseEvent &event)
int getIntValue(const std::string &key) const
StringIntMap::const_iterator StringIntMapCIter
Definition: stringmap.h:29
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
const Backend * getBackend() const
Definition: equipment.h:88
#define delete2(var)
Definition: delete2.h:24
const bool Equipped_true
Definition: equipped.h:29
bool isEmpty() const
Definition: dragdrop.h:195
const bool Equipped_false
Definition: equipped.h:29
void registerWindowForReset(Window *const window)
std::vector< EquipmentBox * > boxes
Definition: equipmentpage.h:45
const Item * getEquipment(const int index) const
Definition: equipment.h:68
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
void setSelectable(const bool selectable)
Definition: widget.h:947
#define new
Definition: debug_new.h:147
virtual void setAlpha(const float alpha)
Definition: image.cpp:285
std::vector< EquipmentPage * > mPages
static ImageSet * getImageSetFromTheme(const std::string &path, const int w, const int h)
Definition: theme.cpp:659
const bool UseVirtFs_true
Definition: usevirtfs.h:29
#define CAST_S32
Definition: cast.h:29
void delete_all(Container &c)
Definition: dtor.h:55
Image * grid[9]
Definition: imagerect.h:41
const bool Equipm_true
Definition: equipm.h:29
virtual int getProjectileSlot() const =0
size_type size() const
Definition: imageset.h:69
const bool Visible_false
Definition: visible.h:29
void addBox(const int idx, int x, int y, const int imageIndex)
int getQuantity() const
Definition: item.h:104
#define fromBool(val, name)
Definition: booldefines.h:48
void draw(Graphics *const graphics)
Definition: window.cpp:303
uint32_t data
bool mLastRedraw
Definition: window.h:649
LocalPlayer * localPlayer
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
void position(const int x, const int y)
Definition: popup.cpp:229
EquipmentWindow * beingEquipmentWindow
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
virtual void add(Widget *const widget)
int getTag() const
Definition: button.h:179
Definition: item.h:48
#define nullptr
Definition: localconsts.h:44
void deselect()
Definition: dragdrop.h:212
void loadRect(ImageRect &image, const std::string &name, const std::string &name2, const int start=0, const int end=8)
Definition: theme.cpp:1092
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void setCloseButton(const bool flag)
Definition: window.cpp:737
int height
Definition: rect.h:223
void setItem(const ItemInfo &item, const ItemColor color, const bool showImage, int id, const int *const cards, const ItemOptionsList *const options)
Definition: itempopup.cpp:183
static StringIntMap mSlotNames
void resetBeing(const Being *const being)
void enableVisibleSound(bool b)
Definition: window.h:473
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:82
void setEnabled(const bool enabled)
Definition: widget.h:351
xmlNodePtr rootNode()
Definition: libxml.cpp:166
Equipment * mEquipment
void mouseReleased(MouseEvent &event)
Definition: window.cpp:895
void setSaveVisible(const bool save)
Definition: window.h:298
void loadSlot(const xmlNodePtr slotNode, const ImageSet *const imageset, const int page)
std::vector< std::string > mPages
Definition: statdb.cpp:40
Configuration paths
int getX() const
Definition: widget.h:268
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:255
Theme * theme
Definition: theme.cpp:61
#define A_UNUSED
Definition: localconsts.h:171
void draw(Graphics *const graphics)
Image * getImage() const
Definition: item.h:86
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:258
#define for_each_xml_child_node(var, parent)
Definition: libxml.h:160
static const int BOX_COUNT
Image * mSlotHighlightedBackground
static int parseSlotName(const std::string &name)
int getWidth(const std::string &text) const
Definition: font.cpp:333
Equipment * mEquipment
Definition: playerinfo.cpp:63
EquipmentWindow * equipmentWindow
EquipmentWindow(Equipment *const equipment, Being *const being, const bool foring=false)
bool mRedraw
Definition: widget.h:1163
ItemColor getItemColor() const
Definition: dragdrop.h:68
void mousePressed(MouseEvent &event)
Definition: window.cpp:824
Definition: image.h:61
Equipm isEquipment() const
Definition: item.h:116
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
int getHeight() const
Definition: widget.h:239
void mouseExited(MouseEvent &event)
int addPage(const std::string &name)
void mouseMoved(MouseEvent &event)
#define reportTrue(val)
Definition: checkutils.h:251
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
int getOption(const std::string &name, const int def=0) const
Definition: window.cpp:1442
DragDropSourceT getSource() const
Definition: dragdrop.h:83
void action(const ActionEvent &event)
int getHeight() const
Definition: font.cpp:360
ItemPopup * itemPopup
Definition: itempopup.cpp:63
void setSelected(const int index)
void loadPage(const xmlNodePtr node)
Definition: being.h:93
#define reportAlways(...)
Definition: checkutils.h:252
Equipment * getEquipment()
Definition: being.cpp:4624
void decRef()
Definition: image.cpp:521
void updateBeing(Being *const being)
void showPopup(const int x, const int y, const Being *const being)
Definition: popupmenu.cpp:201
int getPadding() const
Definition: window.h:496
Image * image
Definition: equipmentbox.h:38
void postInit()
Definition: window.cpp:241
void safeDraw(Graphics *const graphics)
Definition: window.cpp:415
int getItem() const
Definition: dragdrop.h:65
void setWindowName(const std::string &name)
Definition: window.h:353
PlayerBox * mPlayerBox