amélioration de l'UI de l'inventaire et ajout de la récompense d'amélioration de taille d'inventaire #52

This commit is contained in:
2025-09-19 17:31:12 +02:00
parent 00c7e9bc4c
commit bcd8038b3a
19 changed files with 329 additions and 104 deletions

View File

@@ -1,16 +1,14 @@
extends Node
signal inspected_entity_changed(e : InspectableEntity)
signal inspected_changed(info : Inspector.Info)
const DEFAULT_ACTION_COLOR = Color.WHITE
const ENERGY_ACTION_COLOR = Color("ffff2b")
@export var default_cursor : Texture2D
var inspected_entity : InspectableEntity = null :
set(e):
inspected_entity = e
inspected_entity_changed.emit(e)
var inspected : Node = null
var inspected_info : Inspector.Info = null
var player : Player # renseigné par Player
var can_interact : bool = false
var current_selected_item : Item = null
@@ -32,7 +30,7 @@ func _input(_event):
if Input.is_action_just_pressed("action"):
if can_interact:
var interactable = inspected_entity as Interactable
var interactable = inspected as Interactable
player.try_interact(interactable)
elif can_use_item:
player.try_use_item(
@@ -45,9 +43,9 @@ func _process(_delta):
if player:
can_interact = (
inspected_entity
and inspected_entity is Interactable
and player.can_interact(inspected_entity)
inspected
and inspected is Interactable
and player.can_interact(inspected)
)
current_selected_item = player.inventory.get_item()
@@ -67,24 +65,27 @@ func _process(_delta):
update_inspector()
func inspect_entity(entity : InspectableEntity):
if inspected_entity and inspected_entity != entity:
inspected_entity.inspected = false
inspected_entity = entity
inspected_entity.inspected = true
func inspect(node : Node, info : Inspector.Info):
if inspected and inspected != node and inspected.has_method("inspect"):
inspected.inspect(false)
inspected_info = info
inspected = node
inspected_changed.emit(inspected_info)
if inspected.has_method("inspect"):
inspected.inspect(true)
update_inspector()
func update_inspector():
%InspectorText.visible = inspected_entity != null
if inspected_entity:
%InspectorText.text = inspected_entity.pointer_text()
%InspectorText.visible = inspected != null
if inspected and inspected is InspectableEntity:
%InspectorText.text = inspected.pointer_text()
if player:
if can_interact and inspected_entity and inspected_entity is Interactable:
if can_interact and inspected and inspected is Interactable:
%Action.visible = true
%ActionText.text = inspected_entity.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if inspected_entity.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = inspected_entity.interaction_cost(player) != 0
%ActionText.text = inspected.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if inspected.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = inspected.interaction_cost(player) != 0
elif can_use_item and current_selected_item:
%Action.visible = true
%ActionText.text = current_selected_item.use_text()
@@ -96,8 +97,11 @@ func update_inspector():
else:
%Action.visible = false
func stop_inspect_entity(entity : InspectableEntity):
entity.inspected = false
if inspected_entity == entity:
inspected_entity = null
func stop_inspect(node : Node):
if node.has_method("inspect"):
node.inspect(false)
if inspected == node:
inspected = null
inspected_info = null
inspected_changed.emit(inspected_info)
update_inspector()