#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:
50
gui/pointer/assets/icons/left_click.svg
Normal file
50
gui/pointer/assets/icons/left_click.svg
Normal 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 |
37
gui/pointer/assets/icons/left_click.svg.import
Normal file
37
gui/pointer/assets/icons/left_click.svg.import
Normal 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
|
||||
50
gui/pointer/assets/icons/right_click.svg
Normal file
50
gui/pointer/assets/icons/right_click.svg
Normal 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 |
37
gui/pointer/assets/icons/right_click.svg.import
Normal file
37
gui/pointer/assets/icons/right_click.svg.import
Normal 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
|
||||
BIN
gui/pointer/assets/sounds/click.wav
Normal file
BIN
gui/pointer/assets/sounds/click.wav
Normal file
Binary file not shown.
24
gui/pointer/assets/sounds/click.wav.import
Normal file
24
gui/pointer/assets/sounds/click.wav.import
Normal 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
|
||||
@@ -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="."]
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user