diff --git a/arrow.gd b/arrow.gd index 91dc287..0415efe 100644 --- a/arrow.gd +++ b/arrow.gd @@ -2,13 +2,13 @@ extends Node2D var label = "label" setget label_set var target: String setget target_set -var repository: Node2D +var repository: Container func _ready(): pass func _process(delta): - if repository.objects.has(target): + if repository and repository.objects.has(target): var t = repository.objects[target] #print(t) $Line.points[1] = t.global_position - global_position diff --git a/main.gd b/main.gd index 7f31596..77387bd 100644 --- a/main.gd +++ b/main.gd @@ -7,6 +7,8 @@ var client_connection onready var input = $Terminal/Control/Input onready var output = $Terminal/Control/Output +onready var goal_repository = $Repositories/GoalRepository +onready var active_repository = $Repositories/ActiveRepository func _ready(): # Initialize level select. @@ -57,8 +59,8 @@ func load_level(id): construct_repo(goal_script, goal_repository_path) construct_repo(active_script, active_repository_path) - $GoalRepository.path = goal_repository_path - $ActiveRepository.path = active_repository_path + goal_repository.path = goal_repository_path + active_repository.path = active_repository_path func construct_repo(script, path): print(path) @@ -99,11 +101,11 @@ func _process(delta): func read_commit_message(): $CommitMessage.show() input.editable = false - $CommitMessage.text = game.read_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG") + $CommitMessage.text = game.read_file(active_repository.path+"/.git/COMMIT_EDITMSG") $CommitMessage.grab_focus() func save_commit_message(): - game.write_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) + game.write_file(active_repository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) print("disconnect") client_connection.disconnect_from_host() input.editable = true diff --git a/main.tscn b/main.tscn index dbc053a..cd0e062 100644 --- a/main.tscn +++ b/main.tscn @@ -109,15 +109,6 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="GoalRepository" parent="." instance=ExtResource( 3 )] -visible = false -position = Vector2( 21.5742, 19.4168 ) -size = Vector2( 500, 1000 ) - -[node name="ActiveRepository" parent="." instance=ExtResource( 3 )] -position = Vector2( 356.756, 44.1985 ) -size = Vector2( 500, 1000 ) - [node name="LevelSelect" type="MenuButton" parent="."] visible = false margin_left = 11.5584 @@ -129,5 +120,35 @@ flat = false __meta__ = { "_edit_use_anchors_": false } + +[node name="Repositories" type="HBoxContainer" parent="."] +margin_left = 5.0 +margin_top = 75.0 +margin_right = 1203.0 +margin_bottom = 1079.0 +custom_constants/separation = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="GoalRepository" parent="Repositories" instance=ExtResource( 3 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 0.0 +margin_top = 0.0 +margin_right = 599.0 +margin_bottom = 1004.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="ActiveRepository" parent="Repositories" instance=ExtResource( 3 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 599.0 +margin_top = 0.0 +margin_right = 1198.0 +margin_bottom = 1004.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 [connection signal="text_entered" from="Terminal/Control/Input" to="Terminal" method="send_command"] [connection signal="pressed" from="CommitMessage/SaveButton" to="." method="save_commit_message"] diff --git a/node.gd b/node.gd index 6e97f85..f69862e 100644 --- a/node.gd +++ b/node.gd @@ -3,7 +3,7 @@ extends Node2D var id setget id_set var content setget content_set var type setget type_set -var repository: Node2D +var repository: Container var children = {} setget children_set var id_always_visible = false diff --git a/repository.gd b/repository.gd index c421823..989b541 100644 --- a/repository.gd +++ b/repository.gd @@ -1,8 +1,8 @@ -extends Node2D +extends Container export var path: String setget set_path, get_path -export var size: Vector2 var objects = {} + var node = preload("res://node.tscn") func _ready(): @@ -32,7 +32,7 @@ func update_index(): $Index.text = git("ls-files") func random_position(): - return Vector2(rand_range(0, size.x), rand_range(0, size.y)) + return Vector2(rand_range(0, rect_size.x), rand_range(0, rect_size.y)) func update_objects(): for o in all_objects(): @@ -97,8 +97,9 @@ func apply_forces(): var f = 3000/pow(d+0.00001,1.5) o.position += dir*f o2.position -= dir*f - var d = o.position.distance_to(Vector2(size.x/2, size.y/2)) - var dir = (o.position - Vector2(size.x/2, size.y/2)).normalized() + var center_of_gravity = rect_size/2 + var d = o.position.distance_to(center_of_gravity) + var dir = (o.position - center_of_gravity).normalized() var f = (d+0.00001)*0.01 o.position -= dir*f diff --git a/repository.tscn b/repository.tscn index b5bb61d..2f3d4a8 100644 --- a/repository.tscn +++ b/repository.tscn @@ -2,8 +2,17 @@ [ext_resource path="res://repository.gd" type="Script" id=1] -[node name="Repository" type="Node2D"] +[node name="Repository" type="Container"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 2.0 +margin_top = 3.0 +margin_right = -6.0 +margin_bottom = -4.0 script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} [node name="Index" type="Label" parent="."] visible = false diff --git a/terminal.gd b/terminal.gd index 65f7603..670f827 100644 --- a/terminal.gd +++ b/terminal.gd @@ -32,4 +32,4 @@ func run_command_in_a_thread(command): input.text = "" output.text = output.text + "$ " + command + "\n" + o output.scroll_vertical = 999999 - $"../ActiveRepository".update_everything() + $"../Repositories/ActiveRepository".update_everything() # FIXME