## The game's menus (A10), in the paper-and-ink motifs of docs/STYLE.md: the welcome ## that offers the tutorial on the first launch (A12), the main menu, practice against bots, joining a server (with the LAN and list-server browser), ## settings (controls, mouse, gamepad, graphics, audio, display, accessibility), the pause menu and the results. ## ## Menus only edit `settings` and say what the player asked for through signals; the ## program (Main) starts and leaves matches. Every screen can be driven from the ## keyboard or a gamepad: each grabs focus on its first control when shown, the arrows ## or the D-pad move it, and Escape, or East or Start on the pad, goes back (A13). ## show_screen() and the buttons' `pressed` signals are what the UI test drives. class_name Menus extends Control signal practice_requested(bots: int, difficulty: int, team_size: int) signal tutorial_requested signal join_requested(host: String, port: int, player_name: String) signal resume_requested signal leave_requested signal quit_requested signal settings_changed const SCREENS: Array[String] = ["welcome", "main", "practice", "join", "settings", "pause", "results"] const PANEL_WIDTH: float = 560.0 const FONT_TITLE: int = 40 const FONT_HEADING: int = 24 const FONT_BODY: int = 17 const FONT_SMALL: int = 14 ## Seconds a server search listens for answers. const SEARCH_SECONDS: float = 2.0 var settings: GameSettings = GameSettings.new() ## Where settings are saved; tests point it somewhere harmless. var settings_path: String = GameSettings.DEFAULT_PATH ## Screen name -> its panel. var screens: Dictionary = {} ## The screen shown, and the ones Back returns through. var current: String = "" var _history: Array[String] = [] ## Controls tab: the action waiting for a key, or "". var listening_for: String = "" var _binding_buttons: Dictionary = {} var _binding_note: Label ## Practice. var _bots: SpinBox var _difficulty: OptionButton var _mode: OptionButton ## Join. var _name: LineEdit var _address: LineEdit var _servers: ItemList var _found: Array[Dictionary] = [] var _join_note: Label var _browser: ServerBrowser = null var _search_left: float = 0.0 ## Settings. var _tabs: TabContainer var _sensitivity: HSlider var _aim_scale: HSlider var _invert: CheckButton var _quality: OptionButton var _print_pass: CheckButton var _volumes: Dictionary = {} var _window_mode: OptionButton var _vsync: CheckButton var _max_fps: OptionButton var _pad_speed: HSlider var _aim_assist: CheckButton var _vision: OptionButton var _ui_scale: OptionButton var _captions: CheckButton var _reduce_motion: CheckButton ## Results. var _results_title: Label var _results_body: Label ## The backdrop drawn behind the menus when no match is showing. var backdrop: MenuBackdrop ## Over a match, a wash of ink instead, so the match shows through. var shade: ColorRect ## True while a match is being played under the menus (AppShell sets it). var over_match: bool = false: set(value): over_match = value backdrop.visible = not value shade.visible = value func _init() -> void: name = "Menus" PadInput.install_menu_actions() set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) theme = MenuTheme.make() backdrop = MenuBackdrop.new() backdrop.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) add_child(backdrop) shade = ColorRect.new() shade.color = Color(Palette.INK, 0.45) shade.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) shade.mouse_filter = Control.MOUSE_FILTER_IGNORE shade.visible = false add_child(shade) _build_welcome() _build_main() _build_practice() _build_join() _build_settings() _build_pause() _build_results() for screen: String in screens: (screens[screen] as Control).visible = false ## Puts `with` in the menus and refreshes every control from it. func use_settings(with: GameSettings, path: String = GameSettings.DEFAULT_PATH) -> void: settings = with settings_path = path _refresh_controls() ## Shows `screen`, remembering the one before for Back. `remember` false replaces ## the history (the main, pause and results screens start afresh). func show_screen(screen: String, remember: bool = true) -> void: assert(screens.has(screen), "no screen called %s" % screen) if remember and not current.is_empty() and current != screen: _history.append(current) elif not remember: _history.clear() if not current.is_empty(): (screens[current] as Control).visible = false current = screen listening_for = "" visible = true var panel: Control = screens[screen] panel.visible = true if screen == "settings" or screen == "practice" or screen == "join": _refresh_controls() if is_inside_tree(): first_focus(screen).grab_focus() ## Back a screen; from the first one, the pause menu resumes and others stay. func back() -> void: if not listening_for.is_empty(): listening_for = "" _binding_note.text = "Left as it was." _refresh_bindings() return if current == "settings": save_settings() if _history.is_empty(): if current == "pause": resume_requested.emit() return var previous: String = _history.pop_back() (screens[current] as Control).visible = false current = "" show_screen(previous) ## Hides every screen (a match is being played). func close() -> void: if not current.is_empty(): (screens[current] as Control).visible = false current = "" _history.clear() listening_for = "" visible = false ## The control a screen focuses first. func first_focus(screen: String) -> Control: var panel: Control = screens[screen] return panel.get_meta("first") as Control ## The buttons on a screen, by their text, for tests and for keyboard focus order. func buttons_of(screen: String) -> Dictionary: var found: Dictionary = {} _collect_buttons(screens[screen] as Node, found) return found ## Shows the results of a match: `place` (0 when unknown), out of `total`, with ## `eliminations`, and the last lines of the feed. func show_results(place: int, total: int, eliminations: int, lines: Array[String]) -> void: if place == 1: _results_title.text = "Last on dry ground" elif place > 0: _results_title.text = "Placed %d of %d" % [place, total] else: _results_title.text = "The match is over" var body: Array[String] = ["Eliminations: %d" % eliminations] if not lines.is_empty(): body.append("") body.append_array(lines) _results_body.text = "\n".join(body) show_screen("results", false) func save_settings() -> Error: var error: Error = settings.save(settings_path) settings_changed.emit() return error func _process(delta: float) -> void: if _browser == null: return _browser.poll() _search_left -= delta if _search_left <= 0.0: _finish_search() func _unhandled_input(event: InputEvent) -> void: if not visible or current.is_empty(): return if not listening_for.is_empty(): var code: int = KeyBindings.code_of_event(event) var pad: InputEventJoypadButton = event as InputEventJoypadButton if pad != null and pad.pressed and (pad.button_index == JOY_BUTTON_B or pad.button_index == JOY_BUTTON_START): back() get_viewport().set_input_as_handled() elif code == KEY_ESCAPE: back() get_viewport().set_input_as_handled() elif code != 0: try_bind(listening_for, code) get_viewport().set_input_as_handled() return if event.is_action_pressed("ui_cancel"): back() get_viewport().set_input_as_handled() ## Starts waiting for the next key or mouse button for `action`. func listen_for(action: String) -> void: listening_for = action (_binding_buttons[action] as Button).text = "Press a key..." _binding_note.text = "Press the new key or mouse button for %s, or Escape to leave it." % KeyBindings.label_of(action) ## Binds `action` to `code`, saying why not when it can't. Returns bind()'s answer. func try_bind(action: String, code: int) -> String: var answer: String = settings.bindings.bind(action, code) listening_for = "" if answer.is_empty(): _binding_note.text = "%s: %s." % [KeyBindings.label_of(action), KeyBindings.describe(code)] save_settings() elif answer == "reserved": _binding_note.text = "%s is kept for the menus." % KeyBindings.describe(code) elif KeyBindings.has_action(answer): _binding_note.text = "%s is already used for %s. Change that first." % [KeyBindings.describe(code), KeyBindings.label_of(answer)] else: _binding_note.text = "That can't be bound." _refresh_bindings() return answer # --- Building the screens ------------------------------------------------------------ func _panel(screen: String, title: String) -> VBoxContainer: var panel: PanelContainer = PanelContainer.new() panel.name = screen.capitalize() panel.set_anchors_and_offsets_preset(Control.PRESET_CENTER) panel.custom_minimum_size = Vector2(PANEL_WIDTH, 0.0) panel.grow_horizontal = Control.GROW_DIRECTION_BOTH panel.grow_vertical = Control.GROW_DIRECTION_BOTH add_child(panel) var column: VBoxContainer = VBoxContainer.new() column.add_theme_constant_override("separation", 10) panel.add_child(column) var heading: Label = Label.new() heading.text = title heading.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER heading.add_theme_font_size_override("font_size", FONT_TITLE if screen == "main" else FONT_HEADING) column.add_child(heading) column.add_child(MenuTheme.rope()) screens[screen] = panel return column func _button(column: Container, text: String, action: Callable) -> Button: var button: Button = Button.new() button.text = text button.pressed.connect(action) column.add_child(button) var panel: Control = column while panel != null and not screens.values().has(panel): panel = panel.get_parent() as Control if panel != null and not panel.has_meta("first"): panel.set_meta("first", button) return button func _row(column: Container, label_text: String, control: Control) -> void: var row: HBoxContainer = HBoxContainer.new() row.add_theme_constant_override("separation", 12) var label: Label = Label.new() label.text = label_text label.custom_minimum_size = Vector2(200.0, 0.0) row.add_child(label) control.size_flags_horizontal = Control.SIZE_EXPAND_FILL row.add_child(control) column.add_child(row) ## A row with a slider and its value beside it, as `format` % value (or a percentage ## when `percent`). func _slider_row(column: Container, label_text: String, slider: HSlider, percent: bool = false) -> void: var holder: HBoxContainer = HBoxContainer.new() holder.add_theme_constant_override("separation", 10) slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL slider.size_flags_vertical = Control.SIZE_SHRINK_CENTER holder.add_child(slider) var readout: Label = Label.new() readout.custom_minimum_size = Vector2(52.0, 0.0) readout.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT holder.add_child(readout) var show: Callable = func(value: float) -> void: readout.text = ("%d%%" % roundi(value * 100.0)) if percent else ("%.2f" % value) slider.value_changed.connect(show) slider.set_meta("readout", show) _row(column, label_text, holder) func _note(column: Container) -> Label: var label: Label = Label.new() label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART label.add_theme_font_size_override("font_size", FONT_SMALL) label.custom_minimum_size = Vector2(PANEL_WIDTH - 60.0, 0.0) column.add_child(label) return label func _build_main() -> void: var column: VBoxContainer = _panel("main", "TIDEWALL") var motto: Label = Label.new() motto.text = "The sea is rising. Build high, hold your ground." motto.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER motto.add_theme_font_size_override("font_size", FONT_SMALL) column.add_child(motto) var fallback: String = RendererCheck.fallback_notice() if not fallback.is_empty(): var notice: Label = Label.new() notice.name = "RendererNotice" notice.text = fallback notice.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART notice.custom_minimum_size = Vector2(460.0, 0.0) notice.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER notice.add_theme_font_size_override("font_size", FONT_SMALL) notice.add_theme_color_override("font_color", Palette.OCHRE_RED) column.add_child(notice) _button(column, "Practice against bots", func() -> void: show_screen("practice")) _button(column, "Tutorial", _start_tutorial) _button(column, "Join a server", func() -> void: show_screen("join")) _button(column, "Settings", func() -> void: show_screen("settings")) _button(column, "Quit", func() -> void: quit_requested.emit()) var build: Label = Label.new() build.name = "Build" build.text = "Version " + BuildInfo.describe() build.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER build.add_theme_font_size_override("font_size", FONT_SMALL) build.modulate.a = 0.7 column.add_child(build) ## The first launch (A12): the tutorial, or straight on. Either answer is remembered, ## and the tutorial stays on the main menu. func _build_welcome() -> void: var column: VBoxContainer = _panel("welcome", "Welcome aboard") var note: Label = _note(column) note.text = "New to Tidewall? A short tutorial on an island of your own shows you how to drop, gather, build, fight and keep ahead of the tide. It takes a few minutes, and you can leave it whenever you like from the pause menu." _button(column, "Start the tutorial", _start_tutorial) _button(column, "Not now", func() -> void: settings.tutorial_offered = true save_settings() show_screen("main", false)) var later: Label = _note(column) later.text = "The tutorial is always on the main menu." later.modulate.a = 0.7 func _start_tutorial() -> void: settings.tutorial_offered = true save_settings() tutorial_requested.emit() func _build_practice() -> void: var column: VBoxContainer = _panel("practice", "Practice") _bots = SpinBox.new() _bots.min_value = 1 _bots.max_value = Tuning.SOLO_PLAYERS - 1 _bots.step = 1 _row(column, "Bots", _bots) _difficulty = OptionButton.new() _difficulty.add_item("Mixed", 0) for index: int in Tuning.BOT_DIFFICULTIES.size(): _difficulty.add_item(String(Tuning.BOT_DIFFICULTIES[index]["name"]).capitalize(), index + 1) _row(column, "Bot skill", _difficulty) _mode = OptionButton.new() _mode.add_item("Solo", 1) _mode.add_item("Duos, with a bot crewmate", Tuning.DUO_TEAM_SIZE) _row(column, "Crew", _mode) _button(column, "Set out", _start_practice) _button(column, "Back", back) func _start_practice() -> void: settings.practice_bots = int(_bots.value) settings.practice_difficulty = _difficulty.selected - 1 settings.practice_team_size = _mode.get_item_id(_mode.selected) save_settings() practice_requested.emit(settings.practice_bots, settings.practice_difficulty, settings.practice_team_size) func _build_join() -> void: var column: VBoxContainer = _panel("join", "Join a server") _name = LineEdit.new() _name.max_length = GameSettings.MAX_NAME_LENGTH _name.placeholder_text = ClientConfig.DEFAULT_NAME _row(column, "Your name", _name) _address = LineEdit.new() _address.placeholder_text = "host or host:port" _address.text_submitted.connect(func(_text: String) -> void: _join_address()) _row(column, "Address", _address) _button(column, "Join this address", _join_address) screens["join"].set_meta("first", _address) _servers = ItemList.new() _servers.custom_minimum_size = Vector2(0.0, 150.0) _servers.item_activated.connect(_join_listed) column.add_child(_servers) _button(column, "Search the LAN", _search) _button(column, "Join the chosen server", func() -> void: var chosen: PackedInt32Array = _servers.get_selected_items() if chosen.is_empty(): _join_note.text = "Choose a server from the list first." else: _join_listed(chosen[0])) _join_note = _note(column) _button(column, "Back", back) ## Looks for servers on the LAN for a moment, then lists them. func _search() -> void: if _browser != null: return _browser = ServerBrowser.new() if _browser.open() != OK: _browser = null _join_note.text = "Couldn't open a network socket to search." return _browser.scan_lan() _search_left = SEARCH_SECONDS _join_note.text = "Searching..." func _finish_search() -> void: show_servers(_browser.sorted()) _browser.close() _browser = null ## Lists `found` (ServerBrowser.sorted()). func show_servers(found: Array[Dictionary]) -> void: _found = found _servers.clear() for server: Dictionary in found: var line: String = "%s %d/%d %s" % [server.get("name", "?"), int(server.get("players", 0)), int(server.get("max_players", 0)), server.get("source", "")] if not server.get("compatible", false): line += " (another version)" _servers.add_item(line) _servers.set_item_disabled(_servers.item_count - 1, not server.get("compatible", false)) _join_note.text = "%d found." % found.size() if not found.is_empty() else "No servers answered. Try an address." func _join_listed(index: int) -> void: if index < 0 or index >= _found.size() or not _found[index].get("compatible", false): return var server: Dictionary = _found[index] _join(String(server["address"]), int(server["port"])) func _join_address() -> void: var text: String = _address.text.strip_edges() if text.is_empty(): _join_note.text = "Type an address first." return var target: Dictionary = ServerConfig.parse_host_port(text, ServerConfig.DEFAULT_PORT) if target.is_empty(): _join_note.text = "That isn't an address: use host or host:port." return settings.last_server = text _join(String(target["host"]), int(target["port"])) func _join(host: String, port: int) -> void: settings.player_name = _name.text save_settings() join_requested.emit(host, port, settings.player_name) func _build_settings() -> void: var column: VBoxContainer = _panel("settings", "Settings") _tabs = TabContainer.new() _tabs.custom_minimum_size = Vector2(PANEL_WIDTH + 140.0, 420.0) column.add_child(_tabs) var controls_scroll: ScrollContainer = ScrollContainer.new() controls_scroll.name = "Controls" controls_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED controls_scroll.follow_focus = true _tabs.add_child(controls_scroll) var controls: VBoxContainer = VBoxContainer.new() controls.size_flags_horizontal = Control.SIZE_EXPAND_FILL controls_scroll.add_child(controls) for action: Dictionary in KeyBindings.ACTIONS: var id: String = action["id"] var button: Button = Button.new() button.pressed.connect(listen_for.bind(id)) _binding_buttons[id] = button _row(controls, String(action["label"]), button) var reset: Button = Button.new() reset.text = "Put every key back" reset.pressed.connect(func() -> void: settings.bindings.reset() _binding_note.text = "Every key is back to its default." _refresh_bindings() save_settings()) controls.add_child(reset) var mouse: VBoxContainer = _tab("Mouse") _sensitivity = _slider(InputSettings.MIN_SENSITIVITY, 4.0, 0.05) _sensitivity.value_changed.connect(func(value: float) -> void: settings.mouse.mouse_sensitivity = value) _slider_row(mouse, "Look speed", _sensitivity) _aim_scale = _slider(0.1, 2.0, 0.05) _aim_scale.value_changed.connect(func(value: float) -> void: settings.mouse.aim_sensitivity_scale = value) _slider_row(mouse, "Speed while aiming", _aim_scale) _invert = CheckButton.new() _invert.toggled.connect(func(on: bool) -> void: settings.mouse.invert_y = on) _row(mouse, "Invert up and down", _invert) var pad_scroll: ScrollContainer = ScrollContainer.new() pad_scroll.name = "Gamepad" pad_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED pad_scroll.follow_focus = true _tabs.add_child(pad_scroll) var pad_tab: VBoxContainer = VBoxContainer.new() pad_tab.size_flags_horizontal = Control.SIZE_EXPAND_FILL pad_tab.add_theme_constant_override("separation", 10) pad_scroll.add_child(pad_tab) _pad_speed = _slider(InputSettings.MIN_PAD_SENSITIVITY, InputSettings.MAX_PAD_SENSITIVITY, 0.05) _pad_speed.value_changed.connect(func(value: float) -> void: settings.mouse.pad_sensitivity = value) _slider_row(pad_tab, "Stick look speed", _pad_speed) _aim_assist = CheckButton.new() _aim_assist.toggled.connect(func(on: bool) -> void: settings.mouse.aim_assist = on) _row(pad_tab, "Aim assist", _aim_assist) var assist_note: Label = _note(pad_tab) assist_note.text = "Aim assist slows the stick across an opponent in plain sight and, while aiming, eases towards them. It never acts on the mouse. Speed while aiming and Invert (Mouse tab) apply to the stick too." # The layout in two columns of what and which. var layout: GridContainer = GridContainer.new() layout.columns = 4 layout.add_theme_constant_override("h_separation", 14) layout.add_theme_constant_override("v_separation", 2) pad_tab.add_child(layout) for pair: Array in PadInput.LAYOUT: for index: int in 2: var cell: Label = Label.new() cell.text = String(pair[index]) cell.add_theme_font_size_override("font_size", FONT_SMALL) if index == 1: cell.add_theme_color_override("font_color", Palette.GILT_DEEP) layout.add_child(cell) var graphics: VBoxContainer = _tab("Graphics") _quality = OptionButton.new() for index: int in GameSettings.QUALITY_NAMES.size(): _quality.add_item(GameSettings.QUALITY_NAMES[index], index) _quality.item_selected.connect(func(index: int) -> void: settings.quality = index) _row(graphics, "Quality", _quality) _print_pass = CheckButton.new() _print_pass.toggled.connect(func(on: bool) -> void: settings.print_pass = on) _row(graphics, "Woodcut ink lines", _print_pass) var audio: VBoxContainer = _tab("Audio") for bus: Array in [["master", "Everything"], ["music", "Music"], ["effects", "Effects"]]: var slider: HSlider = _slider(0.0, 1.0, 0.05) var key: String = bus[0] slider.value_changed.connect(func(value: float) -> void: settings.set(key + "_volume", value)) _volumes[key] = slider _slider_row(audio, bus[1], slider, true) var display: VBoxContainer = _tab("Display") _window_mode = OptionButton.new() for index: int in GameSettings.WINDOW_MODES.size(): _window_mode.add_item(GameSettings.WINDOW_MODES[index], index) _window_mode.item_selected.connect(func(index: int) -> void: settings.window_mode = index) _row(display, "Window", _window_mode) _vsync = CheckButton.new() _vsync.toggled.connect(func(on: bool) -> void: settings.vsync = on) _row(display, "Vertical sync", _vsync) _max_fps = OptionButton.new() for cap: int in GameSettings.FRAME_CAPS: _max_fps.add_item("No limit" if cap == 0 else "%d" % cap, cap) _max_fps.item_selected.connect(func(index: int) -> void: settings.max_fps = GameSettings.FRAME_CAPS[index]) _row(display, "Frame limit", _max_fps) var access: VBoxContainer = _tab("Access") _vision = OptionButton.new() for index: int in Palette.VISION_NAMES.size(): _vision.add_item(Palette.VISION_NAMES[index], index) _vision.item_selected.connect(func(index: int) -> void: settings.vision = index save_settings()) _row(access, "Colour vision", _vision) _ui_scale = OptionButton.new() for index: int in GameSettings.UI_SCALES.size(): _ui_scale.add_item("%d%%" % roundi(GameSettings.UI_SCALES[index] * 100.0), index) _ui_scale.item_selected.connect(func(index: int) -> void: settings.ui_scale = GameSettings.UI_SCALES[index] save_settings()) _row(access, "Interface size", _ui_scale) _captions = CheckButton.new() _captions.toggled.connect(func(on: bool) -> void: settings.captions = on save_settings()) _row(access, "Captions for sounds", _captions) _reduce_motion = CheckButton.new() _reduce_motion.toggled.connect(func(on: bool) -> void: settings.reduce_motion = on save_settings()) _row(access, "Reduce motion", _reduce_motion) var access_note: Label = _note(access) access_note.text = "Colour vision changes the build preview, danger marks and your own marks to colours told apart with that kind of colour blindness. Captions name the sounds that matter (the tide, gunfire, footsteps, building) and which way they came from. Reduce motion makes the zoom when aiming smaller and slower and the flash when you're hurt gentler." _binding_note = _note(column) _binding_note.text = "Choose an action to change its key." _tabs.tab_changed.connect(func(tab: int) -> void: _binding_note.visible = tab == 0) var done: Button = _button(column, "Back", back) screens["settings"].set_meta("first", _tabs.get_tab_bar()) done.name = "Back" func _tab(title: String) -> VBoxContainer: var column: VBoxContainer = VBoxContainer.new() column.name = title column.add_theme_constant_override("separation", 10) _tabs.add_child(column) return column func _slider(low: float, high: float, step: float) -> HSlider: var slider: HSlider = HSlider.new() slider.min_value = low slider.max_value = high slider.step = step slider.custom_minimum_size = Vector2(220.0, 24.0) return slider func _build_pause() -> void: var column: VBoxContainer = _panel("pause", "Paused") var note: Label = _note(column) note.text = "The match goes on while you're here." note.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER _button(column, "Back to the match", func() -> void: resume_requested.emit()) _button(column, "Settings", func() -> void: show_screen("settings")) _button(column, "Leave the match", func() -> void: leave_requested.emit()) func _build_results() -> void: var column: VBoxContainer = _panel("results", "Results") _results_title = Label.new() _results_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER _results_title.add_theme_font_size_override("font_size", FONT_HEADING) column.add_child(_results_title) _results_body = _note(column) _button(column, "Stay and watch", func() -> void: resume_requested.emit()) _button(column, "Back to the main menu", func() -> void: leave_requested.emit()) # --- Keeping controls in step with the settings ------------------------------------ func _refresh_controls() -> void: _bots.value = settings.practice_bots _difficulty.selected = settings.practice_difficulty + 1 _mode.selected = maxi(_mode.get_item_index(settings.practice_team_size), 0) _name.text = settings.player_name if _address.text.is_empty(): _address.text = settings.last_server _sensitivity.set_value_no_signal(settings.mouse.mouse_sensitivity) _aim_scale.set_value_no_signal(settings.mouse.aim_sensitivity_scale) _invert.set_pressed_no_signal(settings.mouse.invert_y) _quality.selected = settings.quality _print_pass.set_pressed_no_signal(settings.print_pass) (_volumes["master"] as HSlider).set_value_no_signal(settings.master_volume) (_volumes["music"] as HSlider).set_value_no_signal(settings.music_volume) (_volumes["effects"] as HSlider).set_value_no_signal(settings.effects_volume) _window_mode.selected = settings.window_mode _vsync.set_pressed_no_signal(settings.vsync) _max_fps.selected = maxi(GameSettings.FRAME_CAPS.find(settings.max_fps), 0) _pad_speed.set_value_no_signal(settings.mouse.pad_sensitivity) _aim_assist.set_pressed_no_signal(settings.mouse.aim_assist) _vision.selected = settings.vision _ui_scale.selected = maxi(GameSettings.UI_SCALES.find(settings.ui_scale), 0) _captions.set_pressed_no_signal(settings.captions) _reduce_motion.set_pressed_no_signal(settings.reduce_motion) for slider: HSlider in [_sensitivity, _aim_scale, _pad_speed, _volumes["master"], _volumes["music"], _volumes["effects"]]: (slider.get_meta("readout") as Callable).call(slider.value) _refresh_bindings() func _refresh_bindings() -> void: for action: String in _binding_buttons: (_binding_buttons[action] as Button).text = KeyBindings.describe(settings.bindings.code_of(action)) func _collect_buttons(node: Node, found: Dictionary) -> void: for child: Node in node.get_children(): var button: Button = child as Button if button != null and not (button is OptionButton) and not (button is CheckButton): found[button.text] = button _collect_buttons(child, found)