Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor signal connections and set theme override to null #118

Merged
merged 8 commits into from
Sep 4, 2023

Conversation

juliohq
Copy link
Contributor

@juliohq juliohq commented Sep 3, 2023

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.

@juliohq juliohq changed the title Refactors Refactor signal connections and set theme override to null Sep 3, 2023
Copy link
Contributor

@artism90 artism90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a Utils class in res://Assets/World/Utils.gd for static functions. You can append those for signals there and update all references accordingly.

res://Utils/ is supposed to store macros for repititive or tedious tasks in the editor (EditorScript classes).

Utils/SignalUtils.gd Outdated Show resolved Hide resolved
Utils/SignalUtils.gd Outdated Show resolved Hide resolved
@artism90 artism90 added the code Programming code and game logic label Sep 3, 2023
@artism90 artism90 merged commit 8b4479e into unknown-horizons:develop Sep 4, 2023
1 check passed
@juliohq juliohq deleted the refactors branch September 4, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Programming code and game logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants