ManaPlus
tradewindow.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_TRADEWINDOW_H
25 #define GUI_WINDOWS_TRADEWINDOW_H
26 
27 #include "gui/widgets/window.h"
28 
30 
36 
39 
40 class Button;
41 class Inventory;
42 class Item;
43 class ItemContainer;
44 class Label;
45 class TextField;
46 
47 struct ItemOptionsList;
48 
54 class TradeWindow final : public Window,
55  private ActionListener,
56  private SelectionListener
57 {
58  public:
62  TradeWindow();
63 
65 
66 
69  ~TradeWindow() override final;
70 
74  void setMoney(const int quantity);
75 
79  void addItem(const int id,
80  const ItemTypeT type,
81  const bool own,
82  const int quantity,
83  const uint8_t refine,
84  const ItemColor color,
85  const Identified identified,
86  const Damaged damaged,
87  const Favorite favorite) const;
88 
92  void reset();
93 
97  void addItem2(const int id,
98  const ItemTypeT type,
99  const int *const cards,
100  const ItemOptionsList *const options,
101  const int sz,
102  const bool own,
103  const int quantity,
104  const uint8_t refine,
105  const ItemColor color,
106  const Identified identified,
107  const Damaged damaged,
108  const Favorite favorite,
109  const Equipm equipment) const;
110 
114  void changeQuantity(const int index, const bool own,
115  const int quantity) const;
116 
120  void increaseQuantity(const int index, const bool own,
121  const int quantity) const;
122 
126  void receivedOk(const bool own);
127 
131  void tradeItem(const Item *const item,
132  const int quantity,
133  const bool check) const;
134 
139  void valueChanged(const SelectionEvent &event) override final;
140 
144  void action(const ActionEvent &event) override final;
145 
150  void close() override final;
151 
155  void clear() override final;
156 
160  void addAutoItem(const std::string &nick, Item *const item,
161  const int amount);
162 
163  void addAutoMoney(const std::string &nick, const int money);
164 
165  void initTrade(const std::string &nick);
166 
168  { return mAutoAddToNick; }
169 
170  bool checkItem(const Item *const item) const A_WARN_UNUSED;
171 
172  bool isInpupFocused() const A_WARN_UNUSED;
173 
174  void completeTrade();
175 
176  private:
177  enum Status
178  {
179  PREPARING = 0,
182  ACCEPTED
183  };
184 
188  void setStatus(const Status s);
189 
192 
195 
201 
203  std::string mAutoAddToNick;
209  bool mOkOther;
210  bool mOkMe;
211 };
212 
213 extern TradeWindow *tradeWindow;
214 
215 #endif // GUI_WINDOWS_TRADEWINDOW_H
Definition: button.h:102
Definition: item.h:50
Definition: label.h:91
Status mStatus
Definition: tradewindow.h:208
TextField * mMoneyField
Definition: tradewindow.h:200
Label * mMoneyLabel
Definition: tradewindow.h:196
Button * mOkButton
Definition: tradewindow.h:198
std::string mAutoAddToNick
Definition: tradewindow.h:203
void valueChanged(const SelectionEvent &event)
Button * mMoneyChangeButton
Definition: tradewindow.h:199
int mAutoAddAmount
Definition: tradewindow.h:207
Item * mAutoAddItem
Definition: tradewindow.h:202
int mGotMaxMoney
Definition: tradewindow.h:205
ItemContainer * mPartnerItemContainer
Definition: tradewindow.h:194
std::string getAutoTradeNick() const
Definition: tradewindow.h:167
void addAutoMoney(const std::string &nick, const int money)
bool isInpupFocused() const
void addItem(const int id, const ItemTypeT type, const bool own, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite) const
ItemContainer * mMyItemContainer
Definition: tradewindow.h:193
Button * mAddButton
Definition: tradewindow.h:197
void setMoney(const int quantity)
void receivedOk(const bool own)
void initTrade(const std::string &nick)
void completeTrade()
Inventory * mPartnerInventory
Definition: tradewindow.h:191
void setStatus(const Status s)
void action(const ActionEvent &event)
bool checkItem(const Item *const item) const
void changeQuantity(const int index, const bool own, const int quantity) const
void addItem2(const int id, const ItemTypeT type, const int *const cards, const ItemOptionsList *const options, const int sz, const bool own, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment) const
void increaseQuantity(const int index, const bool own, const int quantity) const
Inventory * mMyInventory
Definition: tradewindow.h:190
void tradeItem(const Item *const item, const int quantity, const bool check) const
void addAutoItem(const std::string &nick, Item *const item, const int amount)
Definition: window.h:102
bool Damaged
Definition: damaged.h:30
bool Equipm
Definition: equipm.h:30
bool Favorite
Definition: favorite.h:30
bool Identified
Definition: identified.h:30
uint16_t ItemColor
Definition: itemcolor.h:30
ItemType ::T ItemTypeT
Definition: itemtype.h:43
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
TradeWindow * tradeWindow
Definition: tradewindow.cpp:65