Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Solution 1: Only check click in region of mainmenu if no submenu is active
Solution 2 as comment: Check for active submenu and check the region for the submenu, queue_free() submenu if outside
  • Loading branch information
Fox-Alpha committed Mar 18, 2024
1 parent b739a79 commit 4592772
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions scenes/player/gamemenu/GameMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,29 @@ func _input(event):
if self.visible:
#If the input happens outside the menu while it is open, hide it
if (event is InputEventMouseButton) and event.pressed:
var is_inside_menu: bool = (
Rect2(Vector2(position.x, position.y), Vector2(size.x, size.y))
. has_point(event.position)
)

if not is_inside_menu:
self.hide()
JUI.above_ui = false

get_viewport().set_input_as_handled()
var is_inside_menu: bool
if not is_instance_valid(sub_menu_reference):
#if is_instance_valid(sub_menu_reference):
#is_inside_menu = (
#Rect2(Vector2(sub_menu_reference.position.x,
#sub_menu_reference.position.y),
#Vector2(sub_menu_reference.size.x,
#sub_menu_reference.size.y))
#. has_point(event.position)
#)
#sub_menu_reference.queue_free()
#printt([sub_menu_reference.position, sub_menu_reference.size])
#else:
is_inside_menu = (
Rect2(Vector2(position.x, position.y), Vector2(size.x, size.y))
. has_point(event.position)
)

if not is_inside_menu:
self.hide()
JUI.above_ui = false

get_viewport().set_input_as_handled()


#Also saves changes to disk.
Expand Down

0 comments on commit 4592772

Please sign in to comment.