Lots of little tweaks and fixes

This commit is contained in:
2026-06-12 20:26:00 -05:00
parent 7fc1a4645c
commit 3d01fcce86
32 changed files with 570 additions and 160 deletions
+8
View File
@@ -3,6 +3,9 @@ class_name RootUI extends Control
@export var debugMenu:DebugMenu
@export var gameMenu:GameMenu
@export var pauseMenu:PauseMenu
@export var quitConfirmDialog:QuitConfirmDialog
@export var mainMenuConfirmDialog:ConfirmDialog
@export var modalBackdrop:ModalBackdrop
@export var chatBoxContainer:Control
func _enter_tree() -> void:
@@ -11,3 +14,8 @@ func _enter_tree() -> void:
func _exit_tree() -> void:
if UI.rootUi == self:
UI.rootUi = null
func _ready() -> void:
modalBackdrop.register(pauseMenu)
modalBackdrop.register(quitConfirmDialog)
modalBackdrop.register(mainMenuConfirmDialog)
+37 -7
View File
@@ -1,11 +1,15 @@
[gd_scene load_steps=5 format=3 uid="uid://baos0arpiskbp"]
[gd_scene load_steps=9 format=3 uid="uid://baos0arpiskbp"]
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://ui/RootUI.gd" id="1_son71"]
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://ui/pause/PauseMenu.tscn" id="2_atyu8"]
[ext_resource type="PackedScene" uid="uid://b38dr0wkix76t" path="res://ui/debugmenu/DebugMenu.tscn" id="4_u132g"]
[ext_resource type="PackedScene" uid="uid://bv5r2x9m4k7n1" path="res://ui/gamemenu/GameMenu.tscn" id="5_gmenu"]
[ext_resource type="PackedScene" path="res://ui/component/InteractIndicator.tscn" id="6_iind"]
[ext_resource type="Script" path="res://ui/component/ModalBackdrop.gd" id="7_mbdp"]
[ext_resource type="PackedScene" uid="uid://cqdf1x7m2canp" path="res://ui/component/QuitConfirmDialog.tscn" id="8_qcd"]
[ext_resource type="PackedScene" uid="uid://bmmc3x8n1d7qp" path="res://ui/component/MainMenuConfirmDialog.tscn" id="9_mmcd"]
[node name="RootUI" type="Control" node_paths=PackedStringArray("debugMenu", "gameMenu", "pauseMenu", "chatBoxContainer")]
[node name="RootUI" type="Control" node_paths=PackedStringArray("debugMenu", "gameMenu", "pauseMenu", "quitConfirmDialog", "mainMenuConfirmDialog", "modalBackdrop", "chatBoxContainer")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -17,6 +21,9 @@ script = ExtResource("1_son71")
debugMenu = NodePath("DebugMenu")
gameMenu = NodePath("GameMenu")
pauseMenu = NodePath("PauseMenu")
quitConfirmDialog = NodePath("QuitConfirmDialog")
mainMenuConfirmDialog = NodePath("MainMenuConfirmDialog")
modalBackdrop = NodePath("ModalBackdrop")
chatBoxContainer = NodePath("ChatBoxContainer")
metadata/_custom_type_script = "uid://dq3qyyayugt5l"
@@ -24,11 +31,6 @@ metadata/_custom_type_script = "uid://dq3qyyayugt5l"
visible = false
layout_mode = 1
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
visible = false
layout_mode = 1
process_mode = 3
[node name="GameMenu" parent="." instance=ExtResource("5_gmenu")]
visible = false
layout_mode = 1
@@ -41,3 +43,31 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="InteractIndicator" parent="ChatBoxContainer" instance=ExtResource("6_iind")]
[node name="ModalBackdrop" type="ColorRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
process_mode = 3
color = Color(0, 0, 0, 0.5)
script = ExtResource("7_mbdp")
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
visible = false
layout_mode = 1
process_mode = 3
[node name="QuitConfirmDialog" parent="." instance=ExtResource("8_qcd")]
visible = false
layout_mode = 1
[node name="MainMenuConfirmDialog" parent="." instance=ExtResource("9_mmcd")]
visible = false
layout_mode = 1
+22
View File
@@ -1,6 +1,7 @@
extends Node
var rootUi:RootUI = null
var interactIndicator:InteractIndicator = null
# True whenever any dialogue resource is being processed by DialogueManager.
# Driven by DialogueManager.dialogue_started / dialogue_ended signals.
@@ -19,6 +20,9 @@ func _onDialogueStarted(_resource:DialogueResource) -> void:
func _onDialogueEnded(_resource:DialogueResource) -> void:
dialogueActive = false
var INTERACT_INDICATOR:InteractIndicator:
get(): return interactIndicator
var chatBoxContainer:Control:
get():
if rootUi:
@@ -42,3 +46,21 @@ var PAUSE_MENU:PauseMenu:
if rootUi:
return rootUi.pauseMenu
return null
var QUIT_DIALOG:QuitConfirmDialog:
get():
if rootUi:
return rootUi.quitConfirmDialog
return null
var MAIN_MENU_DIALOG:ConfirmDialog:
get():
if rootUi:
return rootUi.mainMenuConfirmDialog
return null
var BACKDROP:ModalBackdrop:
get():
if rootUi:
return rootUi.modalBackdrop
return null
+30
View File
@@ -0,0 +1,30 @@
class_name ConfirmDialog extends ClosableMenu
signal confirmed
@export var btnYes:Button
@export var btnNo:Button
func _ready() -> void:
close()
btnYes.pressed.connect(_onYes)
btnNo.pressed.connect(close)
btnYes.focus_neighbor_top = btnNo.get_path()
btnYes.focus_neighbor_bottom = btnNo.get_path()
btnNo.focus_neighbor_top = btnYes.get_path()
btnNo.focus_neighbor_bottom = btnYes.get_path()
func _onYes() -> void:
close()
confirmed.emit()
func open() -> void:
super.open()
btnNo.grab_focus()
func _unhandled_input(event:InputEvent) -> void:
if !isOpen:
return
if event.is_action_pressed("ui_cancel"):
close()
get_viewport().set_input_as_handled()
+7 -19
View File
@@ -5,8 +5,7 @@ const SCENE:PackedScene = preload("res://ui/component/DialogueTextbox.tscn")
enum AdvancementMode { PLAYER, TIMED }
const LINES_PER_PAGE:int = 4
const CHARS_PER_SECOND:float = 20.0
const SPEEDUP_MULTIPLIER:float = 4.0
const CHARS_PER_SECOND:float = 24.0
const PAUSE_COMMA:float = 0.15
const PAUSE_SENTENCE:float = 0.4
const PAUSE_ELLIPSIS_DOT:float = 0.3
@@ -24,7 +23,6 @@ var _pauseTimer:float = 0.0
var _autoAdvanceTimer:float = 0.0
var _isRevealing:bool = false
var _isWaitingForInput:bool = false
var _hasLetGoOfInteract:bool = true
var _advancementMode:AdvancementMode = AdvancementMode.PLAYER
@onready var _speakerLabel:Label = $VBoxContainer/SpeakerLabel
@@ -68,7 +66,6 @@ func setup(line:DialogueLine, entity:Entity, mode:AdvancementMode = AdvancementM
_autoAdvanceTimer = 0.0
_isRevealing = true
_isWaitingForInput = false
_hasLetGoOfInteract = !Input.is_action_pressed("interact")
_updateWorldPosition()
visible = true
@@ -85,9 +82,10 @@ func _process(delta:float) -> void:
return
_updateWorldPosition()
_advanceIndicator.visible = _isWaitingForInput
if _isWaitingForInput:
_advanceIndicator.modulate.a = 0.5 + 0.5 * sin(Time.get_ticks_msec() / 300.0)
else:
_advanceIndicator.modulate.a = 0.0
if _isRevealing:
_processReveal(delta)
@@ -119,16 +117,13 @@ func _buildPreWrappedText(parsed:String) -> String:
return result
func _processReveal(delta:float) -> void:
if Input.is_action_just_released("interact"):
_hasLetGoOfInteract = true
var speedMult:float = SPEEDUP_MULTIPLIER if (_hasLetGoOfInteract and Input.is_action_pressed("interact")) else 1.0
var scaledDelta:float = delta * SETTINGS.textSpeed
if _pauseTimer > 0.0:
_pauseTimer -= delta * speedMult
_pauseTimer -= scaledDelta
return
_revealTimer += delta * speedMult
_revealTimer += scaledDelta
while _revealTimer >= 1.0 / CHARS_PER_SECOND:
_revealTimer -= 1.0 / CHARS_PER_SECOND
@@ -185,12 +180,6 @@ func _onRevealComplete() -> void:
_isWaitingForInput = true
func _processAdvanceInput() -> void:
if Input.is_action_just_released("interact"):
_hasLetGoOfInteract = true
if not _hasLetGoOfInteract:
return
if Input.is_action_just_pressed("interact"):
_advance()
@@ -200,8 +189,7 @@ func _processAutoAdvance(delta:float) -> void:
_advance()
func _advance() -> void:
_advanceIndicator.visible = false
_advanceIndicator.modulate.a = 1.0
_advanceIndicator.modulate.a = 0.0
var totalLines:int = _parsedText.count("\n") + 1
var hasMorePages:bool = _startLine + _linesPerPage < totalLines
if hasMorePages:
+1 -1
View File
@@ -28,6 +28,6 @@ autowrap_mode = 3
[node name="AdvanceIndicator" type="Label" parent="VBoxContainer"]
layout_mode = 2
modulate = Color(1, 1, 1, 0)
text = "▼"
horizontal_alignment = 2
visible = false
+56
View File
@@ -0,0 +1,56 @@
class_name InteractIndicator extends PanelContainer
var _entity:Entity = null
func _enter_tree() -> void:
UI.interactIndicator = self
func _exit_tree() -> void:
if UI.interactIndicator == self:
UI.interactIndicator = null
func _ready() -> void:
visible = false
DialogueManager.dialogue_started.connect(_onDialogueStarted)
DialogueManager.dialogue_ended.connect(_onDialogueEnded)
func setEntity(entity:Entity) -> void:
if is_instance_valid(_entity):
_entity.tree_exiting.disconnect(_onEntityExiting)
_entity = entity
_entity.tree_exiting.connect(_onEntityExiting)
visible = _canShow()
if visible:
updateWorldPosition()
func clear() -> void:
if is_instance_valid(_entity):
_entity.tree_exiting.disconnect(_onEntityExiting)
_entity = null
visible = false
func _canShow() -> bool:
return _entity != null and not UI.dialogueActive
func _onEntityExiting() -> void:
_entity = null
visible = false
func _onDialogueStarted(_resource:DialogueResource) -> void:
visible = false
func _onDialogueEnded(_resource:DialogueResource) -> void:
visible = _canShow()
if visible:
updateWorldPosition()
func updateWorldPosition() -> void:
var camera:Camera3D = get_viewport().get_camera_3d()
if camera == null:
return
var worldPos:Vector3 = _entity.global_position + Vector3(0, 2.5, 0)
var screenPos:Vector2 = camera.unproject_position(worldPos)
var viewportSize:Vector2 = get_viewport().get_visible_rect().size
position = screenPos - size * 0.5
position.x = clamp(position.x, 0.0, viewportSize.x - size.x)
position.y = clamp(position.y, 0.0, viewportSize.y - size.y)
+1
View File
@@ -0,0 +1 @@
uid://xrcb2e7jwlm0
+13
View File
@@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Theme" path="res://ui/UI Theme.tres" id="1"]
[ext_resource type="Script" path="res://ui/component/InteractIndicator.gd" id="2"]
[node name="InteractIndicator" type="PanelContainer"]
mouse_filter = 2
theme = ExtResource("1")
script = ExtResource("2")
[node name="Label" type="Label" parent="."]
layout_mode = 2
text = "INTERACT"
+38
View File
@@ -0,0 +1,38 @@
[gd_scene load_steps=2 format=3 uid="uid://bmmc3x8n1d7qp"]
[ext_resource type="Script" path="res://ui/component/ConfirmDialog.gd" id="1_mmcd"]
[node name="MainMenuConfirmDialog" type="Control" node_paths=PackedStringArray("btnYes", "btnNo")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
process_mode = 3
script = ExtResource("1_mmcd")
btnYes = NodePath("VBoxContainer/Yes")
btnNo = NodePath("VBoxContainer/No")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "Return to main menu?"
horizontal_alignment = 1
[node name="Yes" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Yes"
[node name="No" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "No"
+48
View File
@@ -0,0 +1,48 @@
class_name ModalBackdrop extends ColorRect
# Tracks which overlays are currently open. Each entry must be a direct sibling
# (child of the same parent). The backdrop repositions itself in the scene tree
# to sit immediately below whichever open overlay has the highest tree index,
# so only one backdrop is ever visible regardless of how many overlays are open.
var _openOverlays:Array[Control] = []
func _ready() -> void:
visible = false
func register(overlay:Control) -> void:
assert(overlay.get_parent() == get_parent(), "ModalBackdrop: overlay must be a sibling")
assert(overlay.has_signal("opened") and overlay.has_signal("closed"),
"ModalBackdrop: overlay must have opened/closed signals")
overlay.connect("opened", func(): _onOpened(overlay))
overlay.connect("closed", func(): _onClosed(overlay))
func _onOpened(overlay:Control) -> void:
if overlay not in _openOverlays:
_openOverlays.append(overlay)
_reposition()
func _onClosed(overlay:Control) -> void:
_openOverlays.erase(overlay)
_reposition()
func _reposition() -> void:
if _openOverlays.is_empty():
visible = false
return
visible = true
var top := _topOverlay()
var topIdx := top.get_index()
var myIdx := get_index()
if myIdx == topIdx - 1:
return
if myIdx < topIdx:
get_parent().move_child(self, topIdx - 1)
else:
get_parent().move_child(self, topIdx)
func _topOverlay() -> Control:
var top:Control = _openOverlays[0]
for overlay in _openOverlays:
if overlay.get_index() > top.get_index():
top = overlay
return top
+5
View File
@@ -0,0 +1,5 @@
class_name QuitConfirmDialog extends ConfirmDialog
func _ready() -> void:
super._ready()
confirmed.connect(func(): get_tree().quit())
+1
View File
@@ -0,0 +1 @@
uid://deov3ob0lojyo
+38
View File
@@ -0,0 +1,38 @@
[gd_scene load_steps=2 format=3 uid="uid://cqdf1x7m2canp"]
[ext_resource type="Script" path="res://ui/component/QuitConfirmDialog.gd" id="1_qcd"]
[node name="QuitConfirmDialog" type="Control" node_paths=PackedStringArray("btnYes", "btnNo")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
process_mode = 3
script = ExtResource("1_qcd")
btnYes = NodePath("VBoxContainer/Yes")
btnNo = NodePath("VBoxContainer/No")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "Quit to desktop?"
horizontal_alignment = 1
[node name="Yes" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Yes"
[node name="No" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "No"
+9
View File
@@ -2,12 +2,14 @@ class_name MainMenu extends Control
@export var btnNewGame:Button
@export var btnSettings:Button
@export var btnQuit:Button
@export var settingsMenu:ClosableMenu
@export_file("*.tscn") var newGameScene:String
func _ready() -> void:
btnNewGame.pressed.connect(onNewGamePressed)
btnSettings.pressed.connect(onSettingsPressed)
btnQuit.pressed.connect(_onQuitPressed)
settingsMenu.opened.connect(_onSettingsOpened)
settingsMenu.closed.connect(_onSettingsClosed)
btnNewGame.grab_focus()
@@ -26,6 +28,13 @@ func _unhandled_input(event:InputEvent) -> void:
settingsMenu.close()
get_viewport().set_input_as_handled()
func _onQuitPressed() -> void:
UI.QUIT_DIALOG.closed.connect(_onQuitDialogClosed, CONNECT_ONE_SHOT)
UI.QUIT_DIALOG.open()
func _onQuitDialogClosed() -> void:
btnQuit.grab_focus()
func onNewGamePressed() -> void:
SCENE.setScene(SceneSingleton.SceneType.OVERWORLD)
OVERWORLD.mapChange(newGameScene, "PlayerSpawnPoint")
+6 -1
View File
@@ -4,7 +4,7 @@
[ext_resource type="Script" uid="uid://bcjfv6dw0ugvo" path="res://ui/component/ClosableMenu.gd" id="2_f3vro"]
[ext_resource type="PackedScene" uid="uid://d3f31lli1ahts" path="res://ui/settings/SettingsMenu.tscn" id="3_44i87"]
[node name="Main Menu" type="Control" node_paths=PackedStringArray("btnNewGame", "btnSettings", "settingsMenu")]
[node name="Main Menu" type="Control" node_paths=PackedStringArray("btnNewGame", "btnSettings", "btnQuit", "settingsMenu")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -14,6 +14,7 @@ grow_vertical = 2
script = ExtResource("1_vp3lc")
btnNewGame = NodePath("VBoxContainer/NewGame")
btnSettings = NodePath("VBoxContainer/Settings")
btnQuit = NodePath("VBoxContainer/Quit")
settingsMenu = NodePath("MainMenuSettings")
newGameScene = "uid://d0ywgijpuqy0r"
metadata/_custom_type_script = "uid://btfeuku41py2b"
@@ -35,6 +36,10 @@ text = "New Game"
layout_mode = 2
text = "Settings"
[node name="Quit" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Quit Game"
[node name="MainMenuSettings" type="Control" parent="."]
visible = false
layout_mode = 1
+15 -22
View File
@@ -2,44 +2,37 @@ class_name PauseMain extends VBoxContainer
signal resumeRequested
signal settingsRequested
signal mainMenuRequested
signal quitRequested
@export var btnResume:Button
@export var btnSettings:Button
@export var btnMainMenu:Button
@export var btnQuit:Button
@export var mainButtons:VBoxContainer
@export var confirmQuit:VBoxContainer
@export var btnQuitConfirm:Button
@export var btnQuitCancel:Button
func _ready() -> void:
visible = false
btnResume.pressed.connect(resumeRequested.emit)
btnSettings.pressed.connect(settingsRequested.emit)
btnMainMenu.pressed.connect(mainMenuRequested.emit)
btnQuit.pressed.connect(_showConfirm)
btnQuitConfirm.pressed.connect(quitRequested.emit)
btnQuitCancel.pressed.connect(cancelConfirm)
btnMainMenu.pressed.connect(_showMainMenuConfirm)
btnQuit.pressed.connect(_showQuitConfirm)
UI.QUIT_DIALOG.closed.connect(_onQuitDialogClosed)
UI.MAIN_MENU_DIALOG.closed.connect(_onMainMenuDialogClosed)
func _showConfirm() -> void:
mainButtons.visible = false
confirmQuit.visible = true
btnQuitCancel.grab_focus()
func _showQuitConfirm() -> void:
UI.QUIT_DIALOG.open()
func cancelConfirm() -> void:
mainButtons.visible = true
confirmQuit.visible = false
btnQuit.grab_focus()
func _showMainMenuConfirm() -> void:
UI.MAIN_MENU_DIALOG.open()
func isConfirming() -> bool:
return confirmQuit.visible
func _onQuitDialogClosed() -> void:
if isOpen():
btnQuit.grab_focus()
func _onMainMenuDialogClosed() -> void:
if isOpen():
btnMainMenu.grab_focus()
func open() -> void:
visible = true
if isConfirming():
cancelConfirm()
btnResume.grab_focus()
func close() -> void:
+1 -22
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://c7kvg0jw6w340" path="res://ui/pause/PauseMain.gd" id="1_b5xfl"]
[node name="PauseMain" type="VBoxContainer" node_paths=PackedStringArray("btnResume", "btnSettings", "btnMainMenu", "btnQuit", "mainButtons", "confirmQuit", "btnQuitConfirm", "btnQuitCancel")]
[node name="PauseMain" type="VBoxContainer" node_paths=PackedStringArray("btnResume", "btnSettings", "btnMainMenu", "btnQuit")]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
@@ -16,10 +16,6 @@ btnResume = NodePath("MainButtons/Resume")
btnSettings = NodePath("MainButtons/Settings")
btnMainMenu = NodePath("MainButtons/MainMenu")
btnQuit = NodePath("MainButtons/Quit")
mainButtons = NodePath("MainButtons")
confirmQuit = NodePath("ConfirmQuit")
btnQuitConfirm = NodePath("ConfirmQuit/Yes")
btnQuitCancel = NodePath("ConfirmQuit/No")
[node name="Title" type="Label" parent="."]
layout_mode = 2
@@ -44,20 +40,3 @@ text = "Main Menu"
[node name="Quit" type="Button" parent="MainButtons"]
layout_mode = 2
text = "Quit Game"
[node name="ConfirmQuit" type="VBoxContainer" parent="."]
layout_mode = 2
visible = false
[node name="Label" type="Label" parent="ConfirmQuit"]
layout_mode = 2
text = "Quit to desktop?"
horizontal_alignment = 1
[node name="Yes" type="Button" parent="ConfirmQuit"]
layout_mode = 2
text = "Yes"
[node name="No" type="Button" parent="ConfirmQuit"]
layout_mode = 2
text = "No"
+16 -11
View File
@@ -1,5 +1,8 @@
class_name PauseMenu extends Control
signal opened
signal closed
@export var MAIN:PauseMain
@export var settingsPanel:PauseSettings
@@ -7,8 +10,7 @@ func _ready() -> void:
close()
MAIN.resumeRequested.connect(close)
MAIN.settingsRequested.connect(_openSettings)
MAIN.mainMenuRequested.connect(_goToMainMenu)
MAIN.quitRequested.connect(func(): get_tree().quit())
UI.MAIN_MENU_DIALOG.confirmed.connect(_goToMainMenu)
func isOpen() -> bool:
return visible
@@ -17,12 +19,14 @@ func open() -> void:
visible = true
get_tree().paused = true
MAIN.open()
opened.emit()
func close() -> void:
get_tree().paused = false
visible = false
MAIN.close()
settingsPanel.close()
closed.emit()
func _openSettings() -> void:
MAIN.close()
@@ -35,12 +39,13 @@ func _goToMainMenu() -> void:
func _unhandled_input(event:InputEvent) -> void:
if !visible:
return
if event.is_action_pressed("ui_cancel"):
if MAIN.isConfirming():
MAIN.cancelConfirm()
elif settingsPanel.isOpen():
settingsPanel.close()
MAIN.open()
else:
close()
get_viewport().set_input_as_handled()
if !event.is_action_pressed("ui_cancel"):
return
if (UI.QUIT_DIALOG != null and UI.QUIT_DIALOG.isOpen) or (UI.MAIN_MENU_DIALOG != null and UI.MAIN_MENU_DIALOG.isOpen):
return
if settingsPanel.isOpen():
settingsPanel.close()
MAIN.open()
else:
close()
get_viewport().set_input_as_handled()
+11
View File
@@ -1,11 +1,14 @@
class_name SettingsMenu extends Control
const TEXT_SPEED_VALUES:Array[float] = [0.2, 1.0, 2.0]
@export var tabs:TabBar
@export var tabControls:Array[Control]
@export var checkInvertX:CheckBox
@export var checkInvertY:CheckBox
@export var sliderControllerSpeed:HSlider
@export var sliderMouseSpeed:HSlider
@export var optionTextSpeed:OptionButton
func _ready() -> void:
tabs.tab_changed.connect(onTabChanged)
@@ -17,8 +20,16 @@ func _ready() -> void:
sliderMouseSpeed.value = SETTINGS.cameraSpeedMouse
sliderControllerSpeed.value_changed.connect(func(v:float): SETTINGS.cameraSpeedController = v)
sliderMouseSpeed.value_changed.connect(func(v:float): SETTINGS.cameraSpeedMouse = v)
optionTextSpeed.select(_textSpeedToIndex(SETTINGS.textSpeed))
optionTextSpeed.item_selected.connect(func(idx:int): SETTINGS.textSpeed = TEXT_SPEED_VALUES[idx])
onTabChanged(tabs.current_tab)
func _textSpeedToIndex(speed:float) -> int:
match speed:
0.2: return 0
2.0: return 2
_: return 1
func _notification(what:int) -> void:
if what == NOTIFICATION_VISIBILITY_CHANGED and visible:
tabs.grab_focus()
+19 -4
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://efmr0xkbw1py" path="res://ui/settings/SettingsMenu.gd" id="1_4lnig"]
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls", "checkInvertX", "checkInvertY", "sliderControllerSpeed", "sliderMouseSpeed")]
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls", "checkInvertX", "checkInvertY", "sliderControllerSpeed", "sliderMouseSpeed", "optionTextSpeed")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -11,11 +11,12 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_4lnig")
tabs = NodePath("VBoxContainer/TabBar")
tabControls = [NodePath("VBoxContainer/ScrollContainer/LabelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics"), NodePath("VBoxContainer/ScrollContainer/PanelControls")]
tabControls = [NodePath("VBoxContainer/ScrollContainer/PanelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics"), NodePath("VBoxContainer/ScrollContainer/PanelControls")]
checkInvertX = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertX")
checkInvertY = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertY")
sliderControllerSpeed = NodePath("VBoxContainer/ScrollContainer/PanelControls/SliderControllerSpeed")
sliderMouseSpeed = NodePath("VBoxContainer/ScrollContainer/PanelControls/SliderMouseSpeed")
optionTextSpeed = NodePath("VBoxContainer/ScrollContainer/PanelGameplay/OptionTextSpeed")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
@@ -48,10 +49,24 @@ visible = false
layout_mode = 2
text = "Sound"
[node name="LabelGameplay" type="Label" parent="VBoxContainer/ScrollContainer"]
[node name="PanelGameplay" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
visible = false
layout_mode = 2
text = "Gameplay"
[node name="LabelTextSpeed" type="Label" parent="VBoxContainer/ScrollContainer/PanelGameplay"]
layout_mode = 2
text = "Text Speed"
[node name="OptionTextSpeed" type="OptionButton" parent="VBoxContainer/ScrollContainer/PanelGameplay"]
layout_mode = 2
focus_mode = 2
item_count = 3
item_0/text = "Slow"
item_0/id = 0
item_1/text = "Normal"
item_1/id = 1
item_2/text = "Fast"
item_2/id = 2
[node name="PanelControls" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
visible = false