diff --git a/levels/2d/sandbox b/levels/2d/sandbox new file mode 100644 index 0000000..4652b41 --- /dev/null +++ b/levels/2d/sandbox @@ -0,0 +1,13 @@ +title = Sandbox +cards = checkout add reset commit merge rebase-interactive file-new file-delete + +[setup] + +echo "x = 200 +y = 100" > apple + +echo "x = 400 +y = 100" > pen + +git add . +git commit -m "The beginning" diff --git a/levels/2d/sequence b/levels/2d/sequence new file mode 100644 index 0000000..b04600a --- /dev/null +++ b/levels/2d/sequence @@ -0,0 +1 @@ +sandbox diff --git a/resources/cards.json b/resources/cards.json index 0798735..b3a0a80 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -11,7 +11,7 @@ }, { "id": "checkout", - "command": "git checkout [commit, ref]", + "command": "git checkout [commit, ref, file]", "description": "Drag this card to a commit or to a branch to travel to it!" }, { @@ -56,7 +56,7 @@ }, { "id": "reset", - "command": "git reset [commit]", + "command": "git reset [commit, file]", "description": "Jump to the commit, and update the index. Keep the current environment." }, { @@ -86,7 +86,7 @@ }, { "id": "commit", - "command": "git commit", + "command": "git commit -m $RANDOM", "description": "Make a commit from the plan." }, { diff --git a/scenes/file_browser.gd b/scenes/file_browser.gd index e3ff87f..0766bc5 100644 --- a/scenes/file_browser.gd +++ b/scenes/file_browser.gd @@ -79,16 +79,17 @@ func update(): # Populate HEAD versions. if shell.run("test -d .git && echo yes || echo no") == "yes\n": - var files = Array(shell.run("git ls-tree --name-only -r %s" % "HEAD").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) + if shell.run("git rev-parse HEAD &> /dev/null && echo yes || echo no") == "yes\n": + var files = Array(shell.run("git ls-tree --name-only -r %s" % "HEAD").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) # Populate index. @@ -116,12 +117,12 @@ func update(): wd_files.pop_back() wd_files = helpers.map(wd_files, self, "substr2") - var deleted_files = [] - if shell.run("test -d .git && echo yes || echo no") == "yes\n": - deleted_files = Array(shell.run("git status -s | grep '^.D' | sed 's/^...//'").split("\n")) - deleted_files.pop_back() +# var deleted_files = [] +# if shell.run("test -d .git && echo yes || echo no") == "yes\n": +# deleted_files = Array(shell.run("git status -s | grep '^.D' | sed 's/^...//'").split("\n")) +# deleted_files.pop_back() - var files = wd_files + deleted_files + var files = wd_files# + deleted_files player = null files.sort_custom(self, "very_best_sort") diff --git a/scenes/item.gd b/scenes/item.gd index 674512c..3a4b8e9 100644 --- a/scenes/item.gd +++ b/scenes/item.gd @@ -34,21 +34,28 @@ func read_from_file(): "index": content = file_browser.shell.run("git show :'%s'" % label) modulate = Color(0, 0, 1.0) - $Sprite.scale = Vector2(0.75, 0.75) + $Sprite.scale *= 1.2 "head": 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) + $Sprite.scale *= 1.4 content = file_browser.shell.run("git show %s:'%s'" % [commit, label]) attributes = helpers.parse(content) - position.x = int(attributes["x"]) - position.y = int(attributes["y"]) - + if attributes.has("x"): + position.x = float(attributes["x"]) + else: + position.x = rand_range(100, 400) + if attributes.has("y"): + position.y = float(attributes["y"]) + else: + position.y = rand_range(100, 300) + write_to_file() + func write_to_file(): attributes["x"] = str(position.x) attributes["y"] = str(position.y) @@ -62,6 +69,12 @@ func _set_label(new_label): label = new_label if label_node: label_node.text = helpers.abbreviate(new_label, 30) + + if new_label == "you": + $Sprite.texture = preload("res://nodes/head.svg") + else: + $Sprite.texture = preload("res://nodes/document.svg") + $Sprite.scale *= 0.85 #func _gui_input(event): # if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT: