unknown-horizons / godot-port

Unknown Horizons Godot Engine Port
https://www.unknown-horizons.org
GNU General Public License v2.0
663 stars 83 forks source link

Refactor signal connections and set theme override to null #118

Closed juliohq closed 1 year ago

juliohq commented 1 year ago

This PR fixes some errors related to signals (already connected signal errors) by adding a new SignalUtils class with two static functions: ensure_connected (checks if the signal is already connected before trying to connect it) and ensure_disconnected (checks if the signal is not connected before trying to disconnect it). That way, there is no need to check manually if a given signal is connected to a given callable before connecting/disconnecting, which leads to clearer code.

On top of that, I've replaced Callable(self, function_name) by just function_name given it's clearer and Godot will be able to throw errors in the editor before you run the game, in case you made a typo.