feat: Added a pane for previewing dialogue
This commit is contained in:
parent
a57f2193d9
commit
b8eb90cbf7
|
@ -1,7 +1,35 @@
|
||||||
|
title: Sally.Watch
|
||||||
|
tags:
|
||||||
|
colorID:
|
||||||
|
position: 500, 400
|
||||||
|
---
|
||||||
|
Sally: Not really. #line:8c3f98
|
||||||
|
Sally: Same old nebula, doing the same old thing. #line:24c418
|
||||||
|
Sally: Oh, Ship wanted to see you. Go say hi to it. #line:df4eaf
|
||||||
|
<<set $should_see_ship to true>>
|
||||||
|
<<if visited("Ship") is true>>
|
||||||
|
Player: Already done! #line:1fea6c
|
||||||
|
Sally: Go say hi again. #line:5df323
|
||||||
|
<<endif>>
|
||||||
|
===
|
||||||
|
title: Sally.Exit
|
||||||
|
tags:
|
||||||
|
colorID:
|
||||||
|
position: 100, 400
|
||||||
|
---
|
||||||
|
Sally: Bye. #line:60c282
|
||||||
|
===
|
||||||
|
title: Sally.Sorry
|
||||||
|
tags:
|
||||||
|
colorID:
|
||||||
|
position: 900, 400
|
||||||
|
---
|
||||||
|
Sally: Yeah. Don't do it again. #line:d7df49
|
||||||
|
===
|
||||||
title: Sally
|
title: Sally
|
||||||
tags:
|
tags:
|
||||||
colorID: 0
|
colorID:
|
||||||
position: 524,111
|
position: 500, 100
|
||||||
---
|
---
|
||||||
<<if visited("Sally") is false>>
|
<<if visited("Sally") is false>>
|
||||||
Player: Hey, Sally. #line:794945
|
Player: Hey, Sally. #line:794945
|
||||||
|
@ -22,34 +50,3 @@ position: 524,111
|
||||||
<<endif>>
|
<<endif>>
|
||||||
[[See you later.|Sally.Exit]] #line:0facf7
|
[[See you later.|Sally.Exit]] #line:0facf7
|
||||||
===
|
===
|
||||||
|
|
||||||
title: Sally.Watch
|
|
||||||
tags:
|
|
||||||
colorID: 0
|
|
||||||
position: 512,430
|
|
||||||
---
|
|
||||||
Sally: Not really. #line:8c3f98
|
|
||||||
Sally: Same old nebula, doing the same old thing. #line:24c418
|
|
||||||
Sally: Oh, Ship wanted to see you. Go say hi to it. #line:df4eaf
|
|
||||||
<<set $should_see_ship to true>>
|
|
||||||
<<if visited("Ship") is true>>
|
|
||||||
Player: Already done! #line:1fea6c
|
|
||||||
Sally: Go say hi again. #line:5df323
|
|
||||||
<<endif>>
|
|
||||||
===
|
|
||||||
|
|
||||||
title: Sally.Exit
|
|
||||||
tags:
|
|
||||||
colorID: 6
|
|
||||||
position: 211,417
|
|
||||||
---
|
|
||||||
Sally: Bye. #line:60c282
|
|
||||||
===
|
|
||||||
|
|
||||||
title: Sally.Sorry
|
|
||||||
tags:
|
|
||||||
colorID: 0
|
|
||||||
position: 827,439
|
|
||||||
---
|
|
||||||
Sally: Yeah. Don't do it again. #line:d7df49
|
|
||||||
===
|
|
||||||
|
|
|
@ -55,6 +55,9 @@ func set_path(_path):
|
||||||
var compiler = Compiler.new(path)
|
var compiler = Compiler.new(path)
|
||||||
virtual_machine.program = compiler.compile()
|
virtual_machine.program = compiler.compile()
|
||||||
|
|
||||||
|
func set_program(program):
|
||||||
|
virtual_machine.program = program
|
||||||
|
|
||||||
func _on_line(line):
|
func _on_line(line):
|
||||||
if auto_substitute:
|
if auto_substitute:
|
||||||
var index = 0
|
var index = 0
|
||||||
|
@ -106,5 +109,10 @@ func start(node = starting_node):
|
||||||
virtual_machine.set_node(node)
|
virtual_machine.set_node(node)
|
||||||
virtual_machine.start()
|
virtual_machine.start()
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
if running:
|
||||||
|
virtual_machine.call_deferred('stop')
|
||||||
|
running = false
|
||||||
|
|
||||||
func resume():
|
func resume():
|
||||||
virtual_machine.call_deferred('resume')
|
virtual_machine.call_deferred('resume')
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
signal error(message, line_number, column)
|
signal error(message, line_number, column)
|
||||||
|
|
||||||
const Constants = preload('res://addons/Wol/core/Constants.gd')
|
const Constants = preload('res://addons/Wol/core/Constants.gd')
|
||||||
|
@ -25,11 +24,12 @@ func _init(_filename, _source = null, _soft_assert = false):
|
||||||
soft_assert = _soft_assert
|
soft_assert = _soft_assert
|
||||||
|
|
||||||
if not _filename and _source:
|
if not _filename and _source:
|
||||||
self.source = _source
|
filename = 'inline_source'
|
||||||
|
source = _source
|
||||||
else:
|
else:
|
||||||
var file = File.new()
|
var file = File.new()
|
||||||
file.open(_filename, File.READ)
|
file.open(_filename, File.READ)
|
||||||
self.source = file.get_as_text()
|
source = file.get_as_text()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
var source_lines = source.split('\n')
|
var source_lines = source.split('\n')
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
tool
|
tool
|
||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
var current_node
|
|
||||||
var current_graph_node
|
var current_graph_node
|
||||||
|
|
||||||
|
onready var preview = get_node('../Preview')
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
hide()
|
hide()
|
||||||
connect('visibility_changed', self, '_on_visibility_changed')
|
connect('visibility_changed', self, '_on_visibility_changed')
|
||||||
$Close.connect('pressed', self, 'close')
|
$Tools/Left/Play.connect('pressed', self, '_on_play')
|
||||||
|
$Tools/Right/Close.connect('pressed', self, 'close')
|
||||||
|
|
||||||
func close():
|
func close():
|
||||||
hide()
|
hide()
|
||||||
|
preview.close()
|
||||||
|
|
||||||
func open_node(graph_node, node):
|
func open_node(graph_node):
|
||||||
current_node = node
|
|
||||||
current_graph_node = graph_node
|
current_graph_node = graph_node
|
||||||
|
|
||||||
var text_edit = graph_node.get_node('TextEdit')
|
var text_edit = graph_node.get_node('TextEdit')
|
||||||
|
@ -21,9 +23,9 @@ func open_node(graph_node, node):
|
||||||
$Content.add_child(text_edit)
|
$Content.add_child(text_edit)
|
||||||
toggle_text_edit(text_edit)
|
toggle_text_edit(text_edit)
|
||||||
|
|
||||||
$HBoxContainer/TextEdit.disconnect('text_changed', self, '_on_title_changed')
|
$Tools/Left/Title.disconnect('text_changed', self, '_on_title_changed')
|
||||||
$HBoxContainer/TextEdit.text = node.title
|
$Tools/Left/Title.text = graph_node.node.title
|
||||||
$HBoxContainer/TextEdit.connect('text_changed', self, '_on_title_changed')
|
$Tools/Left/Title.connect('text_changed', self, '_on_title_changed')
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
|
||||||
|
@ -50,6 +52,9 @@ func toggle_text_edit(text_edit):
|
||||||
]:
|
]:
|
||||||
text_edit.set(property, not text_edit.get(property))
|
text_edit.set(property, not text_edit.get(property))
|
||||||
|
|
||||||
|
func _on_play():
|
||||||
|
preview.open_node(current_graph_node)
|
||||||
|
|
||||||
func _on_title_changed():
|
func _on_title_changed():
|
||||||
current_graph_node.node.title = $HBoxContainer/TextEdit.text
|
current_graph_node.node.title = $HBoxContainer/TextEdit.text
|
||||||
current_graph_node.compile()
|
current_graph_node.compile()
|
||||||
|
|
76
addons/Wol/editor/Preview.gd
Normal file
76
addons/Wol/editor/Preview.gd
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
extends Panel
|
||||||
|
|
||||||
|
var current_graph_node
|
||||||
|
|
||||||
|
onready var line_template = $Content/List/LineTemplate
|
||||||
|
onready var button_template = $Options/List/ButtonTemplate
|
||||||
|
|
||||||
|
onready var wol_editor = find_parent('WolEditor')
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
hide()
|
||||||
|
$Wol.connect('line', self, '_on_line')
|
||||||
|
$Wol.connect('options', self, '_on_options')
|
||||||
|
$Tools/Right/Close.connect('pressed', self, 'close')
|
||||||
|
|
||||||
|
func open_node(graph_node):
|
||||||
|
current_graph_node = graph_node
|
||||||
|
|
||||||
|
$Wol.stop()
|
||||||
|
|
||||||
|
for child in $Content/List.get_children():
|
||||||
|
if child != line_template and not 'Padding' in child.name:
|
||||||
|
$Content/List.remove_child(child)
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
for child in $Options/List.get_children():
|
||||||
|
if child != button_template:
|
||||||
|
$Options/List.remove_child(child)
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
$Wol.variable_storage = {}
|
||||||
|
$Wol.set_program(wol_editor.get_program())
|
||||||
|
$Wol.start(current_graph_node.node.title)
|
||||||
|
show()
|
||||||
|
|
||||||
|
func close():
|
||||||
|
hide()
|
||||||
|
current_graph_node = null
|
||||||
|
$Wol.stop()
|
||||||
|
|
||||||
|
func next():
|
||||||
|
$Wol.resume()
|
||||||
|
|
||||||
|
func _on_line(line):
|
||||||
|
var line_node = line_template.duplicate()
|
||||||
|
$Content/List.add_child(line_node)
|
||||||
|
$Content/List/PaddingBottom.raise()
|
||||||
|
line_node.get_node('RichTextLabel').bbcode_text = line.text
|
||||||
|
line_node.show()
|
||||||
|
yield(get_tree(), 'idle_frame')
|
||||||
|
$Content.scroll_vertical = $Content/List.rect_size.y
|
||||||
|
|
||||||
|
func _on_options(options):
|
||||||
|
for option in options:
|
||||||
|
var button = button_template.duplicate()
|
||||||
|
$Options/List.add_child(button)
|
||||||
|
|
||||||
|
button.text = option.line.text
|
||||||
|
button.connect('pressed', self, '_on_option_pressed', [option])
|
||||||
|
button.show()
|
||||||
|
|
||||||
|
func _on_option_pressed(option):
|
||||||
|
$Wol.select_option(option.id)
|
||||||
|
|
||||||
|
for child in $Options/List.get_children():
|
||||||
|
if child != button_template:
|
||||||
|
$Options/List.remove_child(child)
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if visible \
|
||||||
|
and ( \
|
||||||
|
(event is InputEventMouseButton and event.doubleclick) \
|
||||||
|
or (event is InputEventKey and not event.pressed and event.scancode in [KEY_SPACE, KEY_ENTER]) \
|
||||||
|
):
|
||||||
|
next()
|
|
@ -37,7 +37,7 @@ func create_node(position = Vector2.ZERO):
|
||||||
}
|
}
|
||||||
|
|
||||||
graph_node.connect('recompiled', self, '_on_graph_node_recompiled', [graph_node])
|
graph_node.connect('recompiled', self, '_on_graph_node_recompiled', [graph_node])
|
||||||
graph_node.connect('gui_input', self, '_on_graph_node_input', [graph_node, node])
|
graph_node.connect('gui_input', self, '_on_graph_node_input', [graph_node])
|
||||||
|
|
||||||
graph_node.node = node
|
graph_node.node = node
|
||||||
graph_node.show()
|
graph_node.show()
|
||||||
|
@ -52,11 +52,14 @@ func build_nodes():
|
||||||
$GraphEdit.add_child(graph_node)
|
$GraphEdit.add_child(graph_node)
|
||||||
|
|
||||||
graph_node.connect('recompiled', self, '_on_graph_node_recompiled', [graph_node])
|
graph_node.connect('recompiled', self, '_on_graph_node_recompiled', [graph_node])
|
||||||
graph_node.connect('gui_input', self, '_on_graph_node_input', [graph_node, node])
|
graph_node.connect('gui_input', self, '_on_graph_node_input', [graph_node])
|
||||||
|
|
||||||
graph_node.node = node
|
graph_node.node = node
|
||||||
graph_node.show()
|
graph_node.show()
|
||||||
|
|
||||||
|
func get_program():
|
||||||
|
return Compiler.new(null, serialize_to_file(), true).compile()
|
||||||
|
|
||||||
func serialize_to_file():
|
func serialize_to_file():
|
||||||
var buffer = []
|
var buffer = []
|
||||||
for graph_node in $GraphEdit.get_children():
|
for graph_node in $GraphEdit.get_children():
|
||||||
|
@ -153,10 +156,10 @@ func _on_graph_node_recompiled(_graph_node):
|
||||||
yield(get_tree().create_timer(.3), 'timeout')
|
yield(get_tree().create_timer(.3), 'timeout')
|
||||||
refreshed = false
|
refreshed = false
|
||||||
|
|
||||||
func _on_graph_node_input(event, graph_node, node):
|
func _on_graph_node_input(event, graph_node):
|
||||||
if event is InputEventMouseButton \
|
if event is InputEventMouseButton \
|
||||||
and event.doubleclick and event.button_index == BUTTON_LEFT:
|
and event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||||
$HBoxContainer/Editor.open_node(graph_node, node)
|
$HBoxContainer/Editor.open_node(graph_node)
|
||||||
accept_event()
|
accept_event()
|
||||||
|
|
||||||
func _on_node_selected(node, selected):
|
func _on_node_selected(node, selected):
|
||||||
|
|
BIN
addons/Wol/editor/WolEditor.tscn
(Stored with Git LFS)
BIN
addons/Wol/editor/WolEditor.tscn
(Stored with Git LFS)
Binary file not shown.
Reference in a new issue