Skip to content

Commit 0f39d3d

Browse files
committed
add simple ui
1 parent e2969f8 commit 0f39d3d

File tree

2 files changed

+57
-18
lines changed

2 files changed

+57
-18
lines changed

godot/main.gd

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
extends Node
22

3+
@onready var input: TextEdit = $"Form/Input"
34

45
# Called when the node enters the scene tree for the first time.
56
func _ready():
@@ -9,3 +10,7 @@ func _ready():
910
# Called every frame. 'delta' is the elapsed time since the previous frame.
1011
func _process(delta):
1112
pass
13+
14+
15+
func _on_button_pressed():
16+
print(input.text)

godot/main.tscn

+52-18
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,63 @@ grow_horizontal = 2
1414
grow_vertical = 2
1515
color = Color(0.980392, 0.952941, 0.929412, 1)
1616

17-
[node name="GodotLlamaSprite" type="Sprite2D" parent="."]
18-
position = Vector2(578, 265)
19-
scale = Vector2(0.2, 0.2)
20-
texture = ExtResource("1_ojdoj")
21-
22-
[node name="HBoxContainer" type="HBoxContainer" parent="."]
23-
visible = false
24-
anchors_preset = 7
25-
anchor_left = 0.5
26-
anchor_top = 1.0
27-
anchor_right = 0.5
28-
anchor_bottom = 1.0
29-
offset_left = -138.0
30-
offset_top = -180.0
31-
offset_right = 138.0
32-
offset_bottom = -42.0
17+
[node name="Form" type="HBoxContainer" parent="."]
18+
custom_minimum_size = Vector2(300, 50)
19+
anchors_preset = -1
20+
anchor_top = 0.7
21+
anchor_right = 1.0
22+
anchor_bottom = 0.7
23+
offset_left = 350.0
24+
offset_top = -1.66893e-05
25+
offset_right = -350.0
26+
offset_bottom = 50.0
3327
grow_horizontal = 2
3428
grow_vertical = 0
3529
alignment = 1
3630

37-
[node name="TextEdit" type="TextEdit" parent="HBoxContainer"]
31+
[node name="Input" type="TextEdit" parent="Form"]
3832
layout_mode = 2
33+
size_flags_horizontal = 3
34+
size_flags_stretch_ratio = 3.0
3935
placeholder_text = "Ask me anything..."
4036

41-
[node name="Button" type="Button" parent="HBoxContainer"]
37+
[node name="SubmitButton" type="Button" parent="Form"]
4238
layout_mode = 2
39+
size_flags_horizontal = 3
40+
text = "Submit"
41+
42+
[node name="SpriteContainer" type="CenterContainer" parent="."]
43+
anchors_preset = -1
44+
anchor_left = 0.5
45+
anchor_top = 0.4
46+
anchor_right = 0.5
47+
anchor_bottom = 0.4
48+
offset_left = -20.0
49+
offset_top = -20.0
50+
offset_right = 20.0
51+
offset_bottom = 20.0
52+
grow_horizontal = 2
53+
grow_vertical = 2
54+
55+
[node name="GodotLlamaSprite" type="Sprite2D" parent="SpriteContainer"]
56+
position = Vector2(20, 20)
57+
scale = Vector2(0.2, 0.2)
58+
texture = ExtResource("1_ojdoj")
59+
60+
[node name="Label" type="Label" parent="."]
61+
anchors_preset = -1
62+
anchor_left = 0.5
63+
anchor_top = 0.6
64+
anchor_right = 0.5
65+
anchor_bottom = 0.6
66+
offset_left = -127.0
67+
offset_top = -22.5
68+
offset_right = 127.0
69+
offset_bottom = 22.5
70+
grow_horizontal = 2
71+
grow_vertical = 2
72+
theme_override_colors/font_color = Color(0.101961, 0.0823529, 0.0627451, 1)
73+
theme_override_font_sizes/font_size = 32
74+
text = "godot-llama-cpp"
75+
76+
[connection signal="pressed" from="Form/SubmitButton" to="." method="_on_button_pressed"]

0 commit comments

Comments
 (0)