Fixed window titles not being detected

This commit is contained in:
Marc Gilleron 2020-06-14 20:30:05 +01:00
parent 3cdfde5f28
commit dc763e93df

View File

@ -96,7 +96,11 @@ func _index_file(fpath: String):
func _process_tscn(f: File, fpath: String): func _process_tscn(f: File, fpath: String):
# TOOD Also search for "window_title" and "dialog_text" # TOOD Also search for "window_title" and "dialog_text"
var pattern := "text =" var patterns := [
"text =",
"window_title =",
"dialog_text ="
]
var text := "" var text := ""
var state := STATE_SEARCHING var state := STATE_SEARCHING
var line_number := 0 var line_number := 0
@ -110,31 +114,39 @@ func _process_tscn(f: File, fpath: String):
match state: match state:
STATE_SEARCHING: STATE_SEARCHING:
var i := line.find(pattern) var pattern : String
var i : int
for p in patterns:
i = line.find(p)
if i != -1:
pattern = p
break
if i != -1: if i == -1:
var begin_quote_index := line.find('"', i + len(pattern)) continue
if begin_quote_index == -1:
_logger.error( var begin_quote_index := line.find('"', i + len(pattern))
"Could not find begin quote after text property, in {0}, line {1}" \ if begin_quote_index == -1:
.format([fpath, line_number])) _logger.error(
continue "Could not find begin quote after text property, in {0}, line {1}" \
.format([fpath, line_number]))
var end_quote_index := line.rfind('"') continue
if end_quote_index != -1 and end_quote_index > begin_quote_index \ var end_quote_index := line.rfind('"')
and line[end_quote_index - 1] != '\\':
text = line.substr(begin_quote_index + 1, if end_quote_index != -1 and end_quote_index > begin_quote_index \
end_quote_index - begin_quote_index - 1) and line[end_quote_index - 1] != '\\':
text = line.substr(begin_quote_index + 1,
if text != "": end_quote_index - begin_quote_index - 1)
_add_string(fpath, line_number, text)
text = ""
else: if text != "":
# The text may be multiline _add_string(fpath, line_number, text)
text = str(line.right(begin_quote_index + 1), "\n") text = ""
state = STATE_READING_TEXT
else:
# The text may be multiline
text = str(line.right(begin_quote_index + 1), "\n")
state = STATE_READING_TEXT
STATE_READING_TEXT: STATE_READING_TEXT:
var end_quote_index = line.rfind('"') var end_quote_index = line.rfind('"')