mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-24 16:20:08 +01:00
Put tiny 2D worlds into all the commits
This commit is contained in:
parent
0ba806108f
commit
ca09ad0245
6 changed files with 41 additions and 36 deletions
|
@ -47,10 +47,10 @@ func _input(event):
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
|
|
||||||
func clear():
|
func clear():
|
||||||
pass
|
if world:
|
||||||
for item in world.get_children():
|
for item in world.get_children():
|
||||||
if item.label != "":
|
if item.label != "":
|
||||||
item.queue_free()
|
item.queue_free()
|
||||||
|
|
||||||
func substr2(s):
|
func substr2(s):
|
||||||
return s.substr(2)
|
return s.substr(2)
|
||||||
|
@ -142,32 +142,17 @@ func update():
|
||||||
|
|
||||||
FileBrowserMode.COMMIT:
|
FileBrowserMode.COMMIT:
|
||||||
if commit:
|
if commit:
|
||||||
var files = Array(commit.repository.shell.run("git ls-tree --name-only -r %s" % commit.id).split("\n"))
|
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
||||||
# The last entry is an empty string, remove it.
|
var files = Array(shell.run("git ls-tree --name-only -r %s" % commit.id).split("\n"))
|
||||||
files.pop_back()
|
# The last entry is an empty string, remove it.
|
||||||
for file_path in files:
|
files.pop_back()
|
||||||
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
for file_path in files:
|
||||||
item.label = file_path
|
var item = preload("res://scenes/item.tscn").instance()
|
||||||
item.connect("clicked", self, "item_clicked")
|
item.label = file_path
|
||||||
#grid.add_child(item)
|
item.item_type = "head"
|
||||||
FileBrowserMode.INDEX:
|
item.type = "nothing"
|
||||||
#var is_visible = false
|
item.file_browser = self
|
||||||
if repository and repository.there_is_a_git():
|
world.add_child(item)
|
||||||
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
|
|
||||||
|
|
||||||
func get_file_status(file_path, the_shell, idx):
|
func get_file_status(file_path, the_shell, idx):
|
||||||
var file_status = the_shell.run("git status -s '%s'" % file_path)
|
var file_status = the_shell.run("git status -s '%s'" % file_path)
|
||||||
|
@ -228,7 +213,8 @@ func save():
|
||||||
|
|
||||||
func _set_commit(new_commit):
|
func _set_commit(new_commit):
|
||||||
commit = new_commit
|
commit = new_commit
|
||||||
update()
|
#update()
|
||||||
|
shell = commit.repository.shell
|
||||||
|
|
||||||
func _set_mode(new_mode):
|
func _set_mode(new_mode):
|
||||||
mode = new_mode
|
mode = new_mode
|
||||||
|
|
|
@ -48,6 +48,7 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="Panel/Margin/Rows"]
|
[node name="Title" type="Label" parent="Panel/Margin/Rows"]
|
||||||
|
visible = false
|
||||||
margin_right = 1904.0
|
margin_right = 1904.0
|
||||||
margin_bottom = 29.0
|
margin_bottom = 29.0
|
||||||
text = "title"
|
text = "title"
|
||||||
|
@ -73,7 +74,6 @@ margin_bottom = 50.0
|
||||||
text = "dir"
|
text = "dir"
|
||||||
|
|
||||||
[node name="World" type="Control" parent="Panel/Margin/Rows"]
|
[node name="World" type="Control" parent="Panel/Margin/Rows"]
|
||||||
margin_top = 29.0
|
|
||||||
margin_right = 1904.0
|
margin_right = 1904.0
|
||||||
margin_bottom = 1064.0
|
margin_bottom = 1064.0
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
|
@ -36,9 +36,14 @@ func read_from_file():
|
||||||
modulate = Color(0, 0, 1.0)
|
modulate = Color(0, 0, 1.0)
|
||||||
$Sprite.scale = Vector2(0.75, 0.75)
|
$Sprite.scale = Vector2(0.75, 0.75)
|
||||||
"head":
|
"head":
|
||||||
content = file_browser.shell.run("git show HEAD:'%s'" % label)
|
var commit = "HEAD"
|
||||||
modulate = Color(0, 0, 0, 0.2)
|
if file_browser.commit:
|
||||||
$Sprite.scale = Vector2(0.8, 0.8)
|
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)
|
attributes = helpers.parse(content)
|
||||||
position.x = int(attributes["x"])
|
position.x = int(attributes["x"])
|
||||||
|
|
|
@ -15,6 +15,7 @@ var hovered = false
|
||||||
var arrow = preload("res://scenes/arrow.tscn")
|
var arrow = preload("res://scenes/arrow.tscn")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
$FileBrowser.hide()
|
||||||
content_set(content)
|
content_set(content)
|
||||||
type_set(type)
|
type_set(type)
|
||||||
if not repository.simplified_view or (type != "tree" and type != "blob"):
|
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")
|
$Sprite.texture = preload("res://nodes/tree.svg")
|
||||||
"commit":
|
"commit":
|
||||||
$Sprite.texture = preload("res://nodes/commit.svg")
|
$Sprite.texture = preload("res://nodes/commit.svg")
|
||||||
|
$FileBrowser.show()
|
||||||
"tag":
|
"tag":
|
||||||
$Sprite.texture = preload("res://nodes/blob.svg")
|
$Sprite.texture = preload("res://nodes/blob.svg")
|
||||||
"ref":
|
"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://fonts/default.tres" type="DynamicFont" id=1]
|
||||||
[ext_resource path="res://scenes/node.gd" type="Script" id=2]
|
[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://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://nodes/pop.wav" type="AudioStream" id=5]
|
||||||
[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=6]
|
[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__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_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_entered" from="Rect" to="." method="_on_hover"]
|
||||||
[connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"]
|
[connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"]
|
||||||
[connection signal="mouse_entered" from="Area2D" to="." method="_on_hover"]
|
[connection signal="mouse_entered" from="Area2D" to="." method="_on_hover"]
|
||||||
|
|
|
@ -107,6 +107,8 @@ func update_objects():
|
||||||
for p in commit_parents(o):
|
for p in commit_parents(o):
|
||||||
c[p] = ""
|
c[p] = ""
|
||||||
n.children = c
|
n.children = c
|
||||||
|
n.find_node("FileBrowser").mode = n.find_node("FileBrowser").FileBrowserMode.COMMIT
|
||||||
|
n.find_node("FileBrowser").commit = n
|
||||||
|
|
||||||
_commit_count += 1
|
_commit_count += 1
|
||||||
# if _commit_count >= 3 and not simplified_view:
|
# if _commit_count >= 3 and not simplified_view:
|
||||||
|
|
Loading…
Reference in a new issue