2 extends DialogicCharacterEditorPortraitSection
4 ## Tab that allows setting a custom scene for a portrait.
6 func _get_title() -> String:
10 hint_text = "You can use a custom scene for this portrait."
12 func _start_opened() -> bool:
15 func _ready() -> void:
16 %ChangeSceneButton.icon = get_theme_icon("Loop", "EditorIcons")
17 %ScenePicker.file_filter = "*.tscn, *.scn; Scenes"
18 %ScenePicker.resource_icon = get_theme_icon('PackedScene', 'EditorIcons')
19 %ScenePicker.placeholder = 'Default scene'
21 %OpenSceneButton.icon = get_theme_icon("ExternalLink", "EditorIcons")
24 func _load_portrait_data(data:Dictionary) -> void:
28 func _on_open_scene_button_pressed() -> void:
29 var data: Dictionary = selected_item.get_metadata(0)
30 if ResourceLoader.exists(data.get("scene", "")):
31 DialogicUtil.get_dialogic_plugin().get_editor_interface().open_scene_from_path(data.get("scene", ""))
32 await get_tree().process_frame
33 EditorInterface.set_main_screen_editor("2D")
36 func _on_change_scene_button_pressed() -> void:
37 %PortraitSceneBrowserWindow.popup_centered_ratio(0.6)
40 func _on_portrait_scene_browser_activate_part(part_info: Dictionary) -> void:
41 %PortraitSceneBrowserWindow.hide()
44 set_scene_path(part_info.path)
46 find_parent("EditorView").godot_file_dialog(
47 create_new_portrait_scene.bind(part_info),
49 EditorFileDialog.FILE_MODE_SAVE_FILE,
50 "Select where to save the new scene",
51 part_info.path.get_file().trim_suffix("."+part_info.path.get_extension())+"_"+character_editor.current_resource.get_character_name().to_lower())
53 find_parent("EditorView").godot_file_dialog(
56 EditorFileDialog.FILE_MODE_OPEN_FILE,
57 "Select custom portrait scene",)
62 func create_new_portrait_scene(target_file: String, info: Dictionary) -> void:
63 var path := make_portrait_preset_custom(target_file, info)
67 func make_portrait_preset_custom(target_file:String, info: Dictionary) -> String:
68 var previous_file: String = info.path
70 var result_path := DialogicUtil.make_file_custom(previous_file, target_file.get_base_dir(), target_file.get_file())
75 func set_scene_path(path:String) -> void:
76 var data: Dictionary = selected_item.get_metadata(0)
83 func reload_ui(data: Dictionary) -> void:
84 var path: String = data.get('scene', '')
85 %OpenSceneButton.hide()
88 %SceneLabel.text = "Default Portrait Scene"
89 %SceneLabel.tooltip_text = "Can be changed in the settings."
90 %SceneLabel.add_theme_color_override("font_color", get_theme_color("readonly_color", "Editor"))
92 elif %PortraitSceneBrowser.is_premade_portrait_scene(path):
93 %SceneLabel.text = %PortraitSceneBrowser.portrait_scenes_info[path].name
94 %SceneLabel.tooltip_text = path
95 %SceneLabel.add_theme_color_override("font_color", get_theme_color("accent_color", "Editor"))
98 %SceneLabel.text = path.get_file()
99 %SceneLabel.tooltip_text = path
100 %SceneLabel.add_theme_color_override("font_color", get_theme_color("property_color_x", "Editor"))
101 %OpenSceneButton.show()