Centre every popup in the window
Most popups sat where they had been placed by hand, up to 328 px off. They are now all centred, and test_popups.gd checks it for every popup.
This commit is contained in:
1 parent
845d08c260
commit
b2d547b650
4 files changed
+3382
-3360
No files matched your search
+3330
-3330
File diff suppressed because it is too large.
Load diff
@@ -130,3 +130,25 @@ func test_toggle_opens_and_closes() -> void:
|
||||
shortcuts.toggle()
|
||||
assert_bool(shortcuts.visible).is_false()
|
||||
|
||||
|
||||
func test_every_popup_is_centred_in_the_window() -> void:
|
||||
var window_centre: Vector2 = Vector2(1920, 1080) / 2
|
||||
var popups: Array[BasePopup] = [_window.get_node("SoundtrackStatsPopup")]
|
||||
for node_name: String in MAIN_POPUPS + QUIZ_POPUPS:
|
||||
popups.append(_popup(node_name))
|
||||
for popup: BasePopup in popups:
|
||||
match popup.name:
|
||||
"WinnerPopup":
|
||||
popup.show_winner(_add_player("Crono"))
|
||||
"CharacterSelectPopup":
|
||||
popup.show_grid("Crono")
|
||||
"SoundtrackStatsPopup":
|
||||
popup.show_soundtrack(SoundtrackWithSongs.new())
|
||||
_:
|
||||
popup.open()
|
||||
await _runner.simulate_frames(1)
|
||||
|
||||
var centre: Vector2 = popup.panel.get_global_rect().get_center()
|
||||
assert_float(centre.distance_to(window_centre)).override_failure_message(
|
||||
"%s is centred at %s" % [popup.name, centre]).is_less_equal(1.0)
|
||||
popup.close()
|
||||
Reference in new issue
Block a user