This repository has been archived on 2023-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
Boups/Elements/Scripts/WindowHeader.gd

46 lines
1.3 KiB
GDScript3
Raw Normal View History

extends Area2D
var is_dragging = false
var grabbed_offset = Vector2()
onready var window = $"../.."
2023-02-26 13:52:50 +01:00
onready var folder_icon = $"../../../Sprite"
func drag_change_state():
2023-02-26 17:39:03 +01:00
is_dragging = !is_dragging
grabbed_offset = window.get_position() - get_global_mouse_position()
func _process(_delta) -> void:
2023-02-26 17:39:03 +01:00
if is_dragging:
var new_pos = get_global_mouse_position() + grabbed_offset
if new_pos.x > 150:
window.set_position(new_pos)
else:
drag_change_state()
func _on_Area2D_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
2023-02-26 17:39:03 +01:00
if event is InputEventMouseButton:
event = event as InputEventMouseButton
if event.pressed and event.button_index == BUTTON_LEFT:
drag_change_state()
#print("here haha")
elif event.button_index == BUTTON_LEFT and !event.pressed:
drag_change_state()
#print("here huhu")
func _on_Area2D2_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
2023-02-26 17:39:03 +01:00
if event is InputEventMouseButton:
event = event as InputEventMouseButton
if event.pressed and event.button_index == BUTTON_LEFT:
drag_change_state()
window.visible = false
folder_icon.modulate = Color(1, 1, 1) # reset shade
2023-02-26 19:09:57 +01:00
var progress_screen = window.get_node("Window2")
if progress_screen.visible:
progress_screen.stop()
window.get_node("Button2").etat = false