Distribute file items randomly in the world. Add an "edit" card.

This commit is contained in:
blinry 2020-11-17 17:07:16 +01:00
parent e97af81c0f
commit 17302c3f01
8 changed files with 39 additions and 18 deletions

View file

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scenes/file_browser_item.gd"
}, {
"base": "Node2D",
"class": "Item",
"language": "GDScript",
"path": "res://scenes/item.gd"
}, {
"base": "Node",
"class": "Level",
"language": "GDScript",
@ -42,6 +47,7 @@ _global_script_classes=[ {
_global_script_class_icons={
"Chapter": "",
"FileBrowserItem": "",
"Item": "",
"Level": "",
"LevelRepo": "",
"Shell": "",

View file

@ -1,4 +1,9 @@
[
{
"id": "edit",
"command": "fake-editor [file]",
"description": "Edit a file."
},
{
"id": "init",
"command": "git init",

View file

@ -15,7 +15,7 @@ var repository
var open_file
#onready var grid = $Panel/Margin/Rows/Scroll/Grid
onready var world = $Panel/Margin/Rows/World
onready var text_edit = $Panel/TextEdit
onready var save_button = $Panel/TextEdit/SaveButton
onready var title_label = $Panel/Margin/Rows/Title
@ -33,8 +33,8 @@ func _input(event):
func clear():
pass
# for item in grid.get_children():
# item.queue_free()
for item in world.get_children():
item.queue_free()
func substr2(s):
return s.substr(2)
@ -63,13 +63,15 @@ func update():
if file_path.substr(0, 5) == ".git/":
continue
#is_visible = true
var item = preload("res://scenes/file_browser_item.tscn").instance()
var item = preload("res://scenes/item.tscn").instance()
item.label = file_path
item.connect("clicked", self, "item_clicked")
item.connect("deleted", self, "item_deleted")
#item.connect("clicked", self, "item_clicked")
#item.connect("deleted", self, "item_deleted")
item.status = get_file_status(file_path, shell, 1)
#grid.add_child(item)
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
FileBrowserMode.COMMIT:
@ -106,19 +108,19 @@ func get_file_status(file_path, the_shell, idx):
if file_status.length()>0:
match file_status[idx]:
"D":
return FileBrowserItem.IconStatus.REMOVED
return Item.IconStatus.REMOVED
"M":
return FileBrowserItem.IconStatus.EDIT
return Item.IconStatus.EDIT
"U":
return FileBrowserItem.IconStatus.CONFLICT
return Item.IconStatus.CONFLICT
" ":
return FileBrowserItem.IconStatus.NONE
return Item.IconStatus.NONE
"A":
return FileBrowserItem.IconStatus.NEW
return Item.IconStatus.NEW
"?":
return FileBrowserItem.IconStatus.UNTRACKED
return Item.IconStatus.UNTRACKED
else:
return FileBrowserItem.IconStatus.NONE
return Item.IconStatus.NONE
func item_clicked(item):
if item.status == item.IconStatus.REMOVED:

View file

@ -124,7 +124,6 @@ margin_bottom = 20.0
[node name="You" parent="." instance=ExtResource( 6 )]
position = Vector2( 175.746, 148.807 )
status = 5
label = "me"
editable = false
[connection signal="pressed" from="Panel/TextEdit/SaveButton" to="." method="save"]
[connection signal="pressed" from="Panel/TextEdit/CloseButton" to="." method="close"]

View file

@ -1,9 +1,11 @@
class_name Item
extends Node2D
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"
export var editable = true
onready var label_node = $Label
onready var status_icon = $Status
@ -11,6 +13,8 @@ onready var status_icon = $Status
func _ready():
_set_label(label)
_set_status(status)
if not editable:
type = "nothing"
#$PopupMenu.add_item("Delete file", 0)
func _set_label(new_label):

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://nodes/head.svg" type="Texture" id=1]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
[ext_resource path="res://scenes/item.gd" type="Script" id=3]
[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=4]
[node name="Item" type="Node2D"]
script = ExtResource( 3 )
@ -26,3 +27,5 @@ __meta__ = {
[node name="Status" type="Sprite" parent="."]
position = Vector2( 34.3633, -34.3633 )
[node name="DropArea" parent="." instance=ExtResource( 4 )]

View file

@ -24,6 +24,7 @@ func load(path):
cards = Array(config.get("cards", "").split(" "))
if cards == [""]:
cards = []
cards.push_back("edit")
var keys = config.keys()
var repo_setups = []

View file

@ -48,6 +48,7 @@ func run_async_thread(shell_command):
var env = {}
env["HOME"] = game.tmp_prefix
env["PATH"] = game.tmp_prefix + ":'\"$PATH\"'"
var hacky_command = ""
for variable in env: