aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession/MainManagamentPanel/PopupPanel.gd
blob: 72e54ae0f938f58f3a0e145ae849e900c968cf0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
extends Control

var _mouse_over_viewport : bool = true
var _mouse_entered : bool = true
const _action_click : StringName = &"map_click"
            
func _on_close_button_pressed():
   self.queue_free()

func _on_top_panel_gui_input(event):
   var far_point1 : Vector2 = Vector2(self.get_global_position().x,self.get_global_position().y)
   var far_point2 : Vector2 = Vector2(self.get_global_position().x+self.size.x,self.get_global_position().y+self.size.y)

   if Input.is_action_pressed(_action_click) and event is InputEventMouseMotion and _mouse_over_viewport: 
      if far_point1.x+event.relative.x > 0 and far_point1.y+event.relative.y > 0 and far_point2.x+event.relative.x < get_viewport().size.x and far_point2.y+event.relative.y < get_viewport().size.y and get_global_mouse_position().x > 0 and get_global_mouse_position().y > 0 and get_global_mouse_position().x < get_viewport().size.x and get_global_mouse_position().y < get_viewport().size.y:
         set_position(self.get_screen_position()+event.relative)
      else:
         pass

func _on_mouse_entered_viewport():
   _mouse_over_viewport = true

func _on_mouse_exited_viewport():
   _mouse_over_viewport = false