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(nullptr),
195  mSortDropDown(nullptr),
196  mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
197  this, "namefilter", true)),
198  mFilterLabel(nullptr),
199  mNick(),
200  mCurrency(),
201  mNpcId(fromInt(Items, BeingId)),
202  mMoney(0),
203  mAmountItems(0),
204  mMaxItems(0),
205  mAdvanced(false)
206 {
207  init();
208 }
209 
211  const std::string &currency) :
212  // TRANSLATORS: buy dialog name
213  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
214  ActionListener(),
219  this, "namefilter", true)),
221  mNick(),
222  mCurrency(currency),
223  mNpcId(npcId),
224  mMoney(0),
225  mAmountItems(0),
226  mMaxItems(0),
228 {
229  init();
230 }
231 
232 #ifdef TMWA_SUPPORT
233 BuyDialog::BuyDialog(const std::string &nick,
234  const std::string &currency) :
235  // TRANSLATORS: buy dialog name
236  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
237  ActionListener(),
240  mSortDropDown(new DropDown(this, mSortModel, false,
241  Modal_false, this, "sort")),
243  this, "namefilter", true)),
245  mNick(nick),
246  mCurrency(currency),
248  mMoney(0),
249  mAmountItems(0),
250  mMaxItems(0),
251  mAdvanced(false)
252 {
253  init();
254 }
255 #endif // TMWA_SUPPORT
256 
257 BuyDialog::BuyDialog(const Being *const being,
258  const std::string &currency) :
259  // TRANSLATORS: buy dialog name
260  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
261  ActionListener(),
264  mSortDropDown(new DropDown(this, mSortModel, false,
265  Modal_false, this, "sort")),
267  this, "namefilter", true)),
269  mNick(being != nullptr ? being->getName() : std::string()),
270  mCurrency(currency),
272  mMoney(0),
273  mAmountItems(0),
274  mMaxItems(0),
275  mAdvanced(true)
276 {
277  init();
278 }
279 
281 {
282  setWindowName("Buy");
283  setResizable(true);
284  setCloseButton(true);
285  setStickyButtonLock(true);
286  setMinWidth(260);
287  setMinHeight(220);
288  setDefaultSize(260, 230, ImagePosition::CENTER, 0, 0);
289 
290 #ifdef TMWA_SUPPORT
291  // reset advance flag for personal shops
292  if (mAdvanced &&
293  mNpcId == fromInt(Nick, BeingId))
294  {
295  mAdvanced = false;
296  }
297 #endif // TMWA_SUPPORT
298 
299  if (setupWindow != nullptr)
301 
302  mShopItems = new ShopItems(false,
303  mCurrency);
304 
308  fromBool(getOptionBool("showbackground", false), Opaque),
309  "buy_background.xml");
311 
312  mSlider = new Slider(this, 1.0, 1.0);
313  mQuantityLabel = new Label(this, strprintf(
314  "%d / %d", mAmountItems, mMaxItems));
316  mMoneyLabel = new Label(this, strprintf(
317  // TRANSLATORS: buy dialog label
318  _("Price: %s / Total: %s"), "", ""));
319 
320  mAmountField = new IntTextField(this, 1, 1, 123, Enable_true, 0);
321  mAmountField->setActionEventId("amount");
324  mAmountField->setEnabled(false);
325 
326  // TRANSLATORS: buy dialog label
327  mAmountLabel = new Label(this, _("Amount:"));
329 
330  // TRANSLATORS: This is a narrow symbol used to denote 'increasing'.
331  // You may change this symbol if your language uses another.
332  mIncreaseButton = new Button(this, _("+"), "inc", this);
333  // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'.
334  // You may change this symbol if your language uses another.
335  mDecreaseButton = new Button(this, _("-"), "dec", this);
336  mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId)
337  // TRANSLATORS: buy dialog button
338  ? _("Create") : (mAdvanced ? _("Add") : _("Buy")), "buy", this);
339  if (mAdvanced)
340  {
341  // TRANSLATORS: buy dialog button
342  mConfirmButton = new Button(this, _("Buy"), "confirm", this);
343  mConfirmButton->setEnabled(false);
344  }
345  else
346  {
347  mConfirmButton = nullptr;
348  }
349  // TRANSLATORS: buy dialog button
350  mQuitButton = new Button(this, _("Quit"), "quit", this);
351  // TRANSLATORS: buy dialog button
352  mAddMaxButton = new Button(this, _("Max"), "max", this);
353 
356 
357  mIncreaseButton->setEnabled(false);
358  mDecreaseButton->setEnabled(false);
359  mBuyButton->setEnabled(false);
360  mSlider->setEnabled(false);
361 
362  mSlider->setActionEventId("slider");
363  mSlider->addActionListener(this);
364 
369 
371 
372  ContainerPlacer placer = getPlacer(0, 0);
373  placer(0, 0, mScrollArea, 9, 5).setPadding(3);
374  placer(0, 5, mDecreaseButton, 1, 1);
375  placer(1, 5, mSlider, 4, 1);
376  placer(5, 5, mIncreaseButton, 1, 1);
377  placer(6, 5, mQuantityLabel, 2, 1);
378  placer(8, 5, mAddMaxButton, 1, 1);
379  placer(0, 6, mAmountLabel, 2, 1);
380  placer(2, 6, mAmountField, 2, 1);
381  placer(0, 7, mMoneyLabel, 8, 1);
382  if (mSortDropDown != nullptr)
383  {
384  placer(0, 8, mSortDropDown, 2, 1);
385  }
386  else
387  {
388  // TRANSLATORS: buy dialog label
389  mFilterLabel = new Label(this, _("Filter:"));
391  placer(0, 8, mFilterLabel, 2, 1);
392  }
393  placer(2, 8, mFilterTextField, 2, 1);
394  if (mAdvanced)
395  {
396  placer(6, 8, mBuyButton, 1, 1);
397  placer(7, 8, mConfirmButton, 1, 1);
398  }
399  else
400  {
401  placer(7, 8, mBuyButton, 1, 1);
402  }
403  placer(8, 8, mQuitButton, 1, 1);
404 
405  Layout &layout = getLayout();
406  layout.setRowHeight(0, LayoutType::SET);
407 
408  center();
409  loadWindowState();
410  enableVisibleSound(true);
411 
412  instances.push_back(this);
414 
415  if (mSortDropDown != nullptr)
416  mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
417 }
418 
420 {
423  instances.remove(this);
424  if (buySellHandler != nullptr)
426 }
427 
428 void BuyDialog::setMoney(const int amount)
429 {
430  mMoney = amount;
432 
434 }
435 
437 {
438  mShopItems->clear();
440 
441  // Reset previous selected items to prevent failing asserts
443  mSlider->setValue(0);
444 
445  setMoney(0);
446 }
447 
449  const ItemTypeT type,
450  const ItemColor color,
451  const int amount,
452  const int price)
453 {
454  ShopItem *const item = mShopItems->addItem(id,
455  type,
456  color,
457  amount,
458  price);
460  return item;
461 }
462 
464 {
465  if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
466  {
467  STD_VECTOR<ShopItem*> &items = mShopItems->items();
468  switch (mSortDropDown->getSelected())
469  {
470  case 1:
471  std::sort(items.begin(), items.end(), itemPriceBuySorter);
472  break;
473  case 2:
474  std::sort(items.begin(), items.end(), itemNameBuySorter);
475  break;
476  case 3:
477  std::sort(items.begin(), items.end(), itemIdBuySorter);
478  break;
479  case 4:
480  std::sort(items.begin(), items.end(), itemWeightBuySorter);
481  break;
482  case 5:
483  std::sort(items.begin(), items.end(), itemAmountBuySorter);
484  break;
485  case 6:
486  std::sort(items.begin(), items.end(), itemTypeBuySorter);
487  break;
488  case 0:
489  default:
490  break;
491  }
492  }
493 }
494 
496 {
497  switch (toInt(mNpcId, int))
498  {
499 #ifdef TMWA_SUPPORT
500  case Nick:
501 #endif // TMWA_SUPPORT
502  case Items:
503  break;
504  case Market:
505  marketHandler->close();
506  break;
507  case Cash:
509  break;
510  case Vending:
512  break;
513  default:
515  break;
516  }
517  Window::close();
518 }
519 
520 void BuyDialog::action(const ActionEvent &event)
521 {
522  const std::string &eventId = event.getId();
523  if (eventId == "quit")
524  {
525  close();
526  return;
527  }
528  else if (eventId == "sort")
529  {
530  sort();
531  if (mSortDropDown != nullptr)
532  config.setValue("buySortOrder", mSortDropDown->getSelected());
533  return;
534  }
535  else if (eventId == "namefilter")
536  {
538  }
539 
540  const int selectedItem = mShopItemList->getSelected();
541 
542  // The following actions require a valid selection
543  if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
544  return;
545 
546  if (eventId == "slider")
547  {
551  }
552  else if (eventId == "inc" && mAmountItems < mMaxItems)
553  {
554  mAmountItems++;
558  }
559  else if (eventId == "dec" && mAmountItems > 1)
560  {
561  mAmountItems--;
565  }
566  else if (eventId == "max")
567  {
572  }
573  else if (eventId == "amount")
574  {
578  }
579  else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
580  {
581  ShopItem *const item = mShopItems->at(selectedItem);
582  if (item == nullptr)
583  return;
584  if (mNpcId == fromInt(Items, BeingId))
585  {
586  adminHandler->createItems(item->getId(),
587  item->getColor(),
588  mAmountItems);
589  }
590 #ifdef TMWA_SUPPORT
591  else if (mNpcId == fromInt(Nick, BeingId))
592  {
593  if (tradeWindow != nullptr)
594  {
596  item, mAmountItems);
598  item->getPrice() * mAmountItems);
599  }
600  }
601 #endif // TMWA_SUPPORT
602  else if (mNpcId == fromInt(Vending, BeingId))
603  {
605  item->update();
606  if (mConfirmButton != nullptr)
607  mConfirmButton->setEnabled(true);
608  }
609 #ifdef TMWA_SUPPORT
610  else if (mNpcId != fromInt(Nick, BeingId))
611 #else
612  else
613 #endif // TMWA_SUPPORT
614  {
615  if (mAdvanced)
616  {
618  item->update();
619  if (mConfirmButton != nullptr)
620  mConfirmButton->setEnabled(true);
621  }
622  else if (mNpcId == fromInt(Market, BeingId))
623  {
624  marketHandler->buyItem(item->getId(),
625  item->getType(),
626  item->getColor(),
627  mAmountItems);
629  item->update();
630  }
631  else if (mNpcId == fromInt(Cash, BeingId))
632  {
634  item->getId(),
635  item->getColor(),
636  mAmountItems);
637  }
638  else
639  {
641  item->getId(),
642  item->getColor(),
643  mAmountItems);
644  }
645 
646  updateSlider(selectedItem);
647  }
648  }
649  else if (eventId == "confirm")
650  {
651  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
652 
653  if (mNpcId == fromInt(Market, BeingId))
654  {
655  marketHandler->buyItems(items);
656  }
657  else if (mNpcId == fromInt(Vending, BeingId))
658  {
659  const Being *const being = actorManager->findBeingByName(
660  mNick,
662  if (being != nullptr)
663  {
664  vendingHandler->buyItems(being,
665  items);
666  }
667  }
668  else if (mNpcId == fromInt(Cash, BeingId))
669  {
670  cashShopHandler->buyItems(0, items);
671  }
672  else
673  {
674  npcHandler->buyItems(items);
675  }
676  close();
677  }
678 }
679 
680 void BuyDialog::updateSlider(const int selectedItem)
681 {
682  // Update money and adjust the max number of items
683  // that can be bought
685  const ShopItem *const item = mShopItems->at(selectedItem);
686  if (item != nullptr)
687  setMoney(mMoney - mAmountItems * item->getPrice());
688  else
689  setMoney(mMoney);
690 
691  // Reset selection
692  mAmountItems = 1;
694  mSlider->setValue(1);
695 }
696 
698 {
699  // Reset amount of items and update labels
700  mAmountItems = 1;
701  mSlider->setValue(1);
702 
707 }
708 
710 {
711  const int selectedItem = mShopItemList->getSelected();
712  int price = 0;
713 
714  if (selectedItem > -1)
715  {
716  const ShopItem *const item = mShopItems->at(selectedItem);
717  if (item != nullptr)
718  {
719  const int itemPrice = item->getPrice();
720 
721  // Calculate how many the player can afford
722  if (mNpcId == fromInt(Items, BeingId))
723  mMaxItems = 100;
724  else if (itemPrice != 0)
725  mMaxItems = mMoney / itemPrice;
726  else
727  mMaxItems = 1;
728 
729  if (item->getQuantity() > 0 && mMaxItems > item->getQuantity())
730  mMaxItems = item->getQuantity();
731 
732  if (mAmountItems > mMaxItems)
734 
735  price = mAmountItems * itemPrice;
736  }
737  }
738  else
739  {
740  mMaxItems = 0;
741  mAmountItems = 0;
742  }
743 
749 
751  // TRANSLATORS: buy dialog label
752  mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
753  UnitsDb::formatCurrency(mCurrency, price).c_str(),
754  UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
755 }
756 
758 {
759  Window::setVisible(visible);
760 
761  if (visible == Visible_true && (mShopItemList != nullptr))
763  else
764  scheduleDelete();
765 }
766 
768 {
769  FOR_EACH (DialogList::const_iterator, it, instances)
770  {
771  if (*it != nullptr)
772  (*it)->close();
773  }
774 }
775 
776 void BuyDialog::applyNameFilter(const std::string &filter)
777 {
778  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
779  std::string filterStr = filter;
780  toLower(filterStr);
781  FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
782  {
783  ShopItem *const item = *it;
784  if (item == nullptr)
785  continue;
786  std::string name = item->getName();
787  toLower(name);
788  if (name.find(filterStr) != std::string::npos)
789  item->setVisible(true);
790  else
791  item->setVisible(false);
792  }
794 }
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:94
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:280
Button * mConfirmButton
Definition: buydialog.h:180
void adjustSize()
void registerWindowForReset(Window *const window)
void adjustSize()
Definition: button.cpp:829
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: buydialog.cpp:448
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:697
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:334
#define CAST_S32
Definition: cast.h:29
virtual void requestFocus()
Definition: widget.cpp:203
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:463
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:776
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:436
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:107
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:99
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:78
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:178
BeingId mNpcId
Definition: buydialog.h:200
int getId() const
Definition: item.h:80
#define A_UNUSED
Definition: localconsts.h:171
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:93
virtual void close() const =0
void setMoney(const int amount)
Definition: buydialog.cpp:428
ItemTypeT getType() const
Definition: item.h:224
void setSendAlwaysEvents(const bool b)
Definition: textfield.h:165
static void closeAll()
Definition: buydialog.cpp:767
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:111
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:767
void updateList()
Definition: shopitems.cpp:197
Net::NpcHandler * npcHandler
Definition: net.cpp:86
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
void close()
Definition: buydialog.cpp:495
void updateSlider(const int selectedItem)
Definition: buydialog.cpp:680
Definition: slider.h:85
std::string mNick
Definition: buydialog.h:198
Definition: layout.h:43
void setVisible(Visible visible)
Definition: buydialog.cpp:757
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:709
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:520
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