OpenMW
apps/openmw/mwgui/tradewindow.hpp
Go to the documentation of this file.
00001 #ifndef MWGUI_TRADEWINDOW_H
00002 #define MWGUI_TRADEWINDOW_H
00003 
00004 #include "container.hpp"
00005 
00006 namespace MyGUI
00007 {
00008   class Gui;
00009   class Widget;
00010 }
00011 
00012 namespace MWGui
00013 {
00014     class WindowManager;
00015 }
00016 
00017 
00018 namespace MWGui
00019 {
00020     class ItemView;
00021     class SortFilterItemModel;
00022     class TradeItemModel;
00023 
00024     class TradeWindow : public WindowBase, public ReferenceInterface
00025     {
00026         public:
00027             TradeWindow();
00028 
00029             void startTrade(const MWWorld::Ptr& actor);
00030 
00031             void addOrRemoveGold(int gold, const MWWorld::Ptr& actor);
00032 
00033             void onFrame(float frameDuration);
00034 
00035             void borrowItem (int index, size_t count);
00036             void returnItem (int index, size_t count);
00037 
00038             int getMerchantServices();
00039 
00040 
00041         private:
00042             ItemView* mItemView;
00043             SortFilterItemModel* mSortModel;
00044             TradeItemModel* mTradeModel;
00045 
00046             static const float sBalanceChangeInitialPause; // in seconds
00047             static const float sBalanceChangeInterval; // in seconds
00048 
00049             MyGUI::Button* mFilterAll;
00050             MyGUI::Button* mFilterWeapon;
00051             MyGUI::Button* mFilterApparel;
00052             MyGUI::Button* mFilterMagic;
00053             MyGUI::Button* mFilterMisc;
00054 
00055             MyGUI::Button* mIncreaseButton;
00056             MyGUI::Button* mDecreaseButton;
00057             MyGUI::TextBox* mTotalBalanceLabel;
00058             MyGUI::TextBox* mTotalBalance;
00059 
00060             MyGUI::Widget* mBottomPane;
00061 
00062             MyGUI::Button* mMaxSaleButton;
00063             MyGUI::Button* mCancelButton;
00064             MyGUI::Button* mOfferButton;
00065             MyGUI::TextBox* mPlayerGold;
00066             MyGUI::TextBox* mMerchantGold;
00067 
00068             int mItemToSell;
00069 
00070             int mCurrentBalance;
00071             int mCurrentMerchantOffer;
00072 
00073             enum BalanceButtonsState {
00074                 BBS_None,
00075                 BBS_Increase,
00076                 BBS_Decrease
00077             } mBalanceButtonsState;
00079             float mBalanceChangePause;
00080 
00081             void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); 
00082             void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); 
00083 
00084             void onItemSelected (int index);
00085             void sellItem (MyGUI::Widget* sender, int count);
00086 
00087             void onFilterChanged(MyGUI::Widget* _sender);
00088             void onOfferButtonClicked(MyGUI::Widget* _sender);
00089             void onCancelButtonClicked(MyGUI::Widget* _sender);
00090             void onMaxSaleButtonClicked(MyGUI::Widget* _sender);
00091             void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
00092             void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
00093             void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
00094 
00095             void onIncreaseButtonTriggered();
00096             void onDecreaseButtonTriggered();
00097 
00098             void updateLabels();
00099 
00100             virtual void onReferenceUnavailable();
00101 
00102             int getMerchantGold();
00103     };
00104 }
00105 
00106 #endif