mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-24 20:33:19 +01:00
Display index versions of items
This commit is contained in:
parent
e635efa796
commit
833475e80b
3 changed files with 56 additions and 28 deletions
|
@ -33,23 +33,23 @@ func _input(event):
|
|||
if event.is_action_pressed("save"):
|
||||
if text_edit.visible:
|
||||
save()
|
||||
if event.is_action_pressed("down", true):
|
||||
player.move(Vector2(0,1))
|
||||
if event.is_action_pressed("up", true):
|
||||
player.move(Vector2(0,-1))
|
||||
if event.is_action_pressed("right", true):
|
||||
player.move(Vector2(1,0))
|
||||
if event.is_action_pressed("left", true):
|
||||
player.move(Vector2(-1,0))
|
||||
if event.is_action_pressed("pickup"):
|
||||
if player.held:
|
||||
player.held = null
|
||||
else:
|
||||
for item in world.get_children():
|
||||
if item.label != "":
|
||||
if item.position == player.position:
|
||||
player.held = item
|
||||
print("player picked up item " + item.label)
|
||||
# if event.is_action_pressed("down", true):
|
||||
# player.move(Vector2(0,1))
|
||||
# if event.is_action_pressed("up", true):
|
||||
# player.move(Vector2(0,-1))
|
||||
# if event.is_action_pressed("right", true):
|
||||
# player.move(Vector2(1,0))
|
||||
# if event.is_action_pressed("left", true):
|
||||
# player.move(Vector2(-1,0))
|
||||
# if event.is_action_pressed("pickup"):
|
||||
# if player.held:
|
||||
# player.held = null
|
||||
# else:
|
||||
# for item in world.get_children():
|
||||
# if item.label != "":
|
||||
# if item.position == player.position:
|
||||
# player.held = item
|
||||
# print("player picked up item " + item.label)
|
||||
|
||||
func clear():
|
||||
pass
|
||||
|
@ -66,6 +66,8 @@ func update():
|
|||
match mode:
|
||||
FileBrowserMode.WORKING_DIRECTORY:
|
||||
if shell:
|
||||
# Populate working directory.
|
||||
|
||||
var wd_files = Array(shell.run("find . -type f").split("\n"))
|
||||
# The last entry is an empty string, remove it.
|
||||
wd_files.pop_back()
|
||||
|
@ -79,22 +81,39 @@ func update():
|
|||
var files = wd_files + deleted_files
|
||||
|
||||
files.sort_custom(self, "very_best_sort")
|
||||
#var is_visible = false
|
||||
for file_path in files:
|
||||
if file_path.substr(0, 5) == ".git/":
|
||||
continue
|
||||
#is_visible = true
|
||||
var item = preload("res://scenes/item.tscn").instance()
|
||||
item.label = file_path
|
||||
item.file_browser = self
|
||||
#item.connect("clicked", self, "item_clicked")
|
||||
#item.connect("deleted", self, "item_deleted")
|
||||
item.status = get_file_status(file_path, shell, 1)
|
||||
seed(item.label.hash())
|
||||
item.position = Vector2(rand_range(0, world.rect_size.x), rand_range(0, world.rect_size.y))
|
||||
randomize()
|
||||
#item.status = get_file_status(file_path, shell, 1)
|
||||
item.item_type = "wd"
|
||||
#seed(item.label.hash())
|
||||
#item.position = Vector2(rand_range(0, world.rect_size.x), rand_range(0, world.rect_size.y))
|
||||
#randomize()
|
||||
world.add_child(item)
|
||||
#visible = is_visible
|
||||
|
||||
# Populate index.
|
||||
|
||||
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
||||
var index_files = Array(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()
|
||||
files = index_files# + deleted_files
|
||||
for file_path in files:
|
||||
var item = preload("res://scenes/item.tscn").instance()
|
||||
item.label = file_path
|
||||
item.item_type = "index"
|
||||
item.type = "nothing"
|
||||
item.file_browser = self
|
||||
print(item)
|
||||
#item.connect("clicked", self, "item_clicked")
|
||||
#item.status = get_file_status(file_path, repository.shell, 0)
|
||||
world.add_child(item)
|
||||
|
||||
|
||||
FileBrowserMode.COMMIT:
|
||||
if commit:
|
||||
|
|
|
@ -5,6 +5,7 @@ enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
|||
export(IconStatus) var status setget _set_status
|
||||
export var label: String setget _set_label
|
||||
var type = "file"
|
||||
var item_type
|
||||
export var editable = true
|
||||
|
||||
var attributes
|
||||
|
@ -26,8 +27,15 @@ func _ready():
|
|||
#$PopupMenu.add_item("Delete file", 0)
|
||||
|
||||
func read_from_file():
|
||||
print(file_browser)
|
||||
attributes = helpers.parse(file_browser.shell.run("cat '%s'" % label))
|
||||
var content
|
||||
match item_type:
|
||||
"wd":
|
||||
content = file_browser.shell.run("cat '%s'" % label)
|
||||
"index":
|
||||
content = file_browser.shell.run("git show :'%s'" % label)
|
||||
modulate = Color(0, 0, 255.0)
|
||||
|
||||
attributes = helpers.parse(content)
|
||||
position.x = int(attributes["x"])
|
||||
position.y = int(attributes["y"])
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ func save():
|
|||
|
||||
func close():
|
||||
if _client_connection and _client_connection.is_connected_to_host():
|
||||
_client_connection.put_string(text)
|
||||
_client_connection.disconnect_from_host()
|
||||
text = ""
|
||||
hide()
|
||||
|
|
Loading…
Reference in a new issue