mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
fake-editor sends filename now, so that we can write tag descriptions, for example
This commit is contained in:
parent
4c79dd24a7
commit
078c1612ac
4 changed files with 28 additions and 9 deletions
24
main.gd
24
main.gd
|
@ -92,7 +92,9 @@ func load_next_level():
|
|||
func construct_repo(script, path):
|
||||
# Becase in an exported game, all assets are in a .pck file, we need to put
|
||||
# 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 = "/tmp/git-hydra-script"
|
||||
game.write_file(script_path_outside, content)
|
||||
|
@ -106,19 +108,25 @@ func _process(_delta):
|
|||
if server.is_connection_available():
|
||||
print("Client connected")
|
||||
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()
|
||||
input.editable = false
|
||||
var fixme_path = game.tmp_prefix+"/active"
|
||||
$CommitMessage.text = game.read_file(fixme_path+"/.git/COMMIT_EDITMSG")
|
||||
var fixme_path = game.tmp_prefix+"/active/"
|
||||
$CommitMessage.text = game.read_file(fixme_path+filename)
|
||||
$CommitMessage.path = filename
|
||||
$CommitMessage.grab_focus()
|
||||
|
||||
func save_commit_message():
|
||||
var fixme_path = game.tmp_prefix+"/active"
|
||||
game.write_file(fixme_path+"/.git/COMMIT_EDITMSG", $CommitMessage.text)
|
||||
print("disconnect")
|
||||
var fixme_path = game.tmp_prefix+"/active/"
|
||||
game.write_file(fixme_path+$CommitMessage.path, $CommitMessage.text)
|
||||
client_connection.disconnect_from_host()
|
||||
input.editable = true
|
||||
$CommitMessage.text = ""
|
||||
|
|
|
@ -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://main.gd" type="Script" id=2]
|
||||
[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://fonts/default.tres" type="DynamicFont" id=5]
|
||||
[ext_resource path="res://text_editor.gd" type="Script" id=6]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=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_colors/background_color = Color( 0, 0, 0, 1 )
|
||||
syntax_highlighting = true
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
|
@ -7,5 +7,11 @@ $socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1",
|
|||
Proto => "tcp",
|
||||
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;
|
||||
$socket->read($reply, 1000);
|
||||
|
|
3
text_editor.gd
Normal file
3
text_editor.gd
Normal file
|
@ -0,0 +1,3 @@
|
|||
extends TextEdit
|
||||
|
||||
var path
|
Loading…
Reference in a new issue