Mana
Loading...
Searching...
No Matches
buydialog.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "guichanfwd.h"
25
26#include "gui/widgets/window.h"
27
28#include <guichan/actionlistener.hpp>
29#include <guichan/selectionlistener.hpp>
30
31class ShopItems;
32class ShopListBox;
33class ListBox;
34
40class BuyDialog : public Window, public gcn::ActionListener,
41 public gcn::SelectionListener
42{
43 public:
44 BuyDialog(int npcId);
45
46 ~BuyDialog() override;
47
51 void reset();
52
56 void setMoney(int amount);
57
61 void addItem(int id, int amount, int price);
62
66 void action(const gcn::ActionEvent &event) override;
67
72
76 void valueChanged(const gcn::SelectionEvent &event) override;
77
81 void mouseClicked(gcn::MouseEvent &mouseEvent) override;
82
86 std::string getElementAt(int i);
87
92
96 void setVisible(bool visible) override;
97
101 static void closeAll();
102
103 private:
104 using DialogList = std::list<BuyDialog *>;
106
108
109 gcn::Button *mBuyButton;
110 gcn::Button *mQuitButton;
111 gcn::Button *mAddMaxButton;
112 gcn::Button *mIncreaseButton;
113 gcn::Button *mDecreaseButton;
115 gcn::ScrollArea *mScrollArea;
116 gcn::Label *mMoneyLabel;
117 gcn::Label *mQuantityLabel;
118 gcn::Slider *mSlider;
119
121
125};
The buy dialog.
Definition buydialog.h:42
void reset()
Resets the dialog, clearing shop inventory.
static DialogList instances
Definition buydialog.h:105
gcn::Button * mBuyButton
Definition buydialog.h:109
gcn::Button * mQuitButton
Definition buydialog.h:110
gcn::Label * mQuantityLabel
Definition buydialog.h:117
int mMaxItems
Definition buydialog.h:124
int mAmountItems
Definition buydialog.h:123
static void closeAll()
Closes all instances.
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
gcn::Slider * mSlider
Definition buydialog.h:118
gcn::ScrollArea * mScrollArea
Definition buydialog.h:115
void addItem(int id, int amount, int price)
Adds an item to the shop inventory.
std::list< BuyDialog * > DialogList
Definition buydialog.h:104
gcn::Button * mDecreaseButton
Definition buydialog.h:113
ShopItems * mShopItems
Definition buydialog.h:120
gcn::Button * mAddMaxButton
Definition buydialog.h:111
gcn::Button * mIncreaseButton
Definition buydialog.h:112
void mouseClicked(gcn::MouseEvent &mouseEvent) override
Allows for quick-buying by extending double-click events.
void updateButtonsAndLabels()
Updates the state of buttons and labels.
~BuyDialog() override
ShopListBox * mShopItemList
Definition buydialog.h:114
void setVisible(bool visible) override
Sets the visibility of this window.
void valueChanged(const gcn::SelectionEvent &event) override
Updates the labels according to the selected item.
void setMoney(int amount)
Sets the amount of available money.
gcn::Label * mMoneyLabel
Definition buydialog.h:116
std::string getElementAt(int i)
Returns the name of item number i in the shop inventory.
int getNumberOfElements()
Returns the number of items in the shop inventory.
A list box, meant to be used inside a scroll area.
Definition listbox.h:36
This class handles the list of items available in a shop.
Definition shopitems.h:41
A list box, meant to be used inside a scroll area.
Definition shoplistbox.h:37
A window.
Definition window.h:59