From 26981534917a271b4351f653adc96d6e10255f34 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 24 Aug 2019 12:56:58 +0200 Subject: [PATCH] fixed elementhelper crash --- MLEM.Ui/Elements/ElementHelper.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MLEM.Ui/Elements/ElementHelper.cs b/MLEM.Ui/Elements/ElementHelper.cs index 20cbf42..d2d8e83 100644 --- a/MLEM.Ui/Elements/ElementHelper.cs +++ b/MLEM.Ui/Elements/ElementHelper.cs @@ -17,7 +17,8 @@ namespace MLEM.Ui.Elements { OnClicked = (element, button) => { if (button == MouseButton.Left) { var text = field.Text.ToString(); - field.SetText(int.Parse(text) + stepPerClick); + if (int.TryParse(text, out var val)) + field.SetText(val + stepPerClick); } } }; @@ -28,7 +29,8 @@ namespace MLEM.Ui.Elements { OnClicked = (element, button) => { if (button == MouseButton.Left) { var text = field.Text.ToString(); - field.SetText(int.Parse(text) - stepPerClick); + if (int.TryParse(text, out var val)) + field.SetText(val - stepPerClick); } } };