MelgMKW / Pulsar

Pulsar is a Mario Kart Wii Kamek-Based engine to create CT distributions
MIT License
32 stars 7 forks source link

Prevent crash when unsuccessfully parsing a number #4

Closed yomcube closed 8 months ago

yomcube commented 8 months ago

Currently, Pulsar crashes when it is unable to correctly parse a number. This pull request fixes that problem by using TryParse instead of Parse.

MelgMKW commented 8 months ago

These fixes wouldn't address the core of the issue, which is that by the time the event is fired, the textbox text has already been changed, meaning you would then have a sync issue between what's displayed and what's internally stored. Obviously, I could restore the box to its previous value, but I believe it's better if the event straight up does not happen. The actual problem what that when I reformatted the main xaml, I forgot to readd the PreviewTextInput events which allow me to ensure only an integer is passed to the TextChanged event. I did implement those that were needed though, most notably in file.cs, since importing a corrupted config.pul could mean some of these parses fail. Thanks for the fixes