feat: started adding new ui
This commit is contained in:
parent
dd4c4bb5e8
commit
72013e48eb
45 changed files with 860 additions and 96 deletions
32
src/draggable.gd
Normal file
32
src/draggable.gd
Normal file
|
@ -0,0 +1,32 @@
|
|||
extends Control
|
||||
class_name DraggableWindow
|
||||
|
||||
|
||||
var dragging: bool = false
|
||||
var dragging_start_position: Vector2i = Vector2i()
|
||||
|
||||
signal on_drag(offset: Vector2i)
|
||||
signal on_drop()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event is not InputEventMouseButton:
|
||||
return
|
||||
if event.button_index != MOUSE_BUTTON_LEFT:
|
||||
return
|
||||
|
||||
if event.pressed:
|
||||
dragging = true
|
||||
dragging_start_position = Vector2i(get_global_mouse_position())
|
||||
else:
|
||||
dragging = false
|
||||
on_drop.emit()
|
||||
|
||||
|
||||
func _process(_delta) -> void:
|
||||
if dragging:
|
||||
on_drag.emit(Vector2i(get_global_mouse_position()) - dragging_start_position)
|
1
src/draggable.gd.uid
Normal file
1
src/draggable.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dxl7onk7x6h8b
|
Loading…
Add table
Add a link
Reference in a new issue