mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-29 21:45:09 +03:00
Handle files without a position in them. Streamline cards a bit.
This commit is contained in:
parent
ca09ad0245
commit
12e9aff7ff
13
levels/2d/sandbox
Normal file
13
levels/2d/sandbox
Normal file
@ -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"
|
1
levels/2d/sequence
Normal file
1
levels/2d/sequence
Normal file
@ -0,0 +1 @@
|
|||||||
|
sandbox
|
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "checkout",
|
"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!"
|
"description": "Drag this card to a commit or to a branch to travel to it!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "reset",
|
"id": "reset",
|
||||||
"command": "git reset [commit]",
|
"command": "git reset [commit, file]",
|
||||||
"description": "Jump to the commit, and update the index. Keep the current environment."
|
"description": "Jump to the commit, and update the index. Keep the current environment."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "commit",
|
"id": "commit",
|
||||||
"command": "git commit",
|
"command": "git commit -m $RANDOM",
|
||||||
"description": "Make a commit from the plan."
|
"description": "Make a commit from the plan."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -79,16 +79,17 @@ func update():
|
|||||||
# Populate HEAD versions.
|
# Populate HEAD versions.
|
||||||
|
|
||||||
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
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"))
|
if shell.run("git rev-parse HEAD &> /dev/null && 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" % "HEAD").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/item.tscn").instance()
|
for file_path in files:
|
||||||
item.label = file_path
|
var item = preload("res://scenes/item.tscn").instance()
|
||||||
item.item_type = "head"
|
item.label = file_path
|
||||||
item.type = "nothing"
|
item.item_type = "head"
|
||||||
item.file_browser = self
|
item.type = "nothing"
|
||||||
world.add_child(item)
|
item.file_browser = self
|
||||||
|
world.add_child(item)
|
||||||
|
|
||||||
# Populate index.
|
# Populate index.
|
||||||
|
|
||||||
@ -116,12 +117,12 @@ func update():
|
|||||||
wd_files.pop_back()
|
wd_files.pop_back()
|
||||||
wd_files = helpers.map(wd_files, self, "substr2")
|
wd_files = helpers.map(wd_files, self, "substr2")
|
||||||
|
|
||||||
var deleted_files = []
|
# var deleted_files = []
|
||||||
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
# 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 = Array(shell.run("git status -s | grep '^.D' | sed 's/^...//'").split("\n"))
|
||||||
deleted_files.pop_back()
|
# deleted_files.pop_back()
|
||||||
|
|
||||||
var files = wd_files + deleted_files
|
var files = wd_files# + deleted_files
|
||||||
|
|
||||||
player = null
|
player = null
|
||||||
files.sort_custom(self, "very_best_sort")
|
files.sort_custom(self, "very_best_sort")
|
||||||
|
@ -34,21 +34,28 @@ func read_from_file():
|
|||||||
"index":
|
"index":
|
||||||
content = file_browser.shell.run("git show :'%s'" % label)
|
content = file_browser.shell.run("git show :'%s'" % label)
|
||||||
modulate = Color(0, 0, 1.0)
|
modulate = Color(0, 0, 1.0)
|
||||||
$Sprite.scale = Vector2(0.75, 0.75)
|
$Sprite.scale *= 1.2
|
||||||
"head":
|
"head":
|
||||||
var commit = "HEAD"
|
var commit = "HEAD"
|
||||||
if file_browser.commit:
|
if file_browser.commit:
|
||||||
commit = file_browser.commit.id
|
commit = file_browser.commit.id
|
||||||
else:
|
else:
|
||||||
modulate = Color(0, 0, 0, 0.2)
|
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])
|
content = file_browser.shell.run("git show %s:'%s'" % [commit, label])
|
||||||
|
|
||||||
|
|
||||||
attributes = helpers.parse(content)
|
attributes = helpers.parse(content)
|
||||||
position.x = int(attributes["x"])
|
if attributes.has("x"):
|
||||||
position.y = int(attributes["y"])
|
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():
|
func write_to_file():
|
||||||
attributes["x"] = str(position.x)
|
attributes["x"] = str(position.x)
|
||||||
attributes["y"] = str(position.y)
|
attributes["y"] = str(position.y)
|
||||||
@ -62,6 +69,12 @@ func _set_label(new_label):
|
|||||||
label = new_label
|
label = new_label
|
||||||
if label_node:
|
if label_node:
|
||||||
label_node.text = helpers.abbreviate(new_label, 30)
|
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):
|
#func _gui_input(event):
|
||||||
# if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
|
# if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
|
||||||
|
Loading…
Reference in New Issue
Block a user