fix popup shifting

This commit is contained in:
Fabien Freling 2020-06-08 18:39:16 +02:00
parent c8bd0412f3
commit 3369c37a00
4 changed files with 23 additions and 26 deletions

View file

@ -3,6 +3,8 @@ extends Control
onready var container = $GridContainer
onready var taquin = $GridContainer/Taquin
var _first_popup_call := true
func _ready():
taquin.rect_min_size = get_viewport().get_visible_rect().size * (2.0 / 3.0)
layout_reflow()
@ -84,7 +86,15 @@ func _on_Taquin_state_changed(previous, new):
pass
func _on_New_game_pressed():
$NewGamePanel.popup_centered_ratio($NewGamePanel.window_scale_factor)
$NewGamePanel.rect_position = Vector2.ZERO
if _first_popup_call:
# We only call popup_centered() once, otherwise the popup shifts to the
# bottom right after each call.
$NewGamePanel.popup_centered_ratio($NewGamePanel.window_scale_factor)
_first_popup_call = false
else:
# After the 1st call, the position should be settled.
$NewGamePanel.popup()
func _on_NewGamePanel_about_to_show():
taquin.set_process_input(false)