ManaPlus
selldialog.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_WIDGETS_SELLDIALOG_H
25 #define GUI_WIDGETS_SELLDIALOG_H
26 
28 
32 
33 #include "gui/widgets/window.h"
34 
37 
38 class Button;
39 class Item;
40 class Label;
41 class ScrollArea;
42 class ShopItem;
43 class ShopItems;
44 class ShopListBox;
45 class Slider;
46 
52 class SellDialog notfinal : public Window,
53  public ActionListener,
54  private SelectionListener
55 {
56  public:
60  SellDialog(const IsSell isSell,
61  const Advanced advanced);
62 
64 
65 
68  ~SellDialog() override;
69 
73  void reset();
74 
78  void addItem(const Item *const item,
79  const int price);
80 
84  void action(const ActionEvent &event) override final;
85 
91  void valueChanged(const SelectionEvent &event) override final;
92 
96  void setMoney(const int amount);
97 
101  void setVisible(Visible visible) override final;
102 
103  ShopItem *addItem(const int id,
104  const ItemTypeT type,
105  const ItemColor color,
106  const int amount,
107  const int price);
108 
112  static bool isActive() A_WARN_UNUSED
113  { return !instances.empty(); }
114 
118  static void closeAll();
119 
120  void postInit() override;
121 
122  protected:
123  typedef std::list<SellDialog*> DialogList;
125 
129  void updateButtonsAndLabels();
130 
131  virtual void sellAction(const ActionEvent &event) = 0;
132 
133  virtual void initButtons()
134  { }
135 
148 
152 
155 };
156 
157 #endif // GUI_WIDGETS_SELLDIALOG_H
bool Advanced
Definition: advanced.h:30
Definition: button.h:102
Definition: item.h:50
Definition: label.h:91
SellDialog(const IsSell isSell, const Advanced advanced)
Definition: selldialog.cpp:56
virtual void initButtons()
Definition: selldialog.h:133
ScrollArea * mScrollArea
Definition: selldialog.h:143
int mMaxItems
Definition: selldialog.h:150
virtual void sellAction(const ActionEvent &event)=0
Advanced mAdvanced
Definition: selldialog.h:154
void addItem(const Item *const item, const int price)
Definition: selldialog.cpp:238
void updateButtonsAndLabels()
Definition: selldialog.cpp:346
void reset()
Definition: selldialog.cpp:229
ShopItems * mShopItems
Definition: selldialog.h:147
Button * mQuitButton
Definition: selldialog.h:137
void setVisible(Visible visible)
Definition: selldialog.cpp:400
Slider * mSlider
Definition: selldialog.h:146
Label * mQuantityLabel
Definition: selldialog.h:145
void valueChanged(const SelectionEvent &event)
Definition: selldialog.cpp:328
Button * mDecreaseButton
Definition: selldialog.h:141
Button * mIncreaseButton
Definition: selldialog.h:140
void postInit()
Definition: selldialog.cpp:82
Button * mAddMaxButton
Definition: selldialog.h:139
static void closeAll()
Definition: selldialog.cpp:415
void setMoney(const int amount)
Definition: selldialog.cpp:340
void action(const ActionEvent &event)
Definition: selldialog.cpp:269
Button * mSellButton
Definition: selldialog.h:136
Button * mConfirmButton
Definition: selldialog.h:138
int mAmountItems
Definition: selldialog.h:151
IsSell mIsSell
Definition: selldialog.h:153
std::list< SellDialog * > DialogList
Definition: selldialog.h:123
static DialogList instances
Definition: selldialog.h:124
static bool isActive()
Definition: selldialog.h:112
ShopListBox * mShopItemList
Definition: selldialog.h:142
int mPlayerMoney
Definition: selldialog.h:149
Label * mMoneyLabel
Definition: selldialog.h:144
Definition: slider.h:89
Definition: window.h:102
bool IsSell
Definition: issell.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 notfinal
Definition: localconsts.h:261
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
bool Visible
Definition: visible.h:30