extends RefCounted ## #41, the menus and settings at phone scale, through the entry scene (main.tscn, test save and ## settings paths) with MobilePort.forced: ## * Fitting: the main menu, the pause menu, the question (ConfirmBox), and settings keep every ## button inside the safe area, at least the minimum touch target tall, on a 19.5:9 phone ## (about 1.6x, notch and home indicator insets), an iPhone SE (the 1.7 cap, the same insets), ## and a 4:3 iPad (1x, status bar and home indicator insets); the main menu's column stays ## clear of its credits, and the pause menu's buttons keep their focus order. ## * Phone settings: Audio, Touch (Interface size, Swap sticks, Camera distance, Haptics, the touch ## guide), Display (3D resolution scale), Gameplay; none of the desktop-only rows. The list ## scrolls by dragging (from a slider too, which then keeps its value); a sideways drag moves a ## slider and doesn't scroll; a drag from a check box doesn't toggle it, a tap does. The ## Interface size applies when its finger lifts. ## * GameSettings: the touch settings round-trip through the file, with fallbacks and clamping; ## Swap sticks reaches every node in &"touch_controls" (a stub here: TouchSticks and ## TouchButtons join with #38); Camera distance sets the follow camera on a phone (at start and ## live), never on desktop; Reset to defaults leaves what isn't shown alone (both platforms). ## * Haptics: a hit buzzes (Scarecrow.buzz) on a phone with it on, not with it off, never on ## desktop. ## * Desktop (forced 0): the settings list has the same sections and rows as before, at the same ## sizes. const Touch := preload("res://game/tests/mobile/touch.gd") const SAVE := "user://test_menus_save.json" const SETTINGS := "user://test_menus_settings.cfg" const ROUND_TRIP := "user://test_menus_round_trip.cfg" const DT := 1.0 / 60.0 ## name, window pixels, density (0: the preview's guess from the shape), insets in window pixels ## (left, top, right, bottom), and the canvas that gives (about). const DEVICES := [ ["19.5:9 phone", Vector2i(2340, 1080), 0.0, [140, 0, 140, 60], Vector2(1469, 678)], ["iPhone SE", Vector2i(1334, 750), 326.0, [140, 0, 140, 60], Vector2(1130, 635)], ["4:3 iPad", Vector2i(1600, 1200), 0.0, [0, 40, 0, 40], Vector2(1920, 1440)], ] ## The desktop settings list, as before #41: a head, a row (its label), a check box, a note, or ## the bindings grid (its cell count). const DESKTOP_ROWS := [ "head:Audio", "row:Master volume", "row:Music and stingers", "row:Sound effects", "row:Ambience", "row:Voice chat (your friend)", "head:Controls", "row:Move stick dead zone", "row:Aim stick dead zone", "note:Mouse aim follows the cursor directly, so it has no sensitivity to set.", "grid:51", "head:Display", "check:Fullscreen", "check:VSync", "row:Pixel size", "row:3D resolution scale", "note:Pixel size 1 turns the pixel look off; the resolution scale is used only then.", "head:Gameplay", "check:Tips on the first day and night", "head:Co-op", "row:Your name", "check:Send my microphone in voice chat", ] const PHONE_ROWS := [ "head:Audio", "row:Master volume", "row:Music and stingers", "row:Sound effects", "row:Ambience", "row:Voice chat (your friend)", "head:Touch", "row:Interface size", "check:Swap the sticks (move on the left)", "row:Camera distance", "check:Buzz when the scarecrow is hit", "note:Playing by touch", "guide", "guide", "guide", "guide", "guide", "head:Display", "row:3D resolution scale", "head:Gameplay", "check:Tips on the first day and night", ] ## A node in &"touch_controls" standing in for TouchSticks and TouchButtons (#38). class Stub extends Node: var calls: Array = [] # swap_sticks at each apply_settings func apply_settings(s: GameSettings) -> void: calls.append(s.swap_sticks) var t: GameTestRunner var main: Main func run(p_t) -> void: t = p_t var root := t.root var pixels := [root.scaling_3d_mode, root.scaling_3d_scale, root.msaa_3d] _clean() _round_trip() MobilePort.forced = 1 var seed := GameSettings.new() # a phone's defaults, but the camera at 15 m seed.camera_distance = 15.0 seed.save_to(SETTINGS) _set_device(DEVICES[0]) main = await _start() _camera(15.0, "phones: the Camera distance setting (15) decides the camera's distance at start") for d: Array in DEVICES: await _device(d) await _main_menu(d[0]) await _confirm_over(main.main_menu, d[0] + " (main menu)") await _settings_layout(d[0]) await _device(DEVICES[0]) main.main_menu.new_button.pressed.emit() t.check(main.screen == Main.Screen.PLAYING, "(a new vacation)") main.pause() for d: Array in DEVICES: await _device(d) await _pause_menu(d[0]) main.pause_menu.restart_button.pressed.emit() await _confirm_over(main.pause_menu, d[0] + " (pause menu)") await _device(DEVICES[0]) main.pause_menu.settings_button.pressed.emit() await _frames() _phone_rows() await _drags() await _swap() await _camera_live() await _interface_size() await _reset_phone() main.settings_menu.back_button.pressed.emit() main.resume() await _haptics_phone() await _stop() MobilePort.forced = 0 MobilePort.preview_insets = [] MobilePort.preview_dpi = 0.0 root.size = Vector2i(1920, 1080) seed.haptics = true seed.save_to(SETTINGS) main = await _start() _camera(16.0, "desktop: the camera starts 16 m away whatever the Camera distance setting (15)") await _desktop() await _stop() MobilePort.forced = -1 MobilePort.preview_insets = [] MobilePort.preview_dpi = 0.0 Scarecrow.haptics = false GameSettings.new().apply(null) # the defaults for the audio and dead zones, as test_save does root.scaling_3d_mode = pixels[0] root.scaling_3d_scale = pixels[1] root.msaa_3d = pixels[2] _clean() func _clean() -> void: for p in [SAVE, SAVE + ".tmp", SETTINGS, ROUND_TRIP]: if FileAccess.file_exists(p): DirAccess.remove_absolute(ProjectSettings.globalize_path(p)) func _start() -> Main: var m := (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main m.save_path = SAVE m.settings_path = SETTINGS t.root.add_child(m) await _frames() await t.physics_frame return m func _stop() -> void: main.queue_free() main = null t.paused = false await t.process_frame func _frames() -> void: await t.process_frame await t.process_frame func _set_device(d: Array) -> void: MobilePort.preview_dpi = d[2] MobilePort.preview_insets = d[3] t.root.size = d[1] ## The window turns into this device: its size, density, and insets, and the scale for it. func _device(d: Array) -> void: _set_device(d) main.settings.apply_scale(t.root) await _frames() var canvas := t.root.get_visible_rect().size var want: Vector2 = d[4] t.check(absf(canvas.x - want.x) < 3.0 and absf(canvas.y - want.y) < 3.0, "%s: the canvas is about %s (%s, ×%.2f)" % [d[0], want, canvas, t.root.content_scale_factor]) ## Each control visible in the safe area, at least the minimum target tall when it's a target. func _fit(where: String, what: String, controls: Array, safe: Rect2, target: float, tall := true) -> void: var bad := PackedStringArray() for c: Control in controls: var r := c.get_global_rect() var name := (c as Button).text if c is Button else String(c.name) if not c.is_visible_in_tree(): bad.append("%s hidden" % name) elif not safe.grow(0.5).encloses(r): bad.append("%s at %s" % [name, r]) elif tall and r.size.y < target - 0.5: bad.append("%s %.0f tall" % [name, r.size.y]) t.check(bad.is_empty(), "%s: %s inside the safe area %s%s (%s)" % [where, what, Rect2i(safe), ", at least %.0f tall" % target if tall else "", ", ".join(bad) if not bad.is_empty() else "all %d" % controls.size()]) func _main_menu(device: String) -> void: var mm := main.main_menu t.check(mm.visible and main.screen == Main.Screen.MENU, "(%s: the main menu)" % device) var safe := MobilePort.safe_rect(mm) var target := MobilePort.minimum_target(mm) _fit(device + " main menu", "Continue, New vacation, and Settings", [mm.continue_button, mm.new_button, mm.settings_button], safe, target) _fit(device + " main menu", "the title, the save note, and the credits", [mm._title, mm._sub, mm.save_note, mm._credits], safe, target, false) var column := mm._box.get_global_rect() var credits := mm._credits.get_global_rect() t.check(column.end.y <= credits.position.y, "%s main menu: the column (to %.0f) stays above the credits (from %.0f)" % [device, column.end.y, credits.position.y]) t.check(not mm.coop_button.visible and not mm.quit_button.visible, "%s main menu: no co-op, no Quit" % device) func _pause_menu(device: String) -> void: var pm := main.pause_menu t.check(pm.visible and main.screen == Main.Screen.PAUSED, "(%s: the pause menu)" % device) var safe := MobilePort.safe_rect(pm) var target := MobilePort.minimum_target(pm) _fit(device + " pause menu", "Resume, Restart the night, Settings, and Save & quit", [pm.resume_button, pm.restart_button, pm.settings_button, pm.menu_button], safe, target) _fit(device + " pause menu", "the panel", [pm._panel], safe, target, false) t.check(pm.resume_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.restart_button and pm.restart_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.settings_button and pm.settings_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.menu_button and pm.menu_button.find_valid_focus_neighbor(SIDE_TOP) == pm.settings_button, "%s pause menu: up and down go through the buttons in order" % device) ## A question over this menu (the longest the game asks). func _confirm_over(menu: Control, where: String) -> void: var box := main.confirm if not box.is_open: box.ask("Start a new vacation? It replaces your saved one (the morning of day 12 of 30).", "New vacation", func() -> void: pass) await _frames() var safe := MobilePort.safe_rect(box) var target := MobilePort.minimum_target(box) _fit(where + " question", "its two buttons", [box.yes_button, box.no_button], safe, target) _fit(where + " question", "the message", [box.message], safe, target, false) t.check(box.no_button.has_focus(), "%s question: Cancel is focused" % where) box.close() t.check(menu.visible, "(%s: closed, the menu still there)" % where) func _settings_layout(device: String) -> void: main.main_menu.settings_button.pressed.emit() var sm := main.settings_menu await _frames() t.check(sm.is_open, "(%s: settings)" % device) var safe := MobilePort.safe_rect(sm) var target := MobilePort.minimum_target(sm) _fit(device + " settings", "Back and Reset to defaults", [sm.back_button, sm.reset_button], safe, target) _fit(device + " settings", "the panel and its list", [sm._panel, sm._scroll], safe, target, false) var short := PackedStringArray() for c in sm._tall: if c.size.y < target - 0.5: short.append("%s %.0f" % [c.name, c.size.y]) t.check(sm._tall.size() == 11 and short.is_empty(), "%s settings: every row (%d) at least %.0f tall (%s)" % [device, sm._tall.size(), target, ", ".join(short)]) t.check(sm._scroll.size.y >= 240.0, "%s settings: the list shows a good part (%.0f tall)" % [device, sm._scroll.size.y]) sm.back_button.pressed.emit() await _frames() t.check(not sm.is_open and main.main_menu.settings_button.has_focus(), "(%s: back to the main menu)" % device) func _row_name(c: Node) -> String: if c is CheckBox: return "check:" + (c as CheckBox).text if c is GridContainer: return "grid:%d" % c.get_child_count() if c is HBoxContainer: return "row:" + (c.get_child(0) as Label).text var l := c as Label if l == null: return c.get_class() if l.autowrap_mode != TextServer.AUTOWRAP_OFF: return "guide" return ("head:" if l.get_theme_font_size(&"font_size") == 28 else "note:") + l.text func _rows(sm: SettingsMenu) -> Array: return sm._box.get_children().map(_row_name) func _phone_rows() -> void: var sm := main.settings_menu var rows := _rows(sm) t.check(rows == PHONE_ROWS, "phone settings: Audio, Touch with the guide, Display, Gameplay (%s)" % ", ".join(rows)) for key in ["move_dead_zone", "aim_dead_zone", "fullscreen", "vsync", "pixel_size", "player_name", "microphone"]: t.check(not sm.controls.has(key), "phone settings: no %s" % key) var guide := SettingsMenu.touch_guide() t.check(guide[0] == "Move: touch the right half of the screen and slide your thumb." and guide[1] == "Attack: touch the left half and slide toward an alien to aim and attack.", "the guide's sticks follow Prompts (move on the %s): '%s'" % [Prompts.move_side(), guide[0]]) var all := " ".join(guide) t.check(["Use", "Build", "Fear", "Bomb", "Patch", "Pause", "hotbar", "backpack"].all(func(w: String) -> bool: return all.contains(w)), "and it names Use, Build, Fear, Bomb, Patch, Pause, the hotbar, and the backpack") var shown := sm._guide.map(func(l: Label) -> String: return l.text) t.check(shown == Array(guide), "the guide shows those lines") t.check((sm._values["camera_distance"] as Label).text == "15 m" and (sm._values["interface_size"] as Label).text == "100%", "Camera distance reads 15 m and Interface size 100%") ## Fingers on the list: scrolling from a slider leaves its value; sideways moves it. func _drags() -> void: var sm := main.settings_menu var scroll := sm._scroll var music := sm.controls["volume/Music"] as HSlider scroll.scroll_vertical = 0 await _frames() var before := music.value var at := music.get_global_rect().get_center() _swipe(at, at + Vector2(6.0, -180.0)) await _frames() t.check(is_equal_approx(music.value, before) and scroll.scroll_vertical > 100, "a drag up starting on a slider scrolls the list (%d px) and leaves the value (%.2f)" % [scroll.scroll_vertical, music.value]) scroll.scroll_vertical = 0 await _frames() at = music.get_global_rect().get_center() _swipe(at, at + Vector2(-160.0, 10.0)) await _frames() t.check(music.value < before - 0.1 and scroll.scroll_vertical == 0, "a sideways drag moves the slider (%.2f, was %.2f) and doesn't scroll" % [music.value, before]) var r := music.get_global_rect() Touch.tap(0, Vector2(r.end.x - 2.0, r.get_center().y)) t.check(is_equal_approx(music.value, 1.0) and is_equal_approx(main.settings.volume["Music"], 1.0), "a tap at a slider's end sets it there (%.2f)" % music.value) var tips := sm.controls["show_tips"] as CheckBox scroll.ensure_control_visible(tips) await _frames() var top := scroll.scroll_vertical var on := tips.button_pressed at = tips.get_global_rect().get_center() _swipe(at, at + Vector2(0.0, 150.0)) await _frames() t.check(tips.button_pressed == on and scroll.scroll_vertical < top - 80, "a drag down from a check box scrolls (%d to %d) and doesn't toggle it" % [top, scroll.scroll_vertical]) scroll.ensure_control_visible(tips) await _frames() Touch.tap(0, tips.get_global_rect().get_center()) t.check(tips.button_pressed != on and main.settings.show_tips != on, "a tap on it toggles it") tips.button_pressed = on ## A finger down at one point, moved to another in steps, and lifted. func _swipe(from: Vector2, to: Vector2, steps := 8) -> void: Touch.touch(0, from, true) var last := from for i in steps: var p := from.lerp(to, float(i + 1) / steps) Touch.drag(0, last, p) last = p Touch.touch(0, to, false) func _swap() -> void: var sm := main.settings_menu var stub := Stub.new() t.root.add_child(stub) stub.add_to_group(&"touch_controls") var swap := sm.controls["swap_sticks"] as CheckBox sm._scroll.ensure_control_visible(swap) await _frames() t.check(not swap.button_pressed and not main.settings.swap_sticks, "(Swap sticks off)") Touch.tap(0, swap.get_global_rect().get_center()) t.check(swap.button_pressed and main.settings.swap_sticks and stub.calls == [true] and GameSettings.load_from(SETTINGS).swap_sticks, "tapping Swap sticks saves it and hands the settings to the touch controls (%s)" % [stub.calls]) swap.button_pressed = false t.check(stub.calls == [true, false] and not GameSettings.load_from(SETTINGS).swap_sticks, "and off again") stub.free() func _camera(want: float, what: String) -> void: var cam := main.sim.camera as FollowCamera t.check(cam != null and is_equal_approx(cam.distance, want) and cam.is_in_group(FollowCamera.GROUP), "%s (%.1f)" % [what, cam.distance]) func _camera_live() -> void: var slider := main.settings_menu.controls["camera_distance"] as HSlider t.check(slider.min_value == 8.0 and slider.max_value == 20.0, "Camera distance goes from 8 to 20 m") slider.value = 19.0 _camera(19.0, "moving Camera distance moves the camera at once") t.check(is_equal_approx(GameSettings.load_from(SETTINGS).camera_distance, 19.0) and (main.settings_menu._values["camera_distance"] as Label).text == "19 m", "and it's saved and reads 19 m") slider.value = 15.0 ## Interface size: the menu rescales only when the finger lifts. func _interface_size() -> void: var sm := main.settings_menu var slider := sm.controls["interface_size"] as HSlider t.check(is_equal_approx(slider.min_value, 0.8) and is_equal_approx(slider.max_value, 1.3), "Interface size goes from 80% to 130%") sm._scroll.ensure_control_visible(slider) await _frames() var factor := t.root.content_scale_factor var r := slider.get_global_rect() var from := r.get_center() var to := Vector2(r.end.x - 4.0, from.y) Touch.touch(0, from, true) Touch.drag(0, from, from + Vector2(40.0, 0.0)) Touch.drag(0, from + Vector2(40.0, 0.0), to) t.check(slider.value > 1.2 and is_equal_approx(t.root.content_scale_factor, factor) and main.settings.interface_size == 1.0, "dragging Interface size (to %d%%) doesn't rescale yet" % roundi(slider.value * 100.0)) Touch.touch(0, to, false) t.check(is_equal_approx(main.settings.interface_size, slider.value) and is_equal_approx(t.root.content_scale_factor, MobilePort.ui_scale(slider.value)) and t.root.content_scale_factor > factor * 1.15, "lifting the finger applies it: ×%.2f, was ×%.2f" % [t.root.content_scale_factor, factor]) await _frames() var safe := MobilePort.safe_rect(sm) _fit("at %d%%" % roundi(slider.value * 100.0), "settings' panel and buttons", [sm._panel, sm.back_button, sm.reset_button], safe, MobilePort.minimum_target(sm)) slider.value = 1.0 t.check(is_equal_approx(t.root.content_scale_factor, factor) and main.settings.interface_size == 1.0, "a key or a set value applies at once (back to 100%)") await _frames() func _reset_phone() -> void: var sm := main.settings_menu var s := main.settings s.move_dead_zone = 0.5 s.aim_dead_zone = 0.6 s.fullscreen = true s.vsync = false s.pixel_size = 3 s.volume["Music"] = 0.2 s.interface_size = 1.0 # (the canvas stays; the reset of the size itself is checked on desktop's side) s.swap_sticks = true s.camera_distance = 18.0 s.haptics = false s.resolution_scale = 0.6 s.show_tips = false sm.reset_to_defaults() var fresh := GameSettings.new() t.check(s.volume["Music"] == fresh.volume["Music"] and not s.swap_sticks and s.camera_distance == FollowCamera.PHONE_DISTANCE and s.haptics and s.resolution_scale == fresh.resolution_scale and s.show_tips, "phone Reset to defaults resets what's shown (volumes, the touch settings, resolution, tips)") t.check(s.move_dead_zone == 0.5 and s.aim_dead_zone == 0.6 and s.fullscreen and not s.vsync and s.pixel_size == 3, "and leaves the hidden ones alone (dead zones, Fullscreen, VSync, pixel size)") _camera(FollowCamera.PHONE_DISTANCE, "and the camera goes back to 12 m") s.move_dead_zone = fresh.move_dead_zone s.aim_dead_zone = fresh.aim_dead_zone s.fullscreen = false s.vsync = true s.pixel_size = fresh.pixel_size s.camera_distance = 15.0 sm._load() main._on_settings_changed() func _haptics_phone() -> void: var sim := main.sim sim.intro.skip() # (the scarecrow can't be hit during the intro) var waited := 0.0 while sim.intro.busy() and waited < 10.0: sim.intro.step(DT) waited += DT var kit := sim.scarecrow t.check(kit.alive and not sim.intro.busy(), "(the intro skipped: the first morning)") var hp := kit.hp() t.check(main.settings.haptics and Scarecrow.haptics, "phones: Haptics on (the default) arms the buzz") var n := Scarecrow.buzzes kit.invulnerable_left = 0.0 t.check(kit.try_damage(1) and Scarecrow.buzzes == n + 1, "phones: a hit buzzes with Haptics on") t.check(not kit.try_damage(1) and Scarecrow.buzzes == n + 1, "a hit refused (invulnerable) doesn't") main.settings.haptics = false main._on_settings_changed() kit.invulnerable_left = 0.0 t.check(not Scarecrow.haptics and kit.try_damage(1) and Scarecrow.buzzes == n + 1, "with Haptics off a hit doesn't buzz") main.settings.haptics = true main._on_settings_changed() kit.invulnerable_left = 0.0 main.sim.campaign.state.scarecrow_hp = hp ## The settings file's touch section: saved, loaded, clamped, and a default when it's wrong. func _round_trip() -> void: var g := GameSettings.new() t.check(not g.swap_sticks and g.camera_distance == FollowCamera.PHONE_DISTANCE and g.haptics and g.interface_size == 1.0, "touch defaults: sticks as they are, the camera 12 m, Haptics on, Interface size 100%") g.swap_sticks = true g.camera_distance = 17.0 g.haptics = false g.interface_size = 1.15 g.save_to(ROUND_TRIP) var f := ConfigFile.new() f.load(ROUND_TRIP) t.check(f.get_value("touch", "swap_sticks") == true and f.get_value("touch", "camera_distance") == 17.0 and f.get_value("touch", "haptics") == false and is_equal_approx(f.get_value("touch", "interface_size"), 1.15), "they're saved under [touch]: %s" % [f.get_section_keys("touch")]) var back := GameSettings.load_from(ROUND_TRIP) t.check(back.swap_sticks and back.camera_distance == 17.0 and not back.haptics and is_equal_approx(back.interface_size, 1.15), "and load back") for bad: Array in [[30.0, 20.0, "too far: 20"], [2, 8.0, "too close: 8"], ["far", 12.0, "not a number: 12"], [NAN, 12.0, "NaN: 12"]]: f.set_value("touch", "camera_distance", bad[0]) f.save(ROUND_TRIP) t.check(GameSettings.load_from(ROUND_TRIP).camera_distance == bad[1], "a camera distance %s" % bad[2]) f.set_value("touch", "swap_sticks", "yes") f.set_value("touch", "haptics", 0) f.save(ROUND_TRIP) var odd := GameSettings.load_from(ROUND_TRIP) t.check(not odd.swap_sticks and odd.haptics, "Swap sticks and Haptics that aren't true/false load as the defaults (off, on)") f.erase_section("touch") f.save(ROUND_TRIP) var none := GameSettings.load_from(ROUND_TRIP) t.check(not none.swap_sticks and none.camera_distance == 12.0 and none.haptics and none.interface_size == 1.0, "a file without [touch] (from before) loads the defaults") func _desktop() -> void: t.check(t.root.content_scale_factor == 1.0 and not Scarecrow.haptics, "desktop: factor 1, and no buzz armed though Haptics is on") var kit := main.sim.scarecrow var n := Scarecrow.buzzes kit.invulnerable_left = 0.0 t.check(kit.try_damage(1) and Scarecrow.buzzes == n, "desktop: a hit doesn't buzz") kit.invulnerable_left = 0.0 var mm := main.main_menu t.check(mm._box.position == Vector2(110.0, 150.0) and mm._shade.offset_right == 700.0 and mm.new_button.custom_minimum_size == Vector2(380.0, 62.0) and mm._credits.autowrap_mode == TextServer.AUTOWRAP_OFF and mm._credits.offset_top == -60.0, "desktop main menu: the column at (110, 150), the shade 700 wide, 380x62 buttons, the credits as before") main.main_menu.settings_button.pressed.emit() await _frames() var sm := main.settings_menu var rows := _rows(sm) t.check(rows == DESKTOP_ROWS, "desktop settings: the same sections and rows as before (%s)" % ", ".join(rows)) var music := sm.controls["volume/Music"] as HSlider t.check(not (music is SettingsMenu.TouchSlider) and music.custom_minimum_size == Vector2(440.0, 32.0) and (music.get_parent().get_child(0) as Label).custom_minimum_size == Vector2(340.0, 0.0) and sm._scroll.custom_minimum_size == Vector2(980.0, 640.0) and sm.back_button.custom_minimum_size == Vector2(220.0, 54.0) and sm.reset_button.custom_minimum_size == Vector2(280.0, 54.0) and sm._title.get_theme_font_size(&"font_size") == 44 and sm.offset_left == 0.0 and sm.offset_bottom == 0.0 and sm._tall.is_empty(), "desktop settings: the same sizes (sliders 440x32, labels 340, the list 980x640, buttons 220 and 280 by 54)") var panel := sm._panel.get_global_rect() t.check(panel.get_center().distance_to(Vector2(960.0, 540.0)) <= 1.0, "desktop settings: centered (%s)" % panel) for key in ["interface_size", "swap_sticks", "camera_distance", "haptics"]: t.check(not sm.controls.has(key), "desktop settings: no %s" % key) var s := main.settings s.interface_size = 1.2 s.swap_sticks = true s.camera_distance = 18.0 s.haptics = false s.move_dead_zone = 0.5 sm.reset_to_defaults() t.check(is_equal_approx(s.interface_size, 1.2) and s.swap_sticks and s.camera_distance == 18.0 and not s.haptics, "desktop Reset to defaults leaves the touch settings alone") t.check(s.move_dead_zone == GameSettings.new().move_dead_zone, "and resets what's shown (the dead zone)") _camera(16.0, "desktop: the Camera distance setting never moves the camera") sm.back_button.pressed.emit() await _frames() var pm := main.pause_menu t.check(pm._side == null and pm.resume_button.get_parent() == pm._box and pm.resume_button.custom_minimum_size == Vector2(420.0, 56.0) and pm._assets[0].get_parent() is HBoxContainer and pm.offset_top == 0.0, "desktop pause menu: one column, 420x56 buttons, as before") var box := main.confirm t.check(box.yes_button.custom_minimum_size == Vector2(240.0, 54.0) and box.no_button.custom_minimum_size == Vector2(200.0, 54.0) and box.offset_left == 0.0 and box.offset_bottom == 0.0, "desktop question: 240x54 and 200x54 buttons, full screen")