Mana
Loading...
Searching...
No Matches
tradewindow.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 "gui/widgets/window.h"
25
26#include <guichan/actionlistener.hpp>
27#include <guichan/selectionlistener.hpp>
28
29#include <memory>
30
31class Inventory;
32class Item;
33class ItemContainer;
34class ScrollArea;
35
41class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
42{
43 public:
45
46 ~TradeWindow() override;
47
51 void setMoney(int quantity);
52
56 void addItem(int id, bool own, int quantity);
57
61 void reset();
62
66 void addItem(int id, bool own, int quantity, bool equipment);
67
71 void changeQuantity(int index, bool own, int quantity);
72
76 void increaseQuantity(int index, bool own, int quantity);
77
81 void receivedOk(bool own);
82
87 void valueChanged(const gcn::SelectionEvent &event) override;
88
92 void action(const gcn::ActionEvent &event) override;
93
98 void close() override;
99
100 private:
108
112 void setStatus(Status s);
113
114 const std::unique_ptr<Inventory> mMyInventory;
115 const std::unique_ptr<Inventory> mPartnerInventory;
116
119
120 gcn::Label *mMoneyLabel;
121 gcn::Button *mAddButton;
122 gcn::Button *mOkButton;
123 gcn::Button *mMoneyChangeButton;
124 gcn::TextField *mMoneyField;
125
128};
129
An item container.
Represents one or more instances of a certain item type.
Definition item.h:35
A scroll area.
Definition scrollarea.h:38
Trade dialog.
Definition tradewindow.h:42
Status mStatus
void addItem(int id, bool own, int quantity)
Add an item to the trade window.
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
void reset()
Reset both item containers.
@ PREPARING
Players are adding items.
@ ACCEPTED
Local player has accepted the trade.
@ ACCEPTING
Accepting the trade.
@ PROPOSING
Local player has confirmed the trade.
gcn::Label * mMoneyLabel
void receivedOk(bool own)
Player received ok message from server.
void valueChanged(const gcn::SelectionEvent &event) override
Updates the labels and makes sure only one item is selected in either my inventory or partner invento...
const std::unique_ptr< Inventory > mPartnerInventory
gcn::Button * mMoneyChangeButton
void setStatus(Status s)
Sets the current status of the trade.
ItemContainer * mPartnerItemContainer
void increaseQuantity(int index, bool own, int quantity)
Increase quantity of an item.
~TradeWindow() override
void changeQuantity(int index, bool own, int quantity)
Change quantity of an item.
ItemContainer * mMyItemContainer
const std::unique_ptr< Inventory > mMyInventory
void addItem(int id, bool own, int quantity, bool equipment)
Add an item to the trade window.
gcn::TextField * mMoneyField
gcn::Button * mOkButton
gcn::Button * mAddButton
void setMoney(int quantity)
Displays expected money in the trade window.
void close() override
Closes the Trade Window, as well as telling the server that the window has been closed.
A window.
Definition window.h:59
TradeWindow * tradeWindow
Definition game.cpp:101