fix(inventory): show/hide inventory on hide/show menu
This commit is contained in:
@@ -369,22 +369,26 @@ func close_inventory():
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide_inventory()
|
||||
|
||||
func hide_ui():
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide_ui()
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide()
|
||||
$CanvasLayer/ui.hide()
|
||||
|
||||
func show_ui():
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.show()
|
||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.show_ui()
|
||||
$CanvasLayer/ui.show()
|
||||
|
||||
|
||||
func hide_main_menu():
|
||||
if get_node(main_menu).visible:
|
||||
get_node(main_menu).hide()
|
||||
show_ui()
|
||||
|
||||
func show_main_menu():
|
||||
if not get_node(main_menu).visible:
|
||||
get_node(main_menu).reset()
|
||||
get_node(main_menu).show()
|
||||
hide_ui()
|
||||
|
||||
func unpause_game():
|
||||
if get_node(pause_menu).visible:
|
||||
|
||||
@@ -89,11 +89,6 @@ margin_right = 1186.0
|
||||
margin_bottom = 90.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="inventory_bg" type="Polygon2D" parent="CanvasLayer/ui/HBoxContainer"]
|
||||
position = Vector2( 0, -964 )
|
||||
color = Color( 0.156863, 0.0627451, 0, 1 )
|
||||
polygon = PoolVector2Array( 0, 874, 1280, 874, 1280, 1047, 0, 1047 )
|
||||
|
||||
[node name="inventory_ui" parent="CanvasLayer/ui/HBoxContainer" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
|
||||
@@ -7,46 +7,25 @@ var inventory_visible: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
$FloatingInventory/panel.rect_position.x = ProjectSettings.get_setting("display/window/size/width") - $FloatingInventory/panel.rect_size.x
|
||||
# Hide inventory by default
|
||||
# $FloatingInventory/panel.rect_position.x = \
|
||||
# ProjectSettings.get_setting("display/window/size/width")
|
||||
|
||||
func _on_inventory_button_pressed():
|
||||
if $FloatingInventory/InventoryTween.is_active():
|
||||
return
|
||||
if inventory_visible:
|
||||
hide_inventory()
|
||||
else:
|
||||
show_inventory()
|
||||
|
||||
|
||||
func show_inventory():
|
||||
$FloatingInventory/InventoryTween.stop_all()
|
||||
$FloatingInventory/InventoryTween.remove_all()
|
||||
$FloatingInventory/InventoryTween.interpolate_property(
|
||||
$FloatingInventory/panel,
|
||||
"visible",
|
||||
0,
|
||||
1,
|
||||
0.6
|
||||
)
|
||||
$FloatingInventory/InventoryTween.start()
|
||||
yield($FloatingInventory/InventoryTween,"tween_all_completed")
|
||||
$FloatingInventory/InventoryTween.stop_all()
|
||||
$FloatingInventory/panel.show()
|
||||
inventory_visible = true
|
||||
|
||||
|
||||
func hide_inventory():
|
||||
$FloatingInventory/InventoryTween.stop_all()
|
||||
$FloatingInventory/InventoryTween.remove_all()
|
||||
$FloatingInventory/InventoryTween.interpolate_property(
|
||||
$FloatingInventory/panel,
|
||||
"visible",
|
||||
1,
|
||||
0,
|
||||
0.01
|
||||
)
|
||||
$FloatingInventory/InventoryTween.start()
|
||||
yield($FloatingInventory/InventoryTween,"tween_all_completed")
|
||||
$FloatingInventory/InventoryTween.stop_all()
|
||||
$FloatingInventory/panel.hide()
|
||||
inventory_visible = false
|
||||
|
||||
|
||||
func show_ui():
|
||||
$FloatingInventory/inventory_bg.show()
|
||||
$FloatingInventory/panel/MarginContainer/ScrollContainer/container.show()
|
||||
inventory_visible = true
|
||||
|
||||
|
||||
func hide_ui():
|
||||
$FloatingInventory/inventory_bg.hide()
|
||||
$FloatingInventory/panel/MarginContainer/ScrollContainer/container.hide()
|
||||
inventory_visible = false
|
||||
|
||||
@@ -20,6 +20,10 @@ inventory_ui_container = NodePath("FloatingInventory/panel/MarginContainer/Scrol
|
||||
|
||||
[node name="FloatingInventory" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="inventory_bg" type="Polygon2D" parent="FloatingInventory"]
|
||||
color = Color( 0.156863, 0.0627451, 0, 1 )
|
||||
polygon = PoolVector2Array( -3, 578, 1280, 578, 1280, 752, -3, 757 )
|
||||
|
||||
[node name="panel" type="TextureRect" parent="FloatingInventory"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
|
||||
Reference in New Issue
Block a user