mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Distribute file items randomly in the world. Add an "edit" card.
This commit is contained in:
parent
e97af81c0f
commit
17302c3f01
8 changed files with 39 additions and 18 deletions
|
@ -19,6 +19,11 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scenes/file_browser_item.gd"
|
"path": "res://scenes/file_browser_item.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Node2D",
|
||||||
|
"class": "Item",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://scenes/item.gd"
|
||||||
|
}, {
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "Level",
|
"class": "Level",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
|
@ -42,6 +47,7 @@ _global_script_classes=[ {
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"Chapter": "",
|
"Chapter": "",
|
||||||
"FileBrowserItem": "",
|
"FileBrowserItem": "",
|
||||||
|
"Item": "",
|
||||||
"Level": "",
|
"Level": "",
|
||||||
"LevelRepo": "",
|
"LevelRepo": "",
|
||||||
"Shell": "",
|
"Shell": "",
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"id": "edit",
|
||||||
|
"command": "fake-editor [file]",
|
||||||
|
"description": "Edit a file."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "init",
|
"id": "init",
|
||||||
"command": "git init",
|
"command": "git init",
|
||||||
|
|
|
@ -15,7 +15,7 @@ var repository
|
||||||
|
|
||||||
var open_file
|
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 text_edit = $Panel/TextEdit
|
||||||
onready var save_button = $Panel/TextEdit/SaveButton
|
onready var save_button = $Panel/TextEdit/SaveButton
|
||||||
onready var title_label = $Panel/Margin/Rows/Title
|
onready var title_label = $Panel/Margin/Rows/Title
|
||||||
|
@ -33,8 +33,8 @@ func _input(event):
|
||||||
|
|
||||||
func clear():
|
func clear():
|
||||||
pass
|
pass
|
||||||
# for item in grid.get_children():
|
for item in world.get_children():
|
||||||
# item.queue_free()
|
item.queue_free()
|
||||||
|
|
||||||
func substr2(s):
|
func substr2(s):
|
||||||
return s.substr(2)
|
return s.substr(2)
|
||||||
|
@ -63,13 +63,15 @@ func update():
|
||||||
if file_path.substr(0, 5) == ".git/":
|
if file_path.substr(0, 5) == ".git/":
|
||||||
continue
|
continue
|
||||||
#is_visible = true
|
#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.label = file_path
|
||||||
item.connect("clicked", self, "item_clicked")
|
#item.connect("clicked", self, "item_clicked")
|
||||||
item.connect("deleted", self, "item_deleted")
|
#item.connect("deleted", self, "item_deleted")
|
||||||
item.status = get_file_status(file_path, shell, 1)
|
item.status = get_file_status(file_path, shell, 1)
|
||||||
|
seed(item.label.hash())
|
||||||
#grid.add_child(item)
|
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
|
#visible = is_visible
|
||||||
|
|
||||||
FileBrowserMode.COMMIT:
|
FileBrowserMode.COMMIT:
|
||||||
|
@ -106,19 +108,19 @@ func get_file_status(file_path, the_shell, idx):
|
||||||
if file_status.length()>0:
|
if file_status.length()>0:
|
||||||
match file_status[idx]:
|
match file_status[idx]:
|
||||||
"D":
|
"D":
|
||||||
return FileBrowserItem.IconStatus.REMOVED
|
return Item.IconStatus.REMOVED
|
||||||
"M":
|
"M":
|
||||||
return FileBrowserItem.IconStatus.EDIT
|
return Item.IconStatus.EDIT
|
||||||
"U":
|
"U":
|
||||||
return FileBrowserItem.IconStatus.CONFLICT
|
return Item.IconStatus.CONFLICT
|
||||||
" ":
|
" ":
|
||||||
return FileBrowserItem.IconStatus.NONE
|
return Item.IconStatus.NONE
|
||||||
"A":
|
"A":
|
||||||
return FileBrowserItem.IconStatus.NEW
|
return Item.IconStatus.NEW
|
||||||
"?":
|
"?":
|
||||||
return FileBrowserItem.IconStatus.UNTRACKED
|
return Item.IconStatus.UNTRACKED
|
||||||
else:
|
else:
|
||||||
return FileBrowserItem.IconStatus.NONE
|
return Item.IconStatus.NONE
|
||||||
|
|
||||||
func item_clicked(item):
|
func item_clicked(item):
|
||||||
if item.status == item.IconStatus.REMOVED:
|
if item.status == item.IconStatus.REMOVED:
|
||||||
|
|
|
@ -124,7 +124,6 @@ margin_bottom = 20.0
|
||||||
|
|
||||||
[node name="You" parent="." instance=ExtResource( 6 )]
|
[node name="You" parent="." instance=ExtResource( 6 )]
|
||||||
position = Vector2( 175.746, 148.807 )
|
position = Vector2( 175.746, 148.807 )
|
||||||
status = 5
|
editable = false
|
||||||
label = "me"
|
|
||||||
[connection signal="pressed" from="Panel/TextEdit/SaveButton" to="." method="save"]
|
[connection signal="pressed" from="Panel/TextEdit/SaveButton" to="." method="save"]
|
||||||
[connection signal="pressed" from="Panel/TextEdit/CloseButton" to="." method="close"]
|
[connection signal="pressed" from="Panel/TextEdit/CloseButton" to="." method="close"]
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
class_name Item
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
||||||
export(IconStatus) var status setget _set_status
|
export(IconStatus) var status setget _set_status
|
||||||
export var label: String setget _set_label
|
export var label: String setget _set_label
|
||||||
var type = "file"
|
var type = "file"
|
||||||
|
export var editable = true
|
||||||
|
|
||||||
onready var label_node = $Label
|
onready var label_node = $Label
|
||||||
onready var status_icon = $Status
|
onready var status_icon = $Status
|
||||||
|
@ -11,6 +13,8 @@ onready var status_icon = $Status
|
||||||
func _ready():
|
func _ready():
|
||||||
_set_label(label)
|
_set_label(label)
|
||||||
_set_status(status)
|
_set_status(status)
|
||||||
|
if not editable:
|
||||||
|
type = "nothing"
|
||||||
#$PopupMenu.add_item("Delete file", 0)
|
#$PopupMenu.add_item("Delete file", 0)
|
||||||
|
|
||||||
func _set_label(new_label):
|
func _set_label(new_label):
|
||||||
|
|
|
@ -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://nodes/head.svg" type="Texture" id=1]
|
||||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
[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/item.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[node name="Item" type="Node2D"]
|
[node name="Item" type="Node2D"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
@ -26,3 +27,5 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="Status" type="Sprite" parent="."]
|
[node name="Status" type="Sprite" parent="."]
|
||||||
position = Vector2( 34.3633, -34.3633 )
|
position = Vector2( 34.3633, -34.3633 )
|
||||||
|
|
||||||
|
[node name="DropArea" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
|
@ -24,6 +24,7 @@ func load(path):
|
||||||
cards = Array(config.get("cards", "").split(" "))
|
cards = Array(config.get("cards", "").split(" "))
|
||||||
if cards == [""]:
|
if cards == [""]:
|
||||||
cards = []
|
cards = []
|
||||||
|
cards.push_back("edit")
|
||||||
|
|
||||||
var keys = config.keys()
|
var keys = config.keys()
|
||||||
var repo_setups = []
|
var repo_setups = []
|
||||||
|
|
|
@ -48,6 +48,7 @@ func run_async_thread(shell_command):
|
||||||
|
|
||||||
var env = {}
|
var env = {}
|
||||||
env["HOME"] = game.tmp_prefix
|
env["HOME"] = game.tmp_prefix
|
||||||
|
env["PATH"] = game.tmp_prefix + ":'\"$PATH\"'"
|
||||||
|
|
||||||
var hacky_command = ""
|
var hacky_command = ""
|
||||||
for variable in env:
|
for variable in env:
|
||||||
|
|
Loading…
Reference in a new issue