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()
|
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide_inventory()
|
||||||
|
|
||||||
func hide_ui():
|
func hide_ui():
|
||||||
|
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide_ui()
|
||||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide()
|
$CanvasLayer/ui/HBoxContainer/inventory_ui.hide()
|
||||||
$CanvasLayer/ui.hide()
|
$CanvasLayer/ui.hide()
|
||||||
|
|
||||||
func show_ui():
|
func show_ui():
|
||||||
$CanvasLayer/ui/HBoxContainer/inventory_ui.show()
|
$CanvasLayer/ui/HBoxContainer/inventory_ui.show()
|
||||||
|
$CanvasLayer/ui/HBoxContainer/inventory_ui.show_ui()
|
||||||
$CanvasLayer/ui.show()
|
$CanvasLayer/ui.show()
|
||||||
|
|
||||||
|
|
||||||
func hide_main_menu():
|
func hide_main_menu():
|
||||||
if get_node(main_menu).visible:
|
if get_node(main_menu).visible:
|
||||||
get_node(main_menu).hide()
|
get_node(main_menu).hide()
|
||||||
|
show_ui()
|
||||||
|
|
||||||
func show_main_menu():
|
func show_main_menu():
|
||||||
if not get_node(main_menu).visible:
|
if not get_node(main_menu).visible:
|
||||||
get_node(main_menu).reset()
|
get_node(main_menu).reset()
|
||||||
get_node(main_menu).show()
|
get_node(main_menu).show()
|
||||||
|
hide_ui()
|
||||||
|
|
||||||
func unpause_game():
|
func unpause_game():
|
||||||
if get_node(pause_menu).visible:
|
if get_node(pause_menu).visible:
|
||||||
|
|||||||
@@ -89,11 +89,6 @@ margin_right = 1186.0
|
|||||||
margin_bottom = 90.0
|
margin_bottom = 90.0
|
||||||
size_flags_horizontal = 3
|
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 )]
|
[node name="inventory_ui" parent="CanvasLayer/ui/HBoxContainer" instance=ExtResource( 1 )]
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
|
|||||||
@@ -7,46 +7,25 @@ var inventory_visible: bool = false
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$FloatingInventory/panel.rect_position.x = ProjectSettings.get_setting("display/window/size/width") - $FloatingInventory/panel.rect_size.x
|
$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():
|
func show_inventory():
|
||||||
$FloatingInventory/InventoryTween.stop_all()
|
$FloatingInventory/panel.show()
|
||||||
$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()
|
|
||||||
inventory_visible = true
|
inventory_visible = true
|
||||||
|
|
||||||
|
|
||||||
func hide_inventory():
|
func hide_inventory():
|
||||||
$FloatingInventory/InventoryTween.stop_all()
|
$FloatingInventory/panel.hide()
|
||||||
$FloatingInventory/InventoryTween.remove_all()
|
inventory_visible = false
|
||||||
$FloatingInventory/InventoryTween.interpolate_property(
|
|
||||||
$FloatingInventory/panel,
|
|
||||||
"visible",
|
func show_ui():
|
||||||
1,
|
$FloatingInventory/inventory_bg.show()
|
||||||
0,
|
$FloatingInventory/panel/MarginContainer/ScrollContainer/container.show()
|
||||||
0.01
|
inventory_visible = true
|
||||||
)
|
|
||||||
$FloatingInventory/InventoryTween.start()
|
|
||||||
yield($FloatingInventory/InventoryTween,"tween_all_completed")
|
func hide_ui():
|
||||||
$FloatingInventory/InventoryTween.stop_all()
|
$FloatingInventory/inventory_bg.hide()
|
||||||
|
$FloatingInventory/panel/MarginContainer/ScrollContainer/container.hide()
|
||||||
inventory_visible = false
|
inventory_visible = false
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ inventory_ui_container = NodePath("FloatingInventory/panel/MarginContainer/Scrol
|
|||||||
|
|
||||||
[node name="FloatingInventory" type="CanvasLayer" parent="."]
|
[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"]
|
[node name="panel" type="TextureRect" parent="FloatingInventory"]
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user