Add addons
This commit is contained in:
parent
2c862b2235
commit
3367bad24f
527 changed files with 36197 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
@tool
|
||||
extends Label
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
label_settings = LabelSettings.new()
|
||||
label_settings.font = get_theme_font("doc_italic", "EditorFonts")
|
||||
label_settings.font_size = get_theme_font_size('font_size', 'Label')
|
||||
label_settings.font_color = get_theme_color("accent_color", "Editor")
|
||||
32
Sprout/addons/dialogic/Editor/Settings/SettingsEditor.gd
Normal file
32
Sprout/addons/dialogic/Editor/Settings/SettingsEditor.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
@tool
|
||||
extends DialogicEditor
|
||||
|
||||
## Editor that contains all settings
|
||||
|
||||
func _register():
|
||||
editors_manager.register_simple_editor(self)
|
||||
|
||||
|
||||
func _ready():
|
||||
for indexer in DialogicUtil.get_indexers():
|
||||
for settings_page in indexer._get_settings_pages():
|
||||
$Tabs.add_child(load(settings_page).instantiate())
|
||||
|
||||
|
||||
func _open(extra_information:Variant = null) -> void:
|
||||
refresh()
|
||||
if typeof(extra_information) == TYPE_STRING and has_node('Tabs/'+extra_information):
|
||||
$Tabs.current_tab = get_node('Tabs/'+extra_information).get_index()
|
||||
|
||||
|
||||
func _close():
|
||||
for child in $Tabs.get_children():
|
||||
if child.has_method('_about_to_close'):
|
||||
child._about_to_close()
|
||||
|
||||
|
||||
func refresh():
|
||||
for child in $Tabs.get_children():
|
||||
if child.has_method('refresh'):
|
||||
child.refresh()
|
||||
|
||||
30
Sprout/addons/dialogic/Editor/Settings/SettingsEditor.tscn
Normal file
30
Sprout/addons/dialogic/Editor/Settings/SettingsEditor.tscn
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cl7g6q68aqt4f"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Editor/Settings/SettingsEditor.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm4kxvcn7d7ug" path="res://addons/dialogic/Editor/Settings/Settings_General.tscn" id="3"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4fay73phesum" path="res://addons/dialogic/Editor/Settings/Settings_Translations.tscn" id="3_q3qwt"]
|
||||
|
||||
[node name="SettingsEditor" type="MarginContainer"]
|
||||
visible = false
|
||||
offset_right = 1020.0
|
||||
offset_bottom = 600.0
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = 0
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = 0
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Tabs" type="TabContainer" parent="."]
|
||||
layout_mode = 2
|
||||
offset_right = 1020.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="General" parent="Tabs" instance=ExtResource("3")]
|
||||
layout_mode = 2
|
||||
offset_top = 31.0
|
||||
|
||||
[node name="Translations" parent="Tabs" instance=ExtResource("3_q3qwt")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
99
Sprout/addons/dialogic/Editor/Settings/Settings_General.gd
Normal file
99
Sprout/addons/dialogic/Editor/Settings/Settings_General.gd
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
signal colors_changed
|
||||
|
||||
var color_palette = null
|
||||
|
||||
func _ready():
|
||||
var s = DCSS.inline({
|
||||
'padding': 5,
|
||||
'background': Color(0.545098, 0.545098, 0.545098, 0.211765)
|
||||
})
|
||||
$General/TitleLabel.add_theme_stylebox_override("normal", s)
|
||||
$General/TitleLabel2.add_theme_stylebox_override("normal", s)
|
||||
|
||||
# Signals
|
||||
%TestingSceneButton.pressed.connect(_on_TestingSceneButton_pressed)
|
||||
%DefaultSceneButton.pressed.connect(_on_DefaultSceneButton_pressed)
|
||||
%CustomEventsFolderButton.pressed.connect(_on_CustomEventsFolderButton_pressed)
|
||||
%PhysicsTimerButton.pressed.connect(_on_physics_timer_button_toggled)
|
||||
|
||||
# Colors
|
||||
%ResetColorsButton.button_up.connect(_on_reset_colors_button)
|
||||
|
||||
for n in $"%Colors".get_children():
|
||||
n.color_changed.connect(_on_color_change.bind(n))
|
||||
|
||||
func refresh():
|
||||
%CustomEventsFolderLabel.text = DialogicUtil.get_project_setting('dialogic/custom_events_folder', 'res://addons/dialogic_additions/Events')
|
||||
%CustomEventsFolderButton.icon = get_theme_icon("Folder", "EditorIcons")
|
||||
%TestingSceneButton.icon = get_theme_icon("Folder", "EditorIcons")
|
||||
%TestingSceneLabel.text = DialogicUtil.get_project_setting('dialogic/editor/test_dialog_scene', "res://addons/dialogic/Example Assets/example-scenes/DialogicDefaultScene.tscn")
|
||||
|
||||
%PhysicsTimerButton.button_pressed = DialogicUtil.is_physics_timer()
|
||||
|
||||
%DefaultSceneButton.icon = get_theme_icon("Folder", "EditorIcons")
|
||||
%DefaultSceneLabel.text = DialogicUtil.get_project_setting('dialogic/editor/default_dialog_scene', "res://addons/dialogic/Example Assets/example-scenes/DialogicDefaultScene.tscn")
|
||||
|
||||
|
||||
# Color Palett
|
||||
color_palette = DialogicUtil.get_color_palette()
|
||||
var _scale = DialogicUtil.get_editor_scale()
|
||||
for n in %Colors.get_children():
|
||||
n.custom_minimum_size = Vector2(50 ,50)*scale
|
||||
n.color = color_palette[n.name]
|
||||
|
||||
|
||||
func _on_CustomEventsFolderButton_pressed() -> void:
|
||||
find_parent('EditorView').godot_file_dialog(custom_events_folder_selected, '', EditorFileDialog.FILE_MODE_OPEN_DIR, 'Select custom events folder')
|
||||
|
||||
|
||||
func custom_events_folder_selected(folder_path:String) -> void:
|
||||
%CustomEventsFolderLabel.text = folder_path
|
||||
ProjectSettings.set_setting('dialogic/custom_events_folder', folder_path)
|
||||
ProjectSettings.save()
|
||||
|
||||
|
||||
func _on_color_change(color: Color, who) -> void:
|
||||
ProjectSettings.set_setting('dialogic/editor/' + str(who.name), color)
|
||||
ProjectSettings.save()
|
||||
emit_signal('colors_changed')
|
||||
|
||||
|
||||
func _on_reset_colors_button() -> void:
|
||||
color_palette = DialogicUtil.get_color_palette(true)
|
||||
for n in %Colors.get_children():
|
||||
n.color = color_palette[n.name]
|
||||
# There is a bug when trying to remove existing values, so we have to
|
||||
# set/create new entries for all the colors used.
|
||||
# If you manage to make it work using the ProjectSettings.clear()
|
||||
# feel free to open a PR!
|
||||
ProjectSettings.set_setting('dialogic/editor/' + str(n.name), color_palette[n.name])
|
||||
ProjectSettings.save()
|
||||
emit_signal('colors_changed')
|
||||
|
||||
|
||||
func _on_TestingSceneButton_pressed() -> void:
|
||||
find_parent('EditorView').godot_file_dialog(custom_testing_scene_selected, '*.tscn, *.scn', EditorFileDialog.FILE_MODE_OPEN_FILE, 'Select testing scene')
|
||||
|
||||
|
||||
func custom_testing_scene_selected(path:String) -> void:
|
||||
%TestingSceneLabel.text = path
|
||||
ProjectSettings.set_setting('dialogic/editor/test_dialog_scene', path)
|
||||
ProjectSettings.save()
|
||||
|
||||
|
||||
func _on_DefaultSceneButton_pressed() -> void:
|
||||
find_parent('EditorView').godot_file_dialog(custom_default_scene_selected, '*.tscn, *.scn', EditorFileDialog.FILE_MODE_OPEN_FILE, 'Select default scene')
|
||||
|
||||
|
||||
func custom_default_scene_selected(path:String) -> void:
|
||||
%DefaultSceneLabel.text = path
|
||||
ProjectSettings.set_setting('dialogic/editor/default_dialog_scene', path)
|
||||
ProjectSettings.save()
|
||||
|
||||
|
||||
func _on_physics_timer_button_toggled(button_pressed:bool) -> void:
|
||||
ProjectSettings.set_setting('dialogic/timer/process_in_physics', button_pressed)
|
||||
ProjectSettings.save()
|
||||
1139
Sprout/addons/dialogic/Editor/Settings/Settings_General.tscn
Normal file
1139
Sprout/addons/dialogic/Editor/Settings/Settings_General.tscn
Normal file
File diff suppressed because one or more lines are too long
195
Sprout/addons/dialogic/Editor/Settings/Settings_Translations.gd
Normal file
195
Sprout/addons/dialogic/Editor/Settings/Settings_Translations.gd
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
enum TranslationModes {PerProject, PerTimeline}
|
||||
var loading := false
|
||||
func _ready():
|
||||
%TransEnabled.toggled.connect(store_changes)
|
||||
%OrigLocale.get_suggestions_func = get_locales
|
||||
%OrigLocale.resource_icon = get_theme_icon("Translation", "EditorIcons")
|
||||
%OrigLocale.value_changed.connect(store_changes)
|
||||
%TransFolderPicker.value_changed.connect(store_changes)
|
||||
|
||||
%UpdateCsvFiles.pressed.connect(update_csv_files)
|
||||
%CollectTranslations.pressed.connect(collect_translations)
|
||||
%TransRemove.pressed.connect(erase_translations)
|
||||
|
||||
func refresh():
|
||||
loading = true
|
||||
%TransEnabled.button_pressed = DialogicUtil.get_project_setting('dialogic/translation/enabled', false)
|
||||
|
||||
%OrigLocale.set_value(DialogicUtil.get_project_setting('dialogic/translation/original_locale', TranslationServer.get_tool_locale()))
|
||||
%TransMode.select(DialogicUtil.get_project_setting('dialogic/translation/file_mode', 1))
|
||||
|
||||
%TransFolderPicker.set_value(DialogicUtil.get_project_setting('dialogic/translation/translation_folder', ''))
|
||||
loading = false
|
||||
|
||||
func store_changes(fake_arg = "", fake_arg2 = ""):
|
||||
if loading: return
|
||||
ProjectSettings.set_setting('dialogic/translation/enabled', %TransEnabled.button_pressed)
|
||||
ProjectSettings.set_setting('dialogic/translation/original_locale', %OrigLocale.current_value)
|
||||
ProjectSettings.set_setting('dialogic/translation/transation_folder', %TransFolderPicker.current_value)
|
||||
ProjectSettings.set_setting('dialogic/translation/file_mode', %TransMode.selected)
|
||||
ProjectSettings.save()
|
||||
|
||||
func get_locales(filter:String) -> Dictionary:
|
||||
var suggestions = {}
|
||||
suggestions[TranslationServer.get_tool_locale()] = {'value':TranslationServer.get_tool_locale()}
|
||||
for locale in TranslationServer.get_all_languages():
|
||||
suggestions[locale] = {'value':locale, 'tooltip':TranslationServer.get_language_name(locale)}
|
||||
return suggestions
|
||||
|
||||
|
||||
func update_csv_files():
|
||||
var orig_locale = %OrigLocale.current_value.strip_edges()
|
||||
if orig_locale.is_empty():
|
||||
orig_locale = ProjectSettings.get_setting('internationalization/locale/fallback')
|
||||
%OrigLocale.set_value(orig_locale)
|
||||
|
||||
var translation_mode = %TransMode.selected
|
||||
|
||||
var file : FileAccess
|
||||
var files : = [] # collected to trigger reimport at the end
|
||||
var csv_lines := [] # collects all current lines
|
||||
var old_csv_lines := {} # contains already existing csv_lines as [key] = [value, value, ...] dict
|
||||
|
||||
# collect old lines in per project mode
|
||||
if translation_mode == TranslationModes.PerProject:
|
||||
var file_path = DialogicUtil.get_project_setting('dialogic/translation/translation_folder', 'res://')+'dialogic_translations.csv'
|
||||
files.append(file_path)
|
||||
if FileAccess.file_exists(file_path):
|
||||
file = FileAccess.open(file_path,FileAccess.READ_WRITE)
|
||||
|
||||
while !file.eof_reached():
|
||||
var line := file.get_csv_line()
|
||||
old_csv_lines[line[0]] = line.slice(1)
|
||||
csv_lines.append(['keys', orig_locale])
|
||||
|
||||
for timeline_path in DialogicUtil.list_resources_of_type('.dtl'):
|
||||
|
||||
# collect old lines in per timeline mode
|
||||
var file_path = timeline_path.trim_suffix('.dtl')+'_translation.csv'
|
||||
if translation_mode == TranslationModes.PerTimeline:
|
||||
files.append(file_path)
|
||||
if FileAccess.file_exists(file_path):
|
||||
file = FileAccess.open(file_path,FileAccess.READ_WRITE)
|
||||
while !file.eof_reached():
|
||||
var line := file.get_csv_line()
|
||||
old_csv_lines[line[0]] = line.slice(1)
|
||||
csv_lines.append(['keys', orig_locale])
|
||||
|
||||
# load and process timeline (make events to resources)
|
||||
var tml : DialogicTimeline = load(timeline_path)
|
||||
tml = find_parent('EditorView').process_timeline(tml)
|
||||
|
||||
# now collect all the current csv_lines from timeline
|
||||
for event in tml.events:
|
||||
if event.can_be_translated():
|
||||
if event._translation_id.is_empty():
|
||||
event.add_translation_id()
|
||||
event.update_text_version()
|
||||
for property in event._get_translatable_properties():
|
||||
csv_lines.append([event.get_property_translation_key(property), event._get_property_original_translation(property)])
|
||||
|
||||
# in case new translation_id's were added, we save the timeline again
|
||||
tml.set_meta("timeline_not_saved", true)
|
||||
tml.events_processed = false
|
||||
ResourceSaver.save(tml, timeline_path)
|
||||
|
||||
# for per_timeline mode save the file now, then reset for next timeline
|
||||
if translation_mode == TranslationModes.PerTimeline:
|
||||
file = FileAccess.open(file_path, FileAccess.WRITE)
|
||||
|
||||
for line in csv_lines:
|
||||
# in case there might be translations for this line already,
|
||||
# add them at the end again (orig locale text is replaced).
|
||||
if line[0] in old_csv_lines:
|
||||
line.append_array(old_csv_lines[line[0]].slice(2))
|
||||
file.store_csv_line(line)
|
||||
|
||||
csv_lines.clear()
|
||||
old_csv_lines.clear()
|
||||
|
||||
if translation_mode == TranslationModes.PerProject:
|
||||
var file_path = DialogicUtil.get_project_setting('dialogic/translation/translation_folder', 'res://')+'dialogic_translations.csv'
|
||||
file = FileAccess.open(file_path, FileAccess.WRITE)
|
||||
|
||||
for line in csv_lines:
|
||||
# in case there might be translations for this line already,
|
||||
# add them at the end again (orig locale text is replaced).
|
||||
if line[0] in old_csv_lines:
|
||||
file.store_csv_line(line+old_csv_lines[line[0]].slice(2))
|
||||
else:
|
||||
file.store_csv_line(line)
|
||||
|
||||
|
||||
## ADD CREATION/UPDATE OF CHARACTER NAMES FILE HERE!
|
||||
|
||||
# trigger reimport
|
||||
# find_parent('EditorView').plugin_reference.editor_interface.get_resource_filesystem().reimport_files(files)
|
||||
find_parent('EditorView').plugin_reference.editor_interface.get_resource_filesystem().scan_sources()
|
||||
|
||||
func collect_translations():
|
||||
var trans_files := []
|
||||
var translation_mode = %TransMode.selected
|
||||
if translation_mode == TranslationModes.PerTimeline:
|
||||
for timeline_path in DialogicUtil.list_resources_of_type('.dtl'):
|
||||
for file in DialogicUtil.listdir(timeline_path.get_base_dir()):
|
||||
file = timeline_path.get_base_dir().path_join(file)
|
||||
if file.ends_with('.translation'):
|
||||
if not file in trans_files:
|
||||
trans_files.append(file)
|
||||
|
||||
if translation_mode == TranslationModes.PerProject:
|
||||
var trans_folder = DialogicUtil.get_project_setting('dialogic/translation/translation_folder', 'res://')
|
||||
for file in DialogicUtil.listdir(trans_folder):
|
||||
file = trans_folder.path_join(file)
|
||||
if file.ends_with('.translation'):
|
||||
if not file in trans_files:
|
||||
trans_files.append(file)
|
||||
|
||||
ProjectSettings.set_setting('internationalization/locale/translations', PackedStringArray(trans_files))
|
||||
ProjectSettings.save()
|
||||
|
||||
func erase_translations():
|
||||
var trans_files := Array(DialogicUtil.get_project_setting('internationalization/locale/translations', []))
|
||||
var translation_mode : int = %TransMode.selected
|
||||
|
||||
if translation_mode == TranslationModes.PerProject:
|
||||
var trans_path :String = DialogicUtil.get_project_setting('dialogic/translation/translation_folder', 'res://')
|
||||
DirAccess.remove_absolute(trans_path+'dialogic_translations.csv')
|
||||
DirAccess.remove_absolute(trans_path+'dialogic_translations.csv.import')
|
||||
for x_file in DialogicUtil.listdir(trans_path):
|
||||
if x_file.ends_with('.translation'):
|
||||
trans_files.erase(trans_path.get_base_dir().path_join(x_file))
|
||||
DirAccess.remove_absolute(trans_path.get_base_dir().path_join(x_file))
|
||||
|
||||
for timeline_path in DialogicUtil.list_resources_of_type('.dtl'):
|
||||
# in per project mode, remove all translation files/resources next to the timelines
|
||||
if translation_mode == TranslationModes.PerTimeline:
|
||||
DirAccess.remove_absolute(timeline_path.trim_suffix('.dtl')+'_translation.csv')
|
||||
DirAccess.remove_absolute(timeline_path.trim_suffix('.dtl')+'_translation.csv.import')
|
||||
for x_file in DialogicUtil.listdir(timeline_path.get_base_dir()):
|
||||
if x_file.ends_with('.translation'):
|
||||
trans_files.erase(timeline_path.get_base_dir().path_join(x_file))
|
||||
DirAccess.remove_absolute(timeline_path.get_base_dir().path_join(x_file))
|
||||
|
||||
# clear the timeline events of their translation_id's
|
||||
var tml:DialogicTimeline = load(timeline_path)
|
||||
tml = await find_parent('EditorView').process_timeline(tml)
|
||||
for event in tml.get_events():
|
||||
if event._translation_id:
|
||||
event.remove_translation_id()
|
||||
event.update_text_version()
|
||||
tml.set_meta("timeline_not_saved", true)
|
||||
tml.events_processed = false
|
||||
ResourceSaver.save(tml, timeline_path)
|
||||
|
||||
ProjectSettings.set_setting('dialogic/translation/id_counter', 16)
|
||||
ProjectSettings.set_setting('internationalization/locale/translations', PackedStringArray(trans_files))
|
||||
ProjectSettings.save()
|
||||
|
||||
find_parent('EditorView').plugin_reference.editor_interface.get_resource_filesystem().scan_sources()
|
||||
|
||||
refresh()
|
||||
|
||||
1322
Sprout/addons/dialogic/Editor/Settings/Settings_Translations.tscn
Normal file
1322
Sprout/addons/dialogic/Editor/Settings/Settings_Translations.tscn
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue