Skip to content

Commit

Permalink
Visual editor improvements (#2005)
Browse files Browse the repository at this point in the history
* Change visual representation of background event

* Change ValueType

* Fix new background UI

* Expand events created by button by default

* Improve/fix timeline dragging
  • Loading branch information
Jowan-Spooner committed Jan 9, 2024
1 parent 918bf06 commit 47e35a0
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 26 deletions.
14 changes: 9 additions & 5 deletions addons/dialogic/Editor/Events/EventBlock/event_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func _ready():
printerr("[Dialogic] Event block was added without a resource specified.")
return

initialize_logic()
initialize_ui()
initialize_logic()


func initialize_ui() -> void:
Expand All @@ -63,7 +63,7 @@ func initialize_ui() -> void:
%Warning.position = Vector2(-5 * _scale, -10 * _scale)

# Expand Button
%ExpandButton.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons")
%ExpandButton.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons")
%ExpandButton.modulate = get_theme_color("readonly_color", "Editor")

# Icon Panel
Expand All @@ -90,6 +90,8 @@ func initialize_ui() -> void:
%CollapseButton.icon = get_theme_icon("Collapse", "EditorIcons")
%CollapseButton.hide()

%Body.add_theme_constant_override("margin_left", icon_size * _scale)

visual_deselect()


Expand All @@ -99,10 +101,10 @@ func initialize_logic() -> void:
resource.ui_update_needed.connect(_on_resource_ui_update_needed)
resource.ui_update_warning.connect(set_warning)

_on_ExpandButton_toggled(resource.expand_by_default)

content_changed.connect(recalculate_field_visibility)

_on_ExpandButton_toggled(resource.expand_by_default or resource.created_by_button)

#endregion


Expand Down Expand Up @@ -162,6 +164,7 @@ var FIELD_SCENES := {

func build_editor(build_header:bool = true, build_body:bool = false) -> void:
var current_body_container: HFlowContainer = null

if build_body and body_was_build:
build_body = false

Expand Down Expand Up @@ -348,13 +351,14 @@ func _on_ExpandButton_toggled(button_pressed:bool) -> void:
if button_pressed and !body_was_build:
build_editor(false, true)
%ExpandButton.set_pressed_no_signal(button_pressed)

if button_pressed:
%ExpandButton.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons")
else:
%ExpandButton.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons")

expanded = button_pressed
%Body.visible = button_pressed
%Body.add_theme_constant_override("margin_left", icon_size*DialogicUtil.get_editor_scale())

if find_parent('VisualEditor') != null:
find_parent('VisualEditor').indent_events()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func _on_event_block_gui_input(event, item: Node):

if len(selected_items) > 0 and event is InputEventMouseMotion:
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
if !%TimelineArea.dragging:
if !%TimelineArea.dragging and !get_viewport().gui_is_dragging():
sort_selection()
%TimelineArea.start_dragging(%TimelineArea.DragTypes.EXISTING_EVENTS, selected_items)

Expand Down
95 changes: 75 additions & 20 deletions addons/dialogic/Modules/Background/event_background.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,33 @@ var fade: float = 0.0
## Name of the transition to use.
var transition: String = ""


################################################################################
## EXECUTION
## Helpers for visual editor
enum ArgumentTypes {IMAGE, CUSTOM}
var _arg_type := ArgumentTypes.IMAGE :
get:
if argument.begins_with("res://"):
return ArgumentTypes.IMAGE
else:
return _arg_type
set(value):
if value == ArgumentTypes.CUSTOM:
if argument.begins_with("res://"):
argument = " "+argument
_arg_type = value

enum SceneTypes {DEFAULT, CUSTOM}
var _scene_type := SceneTypes.DEFAULT :
get:
if scene.is_empty():
return _scene_type
else:
return SceneTypes.CUSTOM
set(value):
if value == SceneTypes.DEFAULT:
scene = ""
_scene_type = value

#region EXECUTION
################################################################################

func _execute() -> void:
Expand All @@ -35,9 +59,9 @@ func _execute() -> void:

finish()

#endregion

################################################################################
## INITIALIZE
#region INITIALIZE
################################################################################

func _init() -> void:
Expand All @@ -46,9 +70,9 @@ func _init() -> void:
event_category = "Visuals"
event_sorting_index = 0

#endregion

################################################################################
## SAVING/LOADING
#region SAVE & LOAD
################################################################################

func get_shortcode() -> String:
Expand All @@ -66,29 +90,58 @@ func get_shortcode_parameters() -> Dictionary:
}


################################################################################
## EDITOR REPRESENTATION
#endregion

#region EDITOR REPRESENTATION
################################################################################

func build_event_editor():
add_header_edit('argument', ValueType.FILE,
{'left_text' : 'Show',
'file_filter':'*.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr; Supported Image Files',
'placeholder': "No background",
'editor_icon':["Image", "EditorIcons"]},
'scene == ""')
add_header_edit('_scene_type', ValueType.FIXED_OPTIONS, {
'left_text' :'Show',
'options': [
{
'label': 'Default Scene',
'value': SceneTypes.DEFAULT,
'icon': ["GuiRadioUnchecked", "EditorIcons"]
},
{
'label': 'Custom Scene',
'value': SceneTypes.CUSTOM,
'icon': ["PackedScene", "EditorIcons"]
}
], "symbol_only": true})
add_header_label("Default BG Scene with", '_scene_type == SceneTypes.DEFAULT')
add_header_edit("scene", ValueType.FILE,
{'left_text' :'Scene:',
'file_filter':'*.tscn, *.scn; Scene Files',
{'file_filter':'*.tscn, *.scn; Scene Files',
'placeholder': "Default scene",
'editor_icon':["PackedScene", "EditorIcons"]})
add_body_edit('argument', ValueType.SINGLELINE_TEXT, {'left_text':'Argument:'}, 'scene != ""')
}, '_scene_type == SceneTypes.CUSTOM')
add_header_edit('_arg_type', ValueType.FIXED_OPTIONS, {
'left_text' : 'with',
'options': [
{
'label': 'Image',
'value': ArgumentTypes.IMAGE,
'icon': ["Image", "EditorIcons"]
},
{
'label': 'Custom Argument',
'value': ArgumentTypes.CUSTOM,
'icon': ["String", "EditorIcons"]
}
], "symbol_only": true}, "_scene_type == SceneTypes.CUSTOM")
add_header_edit('argument', ValueType.FILE,
{'file_filter':'*.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr; Supported Image Files',
'placeholder': "No Image",
},
'_arg_type == ArgumentTypes.IMAGE or _scene_type == SceneTypes.DEFAULT')
add_header_edit('argument', ValueType.SINGLELINE_TEXT, {}, '_arg_type == ArgumentTypes.CUSTOM')

add_body_edit("transition", ValueType.DYNAMIC_OPTIONS,
{'left_text':'Transition:',
'empty_text':'Simple Fade',
'suggestions_func':get_transition_suggestions,
'editor_icon':["PopupMenu", "EditorIcons"]})
add_body_edit("fade", ValueType.NUMBER, {'left_text':'Fade Time:'})
add_body_edit("fade", ValueType.NUMBER, {'left_text':'Fade time:'})


func get_transition_suggestions(filter:String="") -> Dictionary:
Expand All @@ -97,3 +150,5 @@ func get_transition_suggestions(filter:String="") -> Dictionary:
for i in transitions:
suggestions[DialogicUtil.pretty_name(i)] = {'value': DialogicUtil.pretty_name(i), 'editor_icon': ["PopupMenu", "EditorIcons"]}
return suggestions

#endregion

0 comments on commit 47e35a0

Please sign in to comment.