#44 changement de la méthode d'interaction et d'utilisation du joueur pour une plus grande liberté de la souris

This commit is contained in:
2025-08-21 18:02:50 +02:00
parent 3bbb1cfcdc
commit bd852b007c
24 changed files with 433 additions and 146 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://12nak7amd1uq"]
[gd_scene load_steps=22 format=3 uid="uid://12nak7amd1uq"]
[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/game/scripts/game_gui.gd" id="1_udau0"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/game/ressources/default_theme.tres" id="2_nq5i2"]
@@ -136,6 +136,34 @@ tracks/2/keys = {
"values": [Color(0.866667, 0.152941, 0.337255, 0), Color(0.866667, 0.152941, 0.337255, 0.392157), Color(0.866667, 0.152941, 0.337255, 0)]
}
[sub_resource type="Animation" id="Animation_id0t5"]
resource_name = "not_permitted"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Effect:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Effect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.266667),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Color(0.866667, 0.152941, 0.337255, 0), Color(0.866667, 0.152941, 0.337255, 0.392157), Color(0.866667, 0.152941, 0.337255, 0)]
}
[sub_resource type="Animation" id="Animation_k4juk"]
resource_name = "recharge_fade_in"
tracks/0/type = "value"
@@ -234,6 +262,7 @@ tracks/2/keys = {
_data = {
&"RESET": SubResource("Animation_iyvkh"),
&"no_energy_left": SubResource("Animation_n4kem"),
&"not_permitted": SubResource("Animation_id0t5"),
&"recharge_fade_in": SubResource("Animation_k4juk"),
&"recharge_fade_out": SubResource("Animation_fovlv"),
&"upgrade": SubResource("Animation_2wykm")
@@ -260,15 +289,6 @@ size_flags_vertical = 3
mouse_filter = 1
script = ExtResource("1_udau0")
[node name="GameAction" type="TextureButton" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
@@ -401,43 +421,6 @@ label_settings = SubResource("LabelSettings_n4kem")
autowrap_mode = 3
clip_text = true
[node name="AvailableActions" type="HBoxContainer" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
theme = ExtResource("2_nq5i2")
[node name="Plant" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "Space/Click - Plant Seed"
[node name="Interact" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "E - Interact"
[node name="GetItem" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "E - Take Item"
[node name="SwapItem" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "E - Swap Item"
[node name="DropItem" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "W - Drop Item"
[node name="UseItem" type="Label" parent="MarginContainer/AvailableActions"]
visible = false
layout_mode = 2
text = "Space/Click - Use Item"
[node name="TopRightContent" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 8
@@ -493,6 +476,5 @@ grow_vertical = 2
mouse_filter = 2
texture = SubResource("GradientTexture2D_id0t5")
[connection signal="button_down" from="GameAction" to="." method="_on_game_action_button_down"]
[connection signal="pressed" from="MarginContainer/DayPass" to="." method="_on_day_pass_pressed"]
[connection signal="pressed" from="MarginContainer/TopRightContent/Pause" to="." method="_on_pause_pressed"]

View File

@@ -76,8 +76,8 @@ horizontal_alignment = 1
[node name="ControlsText" type="Label" parent="Tutorial/VBoxContainer"]
layout_mode = 2
text = "QWERTY/AZERTY/Directional Arrows : Move
E : Interact/Pickup Items
Space/Click : Use Item
Left Click : Interact/Pickup Items
Right Click/Space : Use Item
W : Drop Item
"
horizontal_alignment = 1

View File

@@ -11,14 +11,6 @@ func _on_player_updated(player:Player):
%EnergyCount.text = str(player.energy) + "/" + str(player.max_energy)
%EnergyInfo.modulate = Color.WHITE if player.energy > 0 else Color.RED
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.get_item() == null
%AvailableActions/Interact.visible = not player.closest_interactable is ItemObject and player.can_interact
%AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.get_item() != null
%AvailableActions/DropItem.visible = player.inventory.get_item() != null
%AvailableActions/UseItem.visible = player.inventory.get_item() and player.can_use_item and not player.inventory.get_item() is Seed
%AvailableActions/Plant.visible = player.inventory.get_item() and player.can_use_item and player.inventory.get_item() is Seed
%ItemInfo.visible = player.inventory.get_item() != null
if player.inventory.get_item():
var item : Item = player.inventory.get_item()
@@ -53,3 +45,7 @@ func _on_pause_pressed():
func _on_player_upgraded():
$AnimationPlayer.play("upgrade")
func _on_player_action_not_permitted():
$AnimationPlayer.play("not_permitted")

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="icon icon-tabler icons-tabler-outline icon-tabler-mouse-2"
version="1.1"
id="svg4"
sodipodi:docname="left_click.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs4" />
<sodipodi:namedview
id="namedview4"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:zoom="37"
inkscape:cx="11.202703"
inkscape:cy="12.945946"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
stroke="none"
d="M0 0h24v24H0z"
fill="none"
id="path1" />
<path
id="path2"
style="color:#000000;fill:#ffffff;fill-opacity:1;stroke:none;-inkscape-stroke:none"
d="M 10,2 C 7.250429,2 5,4.250429 5,7 v 3 7 c 0,2.74957 2.250429,5 5,5 h 4 c 2.74957,0 5,-2.25043 5,-5 V 10 7 C 19,4.250429 16.74957,2 14,2 h -2 z m 3,2 h 1 c 1.668693,0 3,1.3313062 3,3 v 2 h -4 z m -6,7 h 5 5 v 6 c 0,1.668693 -1.331307,3 -3,3 H 10 C 8.3313062,20 7,18.668693 7,17 Z"
sodipodi:nodetypes="sscsssscsscscssccccccssssc" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://djb52fosgmv4j"
path="res://.godot/imported/left_click.svg-163ab642e0d1ce655b5b40384b3f1392.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/pointer/assets/icons/left_click.svg"
dest_files=["res://.godot/imported/left_click.svg-163ab642e0d1ce655b5b40384b3f1392.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="icon icon-tabler icons-tabler-outline icon-tabler-mouse-2"
version="1.1"
id="svg4"
sodipodi:docname="right_click.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs4" />
<sodipodi:namedview
id="namedview4"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:zoom="37"
inkscape:cx="11.202703"
inkscape:cy="12.945946"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
stroke="none"
d="M0 0h24v24H0z"
fill="none"
id="path1" />
<path
id="path2"
style="color:#000000;fill:#ffffff;stroke:none;-inkscape-stroke:none;stroke-opacity:1;fill-opacity:1"
d="M 10,2 C 7.250429,2 5,4.250429 5,7 v 3 7 c 0,2.74957 2.250429,5 5,5 h 4 c 2.74957,0 5,-2.25043 5,-5 V 10 7 C 19,4.250429 16.74957,2 14,2 h -2 z m 0,2 h 1 V 9 H 7 V 7 C 7,5.3313062 8.3313062,4 10,4 Z m -3,7 h 5 5 v 6 c 0,1.668693 -1.331307,3 -3,3 H 10 C 8.3313062,20 7,18.668693 7,17 Z"
sodipodi:nodetypes="sscsssscsscsscccsscccssssc" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://y3083o1fhgn0"
path="res://.godot/imported/right_click.svg-89ed358ede3244ca5dababdd0f091dae.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/pointer/assets/icons/right_click.svg"
dest_files=["res://.godot/imported/right_click.svg-89ed358ede3244ca5dababdd0f091dae.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bym03qp4n6vep"
path="res://.godot/imported/click.wav-fdd6eee7149fdb4e39d8aa55063ce4ff.sample"
[deps]
source_file="res://gui/pointer/assets/sounds/click.wav"
dest_files=["res://.godot/imported/click.wav-fdd6eee7149fdb4e39d8aa55063ce4ff.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

View File

@@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://0yr6b2jtuttm"]
[gd_scene load_steps=6 format=3 uid="uid://0yr6b2jtuttm"]
[ext_resource type="Script" uid="uid://vhumsfntpqcl" path="res://gui/pointer/scripts/pointer.gd" id="1_1pe2k"]
[ext_resource type="Texture2D" uid="uid://bspffyprdywgc" path="res://gui/pointer/assets/cursors/pointer.svg" id="2_q4bvb"]
[ext_resource type="AudioStream" uid="uid://bym03qp4n6vep" path="res://gui/pointer/assets/sounds/click.wav" id="3_kj0cm"]
[ext_resource type="Texture2D" uid="uid://djb52fosgmv4j" path="res://gui/pointer/assets/icons/left_click.svg" id="3_pshoq"]
[ext_resource type="Texture2D" uid="uid://y3083o1fhgn0" path="res://gui/pointer/assets/icons/right_click.svg" id="4_b4uwv"]
[node name="Pointer" type="Node"]
process_mode = 3
@@ -18,17 +20,54 @@ layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
mouse_filter = 2
[node name="Container" type="VBoxContainer" parent="CanvasLayer/Inspector"]
layout_mode = 0
offset_left = 40.0
offset_right = 137.0
offset_bottom = 79.0
size_flags_horizontal = 0
size_flags_vertical = 0
mouse_filter = 2
[node name="InspectorText" type="Label" parent="CanvasLayer/Inspector"]
[node name="InspectorText" type="Label" parent="CanvasLayer/Inspector/Container"]
unique_name_in_owner = true
z_index = 1
layout_mode = 1
offset_left = 26.0
offset_right = 66.0
offset_bottom = 23.0
layout_mode = 2
text = "Item"
[node name="Interact" type="HBoxContainer" parent="CanvasLayer/Inspector/Container"]
unique_name_in_owner = true
modulate = Color(1, 1, 0.168627, 1)
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Inspector/Container/Interact"]
layout_mode = 2
texture = ExtResource("3_pshoq")
[node name="InspectorInteractionText" type="Label" parent="CanvasLayer/Inspector/Container/Interact"]
unique_name_in_owner = true
z_index = 1
layout_mode = 2
text = "Take"
horizontal_alignment = 1
[node name="Use" type="HBoxContainer" parent="CanvasLayer/Inspector/Container"]
unique_name_in_owner = true
modulate = Color(1, 1, 0.168627, 1)
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Inspector/Container/Use"]
layout_mode = 2
texture = ExtResource("4_b4uwv")
[node name="InspectorUseText" type="Label" parent="CanvasLayer/Inspector/Container/Use"]
unique_name_in_owner = true
z_index = 1
layout_mode = 2
text = "Gloubi"
horizontal_alignment = 1
[node name="Audio" type="Node" parent="."]

View File

@@ -3,14 +3,32 @@ extends Node
@export var default_cursor : Texture2D
var inspected_entity : InspectableEntity = null
var player : Player # renseigné par Player
var player : Player :# renseigné par Player
set(v):
# if player:
# player.player_updated.disconnect(update_inspector)
player = v
player.player_updated.connect(
func(p): update_inspector()
)
func _ready():
Input.set_custom_mouse_cursor(default_cursor)
%InspectorText.visible = false
%Interact.visible = false
%Use.visible = false
func _input(_event):
if Input.is_action_just_pressed("interact"):
$Audio/Click.play()
if (
player != null
and inspected_entity
and inspected_entity is Interactable
):
var interactable = inspected_entity as Interactable
if interactable.can_interact(player):
player.target_interactable = interactable
func _process(_delta):
%Inspector.position = get_viewport().get_mouse_position()
@@ -18,14 +36,32 @@ func _process(_delta):
func inspect_entity(entity : InspectableEntity):
if inspected_entity and inspected_entity != entity:
inspected_entity.inspected = false
%InspectorText.text = entity.inspected_text()
%InspectorText.visible = true
inspected_entity = entity
inspected_entity.inspected = true
update_inspector()
func update_inspector():
print("updated")
%InspectorText.visible = inspected_entity != null
if inspected_entity:
%InspectorText.text = inspected_entity.inspected_text()
if player:
%Interact.visible = inspected_entity and inspected_entity is Interactable and inspected_entity.can_interact(player)
if inspected_entity and inspected_entity is Interactable and inspected_entity.can_interact(player):
%InspectorInteractionText.text = inspected_entity.interact_text()
%Use.visible = player.can_use_item
if player.inventory.get_item() and player.can_use_item:
%InspectorUseText.text = player.inventory.get_item().use_text(player)
else:
%Interact.visible = false
%Use.visible = false
func stop_inspect_entity(entity : InspectableEntity):
entity.inspected = false
if inspected_entity == entity:
%InspectorText.visible = false
inspected_entity = null
update_inspector()