mirror of
https://github.com/Relintai/godot_translation_editor.git
synced 2024-11-11 16:25:00 +01:00
Allow to exclude folders, exclude folders starting by '.', show progress
This commit is contained in:
parent
126acb0247
commit
ec4f60d6fa
@ -3,11 +3,13 @@ const STATE_SEARCHING = 0
|
|||||||
const STATE_READING_TEXT = 1
|
const STATE_READING_TEXT = 1
|
||||||
|
|
||||||
signal finished(results)
|
signal finished(results)
|
||||||
|
signal progress_reported(ratio)
|
||||||
|
|
||||||
var _strings = {}
|
var _strings = {}
|
||||||
var _thread = null
|
var _thread = null
|
||||||
var _time_before = 0.0
|
var _time_before = 0.0
|
||||||
var _ignored_paths = {}
|
var _ignored_paths = {}
|
||||||
|
var _paths = []
|
||||||
|
|
||||||
|
|
||||||
func extract(root, ignored_paths=[]):
|
func extract(root, ignored_paths=[]):
|
||||||
@ -23,10 +25,31 @@ func extract(root, ignored_paths=[]):
|
|||||||
|
|
||||||
|
|
||||||
func _extract(root):
|
func _extract(root):
|
||||||
_walk(root, funcref(self, "_process_file"), funcref(self, "_filter"))
|
_walk(root, funcref(self, "_index_file"), funcref(self, "_filter"))
|
||||||
|
|
||||||
|
for i in len(_paths):
|
||||||
|
var fpath = _paths[i]
|
||||||
|
var f = File.new()
|
||||||
|
var err = f.open(fpath, File.READ)
|
||||||
|
if err != OK:
|
||||||
|
printerr("Could not open '", fpath, "', for read, error ", err)
|
||||||
|
continue
|
||||||
|
var ext = fpath.get_extension()
|
||||||
|
match ext:
|
||||||
|
"tscn":
|
||||||
|
_process_tscn(f, fpath)
|
||||||
|
"gd":
|
||||||
|
_process_gd(f, fpath)
|
||||||
|
f.close()
|
||||||
|
call_deferred("_report_progress", float(i) / float(len(_paths)))
|
||||||
|
|
||||||
call_deferred("_finished")
|
call_deferred("_finished")
|
||||||
|
|
||||||
|
|
||||||
|
func _report_progress(ratio):
|
||||||
|
emit_signal("progress_reported", ratio)
|
||||||
|
|
||||||
|
|
||||||
func _finished():
|
func _finished():
|
||||||
_thread.wait_to_finish()
|
_thread.wait_to_finish()
|
||||||
_thread = null
|
_thread = null
|
||||||
@ -38,27 +61,17 @@ func _finished():
|
|||||||
func _filter(path):
|
func _filter(path):
|
||||||
if path in _ignored_paths:
|
if path in _ignored_paths:
|
||||||
return false
|
return false
|
||||||
|
if path[0] == ".":
|
||||||
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
func _process_file(fpath):
|
func _index_file(fpath):
|
||||||
var ext = fpath.get_extension()
|
var ext = fpath.get_extension()
|
||||||
#print("File ", fpath)
|
#print("File ", fpath)
|
||||||
|
|
||||||
if ext != "tscn" and ext != "gd":
|
if ext != "tscn" and ext != "gd":
|
||||||
return
|
return
|
||||||
|
_paths.append(fpath)
|
||||||
var f = File.new()
|
|
||||||
var err = f.open(fpath, File.READ)
|
|
||||||
if err != OK:
|
|
||||||
printerr("Could not open '", fpath, "', for read, error ", err)
|
|
||||||
return
|
|
||||||
|
|
||||||
match ext:
|
|
||||||
"tscn":
|
|
||||||
_process_tscn(f, fpath)
|
|
||||||
"gd":
|
|
||||||
_process_gd(f, fpath)
|
|
||||||
|
|
||||||
|
|
||||||
func _process_tscn(f, fpath):
|
func _process_tscn(f, fpath):
|
||||||
|
@ -6,9 +6,10 @@ const Extractor = preload("extractor.gd")
|
|||||||
signal import_selected(strings)
|
signal import_selected(strings)
|
||||||
|
|
||||||
onready var _root_path_edit = get_node("VBoxContainer/HBoxContainer/RootPathEdit")
|
onready var _root_path_edit = get_node("VBoxContainer/HBoxContainer/RootPathEdit")
|
||||||
onready var _summary_label = get_node("VBoxContainer/SummaryLabel")
|
onready var _excluded_dirs_edit = get_node("VBoxContainer/Options/ExcludedDirsEdit")
|
||||||
|
onready var _summary_label = get_node("VBoxContainer/StatusBar/SummaryLabel")
|
||||||
onready var _results_list = get_node("VBoxContainer/Results")
|
onready var _results_list = get_node("VBoxContainer/Results")
|
||||||
onready var _progress_bar = get_node("VBoxContainer/ProgressBar")
|
onready var _progress_bar = get_node("VBoxContainer/StatusBar/ProgressBar")
|
||||||
onready var _extract_button = get_node("VBoxContainer/Buttons/ExtractButton")
|
onready var _extract_button = get_node("VBoxContainer/Buttons/ExtractButton")
|
||||||
onready var _import_button = get_node("VBoxContainer/Buttons/ImportButton")
|
onready var _import_button = get_node("VBoxContainer/Buttons/ImportButton")
|
||||||
|
|
||||||
@ -48,18 +49,21 @@ func _on_ExtractButton_pressed():
|
|||||||
printerr("Directory `", root, "` does not exist")
|
printerr("Directory `", root, "` does not exist")
|
||||||
return
|
return
|
||||||
|
|
||||||
_extractor = Extractor.new()
|
var excluded_dirs = _excluded_dirs_edit.text.split(";", false)
|
||||||
_extractor.connect("finished", self, "_on_Extractor_finished")
|
for i in len(excluded_dirs):
|
||||||
#_extractor.extract("res://", ["addons"])
|
excluded_dirs[i] = excluded_dirs[i].strip_edges()
|
||||||
_extractor.extract("res://", [])
|
|
||||||
|
|
||||||
# TODO Progress reporting
|
_extractor = Extractor.new()
|
||||||
_progress_bar.value = 50
|
_extractor.connect("progress_reported", self, "_on_Extractor_progress_reported")
|
||||||
|
_extractor.connect("finished", self, "_on_Extractor_finished")
|
||||||
|
_extractor.extract(root, excluded_dirs)
|
||||||
|
|
||||||
|
_progress_bar.value = 0
|
||||||
|
_progress_bar.show()
|
||||||
|
_summary_label.text = ""
|
||||||
|
|
||||||
_extract_button.disabled = true
|
_extract_button.disabled = true
|
||||||
_import_button.disabled = true
|
_import_button.disabled = true
|
||||||
|
|
||||||
_summary_label.text = "Extracting..."
|
|
||||||
|
|
||||||
|
|
||||||
func _on_ImportButton_pressed():
|
func _on_ImportButton_pressed():
|
||||||
@ -73,9 +77,14 @@ func _on_CancelButton_pressed():
|
|||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Extractor_progress_reported(ratio):
|
||||||
|
_progress_bar.value = 100.0 * ratio
|
||||||
|
|
||||||
|
|
||||||
func _on_Extractor_finished(results):
|
func _on_Extractor_finished(results):
|
||||||
print("Extractor finished")
|
print("Extractor finished")
|
||||||
_progress_bar.value = 100
|
_progress_bar.value = 100
|
||||||
|
_progress_bar.hide()
|
||||||
|
|
||||||
_results_list.clear()
|
_results_list.clear()
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ caret_blink_speed = 0.65
|
|||||||
caret_position = 0
|
caret_position = 0
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="SummaryLabel" type="Label" parent="VBoxContainer" index="1"]
|
[node name="Options" type="HBoxContainer" parent="VBoxContainer" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -114,26 +114,133 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 28.0
|
margin_top = 28.0
|
||||||
margin_right = 624.0
|
margin_right = 624.0
|
||||||
margin_bottom = 42.0
|
margin_bottom = 52.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 1
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
alignment = 0
|
||||||
|
|
||||||
|
[node name="ExcludedDirsLabel" type="Label" parent="VBoxContainer/Options" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 5.0
|
||||||
|
margin_right = 122.0
|
||||||
|
margin_bottom = 19.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 1
|
size_flags_horizontal = 1
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
|
text = "Ignored directories"
|
||||||
percent_visible = 1.0
|
percent_visible = 1.0
|
||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
|
|
||||||
[node name="Results" type="Tree" parent="VBoxContainer" index="2"]
|
[node name="ExcludedDirsEdit" type="LineEdit" parent="VBoxContainer/Options" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 46.0
|
margin_left = 126.0
|
||||||
margin_right = 624.0
|
margin_right = 624.0
|
||||||
margin_bottom = 396.0
|
margin_bottom = 24.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
hint_tooltip = "Directories seperated by semicolons `;`"
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 1
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "addons"
|
||||||
|
focus_mode = 2
|
||||||
|
context_menu_enabled = true
|
||||||
|
placeholder_alpha = 0.6
|
||||||
|
caret_blink = false
|
||||||
|
caret_blink_speed = 0.65
|
||||||
|
caret_position = 0
|
||||||
|
_sections_unfolded = [ "Hint" ]
|
||||||
|
|
||||||
|
[node name="StatusBar" type="Control" parent="VBoxContainer" index="2"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 56.0
|
||||||
|
margin_right = 624.0
|
||||||
|
margin_bottom = 80.0
|
||||||
|
rect_min_size = Vector2( 0, 24 )
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
|
[node name="SummaryLabel" type="Label" parent="VBoxContainer/StatusBar" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 4.0
|
||||||
|
margin_right = 624.0
|
||||||
|
margin_bottom = 18.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 4
|
||||||
|
align = 1
|
||||||
|
percent_visible = 1.0
|
||||||
|
lines_skipped = 0
|
||||||
|
max_lines_visible = -1
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer/StatusBar" index="1"]
|
||||||
|
|
||||||
|
visible = false
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_right = 624.0
|
||||||
|
margin_bottom = 16.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 0
|
||||||
|
min_value = 0.0
|
||||||
|
max_value = 100.0
|
||||||
|
step = 1.0
|
||||||
|
page = 0.0
|
||||||
|
value = 0.0
|
||||||
|
exp_edit = false
|
||||||
|
rounded = false
|
||||||
|
percent_visible = true
|
||||||
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
|
[node name="Results" type="Tree" parent="VBoxContainer" index="3"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 84.0
|
||||||
|
margin_right = 624.0
|
||||||
|
margin_bottom = 416.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = true
|
rect_clip_content = true
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
@ -150,30 +257,6 @@ drop_mode_flags = 0
|
|||||||
select_mode = 1
|
select_mode = 1
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer" index="3"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_top = 400.0
|
|
||||||
margin_right = 624.0
|
|
||||||
margin_bottom = 416.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 0
|
|
||||||
min_value = 0.0
|
|
||||||
max_value = 100.0
|
|
||||||
step = 1.0
|
|
||||||
page = 0.0
|
|
||||||
value = 0.0
|
|
||||||
exp_edit = false
|
|
||||||
rounded = false
|
|
||||||
percent_visible = true
|
|
||||||
|
|
||||||
[node name="Spacer" type="Control" parent="VBoxContainer" index="4"]
|
[node name="Spacer" type="Control" parent="VBoxContainer" index="4"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
@ -252,6 +335,7 @@ mouse_filter = 0
|
|||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 1
|
size_flags_horizontal = 1
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
|
disabled = true
|
||||||
toggle_mode = false
|
toggle_mode = false
|
||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
|
Loading…
Reference in New Issue
Block a user