mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-10 08:42:11 +01:00
Item count support for the ui.
This commit is contained in:
parent
824fd02d0f
commit
ea654acf7f
2
HEADS
2
HEADS
@ -1 +1 @@
|
||||
{"engine": "7735af7e768e16efb4b3b6de1c72c3dfb50c9412", "world_generator": "290d973ea9580f748881a54502850ae5fecfb586", "entity_spell_system": "2ba11eec7742295a40146da898ebe02ac4aa5a12", "ui_extensions": "271dcf89e9afe5cb6350de2f2433c8ebf8aba785", "voxelman": "2b369f5be8efc5fe0ef13da57afa46317c413f47", "texture_packer": "604c330188e220c15d10ea5bd545a6fc5aab0132", "fastnoise": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e", "entity-spell-system-addons": "8568888b3c11dec56dbf1088a84bc898d68bd6ce"}
|
||||
{"engine": "f82539944b609dc8327536aa92a3da3851ac1338", "world_generator": "290d973ea9580f748881a54502850ae5fecfb586", "entity_spell_system": "992d0672f9b143fc0b3996e798dcf9aa7e064a92", "ui_extensions": "271dcf89e9afe5cb6350de2f2433c8ebf8aba785", "voxelman": "2b369f5be8efc5fe0ef13da57afa46317c413f47", "texture_packer": "604c330188e220c15d10ea5bd545a6fc5aab0132", "fastnoise": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e", "entity-spell-system-addons": "8568888b3c11dec56dbf1088a84bc898d68bd6ce"}
|
@ -6,9 +6,13 @@ extends Button
|
||||
|
||||
export (NodePath) var button_path : NodePath
|
||||
export (NodePath) var icon_path : NodePath
|
||||
|
||||
export (NodePath) var cooldown_indicator_path : NodePath
|
||||
export (NodePath) var cooldown_text_path : NodePath
|
||||
|
||||
export (NodePath) var stack_counter : NodePath
|
||||
var _stack_counter : Label
|
||||
|
||||
var _tooltip : Popup
|
||||
|
||||
var button : Button
|
||||
@ -35,7 +39,13 @@ func _ready() -> void:
|
||||
cooldown_indicator = get_node(cooldown_indicator_path) as TextureProgress
|
||||
cooldown_text = get_node(cooldown_text_path) as Label
|
||||
|
||||
_stack_counter = get_node(stack_counter) as Label
|
||||
|
||||
button.connect("pressed", self, "_on_button_pressed")
|
||||
|
||||
#func _exit_tree():
|
||||
# if item != null:
|
||||
# item.disconnect("stack_size_changed", self, "stack_size_changed")
|
||||
|
||||
func _process(delta : float) -> void:
|
||||
if cd == null and gcd < 0.001:
|
||||
@ -75,10 +85,19 @@ func hide_cooldown_timer() -> void:
|
||||
cooldown_text.hide()
|
||||
|
||||
func set_item_instance(pitem : ItemInstance) -> void:
|
||||
if item != null and item.item_template.stack_size > 1:
|
||||
item.disconnect("stack_size_changed", self, "stack_size_changed")
|
||||
_stack_counter.hide()
|
||||
|
||||
item = pitem
|
||||
|
||||
setup_icon()
|
||||
|
||||
if item != null and item.item_template.stack_size > 1:
|
||||
item.connect("stack_size_changed", self, "stack_size_changed")
|
||||
_stack_counter.show()
|
||||
stack_size_changed(item)
|
||||
|
||||
func setup_icon() -> void:
|
||||
if (item == null):
|
||||
icon_rect.texture = null
|
||||
@ -105,11 +124,22 @@ func _on_button_pressed() -> void:
|
||||
pass
|
||||
|
||||
func set_button_entry_data(ii : ItemInstance) -> void:
|
||||
if item != null and item.item_template.stack_size > 1:
|
||||
item.disconnect("stack_size_changed", self, "stack_size_changed")
|
||||
_stack_counter.hide()
|
||||
|
||||
item = ii
|
||||
|
||||
|
||||
setup_icon()
|
||||
|
||||
if item != null and item.item_template.stack_size > 1:
|
||||
item.connect("stack_size_changed", self, "stack_size_changed")
|
||||
_stack_counter.show()
|
||||
stack_size_changed(item)
|
||||
|
||||
func stack_size_changed(ii : ItemInstance) -> void:
|
||||
_stack_counter.text = str(ii.stack_size)
|
||||
|
||||
func get_drag_data(pos: Vector2) -> Object:
|
||||
if item == null:
|
||||
return null
|
||||
|
@ -27,6 +27,7 @@ button_path = NodePath(".")
|
||||
icon_path = NodePath("MarginContainer/TextureRect")
|
||||
cooldown_indicator_path = NodePath("CooldownIndicator")
|
||||
cooldown_text_path = NodePath("CooldownText")
|
||||
stack_counter = NodePath("MarginContainer2/StackCounter")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
@ -78,3 +79,26 @@ clip_text = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
custom_constants/margin_right = 4
|
||||
custom_constants/margin_top = 4
|
||||
custom_constants/margin_left = 4
|
||||
custom_constants/margin_bottom = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="StackCounter" type="Label" parent="MarginContainer2"]
|
||||
visible = false
|
||||
margin_left = 4.0
|
||||
margin_top = 4.0
|
||||
margin_right = 41.0
|
||||
margin_bottom = 42.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
align = 2
|
||||
valign = 2
|
||||
|
@ -73,6 +73,7 @@ func cbag_changed(entity: Entity, bag: Bag) -> void:
|
||||
if _bag != null:
|
||||
_bag.disconnect("size_changed", self, "bag_size_changed")
|
||||
_bag.disconnect("item_added", self, "bag_item_added")
|
||||
_bag.disconnect("item_count_changed", self, "item_count_changed")
|
||||
_bag.disconnect("item_removed", self, "item_removed")
|
||||
_bag.disconnect("item_swapped", self, "item_swapped")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user