refonte de l'inventaire en 3D et nettoyage des prints
This commit is contained in:
@@ -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