ManaPlus
buydialog.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-2018 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 
23 #include "gui/windows/buydialog.h"
24 
25 #include "actormanager.h"
26 #include "configuration.h"
27 
28 #include "being/being.h"
29 
30 #include "enums/gui/layouttype.h"
31 
33 #ifdef TMWA_SUPPORT
35 #endif // TMWA_SUPPORT
36 
37 #include "gui/models/shopitems.h"
39 
40 #include "gui/widgets/button.h"
43 #include "gui/widgets/dropdown.h"
45 #include "gui/widgets/label.h"
46 #include "gui/widgets/layout.h"
47 #include "gui/widgets/scrollarea.h"
49 #include "gui/widgets/slider.h"
50 
51 #include "net/adminhandler.h"
52 #include "net/buysellhandler.h"
53 #include "net/cashshophandler.h"
54 #include "net/markethandler.h"
55 #include "net/net.h"
56 #include "net/vendinghandler.h"
57 #include "net/npchandler.h"
58 
59 #include "resources/iteminfo.h"
60 
61 #include "resources/db/unitsdb.h"
62 
63 #include "utils/delete2.h"
64 #include "utils/foreach.h"
65 
66 #include <algorithm>
67 
68 #include "debug.h"
69 
70 namespace
71 {
73  {
74  public:
76 
77  bool operator() (const ShopItem *const item1,
78  const ShopItem *const item2) const
79  {
80  if ((item1 == nullptr) || (item2 == nullptr))
81  return false;
82 
83  const int price1 = item1->getPrice();
84  const int price2 = item2->getPrice();
85  if (price1 == price2)
86  return item1->getDisplayName() < item2->getDisplayName();
87  return price1 < price2;
88  }
90 
92  {
93  public:
95 
96  bool operator() (const ShopItem *const item1,
97  const ShopItem *const item2) const
98  {
99  if ((item1 == nullptr) || (item2 == nullptr))
100  return false;
101 
102  const std::string &name1 = item1->getDisplayName();
103  const std::string &name2 = item2->getDisplayName();
104  if (name1 == name2)
105  return item1->getPrice() < item2->getPrice();
106  return name1 < name2;
107  }
109 
111  {
112  public:
114 
115  bool operator() (const ShopItem *const item1,
116  const ShopItem *const item2) const
117  {
118  if ((item1 == nullptr) || (item2 == nullptr))
119  return false;
120 
121  const int id1 = item1->getId();
122  const int id2 = item2->getId();
123  if (id1 == id2)
124  return item1->getPrice() < item2->getPrice();
125  return id1 < id2;
126  }
127  } itemIdBuySorter;
128 
130  {
131  public:
133 
134  bool operator() (const ShopItem *const item1,
135  const ShopItem *const item2) const
136  {
137  if ((item1 == nullptr) || (item2 == nullptr))
138  return false;
139 
140  const int weight1 = item1->getInfo().getWeight();
141  const int weight2 = item2->getInfo().getWeight();
142  if (weight1 == weight2)
143  return item1->getPrice() < item2->getPrice();
144  return weight1 < weight2;
145  }
147 
149  {
150  public:
152 
153  bool operator() (const ShopItem *const item1,
154  const ShopItem *const item2) const
155  {
156  if ((item1 == nullptr) || (item2 == nullptr))
157  return false;
158 
159  const int amount1 = item1->getQuantity();
160  const int amount2 = item2->getQuantity();
161  if (amount1 == amount2)
162  return item1->getPrice() < item2->getPrice();
163  return amount1 < amount2;
164  }
166 
168  {
169  public:
171 
172  bool operator() (const ShopItem *const item1,
173  const ShopItem *const item2) const
174  {
175  if ((item1 == nullptr) || (item2 == nullptr))
176  return false;
177 
178  const ItemDbTypeT type1 = item1->getInfo().getType();
179  const ItemDbTypeT type2 = item2->getInfo().getType();
180  if (type1 == type2)
181  return item1->getPrice() < item2->getPrice();
182  return type1 < type2;
183  }
185 } // namespace
186 
188 
190  // TRANSLATORS: buy dialog name
191  Window(_("Create items"), Modal_false, nullptr, "buy.xml"),
192  ActionListener(),
194  mSortModel(new SortListModelBuy),
195  mSortDropDown(new DropDown(this, mSortModel, false,
196  Modal_false, this, "sort")),
197  mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
198  this, "namefilter", true)),
199  mFilterLabel(nullptr),
200  mNick(),
201  mCurrency(),
202  mNpcId(fromInt(Items, BeingId)),
203  mMoney(0),
204  mAmountItems(0),
205  mMaxItems(0),
206  mAdvanced(false)
207 {
208  init();
209 }
210 
212  const std::string &currency) :
213  // TRANSLATORS: buy dialog name
214  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
215  ActionListener(),
220  this, "namefilter", true)),
222  mNick(),
223  mCurrency(currency),
224  mNpcId(npcId),
225  mMoney(0),
226  mAmountItems(0),
227  mMaxItems(0),
229 {
230  init();
231 }
232 
233 #ifdef TMWA_SUPPORT
234 BuyDialog::BuyDialog(const std::string &nick,
235  const std::string &currency) :
236  // TRANSLATORS: buy dialog name
237  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
238  ActionListener(),
241  mSortDropDown(new DropDown(this, mSortModel, false,
242  Modal_false, this, "sort")),
244  this, "namefilter", true)),
246  mNick(nick),
247  mCurrency(currency),
249  mMoney(0),
250  mAmountItems(0),
251  mMaxItems(0),
252  mAdvanced(false)
253 {
254  init();
255 }
256 #endif // TMWA_SUPPORT
257 
258 BuyDialog::BuyDialog(const Being *const being,
259  const std::string &currency) :
260  // TRANSLATORS: buy dialog name
261  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
262  ActionListener(),
265  mSortDropDown(new DropDown(this, mSortModel, false,
266  Modal_false, this, "sort")),
268  this, "namefilter", true)),
270  mNick(being != nullptr ? being->getName() : std::string()),
271  mCurrency(currency),
273  mMoney(0),
274  mAmountItems(0),
275  mMaxItems(0),
276  mAdvanced(true)
277 {
278  init();
279 }
280 
282 {
283  setWindowName("Buy");
284  setResizable(true);
285  setCloseButton(true);
286  setStickyButtonLock(true);
287  setMinWidth(260);
288  setMinHeight(220);
289  setDefaultSize(260, 230, ImagePosition::CENTER, 0, 0);
290 
291 #ifdef TMWA_SUPPORT
292  // reset advance flag for personal shops
293  if (mAdvanced &&
294  mNpcId == fromInt(Nick, BeingId))
295  {
296  mAdvanced = false;
297  }
298 #endif // TMWA_SUPPORT
299 
300  if (setupWindow != nullptr)
302 
303  mShopItems = new ShopItems(false,
304  mCurrency);
305 
309  fromBool(getOptionBool("showbackground", false), Opaque),
310  "buy_background.xml");
312 
313  mSlider = new Slider(this, 1.0, 1.0);
314  mQuantityLabel = new Label(this, strprintf(
315  "%d / %d", mAmountItems, mMaxItems));
317  mMoneyLabel = new Label(this, strprintf(
318  // TRANSLATORS: buy dialog label
319  _("Price: %s / Total: %s"), "", ""));
320 
321  mAmountField = new IntTextField(this, 1, 1, 123, Enable_true, 0);
322  mAmountField->setActionEventId("amount");
325  mAmountField->setEnabled(false);
326 
327  // TRANSLATORS: buy dialog label
328  mAmountLabel = new Label(this, _("Amount:"));
330 
331  // TRANSLATORS: This is a narrow symbol used to denote 'increasing'.
332  // You may change this symbol if your language uses another.
333  mIncreaseButton = new Button(this, _("+"), "inc", BUTTON_SKIN, this);
334  // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'.
335  // You may change this symbol if your language uses another.
336  mDecreaseButton = new Button(this, _("-"), "dec", BUTTON_SKIN, this);
337  mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId)
338  // TRANSLATORS: buy dialog button
339  ? _("Create") : (mAdvanced ? _("Add") : _("Buy")),
340  "buy",
341  BUTTON_SKIN,
342  this);
343  if (mAdvanced)
344  {
345  mConfirmButton = new Button(this,
346  // TRANSLATORS: buy dialog button
347  _("Buy"),
348  "confirm",
349  BUTTON_SKIN,
350  this);
351  mConfirmButton->setEnabled(false);
352  }
353  else
354  {
355  mConfirmButton = nullptr;
356  }
357  // TRANSLATORS: buy dialog button
358  mQuitButton = new Button(this, _("Quit"), "quit", BUTTON_SKIN, this);
359  // TRANSLATORS: buy dialog button
360  mAddMaxButton = new Button(this, _("Max"), "max", BUTTON_SKIN, this);
361 
364 
365  mIncreaseButton->setEnabled(false);
366  mDecreaseButton->setEnabled(false);
367  mBuyButton->setEnabled(false);
368  mSlider->setEnabled(false);
369 
370  mSlider->setActionEventId("slider");
371  mSlider->addActionListener(this);
372 
377 
379 
380  ContainerPlacer placer = getPlacer(0, 0);
381  placer(0, 0, mScrollArea, 9, 5).setPadding(3);
382  placer(0, 5, mDecreaseButton, 1, 1);
383  placer(1, 5, mSlider, 4, 1);
384  placer(5, 5, mIncreaseButton, 1, 1);
385  placer(6, 5, mQuantityLabel, 2, 1);
386  placer(8, 5, mAddMaxButton, 1, 1);
387  placer(0, 6, mAmountLabel, 2, 1);
388  placer(2, 6, mAmountField, 2, 1);
389  placer(0, 7, mMoneyLabel, 8, 1);
390  if (mSortDropDown != nullptr)
391  {
392  placer(0, 8, mSortDropDown, 2, 1);
393  }
394  else
395  {
396  // TRANSLATORS: buy dialog label
397  mFilterLabel = new Label(this, _("Filter:"));
399  placer(0, 8, mFilterLabel, 2, 1);
400  }
401  placer(2, 8, mFilterTextField, 2, 1);
402  if (mAdvanced)
403  {
404  placer(6, 8, mBuyButton, 1, 1);
405  placer(7, 8, mConfirmButton, 1, 1);
406  }
407  else
408  {
409  placer(7, 8, mBuyButton, 1, 1);
410  }
411  placer(8, 8, mQuitButton, 1, 1);
412 
413  Layout &layout = getLayout();
414  layout.setRowHeight(0, LayoutType::SET);
415 
416  center();
417  loadWindowState();
418  enableVisibleSound(true);
419 
420  instances.push_back(this);
422 
423  if (mSortDropDown != nullptr)
424  mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
425 }
426 
428 {
431  instances.remove(this);
432  if (buySellHandler != nullptr)
434 }
435 
436 void BuyDialog::setMoney(const int amount)
437 {
438  mMoney = amount;
440 
442 }
443 
445 {
446  mShopItems->clear();
448 
449  // Reset previous selected items to prevent failing asserts
451  mSlider->setValue(0);
452 
453  setMoney(0);
454 }
455 
457  const ItemTypeT type,
458  const ItemColor color,
459  const int amount,
460  const int price)
461 {
462  ShopItem *const item = mShopItems->addItem(id,
463  type,
464  color,
465  amount,
466  price);
468  return item;
469 }
470 
472 {
473  if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
474  {
475  STD_VECTOR<ShopItem*> &items = mShopItems->items();
476  switch (mSortDropDown->getSelected())
477  {
478  case 1:
479  std::sort(items.begin(), items.end(), itemPriceBuySorter);
480  break;
481  case 2:
482  std::sort(items.begin(), items.end(), itemNameBuySorter);
483  break;
484  case 3:
485  std::sort(items.begin(), items.end(), itemIdBuySorter);
486  break;
487  case 4:
488  std::sort(items.begin(), items.end(), itemWeightBuySorter);
489  break;
490  case 5:
491  std::sort(items.begin(), items.end(), itemAmountBuySorter);
492  break;
493  case 6:
494  std::sort(items.begin(), items.end(), itemTypeBuySorter);
495  break;
496  case 0:
497  default:
498  break;
499  }
500  }
501 }
502 
504 {
505  switch (toInt(mNpcId, int))
506  {
507 #ifdef TMWA_SUPPORT
508  case Nick:
509 #endif // TMWA_SUPPORT
510  case Items:
511  break;
512  case Market:
513  marketHandler->close();
514  break;
515  case Cash:
517  break;
518  case Vending:
520  break;
521  default:
523  break;
524  }
525  Window::close();
526 }
527 
528 void BuyDialog::action(const ActionEvent &event)
529 {
530  const std::string &eventId = event.getId();
531  if (eventId == "quit")
532  {
533  close();
534  return;
535  }
536  else if (eventId == "sort")
537  {
538  sort();
539  if (mSortDropDown != nullptr)
540  config.setValue("buySortOrder", mSortDropDown->getSelected());
541  return;
542  }
543  else if (eventId == "namefilter")
544  {
546  }
547 
548  const int selectedItem = mShopItemList->getSelected();
549 
550  // The following actions require a valid selection
551  if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
552  return;
553 
554  if (eventId == "slider")
555  {
559  }
560  else if (eventId == "inc" && mAmountItems < mMaxItems)
561  {
562  mAmountItems++;
566  }
567  else if (eventId == "dec" && mAmountItems > 1)
568  {
569  mAmountItems--;
573  }
574  else if (eventId == "max")
575  {
580  }
581  else if (eventId == "amount")
582  {
586  }
587  else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
588  {
589  ShopItem *const item = mShopItems->at(selectedItem);
590  if (item == nullptr)
591  return;
592  if (mNpcId == fromInt(Items, BeingId))
593  {
594  adminHandler->createItems(item->getId(),
595  item->getColor(),
596  mAmountItems);
597  }
598 #ifdef TMWA_SUPPORT
599  else if (mNpcId == fromInt(Nick, BeingId))
600  {
601  if (tradeWindow != nullptr)
602  {
604  item, mAmountItems);
606  item->getPrice() * mAmountItems);
607  }
608  }
609 #endif // TMWA_SUPPORT
610  else if (mNpcId == fromInt(Vending, BeingId))
611  {
613  item->update();
614  if (mConfirmButton != nullptr)
615  mConfirmButton->setEnabled(true);
616  }
617 #ifdef TMWA_SUPPORT
618  else if (mNpcId != fromInt(Nick, BeingId))
619 #else
620  else
621 #endif // TMWA_SUPPORT
622  {
623  if (mAdvanced)
624  {
626  item->update();
627  if (mConfirmButton != nullptr)
628  mConfirmButton->setEnabled(true);
629  }
630  else if (mNpcId == fromInt(Market, BeingId))
631  {
632  marketHandler->buyItem(item->getId(),
633  item->getType(),
634  item->getColor(),
635  mAmountItems);
637  item->update();
638  }
639  else if (mNpcId == fromInt(Cash, BeingId))
640  {
642  item->getId(),
643  item->getColor(),
644  mAmountItems);
645  }
646  else
647  {
649  item->getId(),
650  item->getColor(),
651  mAmountItems);
652  }
653 
654  updateSlider(selectedItem);
655  }
656  }
657  else if (eventId == "confirm")
658  {
659  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
660 
661  if (mNpcId == fromInt(Market, BeingId))
662  {
663  marketHandler->buyItems(items);
664  }
665  else if (mNpcId == fromInt(Vending, BeingId))
666  {
667  const Being *const being = actorManager->findBeingByName(
668  mNick,
670  if (being != nullptr)
671  {
672  vendingHandler->buyItems(being,
673  items);
674  }
675  }
676  else if (mNpcId == fromInt(Cash, BeingId))
677  {
678  cashShopHandler->buyItems(0, items);
679  }
680  else
681  {
682  npcHandler->buyItems(items);
683  }
684  close();
685  }
686 }
687 
688 void BuyDialog::updateSlider(const int selectedItem)
689 {
690  // Update money and adjust the max number of items
691  // that can be bought
693  const ShopItem *const item = mShopItems->at(selectedItem);
694  if (item != nullptr)
695  setMoney(mMoney - mAmountItems * item->getPrice());
696  else
697  setMoney(mMoney);
698 
699  // Reset selection
700  mAmountItems = 1;
702  mSlider->setValue(1);
703 }
704 
706 {
707  // Reset amount of items and update labels
708  mAmountItems = 1;
709  mSlider->setValue(1);
710 
715 }
716 
718 {
719  const int selectedItem = mShopItemList->getSelected();
720  int price = 0;
721 
722  if (selectedItem > -1)
723  {
724  const ShopItem *const item = mShopItems->at(selectedItem);
725  if (item != nullptr)
726  {
727  const int itemPrice = item->getPrice();
728 
729  // Calculate how many the player can afford
730  if (mNpcId == fromInt(Items, BeingId))
731  mMaxItems = 100;
732  else if (itemPrice != 0)
733  mMaxItems = mMoney / itemPrice;
734  else
735  mMaxItems = 1;
736 
737  if (item->getQuantity() > 0 && mMaxItems > item->getQuantity())
738  mMaxItems = item->getQuantity();
739 
740  if (mAmountItems > mMaxItems)
742 
743  price = mAmountItems * itemPrice;
744  }
745  }
746  else
747  {
748  mMaxItems = 0;
749  mAmountItems = 0;
750  }
751 
757 
759  // TRANSLATORS: buy dialog label
760  mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
761  UnitsDb::formatCurrency(mCurrency, price).c_str(),
762  UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
763 }
764 
766 {
767  Window::setVisible(visible);
768 
769  if (visible == Visible_true && (mShopItemList != nullptr))
771  else
772  scheduleDelete();
773 }
774 
776 {
777  FOR_EACH (DialogList::const_iterator, it, instances)
778  {
779  if (*it != nullptr)
780  (*it)->close();
781  }
782 }
783 
784 void BuyDialog::applyNameFilter(const std::string &filter)
785 {
786  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
787  std::string filterStr = filter;
788  toLower(filterStr);
789  FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
790  {
791  ShopItem *const item = *it;
792  if (item == nullptr)
793  continue;
794  std::string name = item->getName();
795  toLower(name);
796  if (name.find(filterStr) != std::string::npos)
797  item->setVisible(true);
798  else
799  item->setVisible(false);
800  }
802 }
virtual void buyItem(const int itemId, const ItemTypeT type, const ItemColor color, const int amount) const =0
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setDefaultSize()
Definition: window.cpp:1193
#define _(s)
Definition: gettext.h:34
void setSelected(const int selected)
Definition: listbox.cpp:398
void setPlayersMoney(const int money)
Definition: shoplistbox.cpp:86
void setValue(const int value)
int getWidth() const
Definition: widget.h:220
void addAutoMoney(const std::string &nick, const int money)
virtual void cleanDialogReference(const BuyDialog *const dialog) const =0
const bool LoseFocusOnTab_true
void setWidth(const int width)
Definition: widget.cpp:132
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: shopitems.cpp:58
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1461
TradeWindow * tradeWindow
Definition: tradewindow.cpp:64
void setVisible(const bool b)
Definition: shopitem.h:142
Button * mAddMaxButton
Definition: buydialog.h:182
ShopItem * at(const size_t i) const
Definition: shopitems.cpp:128
const bool Visible_true
Definition: visible.h:29
void loadWindowState()
Definition: window.cpp:1082
#define fromInt(val, name)
Definition: intdefines.h:45
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
class anonymous_namespace{buydialog.cpp}::SortItemNameFunctor itemNameBuySorter
Button * mIncreaseButton
Definition: buydialog.h:183
void addSelectionListener(SelectionListener *const selectionListener)
Definition: listbox.cpp:434
void setMinWidth(const int width)
Definition: window.cpp:586
Definition: window.h:98
static DialogList instances
Definition: buydialog.h:177
Definition: button.h:96
Configuration config
#define final
Definition: localconsts.h:45
Button * mDecreaseButton
Definition: buydialog.h:184
int BeingId
Definition: beingid.h:29
std::string formatCurrency(const int value)
Definition: unitsdb.cpp:323
Label * mFilterLabel
Definition: buydialog.h:196
virtual void buyItem(const BeingId beingId, const int itemId, const ItemColor color, const int amount) const =0
void setDistributeMousePressed(const bool b)
Definition: listbox.h:140
uint16_t ItemColor
Definition: itemcolor.h:29
int getIntValue(const std::string &key) const
Slider * mSlider
Definition: buydialog.h:189
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:24
void update()
Definition: shopitem.cpp:118
#define delete2(var)
Definition: delete2.h:24
const bool Enable_true
Definition: enable.h:29
void setScale(const double scaleStart, const double scaleEnd)
Definition: slider.cpp:467
virtual void buyItems(const int points, const std::vector< ShopItem *> &items) const =0
void init()
Definition: buydialog.cpp:281
Button * mConfirmButton
Definition: buydialog.h:180
void adjustSize()
void registerWindowForReset(Window *const window)
void adjustSize()
Definition: button.cpp:798
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: buydialog.cpp:456
void clear()
Definition: shopitems.cpp:173
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:40
virtual void buyItems(const std::vector< ShopItem *> &items) const =0
int mMoney
Definition: buydialog.h:201
void valueChanged(const SelectionEvent &event)
Definition: buydialog.cpp:705
virtual void close() const =0
virtual void close()
Definition: window.cpp:897
int mAmountItems
Definition: buydialog.h:202
#define new
Definition: debug_new.h:147
#define toInt(val, name)
Definition: intdefines.h:46
std::vector< ShopItem * > & items()
Definition: shopitems.h:135
const std::string & getName(const int id)
Definition: groupdb.cpp:343
#define CAST_S32
Definition: cast.h:29
virtual void requestFocus()
Definition: widget.cpp:203
const std::string BUTTON_SKIN
Definition: button.h:88
class anonymous_namespace{buydialog.cpp}::SortItemTypeFunctor itemTypeBuySorter
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setCaption(const std::string &caption)
Definition: label.cpp:261
void sort()
Definition: buydialog.cpp:471
int getPrice() const
Definition: shopitem.h:131
Definition: label.h:87
int getQuantity() const
Definition: item.h:104
#define fromBool(val, name)
Definition: booldefines.h:48
virtual void close() const =0
Button * mQuitButton
Definition: buydialog.h:181
std::string mCurrency
Definition: buydialog.h:199
double getValue() const
Definition: slider.h:203
Button * mBuyButton
Definition: buydialog.h:179
IntTextField * mAmountField
Definition: buydialog.h:191
ItemColor getColor() const
Definition: item.h:180
void setRange(const int minimum, const int maximum)
void applyNameFilter(const std::string &filter)
Definition: buydialog.cpp:784
int getSelected() const
Definition: listbox.h:167
std::string toLower(std::string const &s)
#define nullptr
Definition: localconsts.h:44
void reset()
Definition: buydialog.cpp:444
class anonymous_namespace{buydialog.cpp}::SortItemAmountFunctor itemAmountBuySorter
void setCloseButton(const bool flag)
Definition: window.cpp:744
void increaseUsedQuantity(const int amount)
Definition: shopitem.cpp:158
int getValue() const
Label * mAmountLabel
Definition: buydialog.h:190
Net::MarketHandler * marketHandler
Definition: net.cpp:111
virtual void createItems(const int id, const ItemColor color, const int amount) const =0
void enableVisibleSound(bool b)
Definition: window.h:480
void setMinHeight(const int height)
Definition: window.cpp:599
ScrollArea * mScrollArea
Definition: buydialog.h:186
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1386
ShopItems * mShopItems
Definition: buydialog.h:192
void setEnabled(const bool enabled)
Definition: widget.h:351
Net::CashShopHandler * cashShopHandler
Definition: net.cpp:103
virtual void sendBuyRequest(const std::string &nick, const ShopItem *const item, const int amount) const =0
virtual void scheduleDelete()
Definition: window.cpp:826
Layout & getLayout()
Definition: window.cpp:1360
Net::AdminHandler * adminHandler
Definition: net.cpp:80
class anonymous_namespace{buydialog.cpp}::SortItemIdFunctor itemIdBuySorter
virtual void buyItems(std::vector< ShopItem *> &items) const =0
ItemType ::T ItemTypeT
Definition: itemtype.h:42
std::string getName() const
Definition: item.cpp:139
ServerTypeT getNetworkType()
Definition: net.cpp:182
BeingId mNpcId
Definition: buydialog.h:200
int getId() const
Definition: item.h:80
#define A_UNUSED
Definition: localconsts.h:151
virtual void setVisible(Visible visible)
Definition: window.cpp:773
void center()
Definition: window.cpp:1412
std::vector< ShopItem * > & allItems()
Definition: shopitems.h:138
TextField * mFilterTextField
Definition: buydialog.h:195
void setValue(const double value)
Definition: slider.cpp:473
void setAlignment(Graphics::Alignment alignment)
Definition: label.h:152
Net::BuySellHandler * buySellHandler
Definition: net.cpp:96
virtual void close() const =0
void setMoney(const int amount)
Definition: buydialog.cpp:436
ItemTypeT getType() const
Definition: item.h:224
void setSendAlwaysEvents(const bool b)
Definition: textfield.h:165
static void closeAll()
Definition: buydialog.cpp:775
std::list< BuyDialog * > DialogList
Definition: buydialog.h:176
DropDown * mSortDropDown
Definition: buydialog.h:194
virtual void buyItems(const Being *const being, const std::vector< ShopItem *> &items) const =0
Label * mQuantityLabel
Definition: buydialog.h:188
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
void setResizable(const bool resize)
Definition: window.cpp:622
Net::VendingHandler * vendingHandler
Definition: net.cpp:115
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:767
void updateList()
Definition: shopitems.cpp:197
Net::NpcHandler * npcHandler
Definition: net.cpp:89
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
void close()
Definition: buydialog.cpp:503
void updateSlider(const int selectedItem)
Definition: buydialog.cpp:688
Definition: slider.h:85
std::string mNick
Definition: buydialog.h:198
Definition: layout.h:43
void setVisible(Visible visible)
Definition: buydialog.cpp:765
ShopListBox * mShopItemList
Definition: buydialog.h:185
virtual void buyItem(const int points, const int itemId, const ItemColor color, const int amount) const =0
void updateButtonsAndLabels()
Definition: buydialog.cpp:717
Definition: being.h:93
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
void setSelected(int selected)
Definition: dropdown.cpp:514
void adjustSize()
Definition: label.cpp:197
virtual void close() const =0
void setValue(const std::string &key, const std::string &value)
Label * mMoneyLabel
Definition: buydialog.h:187
const std::string & getText() const
Definition: textfield.h:223
ItemDbType ::T ItemDbTypeT
Definition: itemdbtype.h:48
int getSelected() const
Definition: dropdown.cpp:509
class anonymous_namespace{buydialog.cpp}::SortItemWeightFunctor itemWeightBuySorter
SortListModelBuy * mSortModel
Definition: buydialog.h:193
ActorManager * actorManager
bool mAdvanced
Definition: buydialog.h:204
int mMaxItems
Definition: buydialog.h:203
class anonymous_namespace{buydialog.cpp}::SortItemPriceFunctor itemPriceBuySorter
void action(const ActionEvent &event)
Definition: buydialog.cpp:528
void setWindowName(const std::string &name)
Definition: window.h:354
int getNumberOfElements()
Definition: shopitems.h:98
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void increaseQuantity(const int amount)
Definition: item.h:98