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

Add VariantResource class #30

Merged
merged 10 commits into from
Nov 1, 2020
Merged

Add VariantResource class #30

merged 10 commits into from
Nov 1, 2020

Conversation

Xrayez
Copy link
Contributor

@Xrayez Xrayez commented Oct 30, 2020

Allows to store built-in core data types as resources. Can be edited via editor inspector and stored on disk!

Array

goost_variant_resource_array

Dictionary

Closes godotengine/godot-proposals#1740.

goost_variant_resource_dict

Color

Closes godotengine/godot-proposals#1734.

goost_variant_resource_color

And other types. It means that the value is changed dynamically whenever you change the type property, and in some cases allows you to convert the old value to a new type.

@Xrayez
Copy link
Contributor Author

Xrayez commented Oct 31, 2020

Added various PropertyInfo properties as properties in VariantResource. Allows to customize the value property of the resource itself dynamically:

goost_variant_resource_multiline_string

Hints are listed from PropertyHint enum in the engine, which should be added to Godot: godotengine/godot#43211.

Hint string are used to configure the property's editor behavior:

goost_variant_resource_float_range_hint_string

Most essential hint strings are documented in Godot at global scope documentation.

PropertyUsageFlags are not so trivial to expose to be user-friendly, but still it should be there for completeness.

Modifying String properties in the VariantResource doesn't update the editor inspector for some reason, reported a bug in Godot godotengine/godot#43238, I may try to fix the issue there. The workaround is to switch the history of edited objects back and worth with the arrows above to force update the editor inspector that way.

That said, I think this is good enough to merge!

More in accordance with `Resource` types, rather than built-in types.
Only `Color` is supported for now.

Made sure to initialize via `EditorNode::add_init_callback`, else would crash.
@Xrayez
Copy link
Contributor Author

Xrayez commented Oct 31, 2020

Implemented resource previews as described in godotengine/godot-proposals#1734 (comment).

The `value` is not exposed as property, as it's configured dynamically.
Yet it can still be used as a property in GDScript, and probably other
languages.
@Xrayez
Copy link
Contributor Author

Xrayez commented Oct 31, 2020

Generating default icon resource previews for each Variant compatible type now:

goost_variant_resource_icons

Except for Color currently, because it makes perfect sense to display a color there.

The bool could be displayed as a "switch", "bulb" etc which could encode whether the value is turned on/off right from the filesystem dock.

Integer, float and string values could be rendered I think, but that's only theory and not sure whether it's possible/worth it.

@Xrayez
Copy link
Contributor Author

Xrayez commented Oct 31, 2020

So, there are actually "GuiChecked" and "GuiUnchecked" editor icons which can be reused to preview bool resources:

goost_variant_resource_custom_bool_icons

An appropriate icon was found with the help of https://github.com/Xrayez/godot-editor-icons-previewer plugin. 🙂

Which, may be worth integrating in Goost at some point, currently /editor is empty...

Also optimizes `Color` texture previews.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 💡 New feature proposal topic:core
Projects
None yet
1 participant