Player scoreboard name option

This commit is contained in:
Haze Weathers 2024-12-01 21:37:15 -05:00
parent b61a5122f4
commit 65053aa223
7 changed files with 95 additions and 6 deletions

View file

@ -37,7 +37,7 @@ func _ready():
func _physics_process(delta):
#DEBUG
if debug == true && !entry && !entry_index > 0:
if debug == true && !entry && !entry_index > 0 && !Options.entry:
#Move player to mouse
if Input.is_action_just_pressed("debug_move_player"):
Audio.play_sound(Audio.a_mkey,Audio.ac_jump)
@ -67,6 +67,9 @@ func _physics_process(delta):
if infinite_arrows: Game.arrows = 99
func _input(event):
if Options.entry:
return
if event is InputEventKey && event.is_pressed():
var character = OS.get_scancode_string(event.scancode)
if character.length() > 1:

View file

@ -18,7 +18,7 @@ const TRANS_SPEEDS := [0.8, 0.4, 0.2, 0.0000001]
#Game
var rumble: int = RumbleMode.FULL
var gore: int = Gore.FULL
var scoreboard_name: String = ""
var scoreboard_name: String = "" setget _set_scoreboard_name
var scoreboard_id: int = -1
#Video
@ -42,6 +42,9 @@ var last_file: int = 0
# default values
var defaults = null
# text is being entered
var entry: bool = false
func _ready() -> void:
pause_mode = PAUSE_MODE_PROCESS
@ -51,7 +54,7 @@ func _ready() -> void:
load_options()
func _unhandled_input(event: InputEvent) -> void:
if Debug.entry == false:
if not Debug.entry and not entry:
if event.is_action_pressed("fullscreen"):
OS.window_fullscreen = not OS.window_fullscreen
@ -125,6 +128,10 @@ func save_options() -> void:
# Setters
# game setters
func _set_scoreboard_name(value: String) -> void:
scoreboard_name = value.substr(0, 10).to_lower()
# video setters
func _set_fullscreen(value: bool) -> void:
fullscreen = value

View file

@ -100,6 +100,8 @@ func _on_Exit_area_entered(area: Area2D) -> void:
func _on_player_teleport_finished() -> void:
if file.name.length() > 0:
get_tree().paused = true
if Options.scoreboard_name.empty():
Options.scoreboard_name = file.name
file.save_to_file()
Save.current_file = file
Game.difficulty = file.difficulty

View file

@ -39,7 +39,7 @@ func focus() -> void:
func _unhandled_input(event: InputEvent) -> void:
Options.save_options()
if can_exit and event.is_action_pressed("ui_cancel"):
if can_exit and event.is_action_pressed("ui_cancel") and not Options.entry:
if visible == true: emit_signal("exit")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://objects/hud/options_screen_scholar.gd" type="Script" id=1]
[ext_resource path="res://ui/theme.tres" type="Theme" id=2]
@ -11,6 +11,21 @@
[ext_resource path="res://objects/hud/set_gamepad_button.gd" type="Script" id=9]
[ext_resource path="res://objects/hud/scroll_follow_focus.gd" type="Script" id=10]
[ext_resource path="res://graphics/hud/levelselect_nexlevel.png" type="Texture" id=11]
[ext_resource path="res://objects/hud/player_name_input.gd" type="Script" id=12]
[sub_resource type="StyleBoxFlat" id=5]
content_margin_left = 1.0
content_margin_right = 1.0
bg_color = Color( 0.14902, 0.0980392, 0.247059, 1 )
corner_detail = 1
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id=6]
content_margin_left = 1.0
content_margin_right = 1.0
bg_color = Color( 0.213124, 0.165611, 0.382812, 1 )
corner_detail = 1
anti_aliasing = false
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 4 )
@ -100,7 +115,6 @@ size_flags_vertical = 3
tabs_visible = false
[node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
focus_next = NodePath("Rumble/SelectRumble")
@ -146,11 +160,34 @@ margin_left = 39.0
margin_right = 218.0
margin_bottom = 12.0
focus_neighbour_top = NodePath("../../Rumble/SelectRumble")
focus_neighbour_bottom = NodePath("../../ScoreBoardName/PlayerNameInput")
focus_mode = 2
size_flags_horizontal = 3
script = ExtResource( 3 )
options = [ "none", "no stains", "full" ]
[node name="ScoreBoardName" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game"]
margin_top = 32.0
margin_right = 218.0
margin_bottom = 42.0
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName"]
margin_right = 112.0
margin_bottom = 10.0
text = "Scoreboard name:"
[node name="PlayerNameInput" type="TextEdit" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName"]
margin_left = 130.0
margin_right = 203.0
margin_bottom = 10.0
rect_min_size = Vector2( 73, 0 )
focus_neighbour_top = NodePath("../../Gore/SelectGore")
size_flags_horizontal = 6
custom_constants/line_spacing = 0
custom_styles/focus = SubResource( 5 )
custom_styles/normal = SubResource( 6 )
script = ExtResource( 12 )
[node name="Video" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
visible = false
anchor_right = 1.0
@ -459,6 +496,7 @@ script = ExtResource( 3 )
options = [ "off", "on" ]
[node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
focus_next = NodePath("ScrollContainer/ControlsVBox/Left/Keyboard")
@ -825,6 +863,10 @@ align = 1
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/SelectTab" to="." method="_on_tab_selected"]
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Rumble/SelectRumble" to="." method="_on_Rumble_selected"]
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Gore/SelectGore" to="." method="_on_Gore_selected"]
[connection signal="focus_entered" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_focus_entered"]
[connection signal="focus_exited" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_focus_exited"]
[connection signal="gui_input" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_gui_input"]
[connection signal="text_changed" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_text_changed"]
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/Fullscreen/SelectFullscreen" to="." method="_on_Fullscreen_selected"]
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/WindowSize/SelectWindowSize" to="." method="_on_WindowSize_selected"]
[connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/Scaling/SelectScaling" to="." method="_on_Scaling_selected"]

View file

@ -0,0 +1,29 @@
extends TextEdit
func _ready() -> void:
text = Options.scoreboard_name
func _exit_tree() -> void:
Options.entry = false
func _on_text_changed() -> void:
text = text.substr(0, 10).to_lower().strip_escapes()
Options.scoreboard_name = text
cursor_set_column(text.length())
func _on_focus_entered() -> void:
Options.entry = true
cursor_set_column(text.length())
func _on_focus_exited() -> void:
Options.set_deferred("entry", false)
func _on_gui_input(event: InputEvent) -> void:
if event.is_action_pressed("text_enter"):
get_node(focus_neighbour_top).grab_focus()

View file

@ -359,6 +359,12 @@ shield={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":5,"pressure":0.0,"pressed":false,"script":null)
]
}
text_enter={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
[input_devices]