Files
puzzle-quest/addons/godot_db_manager/dlgs/new_db_dlg.gd
T
Vaillant Jeremy 01ea3af253 Run godot --convert-3to4 (automated conversion)
Apply Godot 4.6 automated conversion: renames Spatial.translate->position,
margin_*->offset_*, tool->@tool, .empty()->.is_empty(), DynamicFont->FontFile,
onready->@onready, export()->@export, and many more.

127 files changed by the tool. Manual fixes still required for:
 - godot_db_manager plugin (incompatible APIs: WindowDialog, Tabs, etc.)
 - lod plugin (Spatial -> Node3D renames)
 - ResourceLoader.load_interactive removed -> load_threaded_request
 - OS.set_window_fullscreen removed -> DisplayServer
 - Viewport.set_size_override removed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 19:18:27 +02:00

64 lines
1.8 KiB
GDScript

@tool
"""
class GDDBNewDBDlg
"""
class_name GDDBNewDBDlg
extends Window
signal create_new_db
var m_current_db_name = ""
# Called when the node enters the scene tree for the first time.
func _ready() -> void :
$v_layout/buttons/ok_btn.connect("pressed", Callable(self, "on_ok_btn_pressed"))
$v_layout/buttons/cancel_btn.connect("pressed", Callable(self, "on_cancel_btn_pressed"))
connect("about_to_popup", Callable(self, "on_about_to_show"))
$v_layout/db_info/db_edt.connect("text_changed", Callable(self, "on_text_changed"))
$v_layout/db_info/db_edt.connect("text_submitted", Callable(self, "on_text_confirmed"))
# Called when the node is about to be shown.
func on_about_to_show() -> void :
m_current_db_name = ""
$v_layout/db_info/db_edt.set_text(m_current_db_name)
# called everytime the text is changed
func on_text_changed(new_text: String) -> void :
var change_text = true
if(!gddb_globals.check_db_name(new_text)):
change_text = false
else:
if(new_text.length() > gddb_constants.c_max_db_name_len):
change_text = false
else:
change_text = true
if(change_text):
m_current_db_name = $v_layout/db_info/db_edt.get_text()
else:
$v_layout/db_info/db_edt.set_text(m_current_db_name)
$v_layout/db_info/db_edt.set_caret_column(m_current_db_name.length())
# called when the user presses the ENTER key
func on_text_confirmed(text : String) -> void :
# print("GDDBNewDBDlg::on_text_confirmed(" + text + ")")
if(m_current_db_name.is_empty()):
return
handle_db_name()
hide()
# called when the OK button is pressed
func on_ok_btn_pressed() -> void :
if(!m_current_db_name.is_empty()):
handle_db_name()
# called when the Cancel button is pressed
func on_cancel_btn_pressed() -> void :
hide()
# handles the name of the database
func handle_db_name() -> void :
emit_signal("create_new_db", m_current_db_name)