Skip to content

Commit

Permalink
Merge pull request #1271 from exelia-antonov/dialogic-1x-speedups
Browse files Browse the repository at this point in the history
1.x Speedups
  • Loading branch information
ii4y-studios authored Jul 20, 2023
2 parents 8498c04 + a3e92e8 commit ac656b6
Show file tree
Hide file tree
Showing 11 changed files with 865 additions and 338 deletions.
4 changes: 3 additions & 1 deletion addons/dialogic/Editor/CharacterEditor/CharacterEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ func _input(event):

func _on_color_changed(color):
var item = master_tree.get_selected()
item.set_icon_modulate(0, color)
if !item == null:
self.set_meta('current_color', color)
item.set_icon_modulate(0, color)



Expand Down
130 changes: 65 additions & 65 deletions addons/dialogic/Editor/DocumentationViewer/DocumentationViewer.gd
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
tool
extends Control

onready var master_tree = get_node('../MasterTreeContainer/MasterTree')
var current_page : String = ""

var previous_pages = []
var next_pages = []

signal open_link(link)

onready var nodes = {
'DocsViewer': $DocsViewer,
'Next': null,
'Previous':null,
}

func _ready():
set("custom_styles/panel", get_stylebox("Background", "EditorStyles"))

var _scale = get_constant("inspector_margin", "Editor")
_scale = _scale * 0.125
nodes['DocsViewer'].MarkdownParser.editor_scale = _scale
nodes['Next'] = find_parent("EditorView").get_node("ToolBar/DocumentationNavigation/Next")
nodes['Next'].connect('pressed',self, 'open_next_page')
nodes['Previous'] = find_parent("EditorView").get_node("ToolBar/DocumentationNavigation/Previous")
nodes['Previous'].connect('pressed',self, 'open_previous_page')



func load_page(page):
if current_page:
previous_pages.push_back(current_page)
nodes['Previous'].disabled = false
next_pages = []
current_page = page
nodes['DocsViewer'].load_page(current_page)
nodes['Next'].disabled = true


func open_previous_page():
if len(previous_pages):
next_pages.push_front(current_page)
current_page = previous_pages.pop_back()
nodes['DocsViewer'].load_page(current_page)
nodes['Previous'].disabled = len(previous_pages) == 0
nodes['Next'].disabled = false


func open_next_page():
if len(next_pages):
previous_pages.push_back(current_page)
current_page = next_pages.pop_front()
nodes['DocsViewer'].load_page(current_page)
nodes['Next'].disabled = len(next_pages) == 0
nodes['Previous'].disabled = false


func toggle_editing():
nodes['DocsViewer'].toggle_editing()


func _on_DocsViewer_open_non_html_link(link, section):
#print(link, " ", section)
master_tree.select_documentation_item(link)
tool
extends Control

onready var master_tree = get_node('../MasterTreeContainer/MasterTree')
var current_page : String = ""

var previous_pages = []
var next_pages = []

signal open_link(link)

onready var nodes = {
'DocsViewer': $DocsViewer,
'Next': null,
'Previous':null,
}

func _ready():
set("custom_styles/panel", get_stylebox("Background", "EditorStyles"))

var _scale = get_constant("inspector_margin", "Editor")
_scale = _scale * 0.125
nodes['DocsViewer'].MarkdownParser.editor_scale = _scale
nodes['Next'] = find_parent("EditorView").get_node("ToolBar/DocumentationNavigation/Next")
nodes['Next'].connect('pressed',self, 'open_next_page')
nodes['Previous'] = find_parent("EditorView").get_node("ToolBar/DocumentationNavigation/Previous")
nodes['Previous'].connect('pressed',self, 'open_previous_page')



func load_page(page):
if current_page:
previous_pages.push_back(current_page)
nodes['Previous'].disabled = false
next_pages = []
current_page = page
nodes['DocsViewer'].load_page(current_page)
nodes['Next'].disabled = true


func open_previous_page():
if len(previous_pages):
next_pages.push_front(current_page)
current_page = previous_pages.pop_back()
nodes['DocsViewer'].load_page(current_page)
nodes['Previous'].disabled = len(previous_pages) == 0
nodes['Next'].disabled = false


func open_next_page():
if len(next_pages):
previous_pages.push_back(current_page)
current_page = next_pages.pop_front()
nodes['DocsViewer'].load_page(current_page)
nodes['Next'].disabled = len(next_pages) == 0
nodes['Previous'].disabled = false


func toggle_editing():
nodes['DocsViewer'].toggle_editing()


func _on_DocsViewer_open_non_html_link(link, section):
#print(link, " ", section)
master_tree.select_documentation_item(link)
18 changes: 10 additions & 8 deletions addons/dialogic/Editor/EditorView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ var file_picker_data: Dictionary = {'method': '', 'node': self}
var version_string: String

var dialogicTranslator = load("res://addons/dialogic/Localization/translation_service.gd").new()

var flat_structure = {}
# this is set when the plugins main-view is instanced in dialogic.gd
var editor_interface = null

#runtime cache of all .tscn's loaded by Dialogic, to speed it up
var editor_scene_cache = {}

func _ready():
# Updating the folder structure
flat_structure = DialogicUtil.flat_structure_to_editor_array(DialogicUtil.get_flat_folders_list())

# Adding file dialog to get used by Events
editor_file_dialog = EditorFileDialog.new()
add_child(editor_file_dialog)
Expand All @@ -20,9 +26,6 @@ func _ready():

$MainPanel/MasterTreeContainer/MasterTree.connect("editor_selected", self, 'on_master_tree_editor_selected')

# Updating the folder structure
DialogicUtil.update_resource_folder_structure()

# Sizes
# This part of the code is a bit terrible. But there is no better way
# of doing this in Godot at the moment. I'm sorry.
Expand Down Expand Up @@ -106,7 +109,7 @@ func _ready():
$ToolBar/Version.text = 'Dialogic v' + version_string

$MainPanel/MasterTreeContainer/FilterMasterTreeEdit.right_icon = get_icon("Search", "EditorIcons")

$MainPanel/MasterTreeContainer/MasterTree.build_full_tree()

func on_master_tree_editor_selected(editor: String):
$ToolBar/FoldTools.visible = editor == 'timeline'
Expand Down Expand Up @@ -135,9 +138,8 @@ func popup_remove_confirmation(what):


func _on_RemoveFolderConfirmation_confirmed():
var item_path = $MainPanel/MasterTreeContainer/MasterTree.get_item_path($MainPanel/MasterTreeContainer/MasterTree.get_selected())
DialogicUtil.remove_folder(item_path)
$MainPanel/MasterTreeContainer/MasterTree.build_full_tree()
var item_data = $MainPanel/MasterTreeContainer/MasterTree.get_selected().get_metadata(0)
$MainPanel/MasterTreeContainer/MasterTree.remove_selected()


func _on_RemoveConfirmation_confirmed(what: String = ''):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,52 @@ func _on_PickerMenu_about_to_show():

func build_PickerMenu():
picker_menu.get_popup().clear()
var folder_structure = DialogicUtil.get_timelines_folder_structure()

var timeline_structure = find_parent('EditorView').flat_structure['Timelines']
var folder_structure = build_PickerMenuFolderFlat(picker_menu.get_popup(), timeline_structure, "MenuButton")
var files_info = build_PickerMenuFiles(timeline_structure)
## building the root level
build_PickerMenuFolder(picker_menu.get_popup(), folder_structure, "MenuButton")
build_PickerMenuFolder(picker_menu.get_popup(), folder_structure, "MenuButton", files_info)


# is called recursively to build all levels of the folder structure
func build_PickerMenuFolder(menu:PopupMenu, folder_structure:Dictionary, current_folder_name:String):

func build_PickerMenuFolderFlat(menu:PopupMenu, folder_structure:Dictionary, current_folder_name:String):
var nested = {}
nested['folders'] = {}
nested['files'] = []
for item in folder_structure.keys():
DialogicResources.recursive_build(item.right(1), folder_structure[item], nested)

return nested

func build_PickerMenuFiles(timeline_structure):
var files_dict = {}

for i in timeline_structure.keys():
if !("/." in i):
#print(timeline_structure[i])
files_dict[timeline_structure[i]['file']] = {'color':timeline_structure[i]['color'], 'file':i, 'name': timeline_structure[i]['name']}
return files_dict

func build_PickerMenuFolder(menu:PopupMenu, folder_structure:Dictionary, current_folder_name:String, files_info:Dictionary):
var index = 0
for folder_name in folder_structure['folders'].keys():
var submenu = PopupMenu.new()
var submenu_name = build_PickerMenuFolder(submenu, folder_structure['folders'][folder_name], folder_name)
var submenu_name = build_PickerMenuFolder(submenu, folder_structure['folders'][folder_name], folder_name, files_info)
submenu.name = submenu_name
menu.add_submenu_item(folder_name, submenu_name)
menu.set_item_icon(index, get_icon("Folder", "EditorIcons"))
menu.add_child(submenu)
picker_menu.update_submenu_style(submenu)
index += 1

var files_info = DialogicUtil.get_timeline_dict()

for file in folder_structure['files']:
menu.add_item(files_info[file]['name'])
menu.set_item_icon(index, editor_reference.get_node("MainPanel/MasterTreeContainer/MasterTree").timeline_icon)
menu.set_item_metadata(index, {'file':file})
index += 1

if not menu.is_connected("index_pressed", self, "_on_PickerMenu_selected"):
menu.connect("index_pressed", self, '_on_PickerMenu_selected', [menu])

return current_folder_name
Loading

0 comments on commit ac656b6

Please sign in to comment.