Make trade balance label editable

deque
scrawl 11 years ago
parent de7fcf0beb
commit a1bdf20958

@ -74,6 +74,8 @@ namespace MWGui
mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed); mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed);
mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased); mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
mTotalBalance->eventEditTextChange += MyGUI::newDelegate(this, &TradeWindow::onBalanceEdited);
setCoord(400, 0, 400, 300); setCoord(400, 0, 400, 300);
} }
@ -410,6 +412,19 @@ namespace MWGui
mBalanceButtonsState = BBS_None; mBalanceButtonsState = BBS_None;
} }
void TradeWindow::onBalanceEdited(MyGUI::EditBox *_sender)
{
try
{
unsigned int count = boost::lexical_cast<unsigned int>(_sender->getCaption());
mCurrentBalance = count * (mCurrentBalance >= 0 ? 1 : -1);
updateLabels();
}
catch (std::bad_cast&)
{
}
}
void TradeWindow::onIncreaseButtonTriggered() void TradeWindow::onIncreaseButtonTriggered()
{ {
if(mCurrentBalance<=-1) mCurrentBalance -= 1; if(mCurrentBalance<=-1) mCurrentBalance -= 1;

@ -55,7 +55,7 @@ namespace MWGui
MyGUI::Button* mIncreaseButton; MyGUI::Button* mIncreaseButton;
MyGUI::Button* mDecreaseButton; MyGUI::Button* mDecreaseButton;
MyGUI::TextBox* mTotalBalanceLabel; MyGUI::TextBox* mTotalBalanceLabel;
MyGUI::TextBox* mTotalBalance; MyGUI::EditBox* mTotalBalance;
MyGUI::Widget* mBottomPane; MyGUI::Widget* mBottomPane;
@ -91,6 +91,7 @@ namespace MWGui
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); 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 onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
void onBalanceButtonReleased(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 onIncreaseButtonTriggered();
void onDecreaseButtonTriggered(); void onDecreaseButtonTriggered();

@ -44,7 +44,7 @@
</Widget> </Widget>
<Widget type="TextBox" skin="SandText" position="48 0 140 24" name="TotalBalanceLabel" align="Left Top "/> <Widget type="TextBox" skin="SandText" position="48 0 140 24" name="TotalBalanceLabel" align="Left Top "/>
<Widget type="TextBox" skin="SandText" position="48 28 140 24" name="TotalBalance" align="Left Top"> <Widget type="EditBox" skin="MW_TextEdit" position="48 28 140 24" name="TotalBalance" align="Left Top">
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
</Widget> </Widget>

Loading…
Cancel
Save