From e9c321701557a51fc1084566ed5874b0ffe30bc0 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Mon, 14 Sep 2020 19:36:58 +0200 Subject: [PATCH] Make command dropdown prettier --- command_button.gd | 12 ------- command_button.tscn | 15 -------- main.gd | 4 +-- terminal.gd | 6 ++-- terminal.tscn | 86 ++++++++++----------------------------------- 5 files changed, 24 insertions(+), 99 deletions(-) delete mode 100644 command_button.gd delete mode 100644 command_button.tscn diff --git a/command_button.gd b/command_button.gd deleted file mode 100644 index fe5828b..0000000 --- a/command_button.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Button - -export var async = false - -func _ready(): - pass - -func pressed(): - if async: - $"../..".send_command_async(text) - else: - $"../..".send_command(text) diff --git a/command_button.tscn b/command_button.tscn deleted file mode 100644 index d638130..0000000 --- a/command_button.tscn +++ /dev/null @@ -1,15 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://command_button.gd" type="Script" id=1] - -[node name="Button" type="Button"] -margin_left = 1418.81 -margin_top = 760.827 -margin_right = 1672.81 -margin_bottom = 780.827 -text = "git commit --allow-empty -m \"emtpy\"" -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} -[connection signal="pressed" from="." to="." method="pressed"] diff --git a/main.gd b/main.gd index 7690b57..47bd9db 100644 --- a/main.gd +++ b/main.gd @@ -7,8 +7,8 @@ var client_connection var current_level = 0 onready var terminal = $Terminal -onready var input = $Terminal/Control/Input -onready var output = $Terminal/Control/Output +onready var input = terminal.input +onready var output = terminal.output onready var goal_repository = $Repositories/GoalRepository onready var active_repository = $Repositories/ActiveRepository diff --git a/terminal.gd b/terminal.gd index 25537af..e492430 100644 --- a/terminal.gd +++ b/terminal.gd @@ -5,10 +5,10 @@ var thread var history = [] var history_position = 0 -onready var input = $Control/Input +onready var input = $Control/InputLine/Input onready var output = $Control/Output onready var repo = $"../Repositories/ActiveRepository" -onready var command_dropdown = $Control/CommandDropdown +onready var command_dropdown = $Control/InputLine/CommandDropdown onready var main = get_parent() var premade_commands = [ @@ -23,6 +23,8 @@ func _ready(): for command in premade_commands: command_dropdown.get_popup().add_item(command) command_dropdown.get_popup().connect("id_pressed", self, "load_command") + command_dropdown.theme = Theme.new() + command_dropdown.theme.default_font = load("res://fonts/default.tres") func _input(event): if event is InputEventKey: diff --git a/terminal.tscn b/terminal.tscn index fe1ee33..1945f52 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1] [ext_resource path="res://terminal.gd" type="Script" id=2] -[ext_resource path="res://command_button.tscn" type="PackedScene" id=4] [sub_resource type="StyleBoxFlat" id=1] content_margin_left = 10.0 @@ -43,7 +42,7 @@ __meta__ = { [node name="Output" type="RichTextLabel" parent="Control"] margin_right = 1920.0 -margin_bottom = 1007.0 +margin_bottom = 1039.0 focus_mode = 2 size_flags_vertical = 3 custom_styles/normal = SubResource( 1 ) @@ -52,73 +51,15 @@ custom_colors/selection_color = Color( 0.14902, 0.368627, 0.168627, 0.690196 ) scroll_following = true selection_enabled = true -[node name="Button" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 887.0 -margin_right = 1920.0 -margin_bottom = 907.0 -text = "git commit --allow-empty" -align = 0 - -[node name="Button5" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 907.0 -margin_right = 1920.0 -margin_bottom = 927.0 -text = "echo $RANDOM | git hash-object -w --stdin" -align = 0 - -[node name="Button6" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 927.0 -margin_right = 1920.0 -margin_bottom = 947.0 -text = "git update-index --add noises; git write-tree" -align = 0 - -[node name="Button2" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 947.0 -margin_right = 1920.0 -margin_bottom = 967.0 -text = "git switch -c $RANDOM" -align = 0 - -[node name="Button3" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 967.0 -margin_right = 1920.0 -margin_bottom = 987.0 -text = "git checkout HEAD^" -align = 0 - -[node name="Button4" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_left = 0.0 -margin_top = 987.0 -margin_right = 1920.0 -margin_bottom = 1007.0 -text = "sleep 1;echo hey" -align = 0 - -[node name="CommandDropdown" type="MenuButton" parent="Control"] -margin_top = 1007.0 -margin_right = 1920.0 -margin_bottom = 1039.0 -custom_fonts/font = ExtResource( 1 ) -text = "Pick a command..." -flat = false -align = 0 - -[node name="Input" type="LineEdit" parent="Control"] +[node name="InputLine" type="HBoxContainer" parent="Control"] margin_top = 1039.0 margin_right = 1920.0 margin_bottom = 1080.0 + +[node name="Input" type="LineEdit" parent="Control/InputLine"] +margin_right = 1874.0 +margin_bottom = 41.0 +size_flags_horizontal = 3 custom_styles/read_only = SubResource( 2 ) custom_styles/normal = SubResource( 3 ) custom_fonts/font = ExtResource( 1 ) @@ -127,6 +68,15 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="CommandDropdown" type="MenuButton" parent="Control/InputLine"] +margin_left = 1878.0 +margin_right = 1920.0 +margin_bottom = 41.0 +custom_fonts/font = ExtResource( 1 ) +text = "..." +flat = false +align = 0 + [node name="ClearButton" type="Button" parent="."] anchor_left = 0.9 anchor_right = 1.0 @@ -135,5 +85,5 @@ margin_top = 10.0 margin_right = -10.0 custom_fonts/font = ExtResource( 1 ) text = "Clear" -[connection signal="text_entered" from="Control/Input" to="." method="send_command"] +[connection signal="text_entered" from="Control/InputLine/Input" to="." method="send_command"] [connection signal="pressed" from="ClearButton" to="." method="clear"]