From a1bdf20958b11eb1f7dc56fe5a3b826aa19c3f9e Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 31 May 2014 13:53:36 +0200 Subject: [PATCH] Make trade balance label editable --- apps/openmw/mwgui/tradewindow.cpp | 15 +++++++++++++++ apps/openmw/mwgui/tradewindow.hpp | 3 ++- files/mygui/openmw_trade_window.layout | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index cb7f3b0bd..03c73d171 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -74,6 +74,8 @@ namespace MWGui mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed); mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased); + mTotalBalance->eventEditTextChange += MyGUI::newDelegate(this, &TradeWindow::onBalanceEdited); + setCoord(400, 0, 400, 300); } @@ -410,6 +412,19 @@ namespace MWGui mBalanceButtonsState = BBS_None; } + void TradeWindow::onBalanceEdited(MyGUI::EditBox *_sender) + { + try + { + unsigned int count = boost::lexical_cast(_sender->getCaption()); + mCurrentBalance = count * (mCurrentBalance >= 0 ? 1 : -1); + updateLabels(); + } + catch (std::bad_cast&) + { + } + } + void TradeWindow::onIncreaseButtonTriggered() { if(mCurrentBalance<=-1) mCurrentBalance -= 1; diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 420a642e8..cc70f1ae9 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -55,7 +55,7 @@ namespace MWGui MyGUI::Button* mIncreaseButton; MyGUI::Button* mDecreaseButton; MyGUI::TextBox* mTotalBalanceLabel; - MyGUI::TextBox* mTotalBalance; + MyGUI::EditBox* mTotalBalance; MyGUI::Widget* mBottomPane; @@ -91,6 +91,7 @@ namespace MWGui 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); + void onBalanceEdited(MyGUI::EditBox* _sender); void onIncreaseButtonTriggered(); void onDecreaseButtonTriggered(); diff --git a/files/mygui/openmw_trade_window.layout b/files/mygui/openmw_trade_window.layout index 8a1be496f..cb00d7d50 100644 --- a/files/mygui/openmw_trade_window.layout +++ b/files/mygui/openmw_trade_window.layout @@ -44,7 +44,7 @@ - +