refonte de l'inventaire en 3D et nettoyage des prints
This commit is contained in:
@@ -1,184 +0,0 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://dadihouw8o3jx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c8qfny4dlg7ql" path="res://gui/game/inventory_gui/inventory_item/scripts/inventory_gui_item.gd" id="2_m0ja8"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/icons/shovel.svg" id="2_xs0u7"]
|
||||
[ext_resource type="Texture2D" uid="uid://baaujfw8piywi" path="res://common/icons/dna.svg" id="3_m0ja8"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_046xr"]
|
||||
length = 0.001
|
||||
|
||||
[sub_resource type="Animation" id="Animation_x2pqk"]
|
||||
resource_name = "squish"
|
||||
length = 0.2
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_k17ff"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_046xr"),
|
||||
&"squish": SubResource("Animation_x2pqk")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k17ff"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BottomSpace:custom_minimum_size")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CenterContainer/ItemTexture:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.033333335),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.27058825, 0.27058825, 0.27058825, 1), Color(0.27058825, 0.27058825, 0.27058825, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("CenterContainer/NoItemTextureRect:modulate")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0.27058825, 0.27058825, 0.27058825, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_m0ja8"]
|
||||
resource_name = "selected"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BottomSpace:custom_minimum_size")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 15)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CenterContainer/ItemTexture:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.27022192, 0.27022192, 0.2702219, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("CenterContainer/NoItemTextureRect:modulate")
|
||||
tracks/2/interp = 2
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.27022192, 0.27022192, 0.2702219, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_2wu2x"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_k17ff"),
|
||||
&"selected": SubResource("Animation_m0ja8")
|
||||
}
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_fu672"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0, 0.44886363)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_vgckh"]
|
||||
gradient = SubResource("Gradient_fu672")
|
||||
fill = 1
|
||||
fill_from = Vector2(0.48290598, 0.48290598)
|
||||
|
||||
[node name="InventoryItem" type="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
offset_right = 48.0
|
||||
offset_bottom = 52.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
script = ExtResource("2_m0ja8")
|
||||
|
||||
[node name="SquishAnimation" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_k17ff")
|
||||
}
|
||||
|
||||
[node name="SelectedAnimation" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_2wu2x")
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="NoItemTextureRect" type="TextureRect" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
modulate = Color(0.27058825, 0.27058825, 0.27058825, 1)
|
||||
custom_minimum_size = Vector2(12, 12)
|
||||
layout_mode = 2
|
||||
texture = SubResource("GradientTexture2D_vgckh")
|
||||
expand_mode = 2
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ItemTexture" type="TextureRect" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.27058825, 0.27058825, 0.27058825, 1)
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_xs0u7")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ParticleTexture" type="TextureRect" parent="CenterContainer/ItemTexture"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 26.0
|
||||
offset_top = 27.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = 49.0
|
||||
texture = ExtResource("3_m0ja8")
|
||||
expand_mode = 1
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="ParticleTexture2" type="TextureRect" parent="CenterContainer/ItemTexture"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -22.0
|
||||
offset_right = 22.0
|
||||
grow_vertical = 0
|
||||
texture = ExtResource("3_m0ja8")
|
||||
expand_mode = 1
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="BottomSpace" type="Control" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
80
gui/game/inventory_gui/inventory_item/inventory_item_3d.tscn
Normal file
80
gui/game/inventory_gui/inventory_item/inventory_item_3d.tscn
Normal file
@@ -0,0 +1,80 @@
|
||||
[gd_scene format=3 uid="uid://4r2ab6foer05"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://mrw23oxsai10" path="res://gui/game/inventory_gui/inventory_item/scripts/inventory_item_3d.gd" id="1_nsad1"]
|
||||
[ext_resource type="PackedScene" uid="uid://oktd71knql00" path="res://gui/game/inventory_gui/assets/3d/item_screen.blend" id="2_1uxm0"]
|
||||
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="2_hv1tg"]
|
||||
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://entities/player/inventory/scripts/item.gd" id="3_ixa47"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_g1uf8"]
|
||||
script = ExtResource("3_ixa47")
|
||||
icon = ExtResource("2_hv1tg")
|
||||
metadata/_custom_type_script = "uid://bq7admu4ahs5r"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_ixa47"]
|
||||
offsets = PackedFloat32Array(0, 0.84549356)
|
||||
colors = PackedColorArray(0.002722778, 0.0025074463, 0.012722934, 1, 0.0627451, 0.05882353, 0.16862746, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_g1uf8"]
|
||||
gradient = SubResource("Gradient_ixa47")
|
||||
width = 14
|
||||
height = 14
|
||||
fill_from = Vector2(0, 1)
|
||||
fill_to = Vector2(0, 0)
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_g1uf8"]
|
||||
colors = PackedColorArray(0.13725491, 0.39215687, 0.6666667, 1, 0.14509805, 0.75686276, 0.2784314, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_jdjjl"]
|
||||
gradient = SubResource("Gradient_g1uf8")
|
||||
width = 14
|
||||
height = 14
|
||||
fill_from = Vector2(0, 1)
|
||||
fill_to = Vector2(0, 0)
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_l7avg"]
|
||||
colors = PackedColorArray(1, 0, 0.43137255, 1, 1, 0.6509804, 0.09019608, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_gj8fm"]
|
||||
gradient = SubResource("Gradient_l7avg")
|
||||
width = 14
|
||||
height = 14
|
||||
fill_from = Vector2(0, 1)
|
||||
fill_to = Vector2(0, 0)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_1uxm0"]
|
||||
size = Vector3(0.21289063, 0.22167969, 0.2841797)
|
||||
|
||||
[node name="InventoryItem3d" type="Node3D" unique_id=797856392]
|
||||
script = ExtResource("1_nsad1")
|
||||
item = SubResource("Resource_g1uf8")
|
||||
|
||||
[node name="Model" parent="." unique_id=1055300734 instance=ExtResource("2_1uxm0")]
|
||||
|
||||
[node name="BlackScreen" type="Sprite3D" parent="." unique_id=1828017914]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.08962244)
|
||||
texture = SubResource("GradientTexture2D_g1uf8")
|
||||
|
||||
[node name="ItemScreen" type="Sprite3D" parent="." unique_id=1128109703]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.08962244)
|
||||
visible = false
|
||||
texture = SubResource("GradientTexture2D_jdjjl")
|
||||
|
||||
[node name="ToolScreen" type="Sprite3D" parent="." unique_id=1384339729]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.08962244)
|
||||
visible = false
|
||||
texture = SubResource("GradientTexture2D_gj8fm")
|
||||
|
||||
[node name="ItemIconSprite" type="Sprite3D" parent="." unique_id=1279203709]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0.004884802, -0.0937915)
|
||||
modulate = Color(1, 1, 1, 0.3)
|
||||
pixel_size = 0.0020833334
|
||||
texture = ExtResource("2_hv1tg")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="." unique_id=426596211]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D" unique_id=2020875183]
|
||||
shape = SubResource("BoxShape3D_1uxm0")
|
||||
@@ -1,55 +0,0 @@
|
||||
extends Control
|
||||
class_name InventoryGuiItem
|
||||
|
||||
@export var no_item_texture_path : Texture2D
|
||||
|
||||
signal item_clicked()
|
||||
|
||||
const MODULATE_INSPECTED_COLOR = Color.GRAY
|
||||
|
||||
var current_item : Item = null
|
||||
var item : Item = null
|
||||
var was_selected : bool = false
|
||||
|
||||
func _ready():
|
||||
mouse_entered.connect(
|
||||
func(): Pointer.inspect(self)
|
||||
)
|
||||
mouse_exited.connect(
|
||||
func(): Pointer.stop_inspect(self)
|
||||
)
|
||||
update(null, false)
|
||||
|
||||
func inspect(is_inspected : bool = true):
|
||||
modulate = MODULATE_INSPECTED_COLOR if is_inspected else Color.WHITE
|
||||
|
||||
func _on_gui_input(_event: InputEvent) -> void:
|
||||
if Input.is_action_just_pressed("action"):
|
||||
emit_signal("item_clicked")
|
||||
|
||||
func update(_item: Item, selected : bool):
|
||||
item = _item
|
||||
if selected and not was_selected:
|
||||
%SelectedAnimation.play("selected")
|
||||
elif not selected and was_selected:
|
||||
%SelectedAnimation.play_backwards("selected")
|
||||
|
||||
if item != current_item:
|
||||
%SquishAnimation.play("squish")
|
||||
if item and item.icon:
|
||||
%ItemTexture.texture = item.icon
|
||||
var particles = item.get_particles()
|
||||
if len(particles) > 0:
|
||||
%ParticleTexture.texture = particles[0].texture
|
||||
%ParticleTexture.modulate = particles[0].color
|
||||
if len(particles) > 1:
|
||||
%ParticleTexture2.texture = particles[1].texture
|
||||
%ParticleTexture2.modulate = particles[1].color
|
||||
%ItemTexture.visible = item != null
|
||||
%NoItemTextureRect.visible = item == null
|
||||
%ParticleTexture.visible = item and len(item.get_particles())>0
|
||||
%ParticleTexture2.visible = item and len(item.get_particles())>1
|
||||
|
||||
|
||||
current_item = item
|
||||
was_selected = selected
|
||||
@@ -1 +0,0 @@
|
||||
uid://c8qfny4dlg7ql
|
||||
@@ -0,0 +1,34 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
class_name InventoryItem3D
|
||||
|
||||
enum State { BLACK,ITEM,TOOL }
|
||||
|
||||
const OFF_TRANSPARENCY = 0.3
|
||||
const SPRITE_SIZE = 0.1
|
||||
|
||||
@export var item : Item : set = set_item
|
||||
@export var state : State = State.BLACK : set = set_state
|
||||
|
||||
@export_tool_button("Reset Texture", "Callable") var reset_texture_action = func() : set_item()
|
||||
|
||||
func _ready():
|
||||
set_item()
|
||||
set_state()
|
||||
|
||||
func set_item(i : Item = item):
|
||||
item = i
|
||||
if is_node_ready():
|
||||
if i and i.icon:
|
||||
%ItemIconSprite.texture = i.icon
|
||||
%ItemIconSprite.pixel_size = SPRITE_SIZE / i.icon.get_width()
|
||||
else:
|
||||
%ItemIconSprite.texture = null
|
||||
|
||||
func set_state(s := state):
|
||||
state = s
|
||||
if is_node_ready():
|
||||
%ItemIconSprite.modulate.a = OFF_TRANSPARENCY if state == State.BLACK else 1.0
|
||||
%BlackScreen.visible = state == State.BLACK
|
||||
%ItemScreen.visible = state == State.ITEM
|
||||
%ToolScreen.visible = state == State.TOOL
|
||||
@@ -0,0 +1 @@
|
||||
uid://mrw23oxsai10
|
||||
Reference in New Issue
Block a user