mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Better colors and fonts
This commit is contained in:
parent
590408e54c
commit
ca8aae560c
13 changed files with 165 additions and 83 deletions
14
arrow.tscn
14
arrow.tscn
|
@ -1,25 +1,29 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://arrow.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
||||
|
||||
[node name="Arrow" type="Node2D"]
|
||||
show_behind_parent = true
|
||||
z_as_relative = false
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Line" type="Line2D" parent="."]
|
||||
z_index = -1
|
||||
points = PoolVector2Array( -0.480499, -0.11055, 158.301, 0.581757 )
|
||||
default_color = Color( 0.447059, 0.447059, 0.447059, 1 )
|
||||
default_color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
|
||||
[node name="Tip" type="Node2D" parent="."]
|
||||
position = Vector2( 149.835, 0.290878 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Polygon" type="Polygon2D" parent="Tip"]
|
||||
position = Vector2( -9.66138, -2.89842 )
|
||||
z_index = -1
|
||||
color = Color( 0.447059, 0.447059, 0.447059, 1 )
|
||||
color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
polygon = PoolVector2Array( -19.8744, 17.0372, 47.7551, 11.8845, -10.5351, -21.2861 )
|
||||
|
||||
[node name="Label" type="Node2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 102, 46 )
|
||||
|
||||
[node name="ID" type="Label" parent="Label"]
|
||||
|
@ -27,6 +31,8 @@ margin_left = -19.374
|
|||
margin_top = -5.93085
|
||||
margin_right = 20.626
|
||||
margin_bottom = 8.06915
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "label"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
|
|
|
@ -5,4 +5,4 @@ func _ready():
|
|||
|
||||
|
||||
func pressed():
|
||||
$"..".send_command(text)
|
||||
$"../..".send_command(text)
|
||||
|
|
7
fonts/default.tres
Normal file
7
fonts/default.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/iosevka-regular.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[resource]
|
||||
size = 20
|
||||
font_data = ExtResource( 1 )
|
BIN
fonts/iosevka-regular.ttf
Normal file
BIN
fonts/iosevka-regular.ttf
Normal file
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
echo -e "bread\ntomato\nbread" > sandwich
|
||||
git add sandwich
|
||||
git commit -m "Initial sandwich"
|
||||
echo -e "bread\ntomato\ncucumber\nbread" > sandwich
|
||||
git commit -am "Add cucumber"
|
11
main.gd
11
main.gd
|
@ -5,6 +5,9 @@ var dragged = null
|
|||
var server
|
||||
var client_connection
|
||||
|
||||
onready var input = $Terminal/Control/Input
|
||||
onready var output = $Terminal/Control/Output
|
||||
|
||||
func _ready():
|
||||
# Initialize level select.
|
||||
var options = $LevelSelect.get_popup()
|
||||
|
@ -18,7 +21,7 @@ func _ready():
|
|||
|
||||
# Load first level.
|
||||
load_level(0)
|
||||
$Terminal/Input.grab_focus()
|
||||
input.grab_focus()
|
||||
|
||||
func list_levels():
|
||||
var levels = []
|
||||
|
@ -95,7 +98,7 @@ func _process(delta):
|
|||
|
||||
func read_commit_message():
|
||||
$CommitMessage.show()
|
||||
$Terminal/Input.editable = false
|
||||
input.editable = false
|
||||
$CommitMessage.text = game.read_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG")
|
||||
$CommitMessage.grab_focus()
|
||||
|
||||
|
@ -103,7 +106,7 @@ func save_commit_message():
|
|||
game.write_file($ActiveRepository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text)
|
||||
print("disconnect")
|
||||
client_connection.disconnect_from_host()
|
||||
$Terminal/Input.editable = true
|
||||
input.editable = true
|
||||
$CommitMessage.text = ""
|
||||
$CommitMessage.hide()
|
||||
$Terminal/Input.grab_focus()
|
||||
input.grab_focus()
|
||||
|
|
130
main.tscn
130
main.tscn
|
@ -1,81 +1,125 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://terminal.gd" type="Script" 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://command_button.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Terminal" type="Node2D" parent="."]
|
||||
z_index = 1
|
||||
script = ExtResource( 1 )
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
margin_right = 1922.0
|
||||
margin_bottom = 1081.0
|
||||
mouse_filter = 2
|
||||
color = Color( 0.0705882, 0.0705882, 0.0705882, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Output" type="TextEdit" parent="Terminal"]
|
||||
margin_left = 1416.0
|
||||
margin_top = 4.0
|
||||
margin_right = 1915.0
|
||||
margin_bottom = 737.0
|
||||
[node name="Terminal" type="Control" parent="."]
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Control" type="VBoxContainer" parent="Terminal"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 1208.0
|
||||
margin_top = 6.0
|
||||
margin_right = 1908.0
|
||||
margin_bottom = 1070.0
|
||||
custom_constants/separation = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Output" type="TextEdit" parent="Terminal/Control"]
|
||||
margin_right = 700.0
|
||||
margin_bottom = 1038.0
|
||||
size_flags_vertical = 3
|
||||
custom_styles/read_only = SubResource( 1 )
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
readonly = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Input" type="LineEdit" parent="Terminal"]
|
||||
margin_left = 1414.0
|
||||
margin_top = 1019.0
|
||||
margin_right = 1913.0
|
||||
margin_bottom = 1075.0
|
||||
[node name="Button" parent="Terminal/Control" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = 0.0
|
||||
margin_top = 852.0
|
||||
margin_right = 700.0
|
||||
margin_bottom = 905.0
|
||||
align = 0
|
||||
|
||||
[node name="Button2" parent="Terminal/Control" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = 0.0
|
||||
margin_top = 905.0
|
||||
margin_right = 700.0
|
||||
margin_bottom = 958.0
|
||||
text = "git switch -c $RANDOM"
|
||||
align = 0
|
||||
|
||||
[node name="Button3" parent="Terminal/Control" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = 0.0
|
||||
margin_top = 958.0
|
||||
margin_right = 700.0
|
||||
margin_bottom = 1011.0
|
||||
text = "git checkout HEAD^"
|
||||
align = 0
|
||||
|
||||
[node name="Input" type="LineEdit" parent="Terminal/Control"]
|
||||
margin_top = 1038.0
|
||||
margin_right = 700.0
|
||||
margin_bottom = 1064.0
|
||||
custom_styles/normal = SubResource( 2 )
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Button" parent="Terminal" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="Button2" parent="Terminal" instance=ExtResource( 4 )]
|
||||
margin_left = 1417.9
|
||||
margin_top = 801.646
|
||||
margin_right = 1671.9
|
||||
margin_bottom = 821.646
|
||||
text = "git switch -c $RANDOM"
|
||||
|
||||
[node name="Button3" parent="Terminal" instance=ExtResource( 4 )]
|
||||
margin_left = 1417.45
|
||||
margin_top = 846.547
|
||||
margin_right = 1671.45
|
||||
margin_bottom = 866.547
|
||||
text = "git checkout HEAD^"
|
||||
|
||||
[node name="CommitMessage" type="TextEdit" parent="."]
|
||||
visible = false
|
||||
margin_left = 889.832
|
||||
margin_top = 16.4234
|
||||
margin_right = 1388.83
|
||||
margin_bottom = 582.423
|
||||
margin_left = 1209.0
|
||||
margin_top = 6.0
|
||||
margin_right = 1907.0
|
||||
margin_bottom = 1068.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Button" type="Button" parent="CommitMessage"]
|
||||
margin_left = 344.277
|
||||
margin_top = 509.45
|
||||
margin_right = 493.277
|
||||
margin_bottom = 558.45
|
||||
text = "SAVE!"
|
||||
[node name="SaveButton" type="Button" parent="CommitMessage"]
|
||||
margin_left = 537.443
|
||||
margin_top = 997.65
|
||||
margin_right = 686.443
|
||||
margin_bottom = 1046.65
|
||||
text = "Save"
|
||||
__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( 704.399, 17.2594 )
|
||||
position = Vector2( 356.756, 44.1985 )
|
||||
size = Vector2( 500, 1000 )
|
||||
|
||||
[node name="LevelSelect" type="MenuButton" parent="."]
|
||||
visible = false
|
||||
margin_left = 11.5584
|
||||
margin_top = 11.1303
|
||||
margin_right = 109.558
|
||||
|
@ -85,5 +129,5 @@ flat = false
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[connection signal="text_entered" from="Terminal/Input" to="Terminal" method="send_command"]
|
||||
[connection signal="pressed" from="CommitMessage/Button" to="." method="save_commit_message"]
|
||||
[connection signal="text_entered" from="Terminal/Control/Input" to="Terminal" method="send_command"]
|
||||
[connection signal="pressed" from="CommitMessage/SaveButton" to="." method="save_commit_message"]
|
||||
|
|
15
node.gd
15
node.gd
|
@ -6,6 +6,7 @@ var type setget type_set
|
|||
var repository: Node2D
|
||||
|
||||
var children = {} setget children_set
|
||||
var id_always_visible = false
|
||||
|
||||
var arrow = preload("res://arrow.tscn")
|
||||
|
||||
|
@ -18,7 +19,7 @@ func _process(delta):
|
|||
var other = get_node("..").objects[c]
|
||||
var d = other.position.distance_to(position)
|
||||
var dir = (other.position - position).normalized()
|
||||
var f = (d*0.05)
|
||||
var f = (d*0.01)
|
||||
position += dir*f
|
||||
other.position -= dir*f
|
||||
|
||||
|
@ -36,17 +37,22 @@ func type_set(new_type):
|
|||
$ID.text = $ID.text.substr(0,8)
|
||||
match new_type:
|
||||
"blob":
|
||||
$Rect.color = Color.gray
|
||||
$Rect.color = Color("#333333")
|
||||
"tree":
|
||||
$Rect.color = Color.darkgreen
|
||||
"commit":
|
||||
$Rect.color = Color.orange
|
||||
"tag":
|
||||
$Rect.color = Color.blue
|
||||
id_always_visible = true
|
||||
"ref":
|
||||
$Rect.color = Color("#6680ff")
|
||||
id_always_visible = true
|
||||
"head":
|
||||
$Rect.color = Color.red
|
||||
id_always_visible = true
|
||||
if id_always_visible:
|
||||
$ID.show()
|
||||
|
||||
func children_set(new_children):
|
||||
for c in $Arrows.get_children():
|
||||
|
@ -63,7 +69,10 @@ func children_set(new_children):
|
|||
|
||||
func _on_hover():
|
||||
$Content.visible = true
|
||||
$ID.visible = true
|
||||
|
||||
func _on_unhover():
|
||||
$Content.visible = false
|
||||
if not id_always_visible:
|
||||
$Content.visible = false
|
||||
$ID.visible = false
|
||||
|
||||
|
|
39
node.tscn
39
node.tscn
|
@ -1,42 +1,47 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://node.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 69.1778, 29.9015 )
|
||||
extents = Vector2( 30.4838, 29.9015 )
|
||||
|
||||
[node name="Node" type="Node2D"]
|
||||
z_index = 1
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Rect" type="ColorRect" parent="."]
|
||||
margin_left = -62.0578
|
||||
margin_top = -20.6286
|
||||
margin_right = 61.9422
|
||||
margin_bottom = 21.3714
|
||||
margin_left = -29.0
|
||||
margin_top = -28.0
|
||||
margin_right = 29.0
|
||||
margin_bottom = 30.0
|
||||
mouse_filter = 2
|
||||
color = Color( 0.984314, 0, 0, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ID" type="Label" parent="."]
|
||||
margin_left = -57.0578
|
||||
margin_top = -7.6286
|
||||
margin_right = 58.9422
|
||||
margin_bottom = 16.3714
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
visible = false
|
||||
margin_left = -14.6409
|
||||
margin_top = -12.4902
|
||||
margin_right = 134.359
|
||||
margin_bottom = 40.5098
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "object_id"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Content" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = -57.0
|
||||
margin_top = 29.0
|
||||
margin_right = 250.0
|
||||
margin_bottom = 238.0
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
margin_left = -12.8299
|
||||
margin_top = 39.5639
|
||||
margin_right = 294.17
|
||||
margin_bottom = 248.564
|
||||
custom_fonts/font = ExtResource( 2 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "content"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
|
|
@ -99,7 +99,7 @@ func apply_forces():
|
|||
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 f = (d+0.00001)*0.02
|
||||
var f = (d+0.00001)*0.01
|
||||
o.position -= dir*f
|
||||
|
||||
func git(args, splitlines = false):
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Index" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = 36.0787
|
||||
margin_top = 120.0
|
||||
margin_right = 375.079
|
||||
|
@ -17,6 +18,7 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="IndexLabel" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = 38.0
|
||||
margin_top = 69.0
|
||||
margin_right = 377.0
|
||||
|
@ -27,6 +29,7 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
visible = false
|
||||
margin_left = 36.5602
|
||||
margin_top = 67.9891
|
||||
margin_right = 94.5602
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo Hi, I am commit-hook
|
||||
echo $*
|
||||
nc localhost 1234
|
||||
echo Goodbye
|
||||
|
|
17
terminal.gd
17
terminal.gd
|
@ -1,20 +1,23 @@
|
|||
extends Node2D
|
||||
extends Control
|
||||
|
||||
var thread
|
||||
|
||||
var history = []
|
||||
var history_position = 0
|
||||
|
||||
onready var input = $Control/Input
|
||||
onready var output = $Control/Output
|
||||
|
||||
func _input(event):
|
||||
if history.size() > 0:
|
||||
if event.is_action_pressed("ui_up"):
|
||||
history_position -= 1
|
||||
history_position %= history.size()
|
||||
$Input.text = history[history_position]
|
||||
input.text = history[history_position]
|
||||
if event.is_action_pressed("ui_down"):
|
||||
history_position += 1
|
||||
history_position %= history.size()
|
||||
$Input.text = history[history_position]
|
||||
input.text = history[history_position]
|
||||
|
||||
func send_command(command):
|
||||
history.push_back(command)
|
||||
|
@ -24,9 +27,9 @@ func send_command(command):
|
|||
thread.start(self, "run_command_in_a_thread", command)
|
||||
|
||||
func run_command_in_a_thread(command):
|
||||
var output = game.sh(command, "/tmp/active")
|
||||
var o = game.sh(command, "/tmp/active")
|
||||
|
||||
$Input.text = ""
|
||||
$Output.text = $Output.text + "$ " + command + "\n" + output
|
||||
$Output.scroll_vertical = 999999
|
||||
input.text = ""
|
||||
output.text = output.text + "$ " + command + "\n" + o
|
||||
output.scroll_vertical = 999999
|
||||
$"../ActiveRepository".update_everything()
|
||||
|
|
Loading…
Reference in a new issue