more work on inventory
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								UI/Inventory/InventoryImages/glue.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								UI/Inventory/InventoryImages/glue.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 517 B  | 
							
								
								
									
										34
									
								
								UI/Inventory/InventoryImages/glue.png.import
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								UI/Inventory/InventoryImages/glue.png.import
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="texture"
 | 
			
		||||
type="CompressedTexture2D"
 | 
			
		||||
uid="uid://bh75ysml2x47r"
 | 
			
		||||
path="res://.godot/imported/glue.png-0d3ace9f3bb8dc6e35f66151fbdec38a.ctex"
 | 
			
		||||
metadata={
 | 
			
		||||
"vram_texture": false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://UI/Inventory/InventoryImages/glue.png"
 | 
			
		||||
dest_files=["res://.godot/imported/glue.png-0d3ace9f3bb8dc6e35f66151fbdec38a.ctex"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
compress/mode=0
 | 
			
		||||
compress/high_quality=false
 | 
			
		||||
compress/lossy_quality=0.7
 | 
			
		||||
compress/hdr_compression=1
 | 
			
		||||
compress/normal_map=0
 | 
			
		||||
compress/channel_pack=0
 | 
			
		||||
mipmaps/generate=false
 | 
			
		||||
mipmaps/limit=-1
 | 
			
		||||
roughness/mode=0
 | 
			
		||||
roughness/src_normal=""
 | 
			
		||||
process/fix_alpha_border=true
 | 
			
		||||
process/premult_alpha=false
 | 
			
		||||
process/normal_map_invert_y=false
 | 
			
		||||
process/hdr_as_srgb=false
 | 
			
		||||
process/hdr_clamp_exposure=false
 | 
			
		||||
process/size_limit=0
 | 
			
		||||
detect_3d/compress_to=1
 | 
			
		||||
							
								
								
									
										48
									
								
								UI/Inventory/InventorySlot.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								UI/Inventory/InventorySlot.gd
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
extends Control
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@onready var slot_label := $SlotLabel
 | 
			
		||||
@onready var ammo_label := $AmmoLabel
 | 
			
		||||
@onready var image_slot := $ItemImage
 | 
			
		||||
@onready var reload_bar := $ReloadBar
 | 
			
		||||
@onready var item_selecter := $ItemSelector
 | 
			
		||||
 | 
			
		||||
func slot_selected():
 | 
			
		||||
	item_selecter.set_visible(true)
 | 
			
		||||
	
 | 
			
		||||
func slot_deselected():
 | 
			
		||||
	item_selecter.set_visible(false)
 | 
			
		||||
	
 | 
			
		||||
func reload_item(cooldown: float):
 | 
			
		||||
	reload_bar.set_visible(true)
 | 
			
		||||
	reload_bar.set_max(cooldown)
 | 
			
		||||
	reload_bar.set_step(0.1)
 | 
			
		||||
	var tween = get_tree().create_tween()
 | 
			
		||||
	tween.tween_method(reload_bar.set_value, 0.0, cooldown, cooldown)
 | 
			
		||||
	await tween.finished
 | 
			
		||||
	reload_bar.set_visible(false)
 | 
			
		||||
	
 | 
			
		||||
func clear_slot():
 | 
			
		||||
	image_slot.set_texture(null)
 | 
			
		||||
 | 
			
		||||
func setup_slot(item_details: Dictionary):
 | 
			
		||||
	clear_slot()
 | 
			
		||||
	var picNode = TextureRect.new()
 | 
			
		||||
	image_slot.add_child(picNode)
 | 
			
		||||
	picNode.set_mouse_filter(2)
 | 
			
		||||
	picNode.set_name("inv_texture")
 | 
			
		||||
	picNode.set_texture(item_details.item_texture)
 | 
			
		||||
	picNode.set_stretch_mode(TextureRect.STRETCH_KEEP)
 | 
			
		||||
	picNode.size = Vector2(16, 16)
 | 
			
		||||
	picNode.position = Vector2(-8, -8)
 | 
			
		||||
	picNode.set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
 | 
			
		||||
	if item_details.item_type == 0: # is weapon
 | 
			
		||||
		set_ammo_label(str(item_details.item_ammo))
 | 
			
		||||
		
 | 
			
		||||
func set_slot_label(slot_index: String):
 | 
			
		||||
	slot_label.set_text(slot_index)
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
func set_ammo_label(ammo_value: String):
 | 
			
		||||
	ammo_label.set_visible(true)
 | 
			
		||||
	ammo_label.set_text(ammo_value)
 | 
			
		||||
							
								
								
									
										96
									
								
								UI/Inventory/InventorySlot.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								UI/Inventory/InventorySlot.tscn
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
[gd_scene load_steps=7 format=3 uid="uid://defhc376y3h1d"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://UI/Inventory/InventorySlot.gd" id="1_pltri"]
 | 
			
		||||
[ext_resource type="FontFile" uid="uid://dj4pldmxeqmtt" path="res://UI/PressStart2P-Regular.ttf" id="1_wew62"]
 | 
			
		||||
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="2_mxhl7"]
 | 
			
		||||
[ext_resource type="Texture2D" uid="uid://4txm3cwkoncp" path="res://UI/Inventory/circle_progress.png" id="3_5flhr"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="Animation" id="Animation_wthnv"]
 | 
			
		||||
resource_name = "blink"
 | 
			
		||||
loop_mode = 1
 | 
			
		||||
tracks/0/type = "value"
 | 
			
		||||
tracks/0/imported = false
 | 
			
		||||
tracks/0/enabled = true
 | 
			
		||||
tracks/0/path = NodePath(".:self_modulate")
 | 
			
		||||
tracks/0/interp = 1
 | 
			
		||||
tracks/0/loop_wrap = true
 | 
			
		||||
tracks/0/keys = {
 | 
			
		||||
"times": PackedFloat32Array(0, 0.5, 1),
 | 
			
		||||
"transitions": PackedFloat32Array(1, 1, 1),
 | 
			
		||||
"update": 0,
 | 
			
		||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_b5fyj"]
 | 
			
		||||
_data = {
 | 
			
		||||
"blink": SubResource("Animation_wthnv")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot" type="Control"]
 | 
			
		||||
layout_mode = 3
 | 
			
		||||
anchors_preset = 8
 | 
			
		||||
anchor_left = 0.5
 | 
			
		||||
anchor_top = 0.5
 | 
			
		||||
anchor_right = 0.5
 | 
			
		||||
anchor_bottom = 0.5
 | 
			
		||||
grow_horizontal = 2
 | 
			
		||||
grow_vertical = 2
 | 
			
		||||
script = ExtResource("1_pltri")
 | 
			
		||||
 | 
			
		||||
[node name="AmmoLabel" type="Label" parent="."]
 | 
			
		||||
visible = false
 | 
			
		||||
layout_mode = 0
 | 
			
		||||
offset_left = 12.0
 | 
			
		||||
offset_top = -26.0
 | 
			
		||||
offset_right = 28.0
 | 
			
		||||
offset_bottom = -7.0
 | 
			
		||||
theme_override_fonts/font = ExtResource("1_wew62")
 | 
			
		||||
theme_override_font_sizes/font_size = 0
 | 
			
		||||
text = "1"
 | 
			
		||||
 | 
			
		||||
[node name="ToolbarSlot" type="Sprite2D" parent="."]
 | 
			
		||||
scale = Vector2(4, 4)
 | 
			
		||||
texture = ExtResource("2_mxhl7")
 | 
			
		||||
region_enabled = true
 | 
			
		||||
region_rect = Rect2(80, 144, 16, 16)
 | 
			
		||||
 | 
			
		||||
[node name="ItemSelector" type="Sprite2D" parent="."]
 | 
			
		||||
visible = false
 | 
			
		||||
modulate = Color(0.054902, 0.290196, 0.258824, 1)
 | 
			
		||||
self_modulate = Color(1, 1, 1, 0.822247)
 | 
			
		||||
scale = Vector2(4, 4)
 | 
			
		||||
texture = ExtResource("2_mxhl7")
 | 
			
		||||
region_enabled = true
 | 
			
		||||
region_rect = Rect2(64, 144, 16, 16)
 | 
			
		||||
 | 
			
		||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="ItemSelector"]
 | 
			
		||||
autoplay = "blink"
 | 
			
		||||
libraries = {
 | 
			
		||||
"": SubResource("AnimationLibrary_b5fyj")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[node name="SlotLabel" type="Label" parent="."]
 | 
			
		||||
visible = false
 | 
			
		||||
layout_mode = 0
 | 
			
		||||
offset_left = -51.0
 | 
			
		||||
offset_top = -58.0
 | 
			
		||||
offset_right = 61.0
 | 
			
		||||
offset_bottom = -35.0
 | 
			
		||||
theme_override_fonts/font = ExtResource("1_wew62")
 | 
			
		||||
theme_override_font_sizes/font_size = 0
 | 
			
		||||
text = "ItemName"
 | 
			
		||||
vertical_alignment = 2
 | 
			
		||||
 | 
			
		||||
[node name="ReloadBar" type="TextureProgressBar" parent="."]
 | 
			
		||||
layout_mode = 0
 | 
			
		||||
offset_left = -32.0
 | 
			
		||||
offset_top = -32.0
 | 
			
		||||
offset_right = 32.0
 | 
			
		||||
offset_bottom = 32.0
 | 
			
		||||
fill_mode = 4
 | 
			
		||||
texture_under = ExtResource("3_5flhr")
 | 
			
		||||
texture_progress = ExtResource("3_5flhr")
 | 
			
		||||
tint_under = Color(1, 1, 1, 0)
 | 
			
		||||
tint_progress = Color(0.254902, 0.654902, 0.407843, 0.588235)
 | 
			
		||||
 | 
			
		||||
[node name="ItemImage" type="Sprite2D" parent="."]
 | 
			
		||||
							
								
								
									
										19
									
								
								UI/Inventory/UserInventory.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								UI/Inventory/UserInventory.gd
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
extends Control
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@export var items:Array = []
 | 
			
		||||
@export var current_slot:int = 0
 | 
			
		||||
@export var active_item:Dictionary = {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func _process(_delta):
 | 
			
		||||
	if current_slot == 0:
 | 
			
		||||
		return
 | 
			
		||||
	if Input.is_action_just_pressed("drop_item"):
 | 
			
		||||
		if items[current_slot]:
 | 
			
		||||
			print("ITEM IN SLOT: ", items[current_slot])
 | 
			
		||||
			
 | 
			
		||||
				
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										68
									
								
								UI/Inventory/UserInventory.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								UI/Inventory/UserInventory.tscn
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
[gd_scene load_steps=3 format=3 uid="uid://drr0ptd6k6uch"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://UI/Inventory/UserInventory.gd" id="1_4kopu"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://defhc376y3h1d" path="res://UI/Inventory/InventorySlot.tscn" id="1_a71mm"]
 | 
			
		||||
 | 
			
		||||
[node name="UserInventory" type="Control"]
 | 
			
		||||
layout_mode = 3
 | 
			
		||||
anchors_preset = 15
 | 
			
		||||
anchor_right = 1.0
 | 
			
		||||
anchor_bottom = 1.0
 | 
			
		||||
grow_horizontal = 2
 | 
			
		||||
grow_vertical = 2
 | 
			
		||||
mouse_filter = 2
 | 
			
		||||
script = ExtResource("1_4kopu")
 | 
			
		||||
 | 
			
		||||
[node name="Panel" type="Panel" parent="."]
 | 
			
		||||
custom_minimum_size = Vector2(430, 75)
 | 
			
		||||
layout_mode = 1
 | 
			
		||||
anchors_preset = 7
 | 
			
		||||
anchor_left = 0.5
 | 
			
		||||
anchor_top = 1.0
 | 
			
		||||
anchor_right = 0.5
 | 
			
		||||
anchor_bottom = 1.0
 | 
			
		||||
offset_left = -20.0
 | 
			
		||||
offset_top = -40.0
 | 
			
		||||
offset_right = 20.0
 | 
			
		||||
grow_horizontal = 2
 | 
			
		||||
grow_vertical = 0
 | 
			
		||||
 | 
			
		||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel"]
 | 
			
		||||
layout_mode = 1
 | 
			
		||||
anchors_preset = 8
 | 
			
		||||
anchor_left = 0.5
 | 
			
		||||
anchor_top = 0.5
 | 
			
		||||
anchor_right = 0.5
 | 
			
		||||
anchor_bottom = 0.5
 | 
			
		||||
offset_left = -20.0
 | 
			
		||||
offset_top = -20.0
 | 
			
		||||
offset_right = 20.0
 | 
			
		||||
offset_bottom = 20.0
 | 
			
		||||
grow_horizontal = 2
 | 
			
		||||
grow_vertical = 2
 | 
			
		||||
theme_override_constants/separation = 70
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot1" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_horizontal = 4
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot2" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot3" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot4" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot5" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
 | 
			
		||||
[node name="InventorySlot6" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
 | 
			
		||||
layout_mode = 2
 | 
			
		||||
size_flags_vertical = 4
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								UI/Inventory/circle_progress.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								UI/Inventory/circle_progress.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 285 B  | 
							
								
								
									
										34
									
								
								UI/Inventory/circle_progress.png.import
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								UI/Inventory/circle_progress.png.import
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
[remap]
 | 
			
		||||
 | 
			
		||||
importer="texture"
 | 
			
		||||
type="CompressedTexture2D"
 | 
			
		||||
uid="uid://4txm3cwkoncp"
 | 
			
		||||
path="res://.godot/imported/circle_progress.png-d5c531fd8f1ad6ba679f56898ed82f77.ctex"
 | 
			
		||||
metadata={
 | 
			
		||||
"vram_texture": false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[deps]
 | 
			
		||||
 | 
			
		||||
source_file="res://UI/Inventory/circle_progress.png"
 | 
			
		||||
dest_files=["res://.godot/imported/circle_progress.png-d5c531fd8f1ad6ba679f56898ed82f77.ctex"]
 | 
			
		||||
 | 
			
		||||
[params]
 | 
			
		||||
 | 
			
		||||
compress/mode=0
 | 
			
		||||
compress/high_quality=false
 | 
			
		||||
compress/lossy_quality=0.7
 | 
			
		||||
compress/hdr_compression=1
 | 
			
		||||
compress/normal_map=0
 | 
			
		||||
compress/channel_pack=0
 | 
			
		||||
mipmaps/generate=false
 | 
			
		||||
mipmaps/limit=-1
 | 
			
		||||
roughness/mode=0
 | 
			
		||||
roughness/src_normal=""
 | 
			
		||||
process/fix_alpha_border=true
 | 
			
		||||
process/premult_alpha=false
 | 
			
		||||
process/normal_map_invert_y=false
 | 
			
		||||
process/hdr_as_srgb=false
 | 
			
		||||
process/hdr_clamp_exposure=false
 | 
			
		||||
process/size_limit=0
 | 
			
		||||
detect_3d/compress_to=1
 | 
			
		||||
		Reference in New Issue
	
	Block a user