mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	CSplitWindow: added input check
This one fixes issue 1952
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user