-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added inventoy ui tentative. item pick up
- Loading branch information
1 parent
91cd532
commit c37a0f2
Showing
12 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
extends CanvasLayer | ||
|
||
|
||
onready var num_items = $"%MenuItems" | ||
onready var inventory_ui = $InventoryContainer | ||
export(NodePath) var player_path | ||
|
||
|
||
var player | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
EventBus.connect("inventory_modified",self, "on_inventory_modified") | ||
inventory_ui.visible = false | ||
player = get_node(player_path) | ||
|
||
func on_inventory_modified(inventory): | ||
print("inventory modified") | ||
num_items.text = str(inventory.get_child_count()) | ||
|
||
for inventory_item in inventory.get_children(): | ||
inventory_ui.show_item(inventory_item) | ||
|
||
|
||
func _on_TextureRect_mouse_entered(): | ||
inventory_ui.visible = true | ||
enable_player_input(false) | ||
|
||
func enable_player_input(enable): | ||
player.set_process_input(enable) | ||
player.set_physics_process(enable) | ||
player.set_process(enable) | ||
player.set_process_unhandled_input(enable) | ||
|
||
|
||
func _on_InventoryContainer_mouse_exited(): | ||
inventory_ui.visible = false | ||
enable_player_input(true) | ||
|
||
|
||
|
||
|
||
func _on_ColorRect_mouse_exited(): | ||
inventory_ui.visible = false | ||
enable_player_input(true) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
[gd_scene load_steps=6 format=2] | ||
|
||
[ext_resource path="res://lib/ui/HUD.gd" type="Script" id=1] | ||
[ext_resource path="res://assets/0x72_DungeonTilesetII_v1.4/0x72_DungeonTilesetII_v1.4/frames/chest_empty_open_anim_f2.png" type="Texture" id=2] | ||
[ext_resource path="res://assets/Frame_mid_2.png" type="Texture" id=3] | ||
[ext_resource path="res://lib/ui/InventoryContainer.gd" type="Script" id=4] | ||
[ext_resource path="res://lib/ui/InventoryItemIcon.tscn" type="PackedScene" id=5] | ||
|
||
[node name="HUD" type="CanvasLayer"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="."] | ||
anchor_right = 1.0 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] | ||
margin_right = 426.0 | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer"] | ||
|
||
[node name="NinePatchRect" type="NinePatchRect" parent="MarginContainer/HBoxContainer/MarginContainer"] | ||
|
||
[node name="MenuItems" type="Label" parent="MarginContainer/HBoxContainer/MarginContainer/NinePatchRect"] | ||
unique_name_in_owner = true | ||
margin_right = 40.0 | ||
margin_bottom = 14.0 | ||
text = "0" | ||
|
||
[node name="InventoryIconContainer" type="MarginContainer" parent="."] | ||
anchor_top = 0.909 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryIconContainer"] | ||
margin_right = 426.0 | ||
margin_bottom = 21.0 | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="InventoryIconContainer/HBoxContainer"] | ||
margin_right = 20.0 | ||
margin_bottom = 21.0 | ||
|
||
[node name="NinePatchRect" type="NinePatchRect" parent="InventoryIconContainer/HBoxContainer/MarginContainer"] | ||
margin_right = 20.0 | ||
margin_bottom = 21.0 | ||
texture = ExtResource( 3 ) | ||
patch_margin_left = 10 | ||
patch_margin_top = 10 | ||
patch_margin_right = 10 | ||
patch_margin_bottom = 10 | ||
|
||
[node name="TextureRect" type="TextureRect" parent="InventoryIconContainer/HBoxContainer/MarginContainer"] | ||
margin_right = 20.0 | ||
margin_bottom = 21.0 | ||
texture = ExtResource( 2 ) | ||
|
||
[node name="InventoryContainer" type="MarginContainer" parent="."] | ||
unique_name_in_owner = true | ||
anchor_top = 1.0 | ||
anchor_bottom = 1.0 | ||
margin_left = 10.0 | ||
margin_top = -197.0 | ||
margin_right = 165.0 | ||
margin_bottom = -25.0 | ||
script = ExtResource( 4 ) | ||
|
||
[node name="ColorRect" type="ColorRect" parent="InventoryContainer"] | ||
margin_right = 155.0 | ||
margin_bottom = 172.0 | ||
color = Color( 0.505882, 0.505882, 0.505882, 0.403922 ) | ||
|
||
[node name="GridContainer" type="GridContainer" parent="InventoryContainer/ColorRect"] | ||
margin_right = 40.0 | ||
margin_bottom = 40.0 | ||
|
||
[node name="InventoryItemIcon" parent="InventoryContainer/ColorRect/GridContainer" instance=ExtResource( 5 )] | ||
|
||
[connection signal="mouse_entered" from="InventoryIconContainer/HBoxContainer/MarginContainer/TextureRect" to="." method="_on_TextureRect_mouse_entered"] | ||
[connection signal="mouse_exited" from="InventoryContainer" to="." method="_on_InventoryContainer_mouse_exited"] | ||
[connection signal="mouse_exited" from="InventoryContainer/ColorRect" to="." method="_on_ColorRect_mouse_exited"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extends MarginContainer | ||
|
||
var InventoryItemIcon = preload("res://lib/ui/InventoryItemIcon.tscn") | ||
|
||
onready var icons_container = $ColorRect/GridContainer | ||
|
||
func show_item(item): | ||
var item_ui = InventoryItemIcon.instance() | ||
item_ui.item = item | ||
item_ui.texture = item.icon_texture | ||
icons_container.add_child(item_ui) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends TextureRect | ||
class_name InventoryItemIcon | ||
|
||
var item = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://assets/0x72_DungeonTilesetII_v1.4/0x72_DungeonTilesetII_v1.4/frames/chest_empty_open_anim_f2.png" type="Texture" id=1] | ||
[ext_resource path="res://lib/ui/InventoryItemIcon.gd" type="Script" id=2] | ||
|
||
[node name="InventoryItemIcon" type="TextureRect"] | ||
margin_right = 16.0 | ||
margin_bottom = 16.0 | ||
texture = ExtResource( 1 ) | ||
script = ExtResource( 2 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters