2012-05-17 13:36:25 +02:00
|
|
|
#ifndef MWGUI_TRADEWINDOW_H
|
|
|
|
#define MWGUI_TRADEWINDOW_H
|
|
|
|
|
2016-06-04 12:28:47 -04:00
|
|
|
#include "../mwmechanics/trading.hpp"
|
|
|
|
|
2015-01-10 01:21:17 +01:00
|
|
|
#include "referenceinterface.hpp"
|
|
|
|
#include "windowbase.hpp"
|
2012-05-17 17:15:44 +02:00
|
|
|
|
2014-09-25 20:28:00 +02:00
|
|
|
namespace Gui
|
2012-05-17 13:36:25 +02:00
|
|
|
{
|
2014-09-25 20:28:00 +02:00
|
|
|
class NumericEditBox;
|
2012-05-17 13:36:25 +02:00
|
|
|
}
|
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
namespace MyGUI
|
2012-05-17 13:36:25 +02:00
|
|
|
{
|
2015-01-10 02:50:43 +01:00
|
|
|
class ControllerItem;
|
2012-05-17 13:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
{
|
2013-05-11 18:38:27 +02:00
|
|
|
class ItemView;
|
|
|
|
class SortFilterItemModel;
|
|
|
|
class TradeItemModel;
|
|
|
|
|
|
|
|
class TradeWindow : public WindowBase, public ReferenceInterface
|
2012-05-17 13:36:25 +02:00
|
|
|
{
|
|
|
|
public:
|
2013-04-10 14:46:21 -04:00
|
|
|
TradeWindow();
|
2012-05-17 13:36:25 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void setPtr(const MWWorld::Ptr& actor) override;
|
2012-05-18 15:51:33 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void onClose() override;
|
|
|
|
void onFrame(float dt) override;
|
|
|
|
void clear() override { resetReference(); }
|
2017-09-23 22:00:15 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void borrowItem (int index, size_t count);
|
|
|
|
void returnItem (int index, size_t count);
|
|
|
|
|
|
|
|
int getMerchantServices();
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool exit() override;
|
2014-05-26 23:13:37 -04:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void resetReference() override;
|
2013-05-11 18:38:27 +02:00
|
|
|
|
2017-09-25 18:07:49 +02:00
|
|
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_TradeDone;
|
|
|
|
EventHandle_TradeDone eventTradeDone;
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
private:
|
|
|
|
ItemView* mItemView;
|
|
|
|
SortFilterItemModel* mSortModel;
|
|
|
|
TradeItemModel* mTradeModel;
|
2016-06-04 12:28:47 -04:00
|
|
|
MWMechanics::Trading mTrading;
|
2013-05-11 18:38:27 +02:00
|
|
|
|
2013-02-22 21:33:23 +04:00
|
|
|
static const float sBalanceChangeInitialPause; // in seconds
|
|
|
|
static const float sBalanceChangeInterval; // in seconds
|
|
|
|
|
2012-05-17 13:36:25 +02:00
|
|
|
MyGUI::Button* mFilterAll;
|
|
|
|
MyGUI::Button* mFilterWeapon;
|
|
|
|
MyGUI::Button* mFilterApparel;
|
|
|
|
MyGUI::Button* mFilterMagic;
|
|
|
|
MyGUI::Button* mFilterMisc;
|
|
|
|
|
2020-02-24 18:14:40 +00:00
|
|
|
MyGUI::EditBox* mFilterEdit;
|
|
|
|
|
2012-05-17 21:15:48 +02:00
|
|
|
MyGUI::Button* mIncreaseButton;
|
|
|
|
MyGUI::Button* mDecreaseButton;
|
|
|
|
MyGUI::TextBox* mTotalBalanceLabel;
|
2014-09-25 20:28:00 +02:00
|
|
|
Gui::NumericEditBox* mTotalBalance;
|
2012-05-17 21:15:48 +02:00
|
|
|
|
|
|
|
MyGUI::Widget* mBottomPane;
|
|
|
|
|
|
|
|
MyGUI::Button* mMaxSaleButton;
|
|
|
|
MyGUI::Button* mCancelButton;
|
|
|
|
MyGUI::Button* mOfferButton;
|
|
|
|
MyGUI::TextBox* mPlayerGold;
|
|
|
|
MyGUI::TextBox* mMerchantGold;
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
int mItemToSell;
|
|
|
|
|
2012-05-17 21:56:16 +02:00
|
|
|
int mCurrentBalance;
|
2012-11-08 13:38:20 +01:00
|
|
|
int mCurrentMerchantOffer;
|
2012-05-17 21:56:16 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance
|
|
|
|
void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance
|
|
|
|
|
2014-09-22 11:26:16 +02:00
|
|
|
void updateOffer();
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void onItemSelected (int index);
|
|
|
|
void sellItem (MyGUI::Widget* sender, int count);
|
|
|
|
|
2012-05-17 13:36:25 +02:00
|
|
|
void onFilterChanged(MyGUI::Widget* _sender);
|
2020-02-24 18:14:40 +00:00
|
|
|
void onNameFilterChanged(MyGUI::EditBox* _sender);
|
2012-05-17 21:15:48 +02:00
|
|
|
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
2017-09-24 13:10:50 +02:00
|
|
|
void onAccept(MyGUI::EditBox* sender);
|
2012-05-17 21:15:48 +02:00
|
|
|
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
2013-03-04 12:21:38 +01:00
|
|
|
void onMaxSaleButtonClicked(MyGUI::Widget* _sender);
|
2013-02-10 08:50:36 +04:00
|
|
|
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
|
|
|
void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
|
|
|
void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
2014-09-25 20:28:00 +02:00
|
|
|
void onBalanceValueChanged(int value);
|
2014-09-11 00:25:09 +02:00
|
|
|
void onRepeatClick(MyGUI::Widget* widget, MyGUI::ControllerItem* controller);
|
|
|
|
|
|
|
|
void addRepeatController(MyGUI::Widget* widget);
|
2013-02-10 08:50:36 +04:00
|
|
|
|
|
|
|
void onIncreaseButtonTriggered();
|
|
|
|
void onDecreaseButtonTriggered();
|
2012-05-17 21:56:16 +02:00
|
|
|
|
2014-01-08 23:37:46 +01:00
|
|
|
void addOrRemoveGold(int gold, const MWWorld::Ptr& actor);
|
|
|
|
|
2012-05-17 21:56:16 +02:00
|
|
|
void updateLabels();
|
2012-05-27 01:14:33 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void onReferenceUnavailable() override;
|
2013-03-04 12:21:38 +01:00
|
|
|
|
|
|
|
int getMerchantGold();
|
2012-05-17 13:36:25 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|