mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-02-19 03:14:21 +01:00
Implement button index support for the in-game menu buttons.
This commit is contained in:
parent
901c275912
commit
9a07052455
@ -13,7 +13,7 @@ func on_request_instance(what : int, node : Node) -> void:
|
||||
node.windows.add_child(sc)
|
||||
|
||||
if add_button:
|
||||
var b = node.buttons.add_image_button(opener_button_texture, 0)
|
||||
var b = node.buttons.add_image_button(opener_button_texture, index)
|
||||
|
||||
b.connect("toggled", sc, "_on_button_toggled")
|
||||
sc.opener_button = b
|
||||
|
@ -39,12 +39,20 @@ func _ready():
|
||||
func add_image_button(texture : Texture, index : int = -1) -> Button:
|
||||
var button : Button = image_button.instance() as Button
|
||||
|
||||
button.set_meta("button_index", index)
|
||||
|
||||
button.get_child(0).texture = texture
|
||||
|
||||
add_child(button)
|
||||
|
||||
if index != -1:
|
||||
move_child(button, index)
|
||||
for ch in get_children():
|
||||
var button_index : int = get_child_count()
|
||||
|
||||
if ch.has_meta("button_index"):
|
||||
button_index = ch.get_meta("button_index")
|
||||
|
||||
if button_index != -1:
|
||||
move_child(ch, button_index)
|
||||
|
||||
return button
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user