mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-05-07 05:02:04 +02:00
Make drop areas react to collision with "cursor" scene
This is a preparation to allow drop areas on GUI elements.
This commit is contained in:
parent
f6c7ef90d8
commit
38faac5485
10 changed files with 53 additions and 12 deletions
scenes
|
@ -46,12 +46,12 @@ func update():
|
|||
# The last entry is an empty string, remove it.
|
||||
files.pop_back()
|
||||
files.sort_custom(self, "very_best_sort")
|
||||
visible = false
|
||||
var is_visible = false
|
||||
for file_path in files:
|
||||
file_path = file_path.substr(2)
|
||||
if file_path.substr(0, 5) == ".git/":
|
||||
continue
|
||||
visible = true
|
||||
is_visible = true
|
||||
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
||||
item.label = file_path
|
||||
item.connect("clicked", self, "item_clicked")
|
||||
|
@ -59,6 +59,8 @@ func update():
|
|||
item.status = get_file_status(file_path, shell, 1)
|
||||
|
||||
grid.add_child(item)
|
||||
visible = is_visible
|
||||
|
||||
FileBrowserMode.COMMIT:
|
||||
if commit:
|
||||
var files = Array(commit.repository.shell.run("git ls-tree --name-only -r %s" % commit.id).split("\n"))
|
||||
|
@ -70,6 +72,7 @@ func update():
|
|||
item.connect("clicked", self, "item_clicked")
|
||||
grid.add_child(item)
|
||||
FileBrowserMode.INDEX:
|
||||
var is_visible = false
|
||||
if repository and repository.there_is_a_git():
|
||||
var files = Array(repository.shell.run("git ls-files -s | cut -f2 | uniq").split("\n"))
|
||||
# The last entry is an empty string, remove it.
|
||||
|
@ -80,6 +83,9 @@ func update():
|
|||
item.connect("clicked", self, "item_clicked")
|
||||
item.status = get_file_status(file_path, repository.shell, 0)
|
||||
grid.add_child(item)
|
||||
if item.status != item.IconStatus.NONE:
|
||||
is_visible = true
|
||||
visible = is_visible
|
||||
|
||||
func get_file_status(file_path, shell, idx):
|
||||
var file_status = shell.run("git status -s '%s'" % file_path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue