|
@@ -96,8 +96,9 @@ func _on_ChoicesList_choices_changed(new_json_structure):
|
96
|
96
|
if (self.get_slot_amount() != slot_number):
|
97
|
97
|
self.set_slot_amount(slot_number)
|
98
|
98
|
self._update_slots()
|
99
|
|
- # TODO fix slots resetting when editing choice data
|
100
|
|
- self.emit_signal("changed_slots", self)
|
|
99
|
+ self.emit_signal("changed_slots", self)
|
|
100
|
+ else:
|
|
101
|
+ _update_slots_labels()
|
101
|
102
|
_emit_text()
|
102
|
103
|
|
103
|
104
|
|
|
@@ -127,12 +128,9 @@ func set_slot_amount(new_amount : int):
|
127
|
128
|
|
128
|
129
|
|
129
|
130
|
func set_text(new_text : String):
|
130
|
|
- print("New text received:")
|
131
|
|
- print(new_text)
|
132
|
131
|
json_structure = JSON.parse(new_text).get_result()
|
133
|
|
- print(JSON.print(json_structure, "\t"))
|
134
|
132
|
_update_components()
|
135
|
|
- self.emit_signal("text_changed", self._nid, new_text)
|
|
133
|
+ _emit_text()
|
136
|
134
|
|
137
|
135
|
#Private Methods
|
138
|
136
|
|
|
@@ -144,7 +142,6 @@ func _update_components():
|
144
|
142
|
_ChoicesList.set_structure(json_structure.dialog.choices_multiple)
|
145
|
143
|
|
146
|
144
|
func _emit_text():
|
147
|
|
- print(get_text())
|
148
|
145
|
self.emit_signal("text_changed", self._nid, get_text())
|
149
|
146
|
|
150
|
147
|
|
|
@@ -152,18 +149,28 @@ func _clear_link_labels():
|
152
|
149
|
var children = self.get_children()
|
153
|
150
|
for child in children:
|
154
|
151
|
if child is Label:
|
155
|
|
- child.free()
|
|
152
|
+ child.queue_free()
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+func _update_slots_labels():
|
|
156
|
+ for slot in range(0, self.get_slot_amount()):
|
|
157
|
+ var output_link_label = self.get_children()[slot]
|
|
158
|
+ if (output_link_label is Label):
|
|
159
|
+ output_link_label.text = self._get_choice_name(slot)
|
156
|
160
|
|
|
161
|
+func _get_choice_name(index):
|
|
162
|
+ var choices: Array = json_structure.dialog.choices_multiple;
|
|
163
|
+ if (choices.size() > 0):
|
|
164
|
+ return choices[index].title
|
|
165
|
+ else:
|
|
166
|
+ return "Next"
|
157
|
167
|
|
158
|
168
|
func _update_slots():
|
159
|
169
|
self.clear_all_slots()
|
160
|
170
|
self._clear_link_labels()
|
161
|
171
|
self.set_slot(0, true, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
|
162
|
172
|
var base_link_label = Label.new()
|
163
|
|
- if (json_structure.dialog.choices_multiple.size() == 0):
|
164
|
|
- base_link_label.text = "Next"
|
165
|
|
- else:
|
166
|
|
- base_link_label.text = "Choice #1"
|
|
173
|
+ base_link_label.text = self._get_choice_name(0)
|
167
|
174
|
base_link_label.align = Label.ALIGN_RIGHT
|
168
|
175
|
self.add_child(base_link_label)
|
169
|
176
|
self.move_child(base_link_label, 0)
|
|
@@ -171,9 +178,7 @@ func _update_slots():
|
171
|
178
|
for slot in range(1, self._slot_amount):
|
172
|
179
|
self.set_slot(slot, false, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
|
173
|
180
|
var output_link_label = Label.new()
|
174
|
|
- output_link_label.text = "Choice #" + str(slot + 1)
|
|
181
|
+ output_link_label.text = self._get_choice_name(slot)
|
175
|
182
|
output_link_label.align = Label.ALIGN_RIGHT
|
176
|
183
|
self.add_child_below_node(last_output_link_label, output_link_label)
|
177
|
184
|
last_output_link_label = output_link_label
|
178
|
|
-
|
179
|
|
-
|