mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
added the game
This commit is contained in:
18
Scripts/UI/TextValidator.gd
Normal file
18
Scripts/UI/TextValidator.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
class_name TextValidator
|
||||
extends Node
|
||||
|
||||
const valid_chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-*!.^/+:,'()?_;<> \n"
|
||||
|
||||
@export var node_to_validate: Control = null
|
||||
const FONT = preload("uid://cd221873lbtj1")
|
||||
signal text_validated(new_text: String)
|
||||
|
||||
func validate_text() -> void:
|
||||
var idx := 0
|
||||
var text = node_to_validate.text.to_upper()
|
||||
node_to_validate.clear()
|
||||
for i in text:
|
||||
if FONT.has_char(text.unicode_at(idx)) == false and valid_chars.contains(i) == false:
|
||||
text = text.replace(i, " ")
|
||||
idx += 1
|
||||
node_to_validate.insert_text_at_caret(text)
|
Reference in New Issue
Block a user