extends Control @onready var mouseFollowerRect2 = $NinePatchRect/V/H1/Title # node with sword image @onready var mouseFollowerRect = $NinePatchRect # node with sword image var moveWindows:bool = false var enterMove:bool = false var enterResizeTopLeft: bool = false var enterResizeTopRight: bool = false var enterResizeLeft: bool = false var enterResizeRight: bool = false var enterResizeBottomLeft: bool = false var enterResizeBottomRight: bool = false var enterResizeBottom: bool = false var lastMousePos:Vector2 enum StateAction {None, Move, ResizeTopLeft, ResizeTopRight, ResizeLeft, ResizeRight, ResizeBottomLeft, ResizeBottomRight, ResizeBottom} var action:StateAction = StateAction.None func resize_windows(): pass func _process(_delta): match action: StateAction.Move: var currentMousePos:Vector2 = get_global_mouse_position() var currentPos:Vector2 = mouseFollowerRect.get_position() var finalTexturePos:Vector2 = currentMousePos - lastMousePos + currentPos mouseFollowerRect.set_position(finalTexturePos) lastMousePos = currentMousePos StateAction.ResizeTopLeft: Common.msg_debug("") StateAction.ResizeTopRight: Common.msg_debug("") StateAction.ResizeLeft: Common.msg_debug("") StateAction.ResizeRight: Common.msg_debug("") StateAction.ResizeBottomLeft: Common.msg_debug("") StateAction.ResizeBottomRight: Common.msg_debug("") StateAction.ResizeBottom: Common.msg_debug("") var currentMousePos:Vector2 = get_global_mouse_position() #var currentPos:Vector2 = mouseFollowerRect.get_position() var t:Vector2 = self.get_size() var n:Vector2 = t + currentMousePos - lastMousePos n.x = t.x if n.y < 224.0: n.y = 224.0 self._set_size(n) lastMousePos = currentMousePos #self.resize func _input(event): if event is InputEventMouseButton: if event.get_button_index() == MOUSE_BUTTON_LEFT: if event.is_pressed(): if action == StateAction.None: if enterMove: lastMousePos = get_global_mouse_position() action = StateAction.Move elif enterResizeTopLeft and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeTopLeft elif enterResizeTopRight and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeTopRight elif enterResizeLeft and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeLeft elif enterResizeRight and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeRight elif enterResizeBottomLeft and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeBottomLeft elif enterResizeBottomRight and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeBottomRight elif enterResizeBottom and not moveWindows: lastMousePos = get_global_mouse_position() action = StateAction.ResizeBottom #SceneTree.set_input_as_handled() else: action = StateAction.None #SceneTree.set_input_as_handled() func show_window(): Common.msg_debug("++ Open windows languages") $NinePatchRect/V/H2/VBoxContainer/Select.clear() var id = 0 var selected = -1 var near_selected = -1 var current_locale = TranslationServer.get_locale() var root_language = current_locale.split('_')[0] for key in TranslationServer.get_loaded_locales(): if key == TranslationServer.get_locale(): selected = id else: var tmp = key.split("_") # print("tmp:" + tmp[0]) if tmp[0] == root_language: if tmp.size() == 1: near_selected = id elif near_selected == -1: near_selected = id $NinePatchRect/V/H2/VBoxContainer/Select.add_item(TranslationServer.get_locale_name(key) + " [" + key + "]", id) id += 1 if selected == -1 and near_selected != -1: selected = near_selected if selected == -1: # Your language not exist, create it just for the form var key = TranslationServer.get_locale() $NinePatchRect/V/H2/VBoxContainer/Select.add_item(TranslationServer.get_locale_name(key) + " (" + key + " !)", id) selected = id $NinePatchRect/V/H2/VBoxContainer/Select.select(selected) self.set_visible(true) #$NinePatchRect/V/H2/VBoxContainer/Quit.grab_focus() func _on_select_item_selected(_index): var pos = 0 for key in TranslationServer.get_loaded_locales(): if pos == $NinePatchRect/V/H2/VBoxContainer/Select.get_selected(): TranslationServer.set_locale(key) return pos += 1 func _on_quit_pressed(): self.set_visible(false) func _on_title_mouse_entered(): enterMove = true func _on_title_mouse_exited(): enterMove = false func _on_resize_top_left_mouse_entered(): enterResizeTopLeft = true func _on_resize_top_left_mouse_exited(): enterResizeTopLeft = false func _on_resize_bottom_left_mouse_entered(): enterResizeBottomLeft = true func _on_resize_bottom_left_mouse_exited(): enterResizeBottomLeft = false func _on_resize_bottom_mouse_entered(): enterResizeBottom = true func _on_resize_bottom_mouse_exited(): enterResizeBottom = false func _on_resize_left_mouse_exited(): enterResizeLeft = true func _on_resize_left_mouse_entered(): enterResizeLeft = false func _on_resize_top_right_mouse_entered(): enterResizeTopRight = true func _on_resize_top_right_mouse_exited(): enterResizeTopRight = false func _on_resize_right_mouse_entered(): enterResizeRight = true func _on_resize_right_mouse_exited(): enterResizeRight = false func _on_resize_bottom_right_mouse_entered(): enterResizeBottomRight = true func _on_resize_bottom_right_mouse_exited(): enterResizeBottomRight = false # # #func _on_visibility_changed(): # if self.visible: # $NinePatchRect/V/H2/VBoxContainer/Quit.grab_focus()