P1X-in / tanks-of-freedom-ii

Indie Turn Based Strategy in Isometric Voxel Art http://tof.p1x.in
Other
194 stars 19 forks source link

Fixed button press issue #5

Closed GaidamakUA closed 2 years ago

GaidamakUA commented 2 years ago

It fixed crash, caused by board receiving "action_released" and expecting initialization in "action_pressed". And I think, it's reasonable for buttons to react on release.

czlowiekimadlo commented 2 years ago

Using "action_pressed" vs. "action_released" should not make a difference here, because initialization happens when mouse enters an Area2D of a radial field. And even then, execute_focused_field() does check if it is initialized. So if you have a crash there, I would like to see a stack trace, as it is probably something else.

Also using "action_pressed" generally makes the game feel "snappier", as it will execute a couple of frames faster than released. It does not make much difference in a game like ToF though.

czlowiekimadlo commented 2 years ago

I have figured out where the issue is. If you click on an option in the radial and hold the button until it folds, then release, game will crash. The game board does react to button release events, and it expects initialization on button press, which causes the issue, because press does not happen with radial menu opened. It needs to be fixed on the board level, as there might be other ways to trigger this.

czlowiekimadlo commented 2 years ago

Fixed in dad0fea32e245ae652de6191c7fd440f7247fefb

czlowiekimadlo commented 2 years ago

Thank you for the issue report!

czlowiekimadlo commented 2 years ago

After giving it a bit of thought, this change, on it's own, should be good as well. Sometimes people might click on a skill and then change their mind, so they will be able to move the mouse away and release.