mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-29 21:45:09 +03:00
Put tiny 2D worlds into all the commits
This commit is contained in:
parent
0ba806108f
commit
ca09ad0245
@ -47,10 +47,10 @@ func _input(event):
|
||||
get_tree().set_input_as_handled()
|
||||
|
||||
func clear():
|
||||
pass
|
||||
for item in world.get_children():
|
||||
if item.label != "":
|
||||
item.queue_free()
|
||||
if world:
|
||||
for item in world.get_children():
|
||||
if item.label != "":
|
||||
item.queue_free()
|
||||
|
||||
func substr2(s):
|
||||
return s.substr(2)
|
||||
@ -142,32 +142,17 @@ func update():
|
||||
|
||||
FileBrowserMode.COMMIT:
|
||||
if commit:
|
||||
var files = Array(commit.repository.shell.run("git ls-tree --name-only -r %s" % commit.id).split("\n"))
|
||||
# The last entry is an empty string, remove it.
|
||||
files.pop_back()
|
||||
for file_path in files:
|
||||
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
||||
item.label = file_path
|
||||
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 index_files = Array(repository.shell.run("git ls-files -s | cut -f2 | uniq").split("\n"))
|
||||
var deleted_files = Array(repository.shell.run("git status -s | grep '^D' | sed 's/^...//'").split("\n"))
|
||||
# The last entries are empty strings, remove them.
|
||||
index_files.pop_back()
|
||||
deleted_files.pop_back()
|
||||
var files = index_files + deleted_files
|
||||
for file_path in files:
|
||||
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
||||
item.label = file_path
|
||||
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
|
||||
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
||||
var files = Array(shell.run("git ls-tree --name-only -r %s" % commit.id).split("\n"))
|
||||
# The last entry is an empty string, remove it.
|
||||
files.pop_back()
|
||||
for file_path in files:
|
||||
var item = preload("res://scenes/item.tscn").instance()
|
||||
item.label = file_path
|
||||
item.item_type = "head"
|
||||
item.type = "nothing"
|
||||
item.file_browser = self
|
||||
world.add_child(item)
|
||||
|
||||
func get_file_status(file_path, the_shell, idx):
|
||||
var file_status = the_shell.run("git status -s '%s'" % file_path)
|
||||
@ -228,7 +213,8 @@ func save():
|
||||
|
||||
func _set_commit(new_commit):
|
||||
commit = new_commit
|
||||
update()
|
||||
#update()
|
||||
shell = commit.repository.shell
|
||||
|
||||
func _set_mode(new_mode):
|
||||
mode = new_mode
|
||||
|
@ -48,6 +48,7 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="Title" type="Label" parent="Panel/Margin/Rows"]
|
||||
visible = false
|
||||
margin_right = 1904.0
|
||||
margin_bottom = 29.0
|
||||
text = "title"
|
||||
@ -73,7 +74,6 @@ margin_bottom = 50.0
|
||||
text = "dir"
|
||||
|
||||
[node name="World" type="Control" parent="Panel/Margin/Rows"]
|
||||
margin_top = 29.0
|
||||
margin_right = 1904.0
|
||||
margin_bottom = 1064.0
|
||||
mouse_filter = 1
|
||||
|
@ -36,9 +36,14 @@ func read_from_file():
|
||||
modulate = Color(0, 0, 1.0)
|
||||
$Sprite.scale = Vector2(0.75, 0.75)
|
||||
"head":
|
||||
content = file_browser.shell.run("git show HEAD:'%s'" % label)
|
||||
modulate = Color(0, 0, 0, 0.2)
|
||||
$Sprite.scale = Vector2(0.8, 0.8)
|
||||
var commit = "HEAD"
|
||||
if file_browser.commit:
|
||||
commit = file_browser.commit.id
|
||||
else:
|
||||
modulate = Color(0, 0, 0, 0.2)
|
||||
$Sprite.scale = Vector2(0.8, 0.8)
|
||||
content = file_browser.shell.run("git show %s:'%s'" % [commit, label])
|
||||
|
||||
|
||||
attributes = helpers.parse(content)
|
||||
position.x = int(attributes["x"])
|
||||
|
@ -15,6 +15,7 @@ var hovered = false
|
||||
var arrow = preload("res://scenes/arrow.tscn")
|
||||
|
||||
func _ready():
|
||||
$FileBrowser.hide()
|
||||
content_set(content)
|
||||
type_set(type)
|
||||
if not repository.simplified_view or (type != "tree" and type != "blob"):
|
||||
@ -75,6 +76,7 @@ func type_set(new_type):
|
||||
$Sprite.texture = preload("res://nodes/tree.svg")
|
||||
"commit":
|
||||
$Sprite.texture = preload("res://nodes/commit.svg")
|
||||
$FileBrowser.show()
|
||||
"tag":
|
||||
$Sprite.texture = preload("res://nodes/blob.svg")
|
||||
"ref":
|
||||
|
@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://scenes/node.gd" type="Script" id=2]
|
||||
[ext_resource path="res://nodes/blob.svg" type="Texture" id=3]
|
||||
[ext_resource path="res://scenes/file_browser.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://nodes/pop.wav" type="AudioStream" id=5]
|
||||
[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=6]
|
||||
|
||||
@ -80,6 +81,15 @@ custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="FileBrowser" parent="." instance=ExtResource( 4 )]
|
||||
margin_left = -21.0
|
||||
margin_top = -20.0
|
||||
margin_right = 578.0
|
||||
margin_bottom = 559.0
|
||||
rect_min_size = Vector2( 0, 0 )
|
||||
rect_scale = Vector2( 0.07, 0.07 )
|
||||
mouse_filter = 2
|
||||
[connection signal="mouse_entered" from="Rect" to="." method="_on_hover"]
|
||||
[connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"]
|
||||
[connection signal="mouse_entered" from="Area2D" to="." method="_on_hover"]
|
||||
|
@ -107,6 +107,8 @@ func update_objects():
|
||||
for p in commit_parents(o):
|
||||
c[p] = ""
|
||||
n.children = c
|
||||
n.find_node("FileBrowser").mode = n.find_node("FileBrowser").FileBrowserMode.COMMIT
|
||||
n.find_node("FileBrowser").commit = n
|
||||
|
||||
_commit_count += 1
|
||||
# if _commit_count >= 3 and not simplified_view:
|
||||
|
Loading…
Reference in New Issue
Block a user