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

Support explicit values in flag properties, add C# flags support #59327

Merged
merged 1 commit into from
Jun 3, 2022

Conversation

raulsntos
Copy link
Member

@raulsntos raulsntos commented Mar 19, 2022

master version of #59328

  • Add support for explicit values in properties using PROPERTY_HINT_FLAGS that works the same way it does for enums.
  • Fix enums and flags in VisualScriptEditor (it wasn't considering the explicit value).
  • Use PROPERTY_HINT_FLAGS for C# enums with the FlagsAttribute instead of PROPERTY_HINT_ENUM.

This allows specifying the explicit value of flags in GDScript and C#:

@export_flags("Red:1,Green:2,Blue:4,RedAndGreen:3") var color: int;
[Flags]
public enum ColorFlags
{
	Red = 1,
	Green = 2,
	Blue = 4,
	RedAndGreen = Red | Green,
}

public partial class MyClass : Node
{
	[Export]
	public ColorFlags Color { get; set; }
}

Uses the same syntax that enums use.

flags.mp4

Also fixed enums and flags in VisualScriptEditor (something like @export_enum("Something:3,Other:4") wasn't working) and adds support for explicit value flags as it was done for GDScript and C#.

I was unable to test the VisualScriptEditor changes in this PR (4.0) but I could test it in the 3.x version:

flags

- Add support for explicit values in properties using `PROPERTY_HINT_FLAGS`
that works the same way it does for enums.
- Fix enums and flags in VisualScriptEditor (it wasn't considering the
explicit value).
- Use `PROPERTY_HINT_FLAGS` for C# enums with the FlagsAttribute instead
of `PROPERTY_HINT_ENUM`.
@raulsntos raulsntos force-pushed the csharp-flag-enums branch from 3f9e439 to 329818f Compare June 3, 2022 03:19
@akien-mga akien-mga added this to the 4.0 milestone Jun 3, 2022
@akien-mga akien-mga merged commit 027c38e into godotengine:master Jun 3, 2022
@akien-mga
Copy link
Member

Thanks!

@raulsntos raulsntos deleted the csharp-flag-enums branch June 3, 2022 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants