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