Adding targeting cursor when placing drone

This commit is contained in:
Dan 2024-05-02 15:00:48 +01:00
parent b0583bd97f
commit 0f5640d789
4 changed files with 50 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bdvbld0afmw6v"
path="res://.godot/imported/launch_drone.png-aa2945541cae29c2447f4294f2ec091e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resources/cursors/launch_drone.png"
dest_files=["res://.godot/imported/launch_drone.png-aa2945541cae29c2447f4294f2ec091e.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

View file

@ -4,6 +4,7 @@ var spawning_drone : bool = false
var spawning_type : String = "" var spawning_type : String = ""
@onready var drone_controls = %DroneControls @onready var drone_controls = %DroneControls
@onready var cursor = preload("res://resources/cursors/launch_drone.png")
func _ready() -> void: func _ready() -> void:
Log.pr("Drone Manager Ready...") Log.pr("Drone Manager Ready...")
@ -23,12 +24,14 @@ func spawn_drone(drone_type : String) -> void:
func place_drone(drone_type : String) -> void: func place_drone(drone_type : String) -> void:
if !spawning_drone: if !spawning_drone:
Input.set_custom_mouse_cursor(cursor, Input.CURSOR_ARROW, Vector2(32, 32))
drone_controls.disable_buttons() drone_controls.disable_buttons()
Log.pr("Placing " + drone_type + "...") Log.pr("Placing " + drone_type + "...")
spawning_drone = true spawning_drone = true
spawning_type = drone_type spawning_type = drone_type
func cancel_spawning() -> void: func cancel_spawning() -> void:
Input.set_custom_mouse_cursor(null)
drone_controls.reset_button_focus() drone_controls.reset_button_focus()
drone_controls.enable_buttons() drone_controls.enable_buttons()
spawning_drone = false spawning_drone = false

View file

@ -49,8 +49,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
metadata/_edit_use_anchors_ = true metadata/_edit_use_anchors_ = true
[node name="DroneControls" type="HBoxContainer" parent="DroneManager/Control"] [node name="MarginContainer" type="MarginContainer" parent="DroneManager/Control"]
unique_name_in_owner = true
layout_mode = 1 layout_mode = 1
anchors_preset = 7 anchors_preset = 7
anchor_left = 0.5 anchor_left = 0.5
@ -62,31 +61,35 @@ offset_top = -31.0
offset_right = 155.5 offset_right = 155.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 0 grow_vertical = 0
[node name="DroneControls" type="HBoxContainer" parent="DroneManager/Control/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 10 size_flags_vertical = 10
alignment = 1 alignment = 1
script = ExtResource("3_rqkyv") script = ExtResource("3_rqkyv")
[node name="SpawnDirector" type="Button" parent="DroneManager/Control/DroneControls"] [node name="SpawnDirector" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2 layout_mode = 2
tooltip_text = "Place a director drone, these are the main drones that define the path bees should follow. The order bees should visit these drones can be defined by clicking on them." tooltip_text = "Place a director drone, these are the main drones that define the path bees should follow. The order bees should visit these drones can be defined by clicking on them."
text = "Director" text = "Director"
[node name="SpawnCollector" type="Button" parent="DroneManager/Control/DroneControls"] [node name="SpawnCollector" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2 layout_mode = 2
tooltip_text = "Place a drone that encourages bees to collect pollen near this area." tooltip_text = "Place a drone that encourages bees to collect pollen near this area."
text = "Collector" text = "Collector"
[node name="SpawnDistractor" type="Button" parent="DroneManager/Control/DroneControls"] [node name="SpawnDistractor" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2 layout_mode = 2
tooltip_text = "Place a distracting drone that will (hopefully) divert threats attention so they ignore the bees." tooltip_text = "Place a distracting drone that will (hopefully) divert threats attention so they ignore the bees."
text = "Distractor" text = "Distractor"
[node name="SpawnDancer" type="Button" parent="DroneManager/Control/DroneControls"] [node name="SpawnDancer" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2 layout_mode = 2
tooltip_text = "Spawn a dancing drone that will encourage bees to leave the hive. Best to put this near to the hive. " tooltip_text = "Spawn a dancing drone that will encourage bees to leave the hive. Best to put this near to the hive. "
text = "Dancer" text = "Dancer"
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDancer" to="DroneManager" method="_on_spawn_dancer_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDancer" to="DroneManager" method="_on_spawn_dancer_pressed"]