wesnoth / haldric

Wesnoth 2.0, being developed in the Godot engine.
https://www.wesnoth.org
368 stars 48 forks source link

Validate map size before enabling creation #149

Closed coelhucas closed 3 years ago

coelhucas commented 3 years ago

Simple update made to prevent crashes and get familiarized with the project architecture before making further contributions.

Peek 2020-11-25 15-30

I'm willing to add also a dialog to save and load map files onto the editor once I have time. Let me know of any changes needed in this PR.

Byteron commented 3 years ago

Hi! Can you check the line edit input also for being numerical? Otherwise it'll crash on parsing to int when the string contains letters I think.

You can use String.is_valid_integer()

coelhucas commented 3 years ago

I made an update to fix a problem in the validation, but about this is_valid_integer, I don't think it's truly necessary. When a cast occurs, any other character is ignored, so:

int("abcde") = 0
int("12a3") = 123
int("dwjao8awujd8aw") = 88

(I made these and other tests to ensure it's fine)

But if you think it's better regardless of this, I can add it

Byteron commented 3 years ago

oh I didn't know that! Nice! Then it's ready to go in. :)

Byteron commented 3 years ago

Thanks!