-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dialog.tscn
171 lines (155 loc) · 4.22 KB
/
Dialog.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[gd_scene load_steps=7 format=2]
[ext_resource path="res://entities/DialogBg.tscn" type="PackedScene" id=1]
[ext_resource path="res://people/emily/portrait.png" type="Texture" id=2]
[ext_resource path="res://basicfont.tres" type="DynamicFont" id=3]
[ext_resource path="res://sounds/MenuSounds.tscn" type="PackedScene" id=4]
[sub_resource type="GDScript" id=1]
script/source = "extends CanvasLayer
signal dialog_actioned(id)
var dialog
var current_choice = 0
# this draws the current text of the dialog
func drawText():
if \"name\" in GameState.current:
$Text.bbcode_text = dialog.dialogue.replace(\"Emily\", GameState.current.name)
else:
$Text.bbcode_text = dialog.dialogue
if dialog.responses.size():
$Text.bbcode_text += '\\n'
# TODO: make a better indicator, with the assumption that each choice is 1 line
for i in range(dialog.responses.size()):
if i == current_choice:
$Text.bbcode_text += '\\n- ' + dialog.responses[i].prompt
else:
$Text.bbcode_text += '\\n ' + dialog.responses[i].prompt
# this is called by GameState.show_dialog()
func handle(d):
dialog = d
# print(dialog.character, \": \", dialog.dialogue)
GameState.camera.zoom = Vector2(1, 1)
if \"name\" in GameState.current:
$Name.bbcode_text = dialog.character.replace(\"Emily\", GameState.current.name)
else:
$Name.bbcode_text = dialog.character
$portrait.texture = load('res://people/%s/portrait.png' % dialog.character.to_lower())
drawText()
if dialog.next_node_id:
$MoreIndicator.play(\"more\")
$MoreIndicator/Label.visible = true
else:
$MoreIndicator.stop()
$MoreIndicator/Label.visible = false
func _input(event):
if event.is_action_pressed('ui_cancel'):
GameState.set_player_move(true)
queue_free()
if dialog.responses.size() == 0:
if event.is_action_pressed('ui_accept'):
$MenuSounds/ok.play()
yield($MenuSounds/ok, \"finished\")
emit_signal('dialog_actioned', dialog.next_node_id)
queue_free()
else:
if event.is_action_pressed('ui_up'):
$MenuSounds/move.play()
current_choice = (current_choice - 1) % dialog.responses.size()
drawText()
if event.is_action_pressed('ui_down'):
$MenuSounds/move.play()
current_choice = (current_choice + 1) % dialog.responses.size()
drawText()
if event.is_action_pressed('ui_accept'):
$MenuSounds/ok.play()
yield($MenuSounds/ok, \"finished\")
emit_signal('dialog_actioned', dialog.responses[current_choice].next_node_id)
queue_free()
"
[sub_resource type="Animation" id=2]
resource_name = "more"
length = 0.3
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("MoreIndicator/Label:text")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 1,
"values": [ ".", "..", "..." ]
}
[node name="Dialog" type="CanvasLayer"]
script = SubResource( 1 )
[node name="DialogBg" parent="." instance=ExtResource( 1 )]
margin_left = -152.0
margin_top = 168.035
margin_right = 150.0
margin_bottom = 232.035
[node name="Text" type="RichTextLabel" parent="."]
margin_left = 15.0
margin_top = 178.0
margin_right = 298.0
margin_bottom = 226.0
rect_clip_content = false
custom_fonts/normal_font = ExtResource( 3 )
bbcode_enabled = true
bbcode_text = "TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT"
text = "TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT
TEXT"
scroll_active = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoreIndicator" type="AnimationPlayer" parent="."]
playback_speed = 0.5
anims/more = SubResource( 2 )
[node name="Label" type="Label" parent="MoreIndicator"]
margin_left = 291.75
margin_top = 212.625
margin_right = 306.75
margin_bottom = 226.625
text = "..."
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MenuSounds" parent="." instance=ExtResource( 4 )]
[node name="portrait" type="Sprite" parent="."]
position = Vector2( 254.165, 123.035 )
texture = ExtResource( 2 )
[node name="Name" type="RichTextLabel" parent="."]
margin_left = 16.0
margin_top = 155.0
margin_right = 217.0
margin_bottom = 165.0
rect_clip_content = false
custom_fonts/normal_font = ExtResource( 3 )
bbcode_enabled = true
bbcode_text = "Emily"
text = "Emily"
scroll_active = false
__meta__ = {
"_edit_use_anchors_": false
}