1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CSplitWindow: added input check

This one fixes issue 1952
This commit is contained in:
ArseniyShestakov 2014-12-23 07:38:58 +03:00
parent 8a697f2ba3
commit 94d0e5486a

View File

@ -400,14 +400,25 @@ CSplitWindow::CSplitWindow(const CCreature * creature, std::function<void(int, i
void CSplitWindow::setAmountText(std::string text, bool left)
{
try
{
setAmount(boost::lexical_cast<int>(text), left);
slider->moveTo(rightAmount - rightMin);
}
catch(boost::bad_lexical_cast &)
int amount = 0;
if (text.length())
{
try
{
amount = boost::lexical_cast<int>(text);
}
catch(boost::bad_lexical_cast &)
{
amount = left ? leftAmount : rightAmount;
}
int total = leftAmount + rightAmount;
if (amount > total)
amount = total;
}
setAmount(amount, left);
slider->moveTo(rightAmount - rightMin);
}
void CSplitWindow::setAmount(int value, bool left)