Skip to content

Commit

Permalink
category_factory: Use AudioStreamPlayer's stream_paused as a property
Browse files Browse the repository at this point in the history
According to the discussion [1], stream_paused is AudioStreamPlayer's a
property. Use it as property flavor to generate blocks automatically.

[1]: #161 (comment)
  • Loading branch information
starnight committed Aug 13, 2024
1 parent 22877e7 commit 621fe34
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions addons/block_code/ui/picker/categories/category_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -737,24 +737,6 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
b.category = "Sounds"
block_list.append(b)

b = BLOCKS["statement_block"].instantiate()
b.block_name = "audiostreamplayer_pause_continue"
b.block_type = Types.BlockType.EXECUTE
b.block_format = "{pause: OPTION} the sound"
b.statement = (
"""
if "{pause}" == "pause":
stream_paused = true
else:
stream_paused = false
"""
. dedent()
)
b.defaults = {"pause": OptionData.new(["Pause", "Continue"])}
b.tooltip_text = "Pause/Continue the audio stream"
b.category = "Sounds"
block_list.append(b)

b = BLOCKS["statement_block"].instantiate()
b.block_name = "audiostreamplayer_stop"
b.block_format = "Stop"
Expand All @@ -763,6 +745,14 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
b.category = "Sounds"
block_list.append(b)

props = {
"stream_paused":
{
"category": "Sounds",
"has_change": false,
},
}

"AnimationPlayer":
var b = BLOCKS["statement_block"].instantiate()
b.block_name = "animationplayer_play"
Expand Down

0 comments on commit 621fe34

Please sign in to comment.