feat(player): give SpriteStudioPlayer2D real enums and ClassDB properties - #259
Merged
Merged
Conversation
…ties
Two parts of the player's public surface were never registered with ClassDB,
so anything that reads the class description - the inspector's own metadata,
ClassDB.class_get_property_list, the doc tooling, and any future binding
generator - could not see them.
Enums. set_playback_direction, set_part_color_override* and
set_part_cell_override took plain ints whose meaning existed only in a comment
above the declarations. Add PlaybackDirection, PlaybackStyle,
ColorBlendOperation and OverridePriority, take them as parameter types, and
bind them alongside the existing AnimationProcessMode. The values follow the
runtime's FFI encoding, which normalizes direction and style to 0/1 on both
sides of the boundary, so they are not the Rust PlaybackDirection
discriminants. DEFVAL now names the default instead of spelling 0 and 1.
While binding them: AnimationProcessMode's two constants were already
registered with BIND_CONSTANT, as constants with no enum. That collided with
BIND_ENUM_CONSTANT ("Class 'SpriteStudioPlayer2D' already has constant") and
kept the enum itself out of ClassDB, even though doc_classes already described
the property as enum="SpriteStudioPlayer2D.AnimationProcessMode". Drop the old
binding.
Properties. Only `ssab` was registered; the other seventeen were served from
_set / _get / _get_property_list. Move them to ADD_PROPERTY / ADD_GROUP and
inject the three hints that genuinely depend on the instance - the animation
name list and the frame / section ranges - through _validate_property, the
same pattern SpriteStudioPartAttachment2D already uses for part_name.
`cellmaps/*` stays in _get_property_list because both its count and its names
come from the resource. frame_rate, playback_direction and playback_style stay
in _set / _get: they are reachable by name but deliberately absent from the
property list, and they already have bound accessors.
The section endpoints needed single-argument setters to be properties, so
set_animation_section_start / set_animation_section_end join the existing
set_animation_section.
Names, order, hints and usage flags are unchanged - including frame's
editor-only usage - so existing scenes keep loading and the inspector looks
the same. One visible difference: ADD_PROPERTY lets Godot resolve default
values, so a re-saved scene omits properties left at their default instead of
writing all seventeen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Registers the two halves of
SpriteStudioPlayer2D's public surface that never reached ClassDB: the enums behind itsintparameters, and the inspector properties.Enums
set_playback_direction,set_part_color_override*andset_part_cell_overridetook plainints documented only in a comment. Four enums are added and taken as parameter types, and bound alongside the existingAnimationProcessMode:AnimationProcessModeANIMATION_PROCESS_PHYSICS/_IDLEPlaybackDirectionPLAYBACK_DIRECTION_FORWARD/_BACKWARDPlaybackStylePLAYBACK_STYLE_NORMAL/_PING_PONGColorBlendOperationCOLOR_BLEND_MIX/_MUL/_ADD/_SUBOverridePriorityOVERRIDE_PRIORITY_NEXT_KEYFRAME/_UNTIL_ANIMATION_CHANGE/_PERMANENTValues follow the runtime's FFI encoding (
ss_runtime_set/get_playback_directionnormalizes direction and style to0/1on both sides, so these are not the RustPlaybackDirectiondiscriminants;blend_opandpriority_modematchssruntime.h).DEFVALnow names the default instead of spelling0/1.Bug fixed along the way:
AnimationProcessMode's two constants were already registered viaBIND_CONSTANT(constants with no enum). That collided withBIND_ENUM_CONSTANT—Class 'SpriteStudioPlayer2D' already has constant 'ANIMATION_PROCESS_PHYSICS'— and kept the enum out of ClassDB, even thoughdoc_classes/already described the property asenum="SpriteStudioPlayer2D.AnimationProcessMode". The old binding is dropped.Properties
Only
ssabwas registered; the other 17 came from_set/_get/_get_property_list, so they were invisible toClassDB.class_get_property_list, to the doc tooling, and to any binding generator. They move toADD_PROPERTY/ADD_GROUP, with the three genuinely instance-dependent hints — theanimationname list and theframe/ section ranges — injected through_validate_property, the same patternSpriteStudioPartAttachment2Dalready uses forpart_name.cellmaps/*stays in_get_property_list: both its count and its names come from the resource.frame_rate/playback_direction/playback_stylestay in_set/_get— reachable by name, deliberately absent from the property list, and already covered by bound accessors.set_animation_section_start/set_animation_section_endare added becauseADD_PROPERTYneeds single-argument setters.set_animation_section(start, end)is unchanged.Compatibility
Names, order, hints and usage flags are unchanged — including
frame's editor-only usage — so existing scenes keep loading and the inspector looks the same. GDScript passing raw ints to the now-enum parameters still compiles.One visible difference:
ADD_PROPERTYlets Godot resolve default values, so a re-saved scene omits properties left at their default instead of writing all 17. Verified by packing and saving a scene:Test plan
./scripts/build-extension.sh target=editor(macOS arm64) — builds and links./scripts/build.sh target=editor(macOS arm64, custom module) — builds and linksclass_get_enum_listwith the expected constantsclass_get_property_listreports the 17 properties + 4 groups in the original order, with the original hints and usage flags (framestillPROPERTY_USAGE_EDITORonly)_validate_propertyinjects the live hints:animation→'Arrow_Attack',frame→'0,70.0,0.01', section →'0,70.0,1'frame_rate, direction/style, section endpoints,animation_process_mode, andset_part_color_overridewith default argumentsdoc_classes/SpriteStudioPlayer2D.xmlcompiles intodoc_data.gen.cppRuntime behaviour of the GDExtension build was not exercised separately — it shares
_bind_methodswith the module build, andADD_GROUP/_validate_propertyalready have working precedent in both builds viaSpriteStudioPartAttachment2D.Docs
doc_classes/SpriteStudioPlayer2D.xmlgains the new constants and the two section members; the value tables indocs/{en,ja}/api/player.mdanddocs/{en,ja}/workflow/usage_scripting.mdnow name the constants next to the numbers.