2020-09-22 13:15:36 +02:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
var shell
|
|
|
|
var thread
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
pass
|
|
|
|
|
|
|
|
func update():
|
|
|
|
$FileTree.clear()
|
|
|
|
var root_item = $FileTree.create_item()
|
|
|
|
root_item.set_text(0, "FILES")
|
|
|
|
|
2020-10-06 16:50:31 +02:00
|
|
|
var file_string = shell.run("find . -type f")
|
2020-09-22 13:15:36 +02:00
|
|
|
var files = file_string.split("\n")
|
|
|
|
files = Array(files)
|
2020-09-22 15:50:57 +02:00
|
|
|
# The last entry is an empty string, remove it.
|
|
|
|
files.pop_back()
|
|
|
|
files.sort_custom(self, "very_best_sort")
|
2020-09-22 13:15:36 +02:00
|
|
|
for file_path in files:
|
|
|
|
file_path = file_path.substr(2)
|
2020-10-22 14:59:44 +02:00
|
|
|
if file_path.substr(0, 5) == ".git/":
|
|
|
|
continue
|
2020-09-22 13:15:36 +02:00
|
|
|
var child = $FileTree.create_item(root_item)
|
|
|
|
child.set_text(0, file_path)
|
|
|
|
#child.set_editable(0, true)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_item_selected():
|
|
|
|
var item = $FileTree.get_selected()
|
|
|
|
var file_path = item.get_text(0)
|
2020-10-06 10:38:31 +02:00
|
|
|
|
2020-10-06 16:50:31 +02:00
|
|
|
shell.run("'%s'/fake-editor-noblock '%s'" % [game.tmp_prefix_inside, file_path])
|
2020-09-22 13:15:36 +02:00
|
|
|
|
2020-09-22 15:50:57 +02:00
|
|
|
func very_best_sort(a,b):
|
|
|
|
# We're looking at the third character because all entries have the form
|
|
|
|
# "./.git/bla".
|
|
|
|
if a.substr(2, 1) == "." and b.substr(2, 1) != ".":
|
|
|
|
return false
|
|
|
|
if a.substr(2, 1) != "." and b.substr(2, 1) == ".":
|
|
|
|
return true
|
|
|
|
return a.casecmp_to(b) == -1
|