ManaPlus
buydialog.h
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 #ifndef GUI_WINDOWS_BUYDIALOG_H
25 #define GUI_WINDOWS_BUYDIALOG_H
26 
28 
31 
32 #include "gui/widgets/window.h"
33 
36 
37 class Being;
38 class Button;
39 class DropDown;
40 class ShopItem;
41 class ShopItems;
42 class ShopListBox;
43 class SortListModelBuy;
44 class IntTextField;
45 class Label;
46 class ScrollArea;
47 class Slider;
48 class TextField;
49 
55 class BuyDialog final : public Window,
56  public ActionListener,
57  public SelectionListener
58 {
59  public:
65  BuyDialog();
66 
72  BuyDialog(const BeingId npcId,
73  const std::string &currency);
74 
75 #ifdef TMWA_SUPPORT
81  BuyDialog(const std::string &nick,
82  const std::string &currency);
83 #endif // TMWA_SUPPORT
84 
90  BuyDialog(const Being *const being,
91  const std::string &currency);
92 
94 
95 
98  ~BuyDialog() override final;
99 
100  enum
101  {
102 #ifdef TMWA_SUPPORT
103  Nick = -1,
104 #endif // TMWA_SUPPORT
105  Items = -2,
106  Market = -3,
107  Cash = -4,
108  Vending = -5
109  };
110 
111  void init();
112 
116  void reset();
117 
121  void setMoney(const int amount);
122 
126  ShopItem *addItem(const int id,
127  const ItemTypeT type,
128  const ItemColor color,
129  const int amount,
130  const int price);
131 
135  void action(const ActionEvent &event) override final;
136 
141 
145  void valueChanged(const SelectionEvent &event) override final;
146 
150  void updateButtonsAndLabels();
151 
155  void setVisible(Visible visible) override final;
156 
157  void sort();
158 
159  void close() override final;
160 
164  static bool isActive() A_WARN_UNUSED
165  { return !instances.empty(); }
166 
170  static void closeAll();
171 
172  private:
173  void updateSlider(const int selectedItem);
174 
175  void applyNameFilter(const std::string &filter);
176 
177  typedef std::list<BuyDialog*> DialogList;
179 
198 
199  std::string mNick;
200  std::string mCurrency;
202  int mMoney;
205  bool mAdvanced;
206 };
207 
208 #endif // GUI_WINDOWS_BUYDIALOG_H
int BeingId
Definition: beingid.h:30
Definition: being.h:96
Definition: button.h:102
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
static bool isActive()
Definition: buydialog.h:164
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
int getNumberOfElements()
void setMoney(const int amount)
Definition: buydialog.cpp:437
Definition: label.h:91
Definition: slider.h:89
Definition: window.h:102
uint16_t ItemColor
Definition: itemcolor.h:30
ItemType ::T ItemTypeT
Definition: itemtype.h:43
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
bool Visible
Definition: visible.h:30