moved the button in the main editor

This commit is contained in:
Bram Dingelstad 2021-12-06 19:43:04 +01:00
parent 31447732ad
commit a35752129e
6 changed files with 39 additions and 12 deletions

View file

@ -39,8 +39,12 @@ There are few things that need to be ironed out to be 100% feature compatible wi
- [ ] Integration with Godot's translation/localization system. - [ ] Integration with Godot's translation/localization system.
- [ ] Auto generation for `#line:` suffixes - [ ] Auto generation for `#line:` suffixes
- [ ] Support for [format functions](https://yarnspinner.dev/docs/syntax/#format-functions). - [ ] Support for [format functions](https://yarnspinner.dev/docs/syntax/#format-functions).
- [ ] Support for conditional options. - [ ] ~Support~ Fix for conditional options.
- [ ] In-editor dialogue editor with preview. - [ ] In-editor dialogue editor with preview.
- [ ] Lines connecting different nodes if they refer to eachother.
- [x] Error hints when doing something wrong.
- [x] Basic saving, opening and saving-as.
- [ ] Remove all `printerr` in favor of (soft) `assert`s.
- [x] Fully extend the documentation of this project. - [x] Fully extend the documentation of this project.
- [x] Porting to usable signals in Godot. - [x] Porting to usable signals in Godot.
- [x] Providing helpful errors when failing to compile. - [x] Providing helpful errors when failing to compile.

View file

@ -126,7 +126,7 @@ func get_nodes():
func assert(statement, message, line_number = -1, column = -1, _absolute_line_number = -1): func assert(statement, message, line_number = -1, column = -1, _absolute_line_number = -1):
if not soft_assert: if not soft_assert:
assert(statement, message + ('; on line %d column %d' % [line_number, column])) assert(statement, '"%s" on line %d column %d' % [message, line_number, column])
elif not statement: elif not statement:
emit_signal('error', message, line_number, column) emit_signal('error', message, line_number, column)

View file

@ -5,7 +5,6 @@ const Compiler = preload('res://addons/Wol/core/compiler/Compiler.gd')
onready var GraphNodeTemplate = $GraphNodeTemplate onready var GraphNodeTemplate = $GraphNodeTemplate
var path var path
var compiler
func _ready(): func _ready():
for menu_button in [$Menu/File]: for menu_button in [$Menu/File]:
@ -13,13 +12,11 @@ func _ready():
# TODO: Conditionally load in theme based on Editor or standalone # TODO: Conditionally load in theme based on Editor or standalone
path = 'res://dialogue.yarn' path = 'res://dialogue.wol'
build_nodes() build_nodes()
func build_nodes(): func build_nodes():
compiler = Compiler.new(path) for node in Compiler.new(path).get_nodes():
for node in compiler.get_nodes():
var graph_node = GraphNodeTemplate.duplicate() var graph_node = GraphNodeTemplate.duplicate()
$GraphEdit.add_child(graph_node) $GraphEdit.add_child(graph_node)
graph_node.node = node graph_node.node = node

BIN
addons/Wol/editor/WolEditor.tscn (Stored with Git LFS)

Binary file not shown.

View file

@ -1,10 +1,15 @@
tool tool
extends GraphNode extends GraphNode
signal recompiled
const Compiler = preload('res://addons/Wol/core/compiler/Compiler.gd') const Compiler = preload('res://addons/Wol/core/compiler/Compiler.gd')
var node setget set_node var node setget set_node
var error_lines = []
var compiler
onready var text_edit = $TextEdit onready var text_edit = $TextEdit
func _ready(): func _ready():
@ -12,23 +17,30 @@ func _ready():
text_edit.connect('text_changed', self, '_on_text_changed') text_edit.connect('text_changed', self, '_on_text_changed')
$TextDebounce.connect('timeout', self, '_on_debounce') $TextDebounce.connect('timeout', self, '_on_debounce')
func get_connections():
print(compiler)
func _on_text_changed(): func _on_text_changed():
$TextDebounce.start(.3) $TextDebounce.start(.3)
func _on_debounce(): func _on_debounce():
text_edit.get_node('ErrorGutter').hide() text_edit.get_node('ErrorGutter').hide()
node.body = text_edit.text node.body = text_edit.text
for line in error_lines:
text_edit.set_line_as_safe(line - 1, false)
compile() compile()
func _on_offset_changed(): func _on_offset_changed():
node.position = offset node.position = offset
func _on_error(message, _line_number, _column): func _on_error(message, line_number, _column):
var error_gutter = text_edit.get_node('ErrorGutter') var error_gutter = text_edit.get_node('ErrorGutter')
error_gutter.show() error_gutter.show()
error_gutter.text = message error_gutter.text = message
# TODO: Highlight line based on line number and column error_lines.append(line_number)
text_edit.set_line_as_safe(line_number - 1, true)
func set_node(_node): func set_node(_node):
node = _node node = _node
@ -41,6 +53,7 @@ func set_node(_node):
func compile(): func compile():
var text = '---\n%s\n===' % text_edit.text var text = '---\n%s\n===' % text_edit.text
var compiler = Compiler.new(null, text, true) compiler = Compiler.new(null, text, true)
compiler.connect('error', self, '_on_error') compiler.connect('error', self, '_on_error')
compiler.compile() compiler.compile()
emit_signal('recompiled')

View file

@ -18,6 +18,18 @@ func _enter_tree():
make_visible(false) make_visible(false)
call_deferred('move_button')
func move_button():
var buttons = get_editor_interface().get_base_control()
var path = [0, 0, 2]
for child_number in path:
if buttons.get_child_count() > child_number:
buttons = buttons.get_child(child_number)
if buttons.has_node('AssetLib'):
buttons.get_node('AssetLib').raise()
func make_visible(visible): func make_visible(visible):
if wol_editor_instance: if wol_editor_instance:
wol_editor_instance.visible = visible wol_editor_instance.visible = visible
@ -35,6 +47,7 @@ func get_plugin_name():
return 'Wol' return 'Wol'
func get_plugin_icon(): func get_plugin_icon():
# FIXME: Change this code so it doesn't show a warning on activation
var icon = ImageTexture.new() var icon = ImageTexture.new()
var image = Image.new() var image = Image.new()
image.load('res://addons/Wol/icon-white.svg') image.load('res://addons/Wol/icon-white.svg')