#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:
parent
3bbb1cfcdc
commit
bd852b007c
@ -11,8 +11,14 @@ func is_one_time_use():
|
||||
func can_use(_player : Player) -> bool:
|
||||
return false
|
||||
|
||||
func use_text(_player) -> String:
|
||||
return ""
|
||||
|
||||
func use_requirement_text() -> String:
|
||||
return ""
|
||||
|
||||
func use(_player : Player):
|
||||
return false
|
||||
|
||||
func generate_action_area(_player) -> ActionArea:
|
||||
return null
|
||||
|
||||
@ -13,14 +13,23 @@ class_name Seed
|
||||
func _init(_plant_type : PlantType = null):
|
||||
plant_type = _plant_type
|
||||
|
||||
func generate_action_area(player : Player) -> ActionArea:
|
||||
return ActionArea.new(
|
||||
player,
|
||||
10
|
||||
)
|
||||
|
||||
func use_text(_player) -> String:
|
||||
return "Plant " + plant_type.name
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player) -> bool:
|
||||
return not player.planet.is_there_contamination(player.global_position)
|
||||
return not player.planet.is_there_contamination(player.action_area.global_position)
|
||||
|
||||
func use(player : Player) -> bool:
|
||||
if not can_use(player):
|
||||
return false
|
||||
player.play_sfx("dig")
|
||||
return player.planet.plant(plant_type, player.global_position)
|
||||
return player.planet.plant(plant_type, player.action_area.global_position)
|
||||
|
||||
@ -3,6 +3,9 @@ class_name Shovel
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func use_text(_player) -> String:
|
||||
return "Dig"
|
||||
|
||||
func can_use(player : Player) -> bool:
|
||||
var areas = player.action_area.get_overlapping_areas()
|
||||
for area in areas :
|
||||
|
||||
@ -2,10 +2,9 @@ extends Item
|
||||
class_name ToolItem
|
||||
|
||||
@export var area_width: float = 50
|
||||
@export var area_distance: float = 50
|
||||
|
||||
func generate_action_area():
|
||||
func generate_action_area(player : Player) -> ActionArea:
|
||||
return ActionArea.new(
|
||||
area_width,
|
||||
area_distance
|
||||
player,
|
||||
area_width
|
||||
)
|
||||
@ -12,6 +12,9 @@ func _process(_delta):
|
||||
func inspected_text():
|
||||
return "Compost"
|
||||
|
||||
func interact_text():
|
||||
return "Put a seed"
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
|
||||
@ -24,6 +24,9 @@ func _ready():
|
||||
func inspected_text():
|
||||
return item.name + (" Seed" if item is Seed else "")
|
||||
|
||||
func interact_text():
|
||||
return "Take"
|
||||
|
||||
func interact(player : Player) -> bool:
|
||||
var swapped_item = player.inventory.get_item()
|
||||
|
||||
|
||||
@ -20,3 +20,6 @@ func generate_collision(area_width : float):
|
||||
|
||||
collision.shape = collision_shape
|
||||
add_child(collision)
|
||||
|
||||
func interact_text():
|
||||
return ""
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/default/growing.png" id="1_fp5j6"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
|
||||
[ext_resource type="Script" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
|
||||
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/default/mature.png" id="3_ffarr"]
|
||||
[ext_resource type="Texture2D" uid="uid://ba413oun7ry78" path="res://entities/plants/assets/sprites/default/planted.png" id="4_2s6re"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_cky1j"]
|
||||
|
||||
@ -1,44 +1,41 @@
|
||||
extends Area2D
|
||||
class_name ActionArea
|
||||
|
||||
const OPACITY = 0.3
|
||||
const OPACITY = 0.4
|
||||
const ACTIVATED_COLOR = Color.TURQUOISE
|
||||
const DEACTIVATED_COLOR = Color.REBECCA_PURPLE
|
||||
|
||||
var collision_shape : CollisionShape2D = null
|
||||
var area_width : float = 40
|
||||
var area_distance : float = 80
|
||||
var area_width : float
|
||||
var area_max_distance : float
|
||||
var player : Player
|
||||
|
||||
var activated : bool = false :
|
||||
set(v):
|
||||
var old = activated
|
||||
activated = v
|
||||
if old != activated:
|
||||
queue_redraw()
|
||||
var activated : bool = false
|
||||
|
||||
func _init(
|
||||
_player: Player,
|
||||
_area_width : float = 40,
|
||||
_area_distance : float = 80
|
||||
):
|
||||
player = _player
|
||||
area_width = _area_width
|
||||
area_distance = _area_distance
|
||||
|
||||
func _ready():
|
||||
collision_shape = CollisionShape2D.new()
|
||||
collision_shape.position.x = area_distance
|
||||
collision_shape.shape = CircleShape2D.new()
|
||||
collision_shape.shape.radius = area_width
|
||||
add_child(collision_shape)
|
||||
|
||||
func _process(_delta):
|
||||
look_at(get_global_mouse_position())
|
||||
var target_position = get_global_mouse_position() - player.global_position
|
||||
if Vector2.ONE.distance_to(target_position) > player.max_reach:
|
||||
target_position = Vector2.ZERO.direction_to(target_position)*player.max_reach
|
||||
|
||||
position = target_position
|
||||
queue_redraw()
|
||||
|
||||
func _draw():
|
||||
draw_circle(
|
||||
Vector2(
|
||||
area_distance,
|
||||
0
|
||||
),
|
||||
Vector2.ZERO,
|
||||
area_width,
|
||||
Color((ACTIVATED_COLOR if activated else DEACTIVATED_COLOR), OPACITY)
|
||||
)
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
const MAX_REACH_CIRCLE_OPACITY = 0.1
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal action_tried_without_energy
|
||||
signal action_not_permitted
|
||||
signal upgraded
|
||||
|
||||
var planet : Planet # mis à jour par la classe Planet
|
||||
@ -11,48 +14,47 @@ var planet : Planet # mis à jour par la classe Planet
|
||||
@onready var inventory : Inventory = Inventory.new()
|
||||
|
||||
var max_energy : int = 3
|
||||
var max_reach : int = 100 :
|
||||
set(v):
|
||||
max_reach = v
|
||||
queue_redraw()
|
||||
|
||||
var controlling_player : bool = true :
|
||||
set(v):
|
||||
controlling_player = v
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
var closest_interactable : Interactable = null :
|
||||
set(v):
|
||||
var old = closest_interactable
|
||||
closest_interactable = v
|
||||
if old != closest_interactable:
|
||||
player_updated.emit(self)
|
||||
var target_interactable : Interactable = null # mis à jour par la classe Interactable
|
||||
|
||||
var can_use_item : bool = false :
|
||||
set(v):
|
||||
var old = can_use_item
|
||||
can_use_item = v
|
||||
if old != can_use_item:
|
||||
player_updated.emit(self)
|
||||
var can_interact : bool = false :
|
||||
set(v):
|
||||
var old = can_interact
|
||||
can_interact = v
|
||||
if old != can_interact:
|
||||
print("emit")
|
||||
player_updated.emit(self)
|
||||
var energy : int = max_energy :
|
||||
set(v):
|
||||
energy = v
|
||||
emit_signal("player_updated", self)
|
||||
var action_area : ActionArea = null
|
||||
player_updated.emit(self)
|
||||
var action_area : ActionArea = null :
|
||||
set(v):
|
||||
action_area = v
|
||||
queue_redraw()
|
||||
|
||||
func _ready():
|
||||
emit_signal("player_updated", self)
|
||||
player_updated.emit(self)
|
||||
inventory.inventory_changed.connect(_on_inventory_updated)
|
||||
Pointer.player = self
|
||||
|
||||
# Méthode déclenchée par la classe planet
|
||||
func _pass_day():
|
||||
energy = max_energy
|
||||
target_interactable = null
|
||||
|
||||
func _process(_delta):
|
||||
get_input()
|
||||
move_and_slide()
|
||||
detect_closest_interactable()
|
||||
|
||||
func _on_root_gui_day_pass_pressed():
|
||||
controlling_player = false
|
||||
@ -66,19 +68,33 @@ func _on_root_gui_game_click():
|
||||
func _on_inventory_updated(_inventory: Inventory):
|
||||
emit_signal("player_updated", self)
|
||||
|
||||
func _draw():
|
||||
if action_area:
|
||||
draw_arc(
|
||||
Vector2.ZERO,
|
||||
max_reach,
|
||||
0.,
|
||||
2*PI,
|
||||
30,
|
||||
Color(Color.WHITE,MAX_REACH_CIRCLE_OPACITY),
|
||||
1
|
||||
)
|
||||
|
||||
func get_input():
|
||||
if controlling_player:
|
||||
var old_velocity=velocity
|
||||
calculate_direction()
|
||||
|
||||
can_use_item = inventory.get_item() and inventory.get_item().can_use(self)
|
||||
can_interact = closest_interactable and closest_interactable.can_interact(self)
|
||||
if action_area:
|
||||
action_area.activated = can_use_item
|
||||
if target_interactable and target_interactable in $InteractArea2D.get_overlapping_areas():
|
||||
if target_interactable.can_interact(self):
|
||||
Pointer.stop_inspect_entity(target_interactable)
|
||||
target_interactable.interact(self)
|
||||
target_interactable = null
|
||||
if Input.is_action_just_pressed("action"):
|
||||
try_use_item()
|
||||
if Input.is_action_just_pressed("interact") and closest_interactable and can_interact:
|
||||
closest_interactable.interact(self)
|
||||
if Input.is_action_just_pressed("drop") and inventory.get_item():
|
||||
drop_item()
|
||||
if old_velocity.length()==0 and velocity.length()!=0:
|
||||
@ -86,21 +102,31 @@ func get_input():
|
||||
|
||||
func calculate_direction():
|
||||
var input_direction: Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
|
||||
if input_direction.length() != 0:
|
||||
target_interactable = null
|
||||
|
||||
if target_interactable:
|
||||
input_direction = self.global_position.direction_to(target_interactable.global_position)
|
||||
|
||||
velocity = input_direction * speed
|
||||
if input_direction.x:
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
|
||||
func try_use_item():
|
||||
if energy == 0 and inventory.get_item():
|
||||
if energy == 0:
|
||||
action_tried_without_energy.emit()
|
||||
elif not can_use_item:
|
||||
action_not_permitted.emit()
|
||||
if energy > 0 and can_use_item:
|
||||
use_item()
|
||||
|
||||
func get_item(item : Item):
|
||||
remove_action_area()
|
||||
inventory.set_item(item)
|
||||
if item is ToolItem:
|
||||
add_action_area(item.generate_action_area())
|
||||
var new_action_area = item.generate_action_area(self)
|
||||
if new_action_area != null :
|
||||
add_action_area(new_action_area)
|
||||
play_sfx("pick")
|
||||
|
||||
func drop_item():
|
||||
@ -121,22 +147,6 @@ func use_item():
|
||||
if item.is_one_time_use():
|
||||
delete_item()
|
||||
|
||||
func detect_closest_interactable():
|
||||
var in_range_interactables : Array[Interactable] = []
|
||||
for area in $InteractArea2D.get_overlapping_areas():
|
||||
if area is Interactable and area.available:
|
||||
in_range_interactables.append(area)
|
||||
|
||||
in_range_interactables.sort_custom(
|
||||
func(a : Node2D, b : Node2D) :
|
||||
return a.global_position.distance_to(global_position) < b.global_position.distance_to(global_position)
|
||||
)
|
||||
|
||||
if len(in_range_interactables) > 0:
|
||||
closest_interactable = in_range_interactables[0]
|
||||
else :
|
||||
closest_interactable = null
|
||||
|
||||
func add_action_area(area : ActionArea):
|
||||
action_area = area
|
||||
add_child(action_area)
|
||||
@ -144,6 +154,8 @@ func add_action_area(area : ActionArea):
|
||||
func remove_action_area():
|
||||
if (action_area):
|
||||
remove_child(action_area)
|
||||
action_area.queue_free()
|
||||
action_area = null
|
||||
|
||||
func upgrade():
|
||||
max_energy += 1
|
||||
|
||||
@ -4,15 +4,14 @@ class_name InspectableEntity
|
||||
const MODULATE_INSPECTED_COLOR = Color.GRAY
|
||||
|
||||
@onready var default_modulate : Color = modulate
|
||||
@onready var mouse_signals_setuped : bool = setup_mouse_signals()
|
||||
@onready var inspectable_signals_setuped : bool = setup_inspectable_signals()
|
||||
|
||||
var inspected : bool = false :
|
||||
set(v):
|
||||
print(v)
|
||||
inspected = v
|
||||
modulate = MODULATE_INSPECTED_COLOR if inspected else default_modulate
|
||||
|
||||
func setup_mouse_signals() -> bool:
|
||||
func setup_inspectable_signals() -> bool:
|
||||
mouse_entered.connect(_on_mouse_entered)
|
||||
mouse_exited.connect(_on_mouse_excited)
|
||||
return true
|
||||
|
||||
@ -90,6 +90,7 @@ following = NodePath("../Entities/Player")
|
||||
[connection signal="day_pass_proceed" from="CanvasLayer/RootGui" to="Planet" method="_on_root_gui_day_pass_proceed"]
|
||||
[connection signal="game_click" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_game_click"]
|
||||
[connection signal="pause_asked" from="CanvasLayer/RootGui" to="CanvasLayer/Pause" method="_on_root_gui_pause_asked"]
|
||||
[connection signal="action_not_permitted" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_action_not_permitted"]
|
||||
[connection signal="action_tried_without_energy" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_action_tried_without_energy"]
|
||||
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
|
||||
[connection signal="upgraded" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_upgraded"]
|
||||
|
||||
@ -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"]
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
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()
|
||||
|
||||
@ -50,12 +50,13 @@ move_down={
|
||||
}
|
||||
interact={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(190, 22),"global_position":Vector2(199, 70),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
action={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(76, 12),"global_position":Vector2(85, 60),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
drop={
|
||||
|
||||
Loading…
Reference in New Issue
Block a user