|
|
|
@ -19,12 +19,17 @@
|
|
|
|
|
|
|
|
|
|
#include "inventorywindow.hpp"
|
|
|
|
|
|
|
|
|
|
static const float BALANCE_CHANGE_INITIAL_PAUSE = 0.5; // in seconds
|
|
|
|
|
static const float BALANCE_CHANGE_INTERVAL = 0.1; // in seconds
|
|
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
|
|
|
|
|
WindowBase("openmw_trade_window.layout", parWindowManager)
|
|
|
|
|
, ContainerBase(NULL) // no drag&drop
|
|
|
|
|
, mCurrentBalance(0)
|
|
|
|
|
, mBalanceButtonsState(BBS_None)
|
|
|
|
|
, mBalanceChangePause(0.0)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::ScrollView* itemView;
|
|
|
|
|
MyGUI::Widget* containerWidget;
|
|
|
|
@ -59,8 +64,10 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
|
|
|
|
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
|
|
|
|
mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked);
|
|
|
|
|
mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked);
|
|
|
|
|
mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed);
|
|
|
|
|
mIncreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
|
|
|
|
mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed);
|
|
|
|
|
mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
|
|
|
|
|
|
|
|
|
setCoord(400, 0, 400, 300);
|
|
|
|
|
|
|
|
|
@ -143,6 +150,21 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onFrame(float frameDuration)
|
|
|
|
|
{
|
|
|
|
|
if (!mMainWidget->getVisible() || mBalanceButtonsState == BBS_None)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mBalanceChangePause -= frameDuration;
|
|
|
|
|
if (mBalanceChangePause < 0.0) {
|
|
|
|
|
mBalanceChangePause += BALANCE_CHANGE_INTERVAL;
|
|
|
|
|
if (mBalanceButtonsState == BBS_Increase)
|
|
|
|
|
onIncreaseButtonTriggered();
|
|
|
|
|
else if (mBalanceButtonsState == BBS_Decrease)
|
|
|
|
|
onDecreaseButtonTriggered();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
|
|
|
@ -242,7 +264,7 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
//skill use!
|
|
|
|
|
MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
|
|
|
|
@ -271,14 +293,33 @@ namespace MWGui
|
|
|
|
|
mWindowManager.removeGuiMode(GM_Barter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onIncreaseButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
|
void TradeWindow::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
|
{
|
|
|
|
|
mBalanceButtonsState = BBS_Increase;
|
|
|
|
|
mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE;
|
|
|
|
|
onIncreaseButtonTriggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
|
{
|
|
|
|
|
mBalanceButtonsState = BBS_Decrease;
|
|
|
|
|
mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE;
|
|
|
|
|
onDecreaseButtonTriggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onBalanceButtonReleased(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
|
{
|
|
|
|
|
mBalanceButtonsState = BBS_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onIncreaseButtonTriggered()
|
|
|
|
|
{
|
|
|
|
|
if(mCurrentBalance<=-1) mCurrentBalance -= 1;
|
|
|
|
|
if(mCurrentBalance>=1) mCurrentBalance += 1;
|
|
|
|
|
updateLabels();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
|
void TradeWindow::onDecreaseButtonTriggered()
|
|
|
|
|
{
|
|
|
|
|
if(mCurrentBalance<-1) mCurrentBalance += 1;
|
|
|
|
|
if(mCurrentBalance>1) mCurrentBalance -= 1;
|
|
|
|
|