fake-editor sends filename now, so that we can write tag descriptions, for example

This commit is contained in:
Sebastian Morr 2020-09-13 18:40:44 +02:00
parent 4c79dd24a7
commit 078c1612ac
4 changed files with 28 additions and 9 deletions

24
main.gd
View file

@ -92,7 +92,9 @@ func load_next_level():
func construct_repo(script, path): func construct_repo(script, path):
# Becase in an exported game, all assets are in a .pck file, we need to put # Becase in an exported game, all assets are in a .pck file, we need to put
# the script somewhere in the filesystem. # the script somewhere in the filesystem.
var content = game.read_file(script) var content = ""
if ResourceLoader.exists(script):
content = game.read_file(script)
var script_path_outside = game.tmp_prefix+"/git-hydra-script" var script_path_outside = game.tmp_prefix+"/git-hydra-script"
var script_path = "/tmp/git-hydra-script" var script_path = "/tmp/git-hydra-script"
game.write_file(script_path_outside, content) game.write_file(script_path_outside, content)
@ -106,19 +108,25 @@ func _process(_delta):
if server.is_connection_available(): if server.is_connection_available():
print("Client connected") print("Client connected")
client_connection = server.take_connection() client_connection = server.take_connection()
read_commit_message() var length = client_connection.get_u8()
var filename = client_connection.get_string(length)
var regex = RegEx.new()
regex.compile("(\\.git\\/.*)")
filename = regex.search(filename).get_string()
print(filename)
read_commit_message(filename)
func read_commit_message(): func read_commit_message(filename):
$CommitMessage.show() $CommitMessage.show()
input.editable = false input.editable = false
var fixme_path = game.tmp_prefix+"/active" var fixme_path = game.tmp_prefix+"/active/"
$CommitMessage.text = game.read_file(fixme_path+"/.git/COMMIT_EDITMSG") $CommitMessage.text = game.read_file(fixme_path+filename)
$CommitMessage.path = filename
$CommitMessage.grab_focus() $CommitMessage.grab_focus()
func save_commit_message(): func save_commit_message():
var fixme_path = game.tmp_prefix+"/active" var fixme_path = game.tmp_prefix+"/active/"
game.write_file(fixme_path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) game.write_file(fixme_path+$CommitMessage.path, $CommitMessage.text)
print("disconnect")
client_connection.disconnect_from_host() client_connection.disconnect_from_host()
input.editable = true input.editable = true
$CommitMessage.text = "" $CommitMessage.text = ""

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://terminal.tscn" type="PackedScene" id=1] [ext_resource path="res://terminal.tscn" type="PackedScene" id=1]
[ext_resource path="res://main.gd" type="Script" id=2] [ext_resource path="res://main.gd" type="Script" id=2]
[ext_resource path="res://repository.tscn" type="PackedScene" id=3] [ext_resource path="res://repository.tscn" type="PackedScene" id=3]
[ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=4] [ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=4]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5]
[ext_resource path="res://text_editor.gd" type="Script" id=6]
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.847059, 0.0666667, 0.0666667, 1 ) bg_color = Color( 0.847059, 0.0666667, 0.0666667, 1 )
@ -42,6 +43,7 @@ margin_bottom = 1068.0
custom_fonts/font = ExtResource( 5 ) custom_fonts/font = ExtResource( 5 )
custom_colors/background_color = Color( 0, 0, 0, 1 ) custom_colors/background_color = Color( 0, 0, 0, 1 )
syntax_highlighting = true syntax_highlighting = true
script = ExtResource( 6 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }

View file

@ -7,5 +7,11 @@ $socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1",
Proto => "tcp", Proto => "tcp",
Type => SOCK_STREAM); Type => SOCK_STREAM);
# Send the length of the first argument as a byte.
$socket->send(chr(length($ARGV[0])));
# Send the first argument as a string.
$socket->send($ARGV[0]);
# This call is intended to block, we're waiting for Godot to close the connection.
my $reply; my $reply;
$socket->read($reply, 1000); $socket->read($reply, 1000);

3
text_editor.gd Normal file
View file

@ -0,0 +1,3 @@
extends TextEdit
var path