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