From 11572c6e309692b62554ae852dfa8fb8943bcbd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 14 Feb 2022 14:00:03 +0100 Subject: Editor: Cleanup some includes dependencies Removes some unnecessary includes from `editor_node.h`, and instead add those where they're used. Removes unnecessary `editor_node.h` includes in various editor classes. Renames `dynamicfont` to `dynamic_font` in a couple files. Misc cleanup while jumping through that rabbit hole. --- editor/action_map_editor.cpp | 2 +- editor/action_map_editor.h | 8 +- editor/code_editor.cpp | 5 +- editor/code_editor.h | 5 +- editor/connections_dialog.cpp | 4 - editor/connections_dialog.h | 7 +- .../debug_adapter/debug_adapter_parser.cpp | 1 + editor/debugger/script_editor_debugger.h | 1 - editor/editor_about.cpp | 1 - editor/editor_data.cpp | 4 +- editor/editor_data.h | 8 +- editor/editor_export.cpp | 1 + editor/editor_node.cpp | 5 +- editor/editor_path.cpp | 1 + editor/editor_path.h | 5 +- editor/editor_paths.cpp | 2 +- editor/editor_paths.h | 1 + editor/editor_plugin.cpp | 5 +- editor/editor_properties_array_dict.cpp | 2 +- editor/editor_resource_picker.cpp | 2 + editor/editor_resource_picker.h | 2 +- editor/editor_resource_preview.cpp | 1 + editor/editor_run_script.h | 2 + editor/editor_settings.cpp | 6 +- editor/editor_settings.h | 6 +- editor/editor_spin_slider.cpp | 1 - editor/editor_toaster.cpp | 2 +- editor/export_template_manager.cpp | 1 + editor/filesystem_dock.cpp | 5 +- editor/filesystem_dock.h | 21 +- editor/import/dynamic_font_import_settings.cpp | 1683 ++++++++++++++++++++ editor/import/dynamic_font_import_settings.h | 181 +++ editor/import/dynamicfont_import_settings.cpp | 1683 -------------------- editor/import/dynamicfont_import_settings.h | 182 --- editor/import/resource_importer_bitmask.cpp | 6 +- editor/import/resource_importer_bitmask.h | 3 - editor/import/resource_importer_dynamic_font.cpp | 314 ++++ editor/import/resource_importer_dynamic_font.h | 69 + editor/import/resource_importer_dynamicfont.cpp | 313 ---- editor/import/resource_importer_dynamicfont.h | 71 - editor/import_defaults_editor.cpp | 1 + editor/import_defaults_editor.h | 1 + editor/inspector_dock.cpp | 2 +- editor/inspector_dock.h | 6 +- editor/plugins/abstract_polygon_2d_editor.h | 1 - .../plugins/animation_blend_tree_editor_plugin.h | 1 - editor/plugins/animation_player_editor_plugin.cpp | 1 - editor/plugins/animation_player_editor_plugin.h | 3 +- editor/plugins/animation_tree_editor_plugin.h | 2 +- editor/plugins/asset_library_editor_plugin.cpp | 1 + editor/plugins/audio_stream_editor_plugin.h | 1 - .../audio_stream_randomizer_editor_plugin.cpp | 2 + .../audio_stream_randomizer_editor_plugin.h | 1 - editor/plugins/camera_3d_editor_plugin.h | 2 - editor/plugins/canvas_item_editor_plugin.h | 1 - editor/plugins/collision_shape_2d_editor_plugin.h | 2 - editor/plugins/control_editor_plugin.cpp | 1 + editor/plugins/control_editor_plugin.h | 2 - editor/plugins/cpu_particles_2d_editor_plugin.h | 1 - editor/plugins/cpu_particles_3d_editor_plugin.h | 2 - editor/plugins/curve_editor_plugin.h | 2 - editor/plugins/debugger_editor_plugin.cpp | 1 + editor/plugins/debugger_editor_plugin.h | 1 - editor/plugins/editor_preview_plugins.cpp | 2 +- editor/plugins/editor_preview_plugins.h | 3 +- editor/plugins/font_editor_plugin.cpp | 1 - editor/plugins/font_editor_plugin.h | 2 - editor/plugins/gpu_particles_2d_editor_plugin.h | 1 - editor/plugins/gpu_particles_3d_editor_plugin.h | 1 - .../gpu_particles_collision_sdf_editor_plugin.h | 1 - editor/plugins/gradient_editor_plugin.h | 2 - editor/plugins/input_event_editor_plugin.cpp | 2 - editor/plugins/input_event_editor_plugin.h | 3 +- editor/plugins/lightmap_gi_editor_plugin.h | 1 - editor/plugins/material_editor_plugin.h | 6 +- editor/plugins/mesh_editor_plugin.cpp | 1 - editor/plugins/mesh_editor_plugin.h | 2 - editor/plugins/mesh_instance_3d_editor_plugin.h | 2 - editor/plugins/mesh_library_editor_plugin.h | 1 - editor/plugins/multimesh_editor_plugin.h | 1 - editor/plugins/node_3d_editor_plugin.h | 1 - .../plugins/occluder_instance_3d_editor_plugin.h | 2 - editor/plugins/ot_features_plugin.cpp | 3 - editor/plugins/ot_features_plugin.h | 2 - editor/plugins/path_2d_editor_plugin.h | 1 - editor/plugins/path_3d_editor_plugin.h | 2 - editor/plugins/physical_bone_3d_editor_plugin.cpp | 2 - editor/plugins/physical_bone_3d_editor_plugin.h | 2 - editor/plugins/polygon_2d_editor_plugin.cpp | 6 +- editor/plugins/polygon_2d_editor_plugin.h | 6 +- editor/plugins/polygon_3d_editor_plugin.h | 1 - editor/plugins/replication_editor_plugin.cpp | 1 + editor/plugins/replication_editor_plugin.h | 1 - editor/plugins/resource_preloader_editor_plugin.h | 2 - editor/plugins/script_editor_plugin.h | 2 - editor/plugins/skeleton_2d_editor_plugin.h | 2 - editor/plugins/skeleton_3d_editor_plugin.h | 1 - editor/plugins/skeleton_ik_3d_editor_plugin.h | 1 - editor/plugins/sprite_2d_editor_plugin.h | 2 - editor/plugins/sprite_frames_editor_plugin.h | 2 - editor/plugins/style_box_editor_plugin.cpp | 1 - editor/plugins/style_box_editor_plugin.h | 2 - .../plugins/sub_viewport_preview_editor_plugin.cpp | 2 - .../plugins/sub_viewport_preview_editor_plugin.h | 2 - editor/plugins/text_control_editor_plugin.h | 2 - editor/plugins/texture_3d_editor_plugin.cpp | 5 - editor/plugins/texture_3d_editor_plugin.h | 2 - editor/plugins/texture_editor_plugin.cpp | 1 - editor/plugins/texture_editor_plugin.h | 2 - editor/plugins/texture_layered_editor_plugin.cpp | 5 - editor/plugins/texture_layered_editor_plugin.h | 2 - editor/plugins/texture_region_editor_plugin.h | 1 - editor/plugins/theme_editor_plugin.h | 1 - editor/plugins/theme_editor_preview.h | 2 - editor/plugins/tiles/atlas_merging_dialog.h | 2 - editor/plugins/tiles/tile_map_editor.h | 1 - editor/plugins/tiles/tile_proxies_manager_dialog.h | 3 - .../plugins/tiles/tile_set_atlas_source_editor.h | 1 - editor/plugins/tiles/tile_set_editor.cpp | 1 + .../tile_set_scenes_collection_source_editor.h | 1 - editor/plugins/visual_shader_editor_plugin.h | 4 +- editor/plugins/voxel_gi_editor_plugin.h | 1 - editor/project_export.h | 1 - editor/rename_dialog.h | 2 + editor/scene_tree_dock.cpp | 3 + editor/scene_tree_dock.h | 5 +- editor/scene_tree_editor.cpp | 1 + editor/script_create_dialog.cpp | 2 +- main/main.cpp | 1 + .../gdnative/gdnative_library_editor_plugin.cpp | 2 + modules/gdnative/gdnative_library_editor_plugin.h | 5 +- modules/gridmap/grid_map_editor_plugin.h | 1 - modules/mono/godotsharp_dirs.cpp | 2 +- modules/navigation/navigation_mesh_generator.cpp | 1 - .../editor/visual_script_property_selector.cpp | 1 - platform/android/export/export.cpp | 3 + platform/android/export/export_plugin.cpp | 18 + platform/android/export/export_plugin.h | 21 +- platform/javascript/export/export_plugin.cpp | 1 - platform/javascript/export/export_plugin.h | 3 +- platform/javascript/export/export_server.h | 2 +- platform/osx/export/codesign.cpp | 2 + platform/osx/export/export_plugin.cpp | 7 +- platform/uwp/export/app_packager.cpp | 1 + platform/uwp/export/export_plugin.h | 1 + scene/gui/dialogs.cpp | 7 +- 146 files changed, 2392 insertions(+), 2479 deletions(-) create mode 100644 editor/import/dynamic_font_import_settings.cpp create mode 100644 editor/import/dynamic_font_import_settings.h delete mode 100644 editor/import/dynamicfont_import_settings.cpp delete mode 100644 editor/import/dynamicfont_import_settings.h create mode 100644 editor/import/resource_importer_dynamic_font.cpp create mode 100644 editor/import/resource_importer_dynamic_font.h delete mode 100644 editor/import/resource_importer_dynamicfont.cpp delete mode 100644 editor/import/resource_importer_dynamicfont.h diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 2b407ecacf..6fd0132ab1 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -29,10 +29,10 @@ /*************************************************************************/ #include "action_map_editor.h" + #include "core/input/input_map.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" -#include "scene/gui/center_container.h" #include "scene/gui/separator.h" ///////////////////////////////////////// diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index 9988cd8db6..de24d3ee1f 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -31,8 +31,14 @@ #ifndef ACTION_MAP_EDITOR_H #define ACTION_MAP_EDITOR_H -#include "editor/editor_data.h" +#include "scene/gui/check_box.h" +#include "scene/gui/check_button.h" #include "scene/gui/color_rect.h" +#include "scene/gui/dialogs.h" +#include "scene/gui/label.h" +#include "scene/gui/option_button.h" +#include "scene/gui/tab_container.h" +#include "scene/gui/tree.h" // Confirmation Dialog used when configuring an input event. // Separate from ActionMapEditor for code cleanliness and separation of responsibilities. diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 3be6d6ea12..56dcd35c64 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -31,14 +31,11 @@ #include "code_editor.h" #include "core/input/input.h" -#include "core/object/message_queue.h" #include "core/os/keyboard.h" #include "core/string/string_builder.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "scene/gui/margin_container.h" -#include "scene/gui/separator.h" +#include "editor/plugins/script_editor_plugin.h" #include "scene/resources/font.h" void GotoLineDialog::popup_find_line(CodeEdit *p_edit) { diff --git a/editor/code_editor.h b/editor/code_editor.h index a385ae2287..aebdfe57c0 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -31,11 +31,12 @@ #ifndef CODE_EDITOR_H #define CODE_EDITOR_H -#include "editor/editor_plugin.h" +#include "scene/gui/box_container.h" +#include "scene/gui/button.h" #include "scene/gui/check_box.h" -#include "scene/gui/check_button.h" #include "scene/gui/code_edit.h" #include "scene/gui/dialogs.h" +#include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/main/timer.h" diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 3f221cd7e0..d4785afcf0 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -30,16 +30,12 @@ #include "connections_dialog.h" -#include "core/string/print_string.h" #include "editor/doc_tools.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/scene_tree_dock.h" #include "plugins/script_editor_plugin.h" -#include "scene/gui/label.h" -#include "scene/gui/popup_menu.h" -#include "scene/gui/spin_box.h" static Node *_find_first_script(Node *p_root, Node *p_node) { if (p_node != p_root && p_node->get_owner() != p_root) { diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 83419a8e08..a075ff0c55 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -35,16 +35,19 @@ #include "editor/editor_inspector.h" #include "editor/scene_tree_editor.h" #include "scene/gui/button.h" +#include "scene/gui/check_box.h" #include "scene/gui/check_button.h" #include "scene/gui/dialogs.h" +#include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/gui/menu_button.h" +#include "scene/gui/option_button.h" #include "scene/gui/popup.h" +#include "scene/gui/popup_menu.h" +#include "scene/gui/spin_box.h" #include "scene/gui/tree.h" -class PopupMenu; class ConnectDialogBinds; -class SpinBox; class ConnectDialog : public ConfirmationDialog { GDCLASS(ConnectDialog, ConfirmationDialog); diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index ff4051fc67..e7baeeeded 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -34,6 +34,7 @@ #include "editor/debugger/script_editor_debugger.h" #include "editor/editor_node.h" #include "editor/editor_run_native.h" +#include "editor/plugins/script_editor_plugin.h" void DebugAdapterParser::_bind_methods() { // Requests diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index b673df6191..e4d3a2fa09 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -39,7 +39,6 @@ #include "scene/gui/margin_container.h" class Tree; -class EditorNode; class LineEdit; class TabContainer; class RichTextLabel; diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 2eae08e741..4ba30eaa0e 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -34,7 +34,6 @@ #include "core/donors.gen.h" #include "core/license.gen.h" #include "core/version.h" -#include "editor/editor_node.h" // The metadata key used to store and retrieve the version text to copy to the clipboard. static const String META_TEXT_TO_COPY = "text_to_copy"; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index ff452f8a96..91bd89b201 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -31,11 +31,11 @@ #include "editor_data.h" #include "core/config/project_settings.h" -#include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "editor/editor_node.h" -#include "editor/editor_settings.h" +#include "editor/editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" #include "scene/resources/packed_scene.h" void EditorHistory::cleanup_history() { diff --git a/editor/editor_data.h b/editor/editor_data.h index e485d47bf6..0d1efc9b62 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -33,11 +33,11 @@ #include "core/object/undo_redo.h" #include "core/templates/list.h" -#include "core/templates/pair.h" -#include "editor/editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "scene/resources/texture.h" +class ConfigFile; +class EditorPlugin; + class EditorHistory { enum { HISTORY_MAX = 64 @@ -59,8 +59,6 @@ class EditorHistory { Vector history; int current; - //Vector editor_plugins; - struct PropertyData { String name; Variant value; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index eee67693e2..98ae459c76 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -45,6 +45,7 @@ #include "core/version.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_settings.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/resources/resource_format_text.h" diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 43100ebf12..208640a2e3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -69,6 +69,7 @@ #include "servers/physics_server_2d.h" #include "servers/rendering/rendering_device.h" +#include "editor/animation_track_editor.h" #include "editor/audio_stream_preview.h" #include "editor/debugger/debug_adapter/debug_adapter_server.h" #include "editor/debugger/editor_debugger_node.h" @@ -103,12 +104,12 @@ #include "editor/editor_translation_parser.h" #include "editor/export_template_manager.h" #include "editor/filesystem_dock.h" -#include "editor/import/dynamicfont_import_settings.h" +#include "editor/import/dynamic_font_import_settings.h" #include "editor/import/editor_import_collada.h" #include "editor/import/resource_importer_bitmask.h" #include "editor/import/resource_importer_bmfont.h" #include "editor/import/resource_importer_csv_translation.h" -#include "editor/import/resource_importer_dynamicfont.h" +#include "editor/import/resource_importer_dynamic_font.h" #include "editor/import/resource_importer_image.h" #include "editor/import/resource_importer_imagefont.h" #include "editor/import/resource_importer_layered_texture.h" diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 716f10c679..5cb3d0cd75 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -30,6 +30,7 @@ #include "editor_path.h" +#include "editor/editor_data.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" diff --git a/editor/editor_path.h b/editor/editor_path.h index 04cf3d2ca7..539ae7a11d 100644 --- a/editor/editor_path.h +++ b/editor/editor_path.h @@ -31,10 +31,13 @@ #ifndef EDITOR_PATH_H #define EDITOR_PATH_H -#include "editor/editor_data.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" +#include "scene/gui/label.h" #include "scene/gui/popup_menu.h" +#include "scene/gui/texture_rect.h" + +class EditorHistory; class EditorPath : public Button { GDCLASS(EditorPath, Button); diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp index c209238447..7b454055e0 100644 --- a/editor/editor_paths.cpp +++ b/editor/editor_paths.cpp @@ -34,7 +34,7 @@ #include "core/config/project_settings.h" #include "core/io/dir_access.h" #include "core/os/os.h" -#include "main/main.h" // For `is_project_manager`. +#include "main/main.h" EditorPaths *EditorPaths::singleton = nullptr; diff --git a/editor/editor_paths.h b/editor/editor_paths.h index 4b814707b2..7d863a7c6c 100644 --- a/editor/editor_paths.h +++ b/editor/editor_paths.h @@ -32,6 +32,7 @@ #define EDITOR_PATHS_H #include "core/object/class_db.h" +#include "core/object/object.h" #include "core/string/ustring.h" class EditorPaths : public Object { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 24ce9e2636..10a2af0cb0 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -37,11 +37,12 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_settings.h" #include "editor/filesystem_dock.h" +#include "editor/plugins/canvas_item_editor_plugin.h" +#include "editor/plugins/node_3d_editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" #include "editor/project_settings_editor.h" #include "editor/scene_tree_dock.h" #include "main/main.h" -#include "plugins/canvas_item_editor_plugin.h" -#include "plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" #include "scene/gui/popup_menu.h" #include "servers/rendering_server.h" diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 162e2192a3..3bd5abb296 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -32,9 +32,9 @@ #include "core/input/input.h" #include "core/io/marshalls.h" -#include "editor/editor_node.h" #include "editor/editor_properties.h" #include "editor/editor_scale.h" +#include "editor/inspector_dock.h" bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index cb6901f130..2f14667fc0 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -36,6 +36,8 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/filesystem_dock.h" +#include "editor/plugins/script_editor_plugin.h" +#include "editor/quick_open.h" #include "editor/scene_tree_dock.h" HashMap> EditorResourcePicker::allowed_types_cache; diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index 192dca50ca..a6eff760e7 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -31,13 +31,13 @@ #ifndef EDITOR_RESOURCE_PICKER_H #define EDITOR_RESOURCE_PICKER_H -#include "quick_open.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/popup_menu.h" #include "scene/gui/texture_rect.h" class EditorFileDialog; +class EditorQuickOpen; class EditorResourcePicker : public HBoxContainer { GDCLASS(EditorResourcePicker, HBoxContainer); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 8a9ca53567..2bc92427e5 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -36,6 +36,7 @@ #include "core/io/resource_saver.h" #include "core/object/message_queue.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h index 1d2d53f299..28a854aaeb 100644 --- a/editor/editor_run_script.h +++ b/editor/editor_run_script.h @@ -33,7 +33,9 @@ #include "core/object/ref_counted.h" #include "editor/editor_plugin.h" + class EditorNode; + class EditorScript : public RefCounted { GDCLASS(EditorScript, RefCounted); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4e1b7bde95..6bd11fcdd6 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -31,18 +31,22 @@ #include "editor_settings.h" #include "core/config/project_settings.h" +#include "core/input/input_event.h" #include "core/input/input_map.h" +#include "core/input/shortcut.h" #include "core/io/certs_compressed.gen.h" -#include "core/io/config_file.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/ip.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/object/class_db.h" #include "core/os/keyboard.h" #include "core/os/os.h" +#include "core/string/translation.h" #include "core/version.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_translation.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 078abcb4d9..f0fec3acc7 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -31,15 +31,13 @@ #ifndef EDITOR_SETTINGS_H #define EDITOR_SETTINGS_H -#include "core/input/shortcut.h" #include "core/io/config_file.h" #include "core/io/resource.h" -#include "core/object/class_db.h" #include "core/os/thread_safe.h" -#include "core/string/translation.h" -#include "editor/editor_paths.h" class EditorPlugin; +class InputEvent; +class Shortcut; class EditorSettings : public Resource { GDCLASS(EditorSettings, Resource); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 6a2e40387b..ccebca4cc9 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -33,7 +33,6 @@ #include "core/input/input.h" #include "core/math/expression.h" #include "core/os/keyboard.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 121d1256dc..f96df86682 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -30,8 +30,8 @@ #include "editor_toaster.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_settings.h" #include "scene/gui/button.h" #include "scene/gui/label.h" #include "scene/gui/panel_container.h" diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 379bbc343c..3cad600002 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -37,6 +37,7 @@ #include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "progress_dialog.h" #include "scene/gui/link_button.h" diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index c940e6bfc6..b41123c0dd 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -42,12 +42,13 @@ #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/import_dock.h" #include "editor/scene_tree_dock.h" -#include "import_dock.h" +#include "editor/shader_create_dialog.h" +#include "scene/gui/label.h" #include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" -#include "shader_create_dialog.h" FileSystemDock *FileSystemDock::singleton = nullptr; diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 0e27adb545..21c50beeb2 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -31,29 +31,22 @@ #ifndef FILESYSTEM_DOCK_H #define FILESYSTEM_DOCK_H +#include "editor/create_dialog.h" +#include "editor/dependency_editor.h" +#include "editor/editor_dir_dialog.h" +#include "editor/editor_file_system.h" +#include "editor/plugins/script_editor_plugin.h" +#include "editor/script_create_dialog.h" #include "scene/gui/box_container.h" #include "scene/gui/control.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" -#include "scene/gui/label.h" +#include "scene/gui/line_edit.h" #include "scene/gui/menu_button.h" -#include "scene/gui/option_button.h" #include "scene/gui/progress_bar.h" #include "scene/gui/split_container.h" #include "scene/gui/tree.h" -#include "scene/main/timer.h" - -#include "core/io/dir_access.h" -#include "core/os/thread.h" - -#include "create_dialog.h" - -#include "dependency_editor.h" -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_system.h" -#include "script_create_dialog.h" -class EditorNode; class ShaderCreateDialog; class FileSystemDock : public VBoxContainer { diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp new file mode 100644 index 0000000000..864e69a16e --- /dev/null +++ b/editor/import/dynamic_font_import_settings.cpp @@ -0,0 +1,1683 @@ +/*************************************************************************/ +/* dynamic_font_import_settings.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "dynamic_font_import_settings.h" + +#include "editor/editor_file_dialog.h" +#include "editor/editor_file_system.h" +#include "editor/editor_inspector.h" +#include "editor/editor_locale_dialog.h" +#include "editor/editor_node.h" +#include "editor/editor_scale.h" + +/*************************************************************************/ +/* Settings data */ +/*************************************************************************/ + +class DynamicFontImportSettingsData : public RefCounted { + GDCLASS(DynamicFontImportSettingsData, RefCounted) + friend class DynamicFontImportSettings; + + Map settings; + Map defaults; + List options; + DynamicFontImportSettings *owner = nullptr; + + bool _set(const StringName &p_name, const Variant &p_value) { + if (defaults.has(p_name) && defaults[p_name] == p_value) { + settings.erase(p_name); + } else { + settings[p_name] = p_value; + } + return true; + } + + bool _get(const StringName &p_name, Variant &r_ret) const { + if (settings.has(p_name)) { + r_ret = settings[p_name]; + return true; + } + if (defaults.has(p_name)) { + r_ret = defaults[p_name]; + return true; + } + return false; + } + + void _get_property_list(List *p_list) const { + for (const List::Element *E = options.front(); E; E = E->next()) { + if (owner && owner->import_settings_data.is_valid()) { + if (owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "size" || E->get().option.name == "outline_size" || E->get().option.name == "oversampling")) { + continue; + } + if (!owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "msdf_pixel_range" || E->get().option.name == "msdf_size")) { + continue; + } + } + p_list->push_back(E->get().option); + } + } +}; + +/*************************************************************************/ +/* Glyph ranges */ +/*************************************************************************/ + +struct UniRange { + int32_t start; + int32_t end; + String name; +}; + +// Unicode Character Blocks +// Source: https://www.unicode.org/Public/14.0.0/ucd/Blocks.txt +static UniRange unicode_ranges[] = { + { 0x0000, 0x007F, U"Basic Latin" }, + { 0x0080, 0x00FF, U"Latin-1 Supplement" }, + { 0x0100, 0x017F, U"Latin Extended-A" }, + { 0x0180, 0x024F, U"Latin Extended-B" }, + { 0x0250, 0x02AF, U"IPA Extensions" }, + { 0x02B0, 0x02FF, U"Spacing Modifier Letters" }, + { 0x0300, 0x036F, U"Combining Diacritical Marks" }, + { 0x0370, 0x03FF, U"Greek and Coptic" }, + { 0x0400, 0x04FF, U"Cyrillic" }, + { 0x0500, 0x052F, U"Cyrillic Supplement" }, + { 0x0530, 0x058F, U"Armenian" }, + { 0x0590, 0x05FF, U"Hebrew" }, + { 0x0600, 0x06FF, U"Arabic" }, + { 0x0700, 0x074F, U"Syriac" }, + { 0x0750, 0x077F, U"Arabic Supplement" }, + { 0x0780, 0x07BF, U"Thaana" }, + { 0x07C0, 0x07FF, U"NKo" }, + { 0x0800, 0x083F, U"Samaritan" }, + { 0x0840, 0x085F, U"Mandaic" }, + { 0x0860, 0x086F, U"Syriac Supplement" }, + { 0x0870, 0x089F, U"Arabic Extended-B" }, + { 0x08A0, 0x08FF, U"Arabic Extended-A" }, + { 0x0900, 0x097F, U"Devanagari" }, + { 0x0980, 0x09FF, U"Bengali" }, + { 0x0A00, 0x0A7F, U"Gurmukhi" }, + { 0x0A80, 0x0AFF, U"Gujarati" }, + { 0x0B00, 0x0B7F, U"Oriya" }, + { 0x0B80, 0x0BFF, U"Tamil" }, + { 0x0C00, 0x0C7F, U"Telugu" }, + { 0x0C80, 0x0CFF, U"Kannada" }, + { 0x0D00, 0x0D7F, U"Malayalam" }, + { 0x0D80, 0x0DFF, U"Sinhala" }, + { 0x0E00, 0x0E7F, U"Thai" }, + { 0x0E80, 0x0EFF, U"Lao" }, + { 0x0F00, 0x0FFF, U"Tibetan" }, + { 0x1000, 0x109F, U"Myanmar" }, + { 0x10A0, 0x10FF, U"Georgian" }, + { 0x1100, 0x11FF, U"Hangul Jamo" }, + { 0x1200, 0x137F, U"Ethiopic" }, + { 0x1380, 0x139F, U"Ethiopic Supplement" }, + { 0x13A0, 0x13FF, U"Cherokee" }, + { 0x1400, 0x167F, U"Unified Canadian Aboriginal Syllabics" }, + { 0x1680, 0x169F, U"Ogham" }, + { 0x16A0, 0x16FF, U"Runic" }, + { 0x1700, 0x171F, U"Tagalog" }, + { 0x1720, 0x173F, U"Hanunoo" }, + { 0x1740, 0x175F, U"Buhid" }, + { 0x1760, 0x177F, U"Tagbanwa" }, + { 0x1780, 0x17FF, U"Khmer" }, + { 0x1800, 0x18AF, U"Mongolian" }, + { 0x18B0, 0x18FF, U"Unified Canadian Aboriginal Syllabics Extended" }, + { 0x1900, 0x194F, U"Limbu" }, + { 0x1950, 0x197F, U"Tai Le" }, + { 0x1980, 0x19DF, U"New Tai Lue" }, + { 0x19E0, 0x19FF, U"Khmer Symbols" }, + { 0x1A00, 0x1A1F, U"Buginese" }, + { 0x1A20, 0x1AAF, U"Tai Tham" }, + { 0x1AB0, 0x1AFF, U"Combining Diacritical Marks Extended" }, + { 0x1B00, 0x1B7F, U"Balinese" }, + { 0x1B80, 0x1BBF, U"Sundanese" }, + { 0x1BC0, 0x1BFF, U"Batak" }, + { 0x1C00, 0x1C4F, U"Lepcha" }, + { 0x1C50, 0x1C7F, U"Ol Chiki" }, + { 0x1C80, 0x1C8F, U"Cyrillic Extended-C" }, + { 0x1C90, 0x1CBF, U"Georgian Extended" }, + { 0x1CC0, 0x1CCF, U"Sundanese Supplement" }, + { 0x1CD0, 0x1CFF, U"Vedic Extensions" }, + { 0x1D00, 0x1D7F, U"Phonetic Extensions" }, + { 0x1D80, 0x1DBF, U"Phonetic Extensions Supplement" }, + { 0x1DC0, 0x1DFF, U"Combining Diacritical Marks Supplement" }, + { 0x1E00, 0x1EFF, U"Latin Extended Additional" }, + { 0x1F00, 0x1FFF, U"Greek Extended" }, + { 0x2000, 0x206F, U"General Punctuation" }, + { 0x2070, 0x209F, U"Superscripts and Subscripts" }, + { 0x20A0, 0x20CF, U"Currency Symbols" }, + { 0x20D0, 0x20FF, U"Combining Diacritical Marks for Symbols" }, + { 0x2100, 0x214F, U"Letterlike Symbols" }, + { 0x2150, 0x218F, U"Number Forms" }, + { 0x2190, 0x21FF, U"Arrows" }, + { 0x2200, 0x22FF, U"Mathematical Operators" }, + { 0x2300, 0x23FF, U"Miscellaneous Technical" }, + { 0x2400, 0x243F, U"Control Pictures" }, + { 0x2440, 0x245F, U"Optical Character Recognition" }, + { 0x2460, 0x24FF, U"Enclosed Alphanumerics" }, + { 0x2500, 0x257F, U"Box Drawing" }, + { 0x2580, 0x259F, U"Block Elements" }, + { 0x25A0, 0x25FF, U"Geometric Shapes" }, + { 0x2600, 0x26FF, U"Miscellaneous Symbols" }, + { 0x2700, 0x27BF, U"Dingbats" }, + { 0x27C0, 0x27EF, U"Miscellaneous Mathematical Symbols-A" }, + { 0x27F0, 0x27FF, U"Supplemental Arrows-A" }, + { 0x2800, 0x28FF, U"Braille Patterns" }, + { 0x2900, 0x297F, U"Supplemental Arrows-B" }, + { 0x2980, 0x29FF, U"Miscellaneous Mathematical Symbols-B" }, + { 0x2A00, 0x2AFF, U"Supplemental Mathematical Operators" }, + { 0x2B00, 0x2BFF, U"Miscellaneous Symbols and Arrows" }, + { 0x2C00, 0x2C5F, U"Glagolitic" }, + { 0x2C60, 0x2C7F, U"Latin Extended-C" }, + { 0x2C80, 0x2CFF, U"Coptic" }, + { 0x2D00, 0x2D2F, U"Georgian Supplement" }, + { 0x2D30, 0x2D7F, U"Tifinagh" }, + { 0x2D80, 0x2DDF, U"Ethiopic Extended" }, + { 0x2DE0, 0x2DFF, U"Cyrillic Extended-A" }, + { 0x2E00, 0x2E7F, U"Supplemental Punctuation" }, + { 0x2E80, 0x2EFF, U"CJK Radicals Supplement" }, + { 0x2F00, 0x2FDF, U"Kangxi Radicals" }, + { 0x2FF0, 0x2FFF, U"Ideographic Description Characters" }, + { 0x3000, 0x303F, U"CJK Symbols and Punctuation" }, + { 0x3040, 0x309F, U"Hiragana" }, + { 0x30A0, 0x30FF, U"Katakana" }, + { 0x3100, 0x312F, U"Bopomofo" }, + { 0x3130, 0x318F, U"Hangul Compatibility Jamo" }, + { 0x3190, 0x319F, U"Kanbun" }, + { 0x31A0, 0x31BF, U"Bopomofo Extended" }, + { 0x31C0, 0x31EF, U"CJK Strokes" }, + { 0x31F0, 0x31FF, U"Katakana Phonetic Extensions" }, + { 0x3200, 0x32FF, U"Enclosed CJK Letters and Months" }, + { 0x3300, 0x33FF, U"CJK Compatibility" }, + { 0x3400, 0x4DBF, U"CJK Unified Ideographs Extension A" }, + { 0x4DC0, 0x4DFF, U"Yijing Hexagram Symbols" }, + { 0x4E00, 0x9FFF, U"CJK Unified Ideographs" }, + { 0xA000, 0xA48F, U"Yi Syllables" }, + { 0xA490, 0xA4CF, U"Yi Radicals" }, + { 0xA4D0, 0xA4FF, U"Lisu" }, + { 0xA500, 0xA63F, U"Vai" }, + { 0xA640, 0xA69F, U"Cyrillic Extended-B" }, + { 0xA6A0, 0xA6FF, U"Bamum" }, + { 0xA700, 0xA71F, U"Modifier Tone Letters" }, + { 0xA720, 0xA7FF, U"Latin Extended-D" }, + { 0xA800, 0xA82F, U"Syloti Nagri" }, + { 0xA830, 0xA83F, U"Common Indic Number Forms" }, + { 0xA840, 0xA87F, U"Phags-pa" }, + { 0xA880, 0xA8DF, U"Saurashtra" }, + { 0xA8E0, 0xA8FF, U"Devanagari Extended" }, + { 0xA900, 0xA92F, U"Kayah Li" }, + { 0xA930, 0xA95F, U"Rejang" }, + { 0xA960, 0xA97F, U"Hangul Jamo Extended-A" }, + { 0xA980, 0xA9DF, U"Javanese" }, + { 0xA9E0, 0xA9FF, U"Myanmar Extended-B" }, + { 0xAA00, 0xAA5F, U"Cham" }, + { 0xAA60, 0xAA7F, U"Myanmar Extended-A" }, + { 0xAA80, 0xAADF, U"Tai Viet" }, + { 0xAAE0, 0xAAFF, U"Meetei Mayek Extensions" }, + { 0xAB00, 0xAB2F, U"Ethiopic Extended-A" }, + { 0xAB30, 0xAB6F, U"Latin Extended-E" }, + { 0xAB70, 0xABBF, U"Cherokee Supplement" }, + { 0xABC0, 0xABFF, U"Meetei Mayek" }, + { 0xAC00, 0xD7AF, U"Hangul Syllables" }, + { 0xD7B0, 0xD7FF, U"Hangul Jamo Extended-B" }, + //{ 0xD800, 0xDB7F, U"High Surrogates" }, + //{ 0xDB80, 0xDBFF, U"High Private Use Surrogates" }, + //{ 0xDC00, 0xDFFF, U"Low Surrogates" }, + { 0xE000, 0xF8FF, U"Private Use Area" }, + { 0xF900, 0xFAFF, U"CJK Compatibility Ideographs" }, + { 0xFB00, 0xFB4F, U"Alphabetic Presentation Forms" }, + { 0xFB50, 0xFDFF, U"Arabic Presentation Forms-A" }, + //{ 0xFE00, 0xFE0F, U"Variation Selectors" }, + { 0xFE10, 0xFE1F, U"Vertical Forms" }, + { 0xFE20, 0xFE2F, U"Combining Half Marks" }, + { 0xFE30, 0xFE4F, U"CJK Compatibility Forms" }, + { 0xFE50, 0xFE6F, U"Small Form Variants" }, + { 0xFE70, 0xFEFF, U"Arabic Presentation Forms-B" }, + { 0xFF00, 0xFFEF, U"Halfwidth and Fullwidth Forms" }, + //{ 0xFFF0, 0xFFFF, U"Specials" }, + { 0x10000, 0x1007F, U"Linear B Syllabary" }, + { 0x10080, 0x100FF, U"Linear B Ideograms" }, + { 0x10100, 0x1013F, U"Aegean Numbers" }, + { 0x10140, 0x1018F, U"Ancient Greek Numbers" }, + { 0x10190, 0x101CF, U"Ancient Symbols" }, + { 0x101D0, 0x101FF, U"Phaistos Disc" }, + { 0x10280, 0x1029F, U"Lycian" }, + { 0x102A0, 0x102DF, U"Carian" }, + { 0x102E0, 0x102FF, U"Coptic Epact Numbers" }, + { 0x10300, 0x1032F, U"Old Italic" }, + { 0x10330, 0x1034F, U"Gothic" }, + { 0x10350, 0x1037F, U"Old Permic" }, + { 0x10380, 0x1039F, U"Ugaritic" }, + { 0x103A0, 0x103DF, U"Old Persian" }, + { 0x10400, 0x1044F, U"Deseret" }, + { 0x10450, 0x1047F, U"Shavian" }, + { 0x10480, 0x104AF, U"Osmanya" }, + { 0x104B0, 0x104FF, U"Osage" }, + { 0x10500, 0x1052F, U"Elbasan" }, + { 0x10530, 0x1056F, U"Caucasian Albanian" }, + { 0x10570, 0x105BF, U"Vithkuqi" }, + { 0x10600, 0x1077F, U"Linear A" }, + { 0x10780, 0x107BF, U"Latin Extended-F" }, + { 0x10800, 0x1083F, U"Cypriot Syllabary" }, + { 0x10840, 0x1085F, U"Imperial Aramaic" }, + { 0x10860, 0x1087F, U"Palmyrene" }, + { 0x10880, 0x108AF, U"Nabataean" }, + { 0x108E0, 0x108FF, U"Hatran" }, + { 0x10900, 0x1091F, U"Phoenician" }, + { 0x10920, 0x1093F, U"Lydian" }, + { 0x10980, 0x1099F, U"Meroitic Hieroglyphs" }, + { 0x109A0, 0x109FF, U"Meroitic Cursive" }, + { 0x10A00, 0x10A5F, U"Kharoshthi" }, + { 0x10A60, 0x10A7F, U"Old South Arabian" }, + { 0x10A80, 0x10A9F, U"Old North Arabian" }, + { 0x10AC0, 0x10AFF, U"Manichaean" }, + { 0x10B00, 0x10B3F, U"Avestan" }, + { 0x10B40, 0x10B5F, U"Inscriptional Parthian" }, + { 0x10B60, 0x10B7F, U"Inscriptional Pahlavi" }, + { 0x10B80, 0x10BAF, U"Psalter Pahlavi" }, + { 0x10C00, 0x10C4F, U"Old Turkic" }, + { 0x10C80, 0x10CFF, U"Old Hungarian" }, + { 0x10D00, 0x10D3F, U"Hanifi Rohingya" }, + { 0x10E60, 0x10E7F, U"Rumi Numeral Symbols" }, + { 0x10E80, 0x10EBF, U"Yezidi" }, + { 0x10F00, 0x10F2F, U"Old Sogdian" }, + { 0x10F30, 0x10F6F, U"Sogdian" }, + { 0x10F70, 0x10FAF, U"Old Uyghur" }, + { 0x10FB0, 0x10FDF, U"Chorasmian" }, + { 0x10FE0, 0x10FFF, U"Elymaic" }, + { 0x11000, 0x1107F, U"Brahmi" }, + { 0x11080, 0x110CF, U"Kaithi" }, + { 0x110D0, 0x110FF, U"Sora Sompeng" }, + { 0x11100, 0x1114F, U"Chakma" }, + { 0x11150, 0x1117F, U"Mahajani" }, + { 0x11180, 0x111DF, U"Sharada" }, + { 0x111E0, 0x111FF, U"Sinhala Archaic Numbers" }, + { 0x11200, 0x1124F, U"Khojki" }, + { 0x11280, 0x112AF, U"Multani" }, + { 0x112B0, 0x112FF, U"Khudawadi" }, + { 0x11300, 0x1137F, U"Grantha" }, + { 0x11400, 0x1147F, U"Newa" }, + { 0x11480, 0x114DF, U"Tirhuta" }, + { 0x11580, 0x115FF, U"Siddham" }, + { 0x11600, 0x1165F, U"Modi" }, + { 0x11660, 0x1167F, U"Mongolian Supplement" }, + { 0x11680, 0x116CF, U"Takri" }, + { 0x11700, 0x1174F, U"Ahom" }, + { 0x11800, 0x1184F, U"Dogra" }, + { 0x118A0, 0x118FF, U"Warang Citi" }, + { 0x11900, 0x1195F, U"Dives Akuru" }, + { 0x119A0, 0x119FF, U"Nandinagari" }, + { 0x11A00, 0x11A4F, U"Zanabazar Square" }, + { 0x11A50, 0x11AAF, U"Soyombo" }, + { 0x11AB0, 0x11ABF, U"Unified Canadian Aboriginal Syllabics Extended-A" }, + { 0x11AC0, 0x11AFF, U"Pau Cin Hau" }, + { 0x11C00, 0x11C6F, U"Bhaiksuki" }, + { 0x11C70, 0x11CBF, U"Marchen" }, + { 0x11D00, 0x11D5F, U"Masaram Gondi" }, + { 0x11D60, 0x11DAF, U"Gunjala Gondi" }, + { 0x11EE0, 0x11EFF, U"Makasar" }, + { 0x11FB0, 0x11FBF, U"Lisu Supplement" }, + { 0x11FC0, 0x11FFF, U"Tamil Supplement" }, + { 0x12000, 0x123FF, U"Cuneiform" }, + { 0x12400, 0x1247F, U"Cuneiform Numbers and Punctuation" }, + { 0x12480, 0x1254F, U"Early Dynastic Cuneiform" }, + { 0x12F90, 0x12FFF, U"Cypro-Minoan" }, + { 0x13000, 0x1342F, U"Egyptian Hieroglyphs" }, + { 0x13430, 0x1343F, U"Egyptian Hieroglyph Format Controls" }, + { 0x14400, 0x1467F, U"Anatolian Hieroglyphs" }, + { 0x16800, 0x16A3F, U"Bamum Supplement" }, + { 0x16A40, 0x16A6F, U"Mro" }, + { 0x16A70, 0x16ACF, U"Tangsa" }, + { 0x16AD0, 0x16AFF, U"Bassa Vah" }, + { 0x16B00, 0x16B8F, U"Pahawh Hmong" }, + { 0x16E40, 0x16E9F, U"Medefaidrin" }, + { 0x16F00, 0x16F9F, U"Miao" }, + { 0x16FE0, 0x16FFF, U"Ideographic Symbols and Punctuation" }, + { 0x17000, 0x187FF, U"Tangut" }, + { 0x18800, 0x18AFF, U"Tangut Components" }, + { 0x18B00, 0x18CFF, U"Khitan Small Script" }, + { 0x18D00, 0x18D7F, U"Tangut Supplement" }, + { 0x1AFF0, 0x1AFFF, U"Kana Extended-B" }, + { 0x1B000, 0x1B0FF, U"Kana Supplement" }, + { 0x1B100, 0x1B12F, U"Kana Extended-A" }, + { 0x1B130, 0x1B16F, U"Small Kana Extension" }, + { 0x1B170, 0x1B2FF, U"Nushu" }, + { 0x1BC00, 0x1BC9F, U"Duployan" }, + { 0x1BCA0, 0x1BCAF, U"Shorthand Format Controls" }, + { 0x1CF00, 0x1CFCF, U"Znamenny Musical Notation" }, + { 0x1D000, 0x1D0FF, U"Byzantine Musical Symbols" }, + { 0x1D100, 0x1D1FF, U"Musical Symbols" }, + { 0x1D200, 0x1D24F, U"Ancient Greek Musical Notation" }, + { 0x1D2E0, 0x1D2FF, U"Mayan Numerals" }, + { 0x1D300, 0x1D35F, U"Tai Xuan Jing Symbols" }, + { 0x1D360, 0x1D37F, U"Counting Rod Numerals" }, + { 0x1D400, 0x1D7FF, U"Mathematical Alphanumeric Symbols" }, + { 0x1D800, 0x1DAAF, U"Sutton SignWriting" }, + { 0x1DF00, 0x1DFFF, U"Latin Extended-G" }, + { 0x1E000, 0x1E02F, U"Glagolitic Supplement" }, + { 0x1E100, 0x1E14F, U"Nyiakeng Puachue Hmong" }, + { 0x1E290, 0x1E2BF, U"Toto" }, + { 0x1E2C0, 0x1E2FF, U"Wancho" }, + { 0x1E7E0, 0x1E7FF, U"Ethiopic Extended-B" }, + { 0x1E800, 0x1E8DF, U"Mende Kikakui" }, + { 0x1E900, 0x1E95F, U"Adlam" }, + { 0x1EC70, 0x1ECBF, U"Indic Siyaq Numbers" }, + { 0x1ED00, 0x1ED4F, U"Ottoman Siyaq Numbers" }, + { 0x1EE00, 0x1EEFF, U"Arabic Mathematical Alphabetic Symbols" }, + { 0x1F000, 0x1F02F, U"Mahjong Tiles" }, + { 0x1F030, 0x1F09F, U"Domino Tiles" }, + { 0x1F0A0, 0x1F0FF, U"Playing Cards" }, + { 0x1F100, 0x1F1FF, U"Enclosed Alphanumeric Supplement" }, + { 0x1F200, 0x1F2FF, U"Enclosed Ideographic Supplement" }, + { 0x1F300, 0x1F5FF, U"Miscellaneous Symbols and Pictographs" }, + { 0x1F600, 0x1F64F, U"Emoticons" }, + { 0x1F650, 0x1F67F, U"Ornamental Dingbats" }, + { 0x1F680, 0x1F6FF, U"Transport and Map Symbols" }, + { 0x1F700, 0x1F77F, U"Alchemical Symbols" }, + { 0x1F780, 0x1F7FF, U"Geometric Shapes Extended" }, + { 0x1F800, 0x1F8FF, U"Supplemental Arrows-C" }, + { 0x1F900, 0x1F9FF, U"Supplemental Symbols and Pictographs" }, + { 0x1FA00, 0x1FA6F, U"Chess Symbols" }, + { 0x1FA70, 0x1FAFF, U"Symbols and Pictographs Extended-A" }, + { 0x1FB00, 0x1FBFF, U"Symbols for Legacy Computing" }, + { 0x20000, 0x2A6DF, U"CJK Unified Ideographs Extension B" }, + { 0x2A700, 0x2B73F, U"CJK Unified Ideographs Extension C" }, + { 0x2B740, 0x2B81F, U"CJK Unified Ideographs Extension D" }, + { 0x2B820, 0x2CEAF, U"CJK Unified Ideographs Extension E" }, + { 0x2CEB0, 0x2EBEF, U"CJK Unified Ideographs Extension F" }, + { 0x2F800, 0x2FA1F, U"CJK Compatibility Ideographs Supplement" }, + { 0x30000, 0x3134F, U"CJK Unified Ideographs Extension G" }, + //{ 0xE0000, 0xE007F, U"Tags" }, + //{ 0xE0100, 0xE01EF, U"Variation Selectors Supplement" }, + { 0xF0000, 0xFFFFF, U"Supplementary Private Use Area-A" }, + { 0x100000, 0x10FFFF, U"Supplementary Private Use Area-B" }, + { 0x10FFFF, 0x10FFFF, String() } +}; + +void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name) { + const int page_size = 512; + int pages = (p_end - p_start) / page_size; + int remain = (p_end - p_start) % page_size; + + int32_t start = p_start; + for (int i = 0; i < pages; i++) { + TreeItem *item = glyph_tree->create_item(glyph_root); + ERR_FAIL_NULL(item); + item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(start + page_size, 16))); + item->set_text(1, p_name); + item->set_metadata(0, Vector2i(start, start + page_size)); + start += page_size; + } + if (remain > 0) { + TreeItem *item = glyph_tree->create_item(glyph_root); + ERR_FAIL_NULL(item); + item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(p_end, 16))); + item->set_text(1, p_name); + item->set_metadata(0, Vector2i(start, p_end)); + } +} + +/*************************************************************************/ +/* Page 1 callbacks: Rendering Options */ +/*************************************************************************/ + +void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_property) { + // Update font preview. + + if (p_edited_property == "antialiased") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased")); + } + } else if (p_edited_property == "multichannel_signed_distance_field") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field")); + } + _variation_selected(); + _variations_validate(); + } else if (p_edited_property == "msdf_pixel_range") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range")); + } + } else if (p_edited_property == "msdf_size") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_msdf_size(import_settings_data->get("msdf_size")); + } + } else if (p_edited_property == "force_autohinter") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); + } + } else if (p_edited_property == "hinting") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); + } + } else if (p_edited_property == "subpixel_positioning") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); + } + } else if (p_edited_property == "oversampling") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); + } + } + font_preview_label->add_theme_font_override("font", font_preview); + font_preview_label->update(); +} + +/*************************************************************************/ +/* Page 2 callbacks: Configurations */ +/*************************************************************************/ + +void DynamicFontImportSettings::_variation_add() { + TreeItem *vars_item = vars_list->create_item(vars_list_root); + ERR_FAIL_NULL(vars_item); + + vars_item->set_text(0, TTR("New configuration")); + vars_item->set_editable(0, true); + vars_item->add_button(1, vars_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); + vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); + + Ref import_variation_data; + import_variation_data.instantiate(); + import_variation_data->owner = this; + ERR_FAIL_NULL(import_variation_data); + + for (List::Element *E = options_variations.front(); E; E = E->next()) { + import_variation_data->defaults[E->get().option.name] = E->get().default_value; + } + + import_variation_data->options = options_variations; + inspector_vars->edit(import_variation_data.ptr()); + import_variation_data->notify_property_list_changed(); + + vars_item->set_metadata(0, import_variation_data); + + _variations_validate(); +} + +void DynamicFontImportSettings::_variation_selected() { + TreeItem *vars_item = vars_list->get_selected(); + if (vars_item) { + Ref import_variation_data = vars_item->get_metadata(0); + ERR_FAIL_NULL(import_variation_data); + + inspector_vars->edit(import_variation_data.ptr()); + import_variation_data->notify_property_list_changed(); + } +} + +void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id) { + TreeItem *vars_item = (TreeItem *)p_item; + ERR_FAIL_NULL(vars_item); + + inspector_vars->edit(nullptr); + + vars_list_root->remove_child(vars_item); + memdelete(vars_item); + + if (vars_list_root->get_first_child()) { + Ref import_variation_data = vars_list_root->get_first_child()->get_metadata(0); + inspector_vars->edit(import_variation_data.ptr()); + import_variation_data->notify_property_list_changed(); + } + + _variations_validate(); +} + +void DynamicFontImportSettings::_variation_changed(const String &p_edited_property) { + _variations_validate(); +} + +void DynamicFontImportSettings::_variations_validate() { + String warn; + if (!vars_list_root->get_first_child()) { + warn = TTR("Warinig: There are no configurations specified, no glyphs will be pre-rendered."); + } + for (TreeItem *vars_item_a = vars_list_root->get_first_child(); vars_item_a; vars_item_a = vars_item_a->get_next()) { + Ref import_variation_data_a = vars_item_a->get_metadata(0); + ERR_FAIL_NULL(import_variation_data_a); + + for (TreeItem *vars_item_b = vars_list_root->get_first_child(); vars_item_b; vars_item_b = vars_item_b->get_next()) { + if (vars_item_b != vars_item_a) { + bool match = true; + for (Map::Element *E = import_variation_data_a->settings.front(); E; E = E->next()) { + Ref import_variation_data_b = vars_item_b->get_metadata(0); + ERR_FAIL_NULL(import_variation_data_b); + match = match && (import_variation_data_b->settings[E->key()] == E->get()); + } + if (match) { + warn = TTR("Warinig: Multiple configurations have identical settings. Duplicates will be ignored."); + break; + } + } + } + } + if (warn.is_empty()) { + label_warn->set_text(""); + label_warn->hide(); + } else { + label_warn->set_text(warn); + label_warn->show(); + } +} + +/*************************************************************************/ +/* Page 3 callbacks: Text to select glyphs */ +/*************************************************************************/ + +void DynamicFontImportSettings::_change_text_opts() { + Vector ftr = ftr_edit->get_text().split(","); + for (int i = 0; i < ftr.size(); i++) { + Vector tokens = ftr[i].split("="); + if (tokens.size() == 2) { + text_edit->set_opentype_feature(tokens[0], tokens[1].to_int()); + } else if (tokens.size() == 1) { + text_edit->set_opentype_feature(tokens[0], 1); + } + } + text_edit->set_language(lang_edit->get_text()); +} + +void DynamicFontImportSettings::_glyph_clear() { + selected_glyphs.clear(); + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); + _range_selected(); +} + +void DynamicFontImportSettings::_glyph_text_selected() { + Dictionary ftrs; + Vector ftr = ftr_edit->get_text().split(","); + for (int i = 0; i < ftr.size(); i++) { + Vector tokens = ftr[i].split("="); + if (tokens.size() == 2) { + ftrs[tokens[0]] = tokens[1].to_int(); + } else if (tokens.size() == 1) { + ftrs[tokens[0]] = 1; + } + } + + RID text_rid = TS->create_shaped_text(); + if (text_rid.is_valid()) { + TS->shaped_text_add_string(text_rid, text_edit->get_text(), font_main->get_rids(), 16, ftrs, text_edit->get_language()); + TS->shaped_text_shape(text_rid); + const Glyph *gl = TS->shaped_text_get_glyphs(text_rid); + const int gl_size = TS->shaped_text_get_glyph_count(text_rid); + + for (int i = 0; i < gl_size; i++) { + if (gl[i].font_rid.is_valid() && gl[i].index != 0) { + selected_glyphs.insert(gl[i].index); + } + } + TS->free(text_rid); + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); + } + _range_selected(); +} + +/*************************************************************************/ +/* Page 4 callbacks: Character map */ +/*************************************************************************/ + +void DynamicFontImportSettings::_glyph_selected() { + TreeItem *item = glyph_table->get_selected(); + ERR_FAIL_NULL(item); + + Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); + Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); + scol.a = 1.f; + + int32_t c = item->get_metadata(glyph_table->get_selected_column()); + if (font_main->has_char(c)) { + if (_char_update(c)) { + item->set_custom_color(glyph_table->get_selected_column(), fcol); + item->set_custom_bg_color(glyph_table->get_selected_column(), scol); + } else { + item->clear_custom_color(glyph_table->get_selected_column()); + item->clear_custom_bg_color(glyph_table->get_selected_column()); + } + } + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); + + item = glyph_tree->get_selected(); + ERR_FAIL_NULL(item); + Vector2i range = item->get_metadata(0); + + int total_chars = range.y - range.x; + int selected_count = 0; + for (int i = range.x; i < range.y; i++) { + if (!font_main->has_char(i)) { + total_chars--; + } + + if (selected_chars.has(i)) { + selected_count++; + } + } + + if (selected_count == total_chars) { + item->set_checked(0, true); + } else if (selected_count > 0) { + item->set_indeterminate(0, true); + } else { + item->set_checked(0, false); + } +} + +void DynamicFontImportSettings::_range_edited() { + TreeItem *item = glyph_tree->get_selected(); + ERR_FAIL_NULL(item); + Vector2i range = item->get_metadata(0); + _range_update(range.x, range.y); +} + +void DynamicFontImportSettings::_range_selected() { + TreeItem *item = glyph_tree->get_selected(); + if (item) { + Vector2i range = item->get_metadata(0); + _edit_range(range.x, range.y); + } +} + +void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { + glyph_table->clear(); + + TreeItem *root = glyph_table->create_item(); + ERR_FAIL_NULL(root); + + Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); + Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); + scol.a = 1.f; + + TreeItem *item = nullptr; + int col = 0; + + for (int32_t c = p_start; c <= p_end; c++) { + if (col == 0) { + item = glyph_table->create_item(root); + ERR_FAIL_NULL(item); + item->set_text(0, _pad_zeros(String::num_int64(c, 16))); + item->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT); + item->set_selectable(0, false); + item->set_custom_bg_color(0, glyph_table->get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); + } + if (font_main->has_char(c)) { + item->set_text(col + 1, String::chr(c)); + item->set_custom_color(col + 1, Color(1, 1, 1)); + if (selected_chars.has(c) || (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, c)))) { + item->set_custom_color(col + 1, fcol); + item->set_custom_bg_color(col + 1, scol); + } else { + item->clear_custom_color(col + 1); + item->clear_custom_bg_color(col + 1); + } + } else { + item->set_custom_bg_color(col + 1, glyph_table->get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + } + item->set_metadata(col + 1, c); + item->set_text_alignment(col + 1, HORIZONTAL_ALIGNMENT_CENTER); + item->set_selectable(col + 1, true); + item->set_custom_font(col + 1, font_main); + item->set_custom_font_size(col + 1, get_theme_font_size(SNAME("font_size")) * 2); + + col++; + if (col == 16) { + col = 0; + } + } + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); +} + +bool DynamicFontImportSettings::_char_update(int32_t p_char) { + if (selected_chars.has(p_char)) { + selected_chars.erase(p_char); + return false; + } else if (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, p_char))) { + selected_glyphs.erase(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, p_char)); + return false; + } else { + selected_chars.insert(p_char); + return true; + } + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); +} + +void DynamicFontImportSettings::_range_update(int32_t p_start, int32_t p_end) { + bool all_selected = true; + for (int32_t i = p_start; i <= p_end; i++) { + if (font_main->has_char(i)) { + if (font_main->get_data(0).is_valid()) { + all_selected = all_selected && (selected_chars.has(i) || (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, i)))); + } else { + all_selected = all_selected && selected_chars.has(i); + } + } + } + for (int32_t i = p_start; i <= p_end; i++) { + if (font_main->has_char(i)) { + if (!all_selected) { + selected_chars.insert(i); + } else { + selected_chars.erase(i); + if (font_main->get_data(0).is_valid()) { + selected_glyphs.erase(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, i)); + } + } + } + } + _edit_range(p_start, p_end); + + TreeItem *item = glyph_tree->get_selected(); + ERR_FAIL_NULL(item); + item->set_checked(0, !all_selected); +} + +/*************************************************************************/ +/* Page 5 callbacks: CMetadata override */ +/*************************************************************************/ + +void DynamicFontImportSettings::_lang_add() { + locale_select->popup_locale_dialog(); +} + +void DynamicFontImportSettings::_lang_add_item(const String &p_locale) { + TreeItem *lang_item = lang_list->create_item(lang_list_root); + ERR_FAIL_NULL(lang_item); + + lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + lang_item->set_editable(0, true); + lang_item->set_checked(0, false); + lang_item->set_text(1, p_locale); + lang_item->set_editable(1, true); + lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + lang_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); +} + +void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id) { + TreeItem *lang_item = (TreeItem *)p_item; + ERR_FAIL_NULL(lang_item); + + lang_list_root->remove_child(lang_item); + memdelete(lang_item); +} + +void DynamicFontImportSettings::_ot_add() { + menu_ot->set_position(ot_list->get_screen_transform().xform(ot_list->get_local_mouse_position())); + menu_ot->set_size(Vector2(1, 1)); + menu_ot->popup(); +} + +void DynamicFontImportSettings::_ot_add_item(int p_option) { + String name = TS->tag_to_name(p_option); + for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { + if (ot_item->get_text(0) == name) { + return; + } + } + TreeItem *ot_item = ot_list->create_item(ot_list_root); + ERR_FAIL_NULL(ot_item); + + ot_item->set_text(0, name); + ot_item->set_editable(0, false); + ot_item->set_text(1, "1"); + ot_item->set_editable(1, true); + ot_item->add_button(2, ot_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); +} + +void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id) { + TreeItem *ot_item = (TreeItem *)p_item; + ERR_FAIL_NULL(ot_item); + + ot_list_root->remove_child(ot_item); + memdelete(ot_item); +} + +void DynamicFontImportSettings::_script_add() { + menu_scripts->set_position(script_list->get_screen_position() + script_list->get_local_mouse_position()); + menu_scripts->reset_size(); + menu_scripts->popup(); +} + +void DynamicFontImportSettings::_script_add_item(int p_option) { + TreeItem *script_item = script_list->create_item(script_list_root); + ERR_FAIL_NULL(script_item); + + script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + script_item->set_editable(0, true); + script_item->set_checked(0, false); + script_item->set_text(1, script_codes[p_option]); + script_item->set_editable(1, true); + script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + script_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); +} + +void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id) { + TreeItem *script_item = (TreeItem *)p_item; + ERR_FAIL_NULL(script_item); + + script_list_root->remove_child(script_item); + memdelete(script_item); +} + +/*************************************************************************/ +/* Common */ +/*************************************************************************/ + +DynamicFontImportSettings *DynamicFontImportSettings::singleton = nullptr; + +String DynamicFontImportSettings::_pad_zeros(const String &p_hex) const { + int len = CLAMP(5 - p_hex.length(), 0, 5); + return String("0").repeat(len) + p_hex; +} + +void DynamicFontImportSettings::_notification(int p_what) { + if (p_what == NOTIFICATION_READY) { + connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import)); + } else if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { + add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + } +} + +void DynamicFontImportSettings::_re_import() { + Map main_settings; + + main_settings["antialiased"] = import_settings_data->get("antialiased"); + main_settings["multichannel_signed_distance_field"] = import_settings_data->get("multichannel_signed_distance_field"); + main_settings["msdf_pixel_range"] = import_settings_data->get("msdf_pixel_range"); + main_settings["msdf_size"] = import_settings_data->get("msdf_size"); + main_settings["force_autohinter"] = import_settings_data->get("force_autohinter"); + main_settings["hinting"] = import_settings_data->get("hinting"); + main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning"); + main_settings["oversampling"] = import_settings_data->get("oversampling"); + main_settings["compress"] = import_settings_data->get("compress"); + + Vector variations; + for (TreeItem *vars_item = vars_list_root->get_first_child(); vars_item; vars_item = vars_item->get_next()) { + String variation; + Ref import_variation_data = vars_item->get_metadata(0); + ERR_FAIL_NULL(import_variation_data); + + String name = vars_item->get_text(0); + variation += ("name=" + name); + for (Map::Element *E = import_variation_data->settings.front(); E; E = E->next()) { + if (!variation.is_empty()) { + variation += ","; + } + variation += (String(E->key()) + "=" + String(E->get())); + } + variations.push_back(variation); + } + main_settings["preload/configurations"] = variations; + + Vector langs_enabled; + Vector langs_disabled; + for (TreeItem *lang_item = lang_list_root->get_first_child(); lang_item; lang_item = lang_item->get_next()) { + bool selected = lang_item->is_checked(0); + String name = lang_item->get_text(1); + if (selected) { + langs_enabled.push_back(name); + } else { + langs_disabled.push_back(name); + } + } + main_settings["support_overrides/language_enabled"] = langs_enabled; + main_settings["support_overrides/language_disabled"] = langs_disabled; + + Vector scripts_enabled; + Vector scripts_disabled; + for (TreeItem *script_item = script_list_root->get_first_child(); script_item; script_item = script_item->get_next()) { + bool selected = script_item->is_checked(0); + String name = script_item->get_text(1); + if (selected) { + scripts_enabled.push_back(name); + } else { + scripts_disabled.push_back(name); + } + } + main_settings["support_overrides/script_enabled"] = scripts_enabled; + main_settings["support_overrides/script_disabled"] = scripts_disabled; + + if (!selected_chars.is_empty()) { + Vector ranges; + char32_t start = selected_chars.front()->get(); + for (Set::Element *E = selected_chars.front()->next(); E; E = E->next()) { + if (E->prev() && ((E->prev()->get() + 1) != E->get())) { + ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); + start = E->get(); + } + } + ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(selected_chars.back()->get(), 16)); + main_settings["preload/char_ranges"] = ranges; + } + + if (!selected_glyphs.is_empty()) { + Vector ranges; + int32_t start = selected_glyphs.front()->get(); + for (Set::Element *E = selected_glyphs.front()->next(); E; E = E->next()) { + if (E->prev() && ((E->prev()->get() + 1) != E->get())) { + ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); + start = E->get(); + } + } + ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(selected_glyphs.back()->get(), 16)); + main_settings["preload/glyph_ranges"] = ranges; + } + + Dictionary ot_ov; + for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { + String tag = ot_item->get_text(0); + int32_t value = ot_item->get_text(1).to_int(); + ot_ov[tag] = value; + } + main_settings["opentype_feature_overrides"] = ot_ov; + + if (OS::get_singleton()->is_stdout_verbose()) { + print_line("Import settings:"); + for (Map::Element *E = main_settings.front(); E; E = E->next()) { + print_line(String(" ") + String(E->key()).utf8().get_data() + " == " + String(E->get()).utf8().get_data()); + } + } + + EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(base_path, "font_data_dynamic", main_settings); +} + +void DynamicFontImportSettings::open_settings(const String &p_path) { + // Load base font data. + Vector data = FileAccess::get_file_as_array(p_path); + + // Load font for preview. + Ref dfont_prev; + dfont_prev.instantiate(); + dfont_prev->set_data(data); + + font_preview.instantiate(); + font_preview->add_data(dfont_prev); + + String sample; + static const String sample_base = U"12漢字ԱբΑαАбΑαאבابܐܒހށआআਆઆଆஆఆಆആආกิກິༀကႠა한글ሀᎣᐁᚁᚠᜀᜠᝀᝠកᠠᤁᥐAb😀"; + for (int i = 0; i < sample_base.length(); i++) { + if (dfont_prev->has_char(sample_base[i])) { + sample += sample_base[i]; + } + } + if (sample.is_empty()) { + sample = dfont_prev->get_supported_chars().substr(0, 6); + } + font_preview_label->set_text(sample); + + // Load second copy of font with MSDF disabled for the glyph table and metadata extraction. + Ref dfont_main; + dfont_main.instantiate(); + dfont_main->set_data(data); + dfont_main->set_multichannel_signed_distance_field(false); + + font_main.instantiate(); + font_main->add_data(dfont_main); + text_edit->add_theme_font_override("font", font_main); + + base_path = p_path; + + inspector_vars->edit(nullptr); + inspector_general->edit(nullptr); + + int gww = get_theme_font(SNAME("font"))->get_string_size("00000", get_theme_font_size(SNAME("font_size"))).x + 50; + glyph_table->set_column_custom_minimum_width(0, gww); + + glyph_table->clear(); + vars_list->clear(); + lang_list->clear(); + script_list->clear(); + ot_list->clear(); + + selected_chars.clear(); + selected_glyphs.clear(); + text_edit->set_text(String()); + + vars_list_root = vars_list->create_item(); + lang_list_root = lang_list->create_item(); + script_list_root = script_list->create_item(); + ot_list_root = ot_list->create_item(); + + options_variations.clear(); + Dictionary var_list = dfont_main->get_supported_variation_list(); + for (int i = 0; i < var_list.size(); i++) { + int32_t tag = var_list.get_key_at_index(i); + Vector3i value = var_list.get_value_at_index(i); + options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, TS->tag_to_name(tag), PROPERTY_HINT_RANGE, itos(value.x) + "," + itos(value.y) + ",1"), value.z)); + } + options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "0,127,1"), 16)); + options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,127,1"), 0)); + options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "extra_spacing_glyph"), 0)); + options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "extra_spacing_space"), 0)); + + import_settings_data->defaults.clear(); + for (List::Element *E = options_general.front(); E; E = E->next()) { + import_settings_data->defaults[E->get().option.name] = E->get().default_value; + } + + Ref config; + config.instantiate(); + ERR_FAIL_NULL(config); + + Error err = config->load(p_path + ".import"); + print_verbose("Loading import settings:"); + if (err == OK) { + List keys; + config->get_section_keys("params", &keys); + for (List::Element *E = keys.front(); E; E = E->next()) { + String key = E->get(); + print_verbose(String(" ") + key + " == " + String(config->get_value("params", key))); + if (key == "preload/char_ranges") { + Vector ranges = config->get_value("params", key); + for (int i = 0; i < ranges.size(); i++) { + int32_t start, end; + Vector tokens = ranges[i].split("-"); + if (tokens.size() == 2) { + if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start) || !ResourceImporterDynamicFont::_decode_range(tokens[1], end)) { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + } else if (tokens.size() == 1) { + if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start)) { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + end = start; + } else { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + for (int32_t j = start; j <= end; j++) { + selected_chars.insert(j); + } + } + } else if (key == "preload/glyph_ranges") { + Vector ranges = config->get_value("params", key); + for (int i = 0; i < ranges.size(); i++) { + int32_t start, end; + Vector tokens = ranges[i].split("-"); + if (tokens.size() == 2) { + if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start) || !ResourceImporterDynamicFont::_decode_range(tokens[1], end)) { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + } else if (tokens.size() == 1) { + if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start)) { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + end = start; + } else { + WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); + continue; + } + for (int32_t j = start; j <= end; j++) { + selected_glyphs.insert(j); + } + } + } else if (key == "preload/configurations") { + Vector variations = config->get_value("params", key); + for (int i = 0; i < variations.size(); i++) { + TreeItem *vars_item = vars_list->create_item(vars_list_root); + ERR_FAIL_NULL(vars_item); + + vars_item->set_text(0, TTR("Configuration") + " " + itos(i)); + vars_item->set_editable(0, true); + vars_item->add_button(1, vars_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); + vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); + + Ref import_variation_data_custom; + import_variation_data_custom.instantiate(); + import_variation_data_custom->owner = this; + ERR_FAIL_NULL(import_variation_data_custom); + + for (List::Element *F = options_variations.front(); F; F = F->next()) { + import_variation_data_custom->defaults[F->get().option.name] = F->get().default_value; + } + + import_variation_data_custom->options = options_variations; + + vars_item->set_metadata(0, import_variation_data_custom); + Vector variation_tags = variations[i].split(","); + for (int j = 0; j < variation_tags.size(); j++) { + Vector tokens = variation_tags[j].split("="); + if (tokens[0] == "name") { + vars_item->set_text(0, tokens[1]); + } else if (tokens[0] == "size" || tokens[0] == "outline_size" || tokens[0] == "extra_spacing_space" || tokens[0] == "extra_spacing_glyph") { + import_variation_data_custom->set(tokens[0], tokens[1].to_int()); + } else { + import_variation_data_custom->set(tokens[0], tokens[1].to_float()); + } + } + } + } else if (key == "support_overrides/language_enabled") { + PackedStringArray _langs = config->get_value("params", key); + for (int i = 0; i < _langs.size(); i++) { + TreeItem *lang_item = lang_list->create_item(lang_list_root); + ERR_FAIL_NULL(lang_item); + + lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + lang_item->set_editable(0, true); + lang_item->set_checked(0, true); + lang_item->set_text(1, _langs[i]); + lang_item->set_editable(1, true); + lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + } + } else if (key == "support_overrides/language_disabled") { + PackedStringArray _langs = config->get_value("params", key); + for (int i = 0; i < _langs.size(); i++) { + TreeItem *lang_item = lang_list->create_item(lang_list_root); + ERR_FAIL_NULL(lang_item); + + lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + lang_item->set_editable(0, true); + lang_item->set_checked(0, false); + lang_item->set_text(1, _langs[i]); + lang_item->set_editable(1, true); + lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + } + } else if (key == "support_overrides/script_enabled") { + PackedStringArray _scripts = config->get_value("params", key); + for (int i = 0; i < _scripts.size(); i++) { + TreeItem *script_item = script_list->create_item(script_list_root); + ERR_FAIL_NULL(script_item); + + script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + script_item->set_editable(0, true); + script_item->set_checked(0, true); + script_item->set_text(1, _scripts[i]); + script_item->set_editable(1, true); + script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + } + } else if (key == "support_overrides/script_disabled") { + PackedStringArray _scripts = config->get_value("params", key); + for (int i = 0; i < _scripts.size(); i++) { + TreeItem *script_item = script_list->create_item(script_list_root); + ERR_FAIL_NULL(script_item); + + script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + script_item->set_editable(0, true); + script_item->set_checked(0, false); + script_item->set_text(1, _scripts[i]); + script_item->set_editable(1, true); + script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + } + } else if (key == "opentype_feature_overrides") { + Dictionary features = config->get_value("params", key); + for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { + TreeItem *ot_item = ot_list->create_item(ot_list_root); + ERR_FAIL_NULL(ot_item); + int32_t value = features[*ftr]; + if (ftr->get_type() == Variant::STRING) { + ot_item->set_text(0, *ftr); + } else { + ot_item->set_text(0, TS->tag_to_name(*ftr)); + } + ot_item->set_editable(0, false); + ot_item->set_text(1, itos(value)); + ot_item->set_editable(1, true); + ot_item->add_button(2, ot_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); + ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); + } + } else { + Variant value = config->get_value("params", key); + import_settings_data->defaults[key] = value; + } + } + } + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); + + import_settings_data->options = options_general; + inspector_general->edit(import_settings_data.ptr()); + import_settings_data->notify_property_list_changed(); + + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased")); + font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field")); + font_preview->get_data(0)->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range")); + font_preview->get_data(0)->set_msdf_size(import_settings_data->get("msdf_size")); + font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); + font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); + font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); + font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); + } + font_preview_label->add_theme_font_override("font", font_preview); + font_preview_label->update(); + + menu_ot->clear(); + menu_ot_ss->clear(); + menu_ot_cv->clear(); + menu_ot_cu->clear(); + bool have_ss = false; + bool have_cv = false; + bool have_cu = false; + Dictionary features = font_preview->get_feature_list(); + for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { + String ftr_name = TS->tag_to_name(*ftr); + if (ftr_name.begins_with("stylistic_set_")) { + menu_ot_ss->add_item(ftr_name.capitalize(), (int32_t)*ftr); + have_ss = true; + } else if (ftr_name.begins_with("character_variant_")) { + menu_ot_cv->add_item(ftr_name.capitalize(), (int32_t)*ftr); + have_cv = true; + } else if (ftr_name.begins_with("custom_")) { + menu_ot_cu->add_item(ftr_name.replace("custom_", ""), (int32_t)*ftr); + have_cu = true; + } else { + menu_ot->add_item(ftr_name.capitalize(), (int32_t)*ftr); + } + } + if (have_ss) { + menu_ot->add_submenu_item(RTR("Stylistic Sets"), "SSMenu"); + } + if (have_cv) { + menu_ot->add_submenu_item(RTR("Character Variants"), "CVMenu"); + } + if (have_cu) { + menu_ot->add_submenu_item(RTR("Custom"), "CUMenu"); + } + + _variations_validate(); + + popup_centered_ratio(); + + set_title(vformat(TTR("Advanced Import Settings for '%s'"), base_path.get_file())); +} + +DynamicFontImportSettings *DynamicFontImportSettings::get_singleton() { + return singleton; +} + +DynamicFontImportSettings::DynamicFontImportSettings() { + singleton = this; + + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "compress", PROPERTY_HINT_NONE, ""), false)); + + // Popup menus + + locale_select = memnew(EditorLocaleDialog); + locale_select->connect("locale_selected", callable_mp(this, &DynamicFontImportSettings::_lang_add_item)); + add_child(locale_select); + + menu_scripts = memnew(PopupMenu); + menu_scripts->set_name("Script"); + script_codes = TranslationServer::get_singleton()->get_all_scripts(); + for (int i = 0; i < script_codes.size(); i++) { + menu_scripts->add_item(TranslationServer::get_singleton()->get_script_name(script_codes[i]) + " (" + script_codes[i] + ")", i); + } + add_child(menu_scripts); + menu_scripts->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_script_add_item)); + + menu_ot = memnew(PopupMenu); + add_child(menu_ot); + menu_ot->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_cv = memnew(PopupMenu); + menu_ot_cv->set_name("CVMenu"); + menu_ot->add_child(menu_ot_cv); + menu_ot_cv->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_ss = memnew(PopupMenu); + menu_ot_ss->set_name("SSMenu"); + menu_ot->add_child(menu_ot_ss); + menu_ot_ss->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_cu = memnew(PopupMenu); + menu_ot_cu->set_name("CUMenu"); + menu_ot->add_child(menu_ot_cu); + menu_ot_cu->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + Color warn_color = (EditorNode::get_singleton()) ? EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")) : Color(1, 1, 0); + + // Root layout + + VBoxContainer *root_vb = memnew(VBoxContainer); + add_child(root_vb); + + main_pages = memnew(TabContainer); + main_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL); + main_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL); + root_vb->add_child(main_pages); + + label_warn = memnew(Label); + label_warn->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_warn->set_text(""); + root_vb->add_child(label_warn); + label_warn->add_theme_color_override("font_color", warn_color); + label_warn->hide(); + + // Page 1 layout: Rendering Options + + VBoxContainer *page1_vb = memnew(VBoxContainer); + page1_vb->set_meta("_tab_name", TTR("Rendering options")); + main_pages->add_child(page1_vb); + + page1_description = memnew(Label); + page1_description->set_text(TTR("Select font rendering options:")); + page1_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page1_vb->add_child(page1_description); + + HSplitContainer *page1_hb = memnew(HSplitContainer); + page1_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); + page1_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page1_vb->add_child(page1_hb); + + font_preview_label = memnew(Label); + font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); + font_preview_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + font_preview_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); + font_preview_label->set_autowrap_mode(Label::AUTOWRAP_ARBITRARY); + font_preview_label->set_clip_text(true); + font_preview_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); + font_preview_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page1_hb->add_child(font_preview_label); + + inspector_general = memnew(EditorInspector); + inspector_general->set_v_size_flags(Control::SIZE_EXPAND_FILL); + inspector_general->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE)); + inspector_general->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_main_prop_changed)); + page1_hb->add_child(inspector_general); + + // Page 2 layout: Configurations + VBoxContainer *page2_vb = memnew(VBoxContainer); + page2_vb->set_meta("_tab_name", TTR("Sizes and variations")); + main_pages->add_child(page2_vb); + + page2_description = memnew(Label); + page2_description->set_text(TTR("Add font size, variation coordinates, and extra spacing combinations to pre-render:")); + page2_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page2_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); + page2_vb->add_child(page2_description); + + HSplitContainer *page2_hb = memnew(HSplitContainer); + page2_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); + page2_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page2_vb->add_child(page2_hb); + + VBoxContainer *page2_side_vb = memnew(VBoxContainer); + page2_hb->add_child(page2_side_vb); + + HBoxContainer *page2_hb_vars = memnew(HBoxContainer); + page2_side_vb->add_child(page2_hb_vars); + + label_vars = memnew(Label); + page2_hb_vars->add_child(label_vars); + label_vars->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_vars->set_h_size_flags(Control::SIZE_EXPAND_FILL); + label_vars->set_text(TTR("Configuration:")); + + add_var = memnew(Button); + page2_hb_vars->add_child(add_var); + add_var->set_tooltip(TTR("Add configuration")); + add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_var->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_variation_add)); + + vars_list = memnew(Tree); + page2_side_vb->add_child(vars_list); + vars_list->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); + vars_list->set_hide_root(true); + vars_list->set_columns(2); + vars_list->set_column_expand(0, true); + vars_list->set_column_custom_minimum_width(0, 80 * EDSCALE); + vars_list->set_column_expand(1, false); + vars_list->set_column_custom_minimum_width(1, 50 * EDSCALE); + vars_list->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_variation_selected)); + vars_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_variation_remove)); + vars_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + + inspector_vars = memnew(EditorInspector); + inspector_vars->set_v_size_flags(Control::SIZE_EXPAND_FILL); + inspector_vars->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_variation_changed)); + page2_hb->add_child(inspector_vars); + + // Page 3 layout: Text to select glyphs + VBoxContainer *page3_vb = memnew(VBoxContainer); + page3_vb->set_meta("_tab_name", TTR("Glyphs from the text")); + main_pages->add_child(page3_vb); + + page3_description = memnew(Label); + page3_description->set_text(TTR("Enter a text to shape and add all required glyphs to pre-render list:")); + page3_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page3_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); + page3_vb->add_child(page3_description); + + HBoxContainer *ot_hb = memnew(HBoxContainer); + page3_vb->add_child(ot_hb); + ot_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + + Label *label_ed_ftr = memnew(Label); + ot_hb->add_child(label_ed_ftr); + label_ed_ftr->set_text(TTR("OpenType features:")); + + ftr_edit = memnew(LineEdit); + ot_hb->add_child(ftr_edit); + ftr_edit->connect("text_changed", callable_mp(this, &DynamicFontImportSettings::_change_text_opts)); + ftr_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); + + Label *label_ed_lang = memnew(Label); + ot_hb->add_child(label_ed_lang); + label_ed_lang->set_text(TTR("Text language:")); + + lang_edit = memnew(LineEdit); + ot_hb->add_child(lang_edit); + lang_edit->connect("text_changed", callable_mp(this, &DynamicFontImportSettings::_change_text_opts)); + lang_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); + + text_edit = memnew(TextEdit); + page3_vb->add_child(text_edit); + text_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL); + text_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); + + HBoxContainer *text_hb = memnew(HBoxContainer); + page3_vb->add_child(text_hb); + text_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + + label_glyphs = memnew(Label); + text_hb->add_child(label_glyphs); + label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(0)); + label_glyphs->set_custom_minimum_size(Size2(50 * EDSCALE, 0)); + + Button *btn_fill = memnew(Button); + text_hb->add_child(btn_fill); + btn_fill->set_text(TTR("Shape text and add glyphs")); + btn_fill->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_glyph_text_selected)); + + Button *btn_clear = memnew(Button); + text_hb->add_child(btn_clear); + btn_clear->set_text(TTR("Clear glyph list")); + btn_clear->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_glyph_clear)); + + // Page 4 layout: Character map + VBoxContainer *page4_vb = memnew(VBoxContainer); + page4_vb->set_meta("_tab_name", TTR("Glyphs from the character map")); + main_pages->add_child(page4_vb); + + page4_description = memnew(Label); + page4_description->set_text(TTR("Add or remove additional glyphs from the character map to pre-render list:\nNote: Some stylistic alternatives and glyph variants do not have one-to-one correspondence to character, and not shown in this map, use \"Glyphs from the text\" to add these.")); + page4_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page4_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); + page4_vb->add_child(page4_description); + + HSplitContainer *glyphs_split = memnew(HSplitContainer); + glyphs_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); + glyphs_split->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page4_vb->add_child(glyphs_split); + + glyph_table = memnew(Tree); + glyphs_split->add_child(glyph_table); + glyph_table->set_custom_minimum_size(Size2((30 * 16 + 100) * EDSCALE, 0)); + glyph_table->set_columns(17); + glyph_table->set_column_expand(0, false); + glyph_table->set_hide_root(true); + glyph_table->set_allow_reselect(true); + glyph_table->set_select_mode(Tree::SELECT_SINGLE); + glyph_table->connect("item_activated", callable_mp(this, &DynamicFontImportSettings::_glyph_selected)); + glyph_table->set_column_titles_visible(true); + for (int i = 0; i < 16; i++) { + glyph_table->set_column_title(i + 1, String::num_int64(i, 16)); + } + glyph_table->add_theme_style_override("selected", glyph_table->get_theme_stylebox(SNAME("bg"))); + glyph_table->add_theme_style_override("selected_focus", glyph_table->get_theme_stylebox(SNAME("bg"))); + glyph_table->add_theme_constant_override("hseparation", 0); + glyph_table->set_h_size_flags(Control::SIZE_EXPAND_FILL); + glyph_table->set_v_size_flags(Control::SIZE_EXPAND_FILL); + + glyph_tree = memnew(Tree); + glyphs_split->add_child(glyph_tree); + glyph_tree->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); + glyph_tree->set_columns(2); + glyph_tree->set_hide_root(true); + glyph_tree->set_column_expand(0, false); + glyph_tree->set_column_expand(1, true); + glyph_tree->set_column_custom_minimum_width(0, 120 * EDSCALE); + glyph_tree->connect("item_activated", callable_mp(this, &DynamicFontImportSettings::_range_edited)); + glyph_tree->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_range_selected)); + glyph_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); + glyph_root = glyph_tree->create_item(); + for (int i = 0; !unicode_ranges[i].name.is_empty(); i++) { + _add_glyph_range_item(unicode_ranges[i].start, unicode_ranges[i].end, unicode_ranges[i].name); + } + + // Page 4 layout: Metadata override + VBoxContainer *page5_vb = memnew(VBoxContainer); + page5_vb->set_meta("_tab_name", TTR("Metadata override")); + main_pages->add_child(page5_vb); + + page5_description = memnew(Label); + page5_description->set_text(TTR("Add or remove language and script support overrides, to control fallback font selection order:")); + page5_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); + page5_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); + page5_vb->add_child(page5_description); + + HBoxContainer *hb_lang = memnew(HBoxContainer); + page5_vb->add_child(hb_lang); + + label_langs = memnew(Label); + label_langs->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_langs->set_h_size_flags(Control::SIZE_EXPAND_FILL); + label_langs->set_text(TTR("Language support overrides")); + hb_lang->add_child(label_langs); + + add_lang = memnew(Button); + hb_lang->add_child(add_lang); + add_lang->set_tooltip(TTR("Add language override")); + add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_lang->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_lang_add)); + + lang_list = memnew(Tree); + page5_vb->add_child(lang_list); + lang_list->set_hide_root(true); + lang_list->set_columns(3); + lang_list->set_column_expand(0, false); // Check + lang_list->set_column_custom_minimum_width(0, 50 * EDSCALE); + lang_list->set_column_expand(1, true); + lang_list->set_column_custom_minimum_width(1, 80 * EDSCALE); + lang_list->set_column_expand(2, false); + lang_list->set_column_custom_minimum_width(2, 50 * EDSCALE); + lang_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_lang_remove)); + lang_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + + HBoxContainer *hb_script = memnew(HBoxContainer); + page5_vb->add_child(hb_script); + + label_script = memnew(Label); + label_script->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_script->set_h_size_flags(Control::SIZE_EXPAND_FILL); + label_script->set_text(TTR("Script support overrides")); + hb_script->add_child(label_script); + + add_script = memnew(Button); + hb_script->add_child(add_script); + add_script->set_tooltip(TTR("Add script override")); + add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_script->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_script_add)); + + script_list = memnew(Tree); + page5_vb->add_child(script_list); + script_list->set_hide_root(true); + script_list->set_columns(3); + script_list->set_column_expand(0, false); + script_list->set_column_custom_minimum_width(0, 50 * EDSCALE); + script_list->set_column_expand(1, true); + script_list->set_column_custom_minimum_width(1, 80 * EDSCALE); + script_list->set_column_expand(2, false); + script_list->set_column_custom_minimum_width(2, 50 * EDSCALE); + script_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_script_remove)); + script_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + + HBoxContainer *hb_ot = memnew(HBoxContainer); + page5_vb->add_child(hb_ot); + + label_ot = memnew(Label); + label_ot->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_ot->set_h_size_flags(Control::SIZE_EXPAND_FILL); + label_ot->set_text(TTR("OpenType feature overrides")); + hb_ot->add_child(label_ot); + + add_ot = memnew(Button); + hb_ot->add_child(add_ot); + add_ot->set_tooltip(TTR("Add feature override")); + add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + add_ot->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add)); + + ot_list = memnew(Tree); + page5_vb->add_child(ot_list); + ot_list->set_hide_root(true); + ot_list->set_columns(3); + ot_list->set_column_expand(0, true); + ot_list->set_column_custom_minimum_width(0, 80 * EDSCALE); + ot_list->set_column_expand(1, true); + ot_list->set_column_custom_minimum_width(1, 80 * EDSCALE); + ot_list->set_column_expand(2, false); + ot_list->set_column_custom_minimum_width(2, 50 * EDSCALE); + ot_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_remove)); + ot_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + + // Common + + import_settings_data.instantiate(); + import_settings_data->owner = this; + + get_ok_button()->set_text(TTR("Reimport")); + get_cancel_button()->set_text(TTR("Close")); +} diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h new file mode 100644 index 0000000000..7b2a9184a4 --- /dev/null +++ b/editor/import/dynamic_font_import_settings.h @@ -0,0 +1,181 @@ +/*************************************************************************/ +/* dynamic_font_import_settings.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef DYNAMIC_FONT_IMPORT_SETTINGS_H +#define DYNAMIC_FONT_IMPORT_SETTINGS_H + +#include "editor/import/resource_importer_dynamic_font.h" + +#include "scene/gui/dialogs.h" +#include "scene/gui/item_list.h" +#include "scene/gui/option_button.h" +#include "scene/gui/split_container.h" +#include "scene/gui/subviewport_container.h" +#include "scene/gui/tab_container.h" +#include "scene/gui/text_edit.h" +#include "scene/gui/tree.h" +#include "scene/resources/font.h" +#include "servers/text_server.h" + +class DynamicFontImportSettingsData; +class EditorFileDialog; +class EditorInspector; +class EditorLocaleDialog; + +class DynamicFontImportSettings : public ConfirmationDialog { + GDCLASS(DynamicFontImportSettings, ConfirmationDialog) + friend class DynamicFontImportSettingsData; + + enum ItemButton { + BUTTON_ADD_VAR, + BUTTON_REMOVE_VAR, + }; + + static DynamicFontImportSettings *singleton; + + String base_path; + + Ref import_settings_data; + List options_variations; + List options_general; + + EditorLocaleDialog *locale_select; + Vector script_codes; + + // Root layout + Label *label_warn = nullptr; + TabContainer *main_pages = nullptr; + + // Page 1 layout: Rendering Options + Label *page1_description = nullptr; + Label *font_preview_label = nullptr; + EditorInspector *inspector_general = nullptr; + + void _main_prop_changed(const String &p_edited_property); + + // Page 2 layout: Configurations + Label *page2_description = nullptr; + Label *label_vars = nullptr; + Button *add_var = nullptr; + Tree *vars_list = nullptr; + TreeItem *vars_list_root = nullptr; + EditorInspector *inspector_vars = nullptr; + + void _variation_add(); + void _variation_selected(); + void _variation_remove(Object *p_item, int p_column, int p_id); + void _variation_changed(const String &p_edited_property); + void _variations_validate(); + + // Page 3 layout: Text to select glyphs + Label *page3_description = nullptr; + Label *label_glyphs = nullptr; + TextEdit *text_edit = nullptr; + LineEdit *ftr_edit = nullptr; + LineEdit *lang_edit = nullptr; + + void _change_text_opts(); + void _glyph_text_selected(); + void _glyph_clear(); + + // Page 4 layout: Character map + Label *page4_description = nullptr; + Tree *glyph_table = nullptr; + Tree *glyph_tree = nullptr; + TreeItem *glyph_root = nullptr; + + void _glyph_selected(); + void _range_edited(); + void _range_selected(); + void _edit_range(int32_t p_start, int32_t p_end); + bool _char_update(int32_t p_char); + void _range_update(int32_t p_start, int32_t p_end); + + // Page 5 layout: Metadata override + Label *page5_description = nullptr; + Button *add_lang = nullptr; + Button *add_script = nullptr; + Button *add_ot = nullptr; + + PopupMenu *menu_scripts = nullptr; + PopupMenu *menu_ot = nullptr; + PopupMenu *menu_ot_ss = nullptr; + PopupMenu *menu_ot_cv = nullptr; + PopupMenu *menu_ot_cu = nullptr; + + Tree *lang_list = nullptr; + TreeItem *lang_list_root = nullptr; + Label *label_langs = nullptr; + + Tree *script_list = nullptr; + TreeItem *script_list_root = nullptr; + Label *label_script = nullptr; + + Tree *ot_list = nullptr; + TreeItem *ot_list_root = nullptr; + Label *label_ot = nullptr; + + void _lang_add(); + void _lang_add_item(const String &p_locale); + void _lang_remove(Object *p_item, int p_column, int p_id); + + void _script_add(); + void _script_add_item(int p_option); + void _script_remove(Object *p_item, int p_column, int p_id); + + void _ot_add(); + void _ot_add_item(int p_option); + void _ot_remove(Object *p_item, int p_column, int p_id); + + // Common + + void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name); + + Ref font_preview; + Ref font_main; + + Set selected_chars; + Set selected_glyphs; + + void _re_import(); + + String _pad_zeros(const String &p_hex) const; + +protected: + void _notification(int p_what); + +public: + void open_settings(const String &p_path); + static DynamicFontImportSettings *get_singleton(); + + DynamicFontImportSettings(); +}; + +#endif // DYNAMIC_FONT_IMPORT_SETTINGS_H diff --git a/editor/import/dynamicfont_import_settings.cpp b/editor/import/dynamicfont_import_settings.cpp deleted file mode 100644 index ead3d67e39..0000000000 --- a/editor/import/dynamicfont_import_settings.cpp +++ /dev/null @@ -1,1683 +0,0 @@ -/*************************************************************************/ -/* dynamicfont_import_settings.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "dynamicfont_import_settings.h" - -#include "editor/editor_file_dialog.h" -#include "editor/editor_file_system.h" -#include "editor/editor_inspector.h" -#include "editor/editor_locale_dialog.h" -#include "editor/editor_node.h" -#include "editor/editor_scale.h" - -/*************************************************************************/ -/* Settings data */ -/*************************************************************************/ - -class DynamicFontImportSettingsData : public RefCounted { - GDCLASS(DynamicFontImportSettingsData, RefCounted) - friend class DynamicFontImportSettings; - - Map settings; - Map defaults; - List options; - DynamicFontImportSettings *owner = nullptr; - - bool _set(const StringName &p_name, const Variant &p_value) { - if (defaults.has(p_name) && defaults[p_name] == p_value) { - settings.erase(p_name); - } else { - settings[p_name] = p_value; - } - return true; - } - - bool _get(const StringName &p_name, Variant &r_ret) const { - if (settings.has(p_name)) { - r_ret = settings[p_name]; - return true; - } - if (defaults.has(p_name)) { - r_ret = defaults[p_name]; - return true; - } - return false; - } - - void _get_property_list(List *p_list) const { - for (const List::Element *E = options.front(); E; E = E->next()) { - if (owner && owner->import_settings_data.is_valid()) { - if (owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "size" || E->get().option.name == "outline_size" || E->get().option.name == "oversampling")) { - continue; - } - if (!owner->import_settings_data->get("multichannel_signed_distance_field") && (E->get().option.name == "msdf_pixel_range" || E->get().option.name == "msdf_size")) { - continue; - } - } - p_list->push_back(E->get().option); - } - } -}; - -/*************************************************************************/ -/* Glyph ranges */ -/*************************************************************************/ - -struct UniRange { - int32_t start; - int32_t end; - String name; -}; - -// Unicode Character Blocks -// Source: https://www.unicode.org/Public/14.0.0/ucd/Blocks.txt -static UniRange unicode_ranges[] = { - { 0x0000, 0x007F, U"Basic Latin" }, - { 0x0080, 0x00FF, U"Latin-1 Supplement" }, - { 0x0100, 0x017F, U"Latin Extended-A" }, - { 0x0180, 0x024F, U"Latin Extended-B" }, - { 0x0250, 0x02AF, U"IPA Extensions" }, - { 0x02B0, 0x02FF, U"Spacing Modifier Letters" }, - { 0x0300, 0x036F, U"Combining Diacritical Marks" }, - { 0x0370, 0x03FF, U"Greek and Coptic" }, - { 0x0400, 0x04FF, U"Cyrillic" }, - { 0x0500, 0x052F, U"Cyrillic Supplement" }, - { 0x0530, 0x058F, U"Armenian" }, - { 0x0590, 0x05FF, U"Hebrew" }, - { 0x0600, 0x06FF, U"Arabic" }, - { 0x0700, 0x074F, U"Syriac" }, - { 0x0750, 0x077F, U"Arabic Supplement" }, - { 0x0780, 0x07BF, U"Thaana" }, - { 0x07C0, 0x07FF, U"NKo" }, - { 0x0800, 0x083F, U"Samaritan" }, - { 0x0840, 0x085F, U"Mandaic" }, - { 0x0860, 0x086F, U"Syriac Supplement" }, - { 0x0870, 0x089F, U"Arabic Extended-B" }, - { 0x08A0, 0x08FF, U"Arabic Extended-A" }, - { 0x0900, 0x097F, U"Devanagari" }, - { 0x0980, 0x09FF, U"Bengali" }, - { 0x0A00, 0x0A7F, U"Gurmukhi" }, - { 0x0A80, 0x0AFF, U"Gujarati" }, - { 0x0B00, 0x0B7F, U"Oriya" }, - { 0x0B80, 0x0BFF, U"Tamil" }, - { 0x0C00, 0x0C7F, U"Telugu" }, - { 0x0C80, 0x0CFF, U"Kannada" }, - { 0x0D00, 0x0D7F, U"Malayalam" }, - { 0x0D80, 0x0DFF, U"Sinhala" }, - { 0x0E00, 0x0E7F, U"Thai" }, - { 0x0E80, 0x0EFF, U"Lao" }, - { 0x0F00, 0x0FFF, U"Tibetan" }, - { 0x1000, 0x109F, U"Myanmar" }, - { 0x10A0, 0x10FF, U"Georgian" }, - { 0x1100, 0x11FF, U"Hangul Jamo" }, - { 0x1200, 0x137F, U"Ethiopic" }, - { 0x1380, 0x139F, U"Ethiopic Supplement" }, - { 0x13A0, 0x13FF, U"Cherokee" }, - { 0x1400, 0x167F, U"Unified Canadian Aboriginal Syllabics" }, - { 0x1680, 0x169F, U"Ogham" }, - { 0x16A0, 0x16FF, U"Runic" }, - { 0x1700, 0x171F, U"Tagalog" }, - { 0x1720, 0x173F, U"Hanunoo" }, - { 0x1740, 0x175F, U"Buhid" }, - { 0x1760, 0x177F, U"Tagbanwa" }, - { 0x1780, 0x17FF, U"Khmer" }, - { 0x1800, 0x18AF, U"Mongolian" }, - { 0x18B0, 0x18FF, U"Unified Canadian Aboriginal Syllabics Extended" }, - { 0x1900, 0x194F, U"Limbu" }, - { 0x1950, 0x197F, U"Tai Le" }, - { 0x1980, 0x19DF, U"New Tai Lue" }, - { 0x19E0, 0x19FF, U"Khmer Symbols" }, - { 0x1A00, 0x1A1F, U"Buginese" }, - { 0x1A20, 0x1AAF, U"Tai Tham" }, - { 0x1AB0, 0x1AFF, U"Combining Diacritical Marks Extended" }, - { 0x1B00, 0x1B7F, U"Balinese" }, - { 0x1B80, 0x1BBF, U"Sundanese" }, - { 0x1BC0, 0x1BFF, U"Batak" }, - { 0x1C00, 0x1C4F, U"Lepcha" }, - { 0x1C50, 0x1C7F, U"Ol Chiki" }, - { 0x1C80, 0x1C8F, U"Cyrillic Extended-C" }, - { 0x1C90, 0x1CBF, U"Georgian Extended" }, - { 0x1CC0, 0x1CCF, U"Sundanese Supplement" }, - { 0x1CD0, 0x1CFF, U"Vedic Extensions" }, - { 0x1D00, 0x1D7F, U"Phonetic Extensions" }, - { 0x1D80, 0x1DBF, U"Phonetic Extensions Supplement" }, - { 0x1DC0, 0x1DFF, U"Combining Diacritical Marks Supplement" }, - { 0x1E00, 0x1EFF, U"Latin Extended Additional" }, - { 0x1F00, 0x1FFF, U"Greek Extended" }, - { 0x2000, 0x206F, U"General Punctuation" }, - { 0x2070, 0x209F, U"Superscripts and Subscripts" }, - { 0x20A0, 0x20CF, U"Currency Symbols" }, - { 0x20D0, 0x20FF, U"Combining Diacritical Marks for Symbols" }, - { 0x2100, 0x214F, U"Letterlike Symbols" }, - { 0x2150, 0x218F, U"Number Forms" }, - { 0x2190, 0x21FF, U"Arrows" }, - { 0x2200, 0x22FF, U"Mathematical Operators" }, - { 0x2300, 0x23FF, U"Miscellaneous Technical" }, - { 0x2400, 0x243F, U"Control Pictures" }, - { 0x2440, 0x245F, U"Optical Character Recognition" }, - { 0x2460, 0x24FF, U"Enclosed Alphanumerics" }, - { 0x2500, 0x257F, U"Box Drawing" }, - { 0x2580, 0x259F, U"Block Elements" }, - { 0x25A0, 0x25FF, U"Geometric Shapes" }, - { 0x2600, 0x26FF, U"Miscellaneous Symbols" }, - { 0x2700, 0x27BF, U"Dingbats" }, - { 0x27C0, 0x27EF, U"Miscellaneous Mathematical Symbols-A" }, - { 0x27F0, 0x27FF, U"Supplemental Arrows-A" }, - { 0x2800, 0x28FF, U"Braille Patterns" }, - { 0x2900, 0x297F, U"Supplemental Arrows-B" }, - { 0x2980, 0x29FF, U"Miscellaneous Mathematical Symbols-B" }, - { 0x2A00, 0x2AFF, U"Supplemental Mathematical Operators" }, - { 0x2B00, 0x2BFF, U"Miscellaneous Symbols and Arrows" }, - { 0x2C00, 0x2C5F, U"Glagolitic" }, - { 0x2C60, 0x2C7F, U"Latin Extended-C" }, - { 0x2C80, 0x2CFF, U"Coptic" }, - { 0x2D00, 0x2D2F, U"Georgian Supplement" }, - { 0x2D30, 0x2D7F, U"Tifinagh" }, - { 0x2D80, 0x2DDF, U"Ethiopic Extended" }, - { 0x2DE0, 0x2DFF, U"Cyrillic Extended-A" }, - { 0x2E00, 0x2E7F, U"Supplemental Punctuation" }, - { 0x2E80, 0x2EFF, U"CJK Radicals Supplement" }, - { 0x2F00, 0x2FDF, U"Kangxi Radicals" }, - { 0x2FF0, 0x2FFF, U"Ideographic Description Characters" }, - { 0x3000, 0x303F, U"CJK Symbols and Punctuation" }, - { 0x3040, 0x309F, U"Hiragana" }, - { 0x30A0, 0x30FF, U"Katakana" }, - { 0x3100, 0x312F, U"Bopomofo" }, - { 0x3130, 0x318F, U"Hangul Compatibility Jamo" }, - { 0x3190, 0x319F, U"Kanbun" }, - { 0x31A0, 0x31BF, U"Bopomofo Extended" }, - { 0x31C0, 0x31EF, U"CJK Strokes" }, - { 0x31F0, 0x31FF, U"Katakana Phonetic Extensions" }, - { 0x3200, 0x32FF, U"Enclosed CJK Letters and Months" }, - { 0x3300, 0x33FF, U"CJK Compatibility" }, - { 0x3400, 0x4DBF, U"CJK Unified Ideographs Extension A" }, - { 0x4DC0, 0x4DFF, U"Yijing Hexagram Symbols" }, - { 0x4E00, 0x9FFF, U"CJK Unified Ideographs" }, - { 0xA000, 0xA48F, U"Yi Syllables" }, - { 0xA490, 0xA4CF, U"Yi Radicals" }, - { 0xA4D0, 0xA4FF, U"Lisu" }, - { 0xA500, 0xA63F, U"Vai" }, - { 0xA640, 0xA69F, U"Cyrillic Extended-B" }, - { 0xA6A0, 0xA6FF, U"Bamum" }, - { 0xA700, 0xA71F, U"Modifier Tone Letters" }, - { 0xA720, 0xA7FF, U"Latin Extended-D" }, - { 0xA800, 0xA82F, U"Syloti Nagri" }, - { 0xA830, 0xA83F, U"Common Indic Number Forms" }, - { 0xA840, 0xA87F, U"Phags-pa" }, - { 0xA880, 0xA8DF, U"Saurashtra" }, - { 0xA8E0, 0xA8FF, U"Devanagari Extended" }, - { 0xA900, 0xA92F, U"Kayah Li" }, - { 0xA930, 0xA95F, U"Rejang" }, - { 0xA960, 0xA97F, U"Hangul Jamo Extended-A" }, - { 0xA980, 0xA9DF, U"Javanese" }, - { 0xA9E0, 0xA9FF, U"Myanmar Extended-B" }, - { 0xAA00, 0xAA5F, U"Cham" }, - { 0xAA60, 0xAA7F, U"Myanmar Extended-A" }, - { 0xAA80, 0xAADF, U"Tai Viet" }, - { 0xAAE0, 0xAAFF, U"Meetei Mayek Extensions" }, - { 0xAB00, 0xAB2F, U"Ethiopic Extended-A" }, - { 0xAB30, 0xAB6F, U"Latin Extended-E" }, - { 0xAB70, 0xABBF, U"Cherokee Supplement" }, - { 0xABC0, 0xABFF, U"Meetei Mayek" }, - { 0xAC00, 0xD7AF, U"Hangul Syllables" }, - { 0xD7B0, 0xD7FF, U"Hangul Jamo Extended-B" }, - //{ 0xD800, 0xDB7F, U"High Surrogates" }, - //{ 0xDB80, 0xDBFF, U"High Private Use Surrogates" }, - //{ 0xDC00, 0xDFFF, U"Low Surrogates" }, - { 0xE000, 0xF8FF, U"Private Use Area" }, - { 0xF900, 0xFAFF, U"CJK Compatibility Ideographs" }, - { 0xFB00, 0xFB4F, U"Alphabetic Presentation Forms" }, - { 0xFB50, 0xFDFF, U"Arabic Presentation Forms-A" }, - //{ 0xFE00, 0xFE0F, U"Variation Selectors" }, - { 0xFE10, 0xFE1F, U"Vertical Forms" }, - { 0xFE20, 0xFE2F, U"Combining Half Marks" }, - { 0xFE30, 0xFE4F, U"CJK Compatibility Forms" }, - { 0xFE50, 0xFE6F, U"Small Form Variants" }, - { 0xFE70, 0xFEFF, U"Arabic Presentation Forms-B" }, - { 0xFF00, 0xFFEF, U"Halfwidth and Fullwidth Forms" }, - //{ 0xFFF0, 0xFFFF, U"Specials" }, - { 0x10000, 0x1007F, U"Linear B Syllabary" }, - { 0x10080, 0x100FF, U"Linear B Ideograms" }, - { 0x10100, 0x1013F, U"Aegean Numbers" }, - { 0x10140, 0x1018F, U"Ancient Greek Numbers" }, - { 0x10190, 0x101CF, U"Ancient Symbols" }, - { 0x101D0, 0x101FF, U"Phaistos Disc" }, - { 0x10280, 0x1029F, U"Lycian" }, - { 0x102A0, 0x102DF, U"Carian" }, - { 0x102E0, 0x102FF, U"Coptic Epact Numbers" }, - { 0x10300, 0x1032F, U"Old Italic" }, - { 0x10330, 0x1034F, U"Gothic" }, - { 0x10350, 0x1037F, U"Old Permic" }, - { 0x10380, 0x1039F, U"Ugaritic" }, - { 0x103A0, 0x103DF, U"Old Persian" }, - { 0x10400, 0x1044F, U"Deseret" }, - { 0x10450, 0x1047F, U"Shavian" }, - { 0x10480, 0x104AF, U"Osmanya" }, - { 0x104B0, 0x104FF, U"Osage" }, - { 0x10500, 0x1052F, U"Elbasan" }, - { 0x10530, 0x1056F, U"Caucasian Albanian" }, - { 0x10570, 0x105BF, U"Vithkuqi" }, - { 0x10600, 0x1077F, U"Linear A" }, - { 0x10780, 0x107BF, U"Latin Extended-F" }, - { 0x10800, 0x1083F, U"Cypriot Syllabary" }, - { 0x10840, 0x1085F, U"Imperial Aramaic" }, - { 0x10860, 0x1087F, U"Palmyrene" }, - { 0x10880, 0x108AF, U"Nabataean" }, - { 0x108E0, 0x108FF, U"Hatran" }, - { 0x10900, 0x1091F, U"Phoenician" }, - { 0x10920, 0x1093F, U"Lydian" }, - { 0x10980, 0x1099F, U"Meroitic Hieroglyphs" }, - { 0x109A0, 0x109FF, U"Meroitic Cursive" }, - { 0x10A00, 0x10A5F, U"Kharoshthi" }, - { 0x10A60, 0x10A7F, U"Old South Arabian" }, - { 0x10A80, 0x10A9F, U"Old North Arabian" }, - { 0x10AC0, 0x10AFF, U"Manichaean" }, - { 0x10B00, 0x10B3F, U"Avestan" }, - { 0x10B40, 0x10B5F, U"Inscriptional Parthian" }, - { 0x10B60, 0x10B7F, U"Inscriptional Pahlavi" }, - { 0x10B80, 0x10BAF, U"Psalter Pahlavi" }, - { 0x10C00, 0x10C4F, U"Old Turkic" }, - { 0x10C80, 0x10CFF, U"Old Hungarian" }, - { 0x10D00, 0x10D3F, U"Hanifi Rohingya" }, - { 0x10E60, 0x10E7F, U"Rumi Numeral Symbols" }, - { 0x10E80, 0x10EBF, U"Yezidi" }, - { 0x10F00, 0x10F2F, U"Old Sogdian" }, - { 0x10F30, 0x10F6F, U"Sogdian" }, - { 0x10F70, 0x10FAF, U"Old Uyghur" }, - { 0x10FB0, 0x10FDF, U"Chorasmian" }, - { 0x10FE0, 0x10FFF, U"Elymaic" }, - { 0x11000, 0x1107F, U"Brahmi" }, - { 0x11080, 0x110CF, U"Kaithi" }, - { 0x110D0, 0x110FF, U"Sora Sompeng" }, - { 0x11100, 0x1114F, U"Chakma" }, - { 0x11150, 0x1117F, U"Mahajani" }, - { 0x11180, 0x111DF, U"Sharada" }, - { 0x111E0, 0x111FF, U"Sinhala Archaic Numbers" }, - { 0x11200, 0x1124F, U"Khojki" }, - { 0x11280, 0x112AF, U"Multani" }, - { 0x112B0, 0x112FF, U"Khudawadi" }, - { 0x11300, 0x1137F, U"Grantha" }, - { 0x11400, 0x1147F, U"Newa" }, - { 0x11480, 0x114DF, U"Tirhuta" }, - { 0x11580, 0x115FF, U"Siddham" }, - { 0x11600, 0x1165F, U"Modi" }, - { 0x11660, 0x1167F, U"Mongolian Supplement" }, - { 0x11680, 0x116CF, U"Takri" }, - { 0x11700, 0x1174F, U"Ahom" }, - { 0x11800, 0x1184F, U"Dogra" }, - { 0x118A0, 0x118FF, U"Warang Citi" }, - { 0x11900, 0x1195F, U"Dives Akuru" }, - { 0x119A0, 0x119FF, U"Nandinagari" }, - { 0x11A00, 0x11A4F, U"Zanabazar Square" }, - { 0x11A50, 0x11AAF, U"Soyombo" }, - { 0x11AB0, 0x11ABF, U"Unified Canadian Aboriginal Syllabics Extended-A" }, - { 0x11AC0, 0x11AFF, U"Pau Cin Hau" }, - { 0x11C00, 0x11C6F, U"Bhaiksuki" }, - { 0x11C70, 0x11CBF, U"Marchen" }, - { 0x11D00, 0x11D5F, U"Masaram Gondi" }, - { 0x11D60, 0x11DAF, U"Gunjala Gondi" }, - { 0x11EE0, 0x11EFF, U"Makasar" }, - { 0x11FB0, 0x11FBF, U"Lisu Supplement" }, - { 0x11FC0, 0x11FFF, U"Tamil Supplement" }, - { 0x12000, 0x123FF, U"Cuneiform" }, - { 0x12400, 0x1247F, U"Cuneiform Numbers and Punctuation" }, - { 0x12480, 0x1254F, U"Early Dynastic Cuneiform" }, - { 0x12F90, 0x12FFF, U"Cypro-Minoan" }, - { 0x13000, 0x1342F, U"Egyptian Hieroglyphs" }, - { 0x13430, 0x1343F, U"Egyptian Hieroglyph Format Controls" }, - { 0x14400, 0x1467F, U"Anatolian Hieroglyphs" }, - { 0x16800, 0x16A3F, U"Bamum Supplement" }, - { 0x16A40, 0x16A6F, U"Mro" }, - { 0x16A70, 0x16ACF, U"Tangsa" }, - { 0x16AD0, 0x16AFF, U"Bassa Vah" }, - { 0x16B00, 0x16B8F, U"Pahawh Hmong" }, - { 0x16E40, 0x16E9F, U"Medefaidrin" }, - { 0x16F00, 0x16F9F, U"Miao" }, - { 0x16FE0, 0x16FFF, U"Ideographic Symbols and Punctuation" }, - { 0x17000, 0x187FF, U"Tangut" }, - { 0x18800, 0x18AFF, U"Tangut Components" }, - { 0x18B00, 0x18CFF, U"Khitan Small Script" }, - { 0x18D00, 0x18D7F, U"Tangut Supplement" }, - { 0x1AFF0, 0x1AFFF, U"Kana Extended-B" }, - { 0x1B000, 0x1B0FF, U"Kana Supplement" }, - { 0x1B100, 0x1B12F, U"Kana Extended-A" }, - { 0x1B130, 0x1B16F, U"Small Kana Extension" }, - { 0x1B170, 0x1B2FF, U"Nushu" }, - { 0x1BC00, 0x1BC9F, U"Duployan" }, - { 0x1BCA0, 0x1BCAF, U"Shorthand Format Controls" }, - { 0x1CF00, 0x1CFCF, U"Znamenny Musical Notation" }, - { 0x1D000, 0x1D0FF, U"Byzantine Musical Symbols" }, - { 0x1D100, 0x1D1FF, U"Musical Symbols" }, - { 0x1D200, 0x1D24F, U"Ancient Greek Musical Notation" }, - { 0x1D2E0, 0x1D2FF, U"Mayan Numerals" }, - { 0x1D300, 0x1D35F, U"Tai Xuan Jing Symbols" }, - { 0x1D360, 0x1D37F, U"Counting Rod Numerals" }, - { 0x1D400, 0x1D7FF, U"Mathematical Alphanumeric Symbols" }, - { 0x1D800, 0x1DAAF, U"Sutton SignWriting" }, - { 0x1DF00, 0x1DFFF, U"Latin Extended-G" }, - { 0x1E000, 0x1E02F, U"Glagolitic Supplement" }, - { 0x1E100, 0x1E14F, U"Nyiakeng Puachue Hmong" }, - { 0x1E290, 0x1E2BF, U"Toto" }, - { 0x1E2C0, 0x1E2FF, U"Wancho" }, - { 0x1E7E0, 0x1E7FF, U"Ethiopic Extended-B" }, - { 0x1E800, 0x1E8DF, U"Mende Kikakui" }, - { 0x1E900, 0x1E95F, U"Adlam" }, - { 0x1EC70, 0x1ECBF, U"Indic Siyaq Numbers" }, - { 0x1ED00, 0x1ED4F, U"Ottoman Siyaq Numbers" }, - { 0x1EE00, 0x1EEFF, U"Arabic Mathematical Alphabetic Symbols" }, - { 0x1F000, 0x1F02F, U"Mahjong Tiles" }, - { 0x1F030, 0x1F09F, U"Domino Tiles" }, - { 0x1F0A0, 0x1F0FF, U"Playing Cards" }, - { 0x1F100, 0x1F1FF, U"Enclosed Alphanumeric Supplement" }, - { 0x1F200, 0x1F2FF, U"Enclosed Ideographic Supplement" }, - { 0x1F300, 0x1F5FF, U"Miscellaneous Symbols and Pictographs" }, - { 0x1F600, 0x1F64F, U"Emoticons" }, - { 0x1F650, 0x1F67F, U"Ornamental Dingbats" }, - { 0x1F680, 0x1F6FF, U"Transport and Map Symbols" }, - { 0x1F700, 0x1F77F, U"Alchemical Symbols" }, - { 0x1F780, 0x1F7FF, U"Geometric Shapes Extended" }, - { 0x1F800, 0x1F8FF, U"Supplemental Arrows-C" }, - { 0x1F900, 0x1F9FF, U"Supplemental Symbols and Pictographs" }, - { 0x1FA00, 0x1FA6F, U"Chess Symbols" }, - { 0x1FA70, 0x1FAFF, U"Symbols and Pictographs Extended-A" }, - { 0x1FB00, 0x1FBFF, U"Symbols for Legacy Computing" }, - { 0x20000, 0x2A6DF, U"CJK Unified Ideographs Extension B" }, - { 0x2A700, 0x2B73F, U"CJK Unified Ideographs Extension C" }, - { 0x2B740, 0x2B81F, U"CJK Unified Ideographs Extension D" }, - { 0x2B820, 0x2CEAF, U"CJK Unified Ideographs Extension E" }, - { 0x2CEB0, 0x2EBEF, U"CJK Unified Ideographs Extension F" }, - { 0x2F800, 0x2FA1F, U"CJK Compatibility Ideographs Supplement" }, - { 0x30000, 0x3134F, U"CJK Unified Ideographs Extension G" }, - //{ 0xE0000, 0xE007F, U"Tags" }, - //{ 0xE0100, 0xE01EF, U"Variation Selectors Supplement" }, - { 0xF0000, 0xFFFFF, U"Supplementary Private Use Area-A" }, - { 0x100000, 0x10FFFF, U"Supplementary Private Use Area-B" }, - { 0x10FFFF, 0x10FFFF, String() } -}; - -void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name) { - const int page_size = 512; - int pages = (p_end - p_start) / page_size; - int remain = (p_end - p_start) % page_size; - - int32_t start = p_start; - for (int i = 0; i < pages; i++) { - TreeItem *item = glyph_tree->create_item(glyph_root); - ERR_FAIL_NULL(item); - item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(start + page_size, 16))); - item->set_text(1, p_name); - item->set_metadata(0, Vector2i(start, start + page_size)); - start += page_size; - } - if (remain > 0) { - TreeItem *item = glyph_tree->create_item(glyph_root); - ERR_FAIL_NULL(item); - item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(p_end, 16))); - item->set_text(1, p_name); - item->set_metadata(0, Vector2i(start, p_end)); - } -} - -/*************************************************************************/ -/* Page 1 callbacks: Rendering Options */ -/*************************************************************************/ - -void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_property) { - // Update font preview. - - if (p_edited_property == "antialiased") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased")); - } - } else if (p_edited_property == "multichannel_signed_distance_field") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field")); - } - _variation_selected(); - _variations_validate(); - } else if (p_edited_property == "msdf_pixel_range") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range")); - } - } else if (p_edited_property == "msdf_size") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_msdf_size(import_settings_data->get("msdf_size")); - } - } else if (p_edited_property == "force_autohinter") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); - } - } else if (p_edited_property == "hinting") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); - } - } else if (p_edited_property == "subpixel_positioning") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); - } - } else if (p_edited_property == "oversampling") { - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); - } - } - font_preview_label->add_theme_font_override("font", font_preview); - font_preview_label->update(); -} - -/*************************************************************************/ -/* Page 2 callbacks: Configurations */ -/*************************************************************************/ - -void DynamicFontImportSettings::_variation_add() { - TreeItem *vars_item = vars_list->create_item(vars_list_root); - ERR_FAIL_NULL(vars_item); - - vars_item->set_text(0, TTR("New configuration")); - vars_item->set_editable(0, true); - vars_item->add_button(1, vars_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); - vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); - - Ref import_variation_data; - import_variation_data.instantiate(); - import_variation_data->owner = this; - ERR_FAIL_NULL(import_variation_data); - - for (List::Element *E = options_variations.front(); E; E = E->next()) { - import_variation_data->defaults[E->get().option.name] = E->get().default_value; - } - - import_variation_data->options = options_variations; - inspector_vars->edit(import_variation_data.ptr()); - import_variation_data->notify_property_list_changed(); - - vars_item->set_metadata(0, import_variation_data); - - _variations_validate(); -} - -void DynamicFontImportSettings::_variation_selected() { - TreeItem *vars_item = vars_list->get_selected(); - if (vars_item) { - Ref import_variation_data = vars_item->get_metadata(0); - ERR_FAIL_NULL(import_variation_data); - - inspector_vars->edit(import_variation_data.ptr()); - import_variation_data->notify_property_list_changed(); - } -} - -void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id) { - TreeItem *vars_item = (TreeItem *)p_item; - ERR_FAIL_NULL(vars_item); - - inspector_vars->edit(nullptr); - - vars_list_root->remove_child(vars_item); - memdelete(vars_item); - - if (vars_list_root->get_first_child()) { - Ref import_variation_data = vars_list_root->get_first_child()->get_metadata(0); - inspector_vars->edit(import_variation_data.ptr()); - import_variation_data->notify_property_list_changed(); - } - - _variations_validate(); -} - -void DynamicFontImportSettings::_variation_changed(const String &p_edited_property) { - _variations_validate(); -} - -void DynamicFontImportSettings::_variations_validate() { - String warn; - if (!vars_list_root->get_first_child()) { - warn = TTR("Warinig: There are no configurations specified, no glyphs will be pre-rendered."); - } - for (TreeItem *vars_item_a = vars_list_root->get_first_child(); vars_item_a; vars_item_a = vars_item_a->get_next()) { - Ref import_variation_data_a = vars_item_a->get_metadata(0); - ERR_FAIL_NULL(import_variation_data_a); - - for (TreeItem *vars_item_b = vars_list_root->get_first_child(); vars_item_b; vars_item_b = vars_item_b->get_next()) { - if (vars_item_b != vars_item_a) { - bool match = true; - for (Map::Element *E = import_variation_data_a->settings.front(); E; E = E->next()) { - Ref import_variation_data_b = vars_item_b->get_metadata(0); - ERR_FAIL_NULL(import_variation_data_b); - match = match && (import_variation_data_b->settings[E->key()] == E->get()); - } - if (match) { - warn = TTR("Warinig: Multiple configurations have identical settings. Duplicates will be ignored."); - break; - } - } - } - } - if (warn.is_empty()) { - label_warn->set_text(""); - label_warn->hide(); - } else { - label_warn->set_text(warn); - label_warn->show(); - } -} - -/*************************************************************************/ -/* Page 3 callbacks: Text to select glyphs */ -/*************************************************************************/ - -void DynamicFontImportSettings::_change_text_opts() { - Vector ftr = ftr_edit->get_text().split(","); - for (int i = 0; i < ftr.size(); i++) { - Vector tokens = ftr[i].split("="); - if (tokens.size() == 2) { - text_edit->set_opentype_feature(tokens[0], tokens[1].to_int()); - } else if (tokens.size() == 1) { - text_edit->set_opentype_feature(tokens[0], 1); - } - } - text_edit->set_language(lang_edit->get_text()); -} - -void DynamicFontImportSettings::_glyph_clear() { - selected_glyphs.clear(); - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); - _range_selected(); -} - -void DynamicFontImportSettings::_glyph_text_selected() { - Dictionary ftrs; - Vector ftr = ftr_edit->get_text().split(","); - for (int i = 0; i < ftr.size(); i++) { - Vector tokens = ftr[i].split("="); - if (tokens.size() == 2) { - ftrs[tokens[0]] = tokens[1].to_int(); - } else if (tokens.size() == 1) { - ftrs[tokens[0]] = 1; - } - } - - RID text_rid = TS->create_shaped_text(); - if (text_rid.is_valid()) { - TS->shaped_text_add_string(text_rid, text_edit->get_text(), font_main->get_rids(), 16, ftrs, text_edit->get_language()); - TS->shaped_text_shape(text_rid); - const Glyph *gl = TS->shaped_text_get_glyphs(text_rid); - const int gl_size = TS->shaped_text_get_glyph_count(text_rid); - - for (int i = 0; i < gl_size; i++) { - if (gl[i].font_rid.is_valid() && gl[i].index != 0) { - selected_glyphs.insert(gl[i].index); - } - } - TS->free(text_rid); - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); - } - _range_selected(); -} - -/*************************************************************************/ -/* Page 4 callbacks: Character map */ -/*************************************************************************/ - -void DynamicFontImportSettings::_glyph_selected() { - TreeItem *item = glyph_table->get_selected(); - ERR_FAIL_NULL(item); - - Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); - Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); - scol.a = 1.f; - - int32_t c = item->get_metadata(glyph_table->get_selected_column()); - if (font_main->has_char(c)) { - if (_char_update(c)) { - item->set_custom_color(glyph_table->get_selected_column(), fcol); - item->set_custom_bg_color(glyph_table->get_selected_column(), scol); - } else { - item->clear_custom_color(glyph_table->get_selected_column()); - item->clear_custom_bg_color(glyph_table->get_selected_column()); - } - } - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); - - item = glyph_tree->get_selected(); - ERR_FAIL_NULL(item); - Vector2i range = item->get_metadata(0); - - int total_chars = range.y - range.x; - int selected_count = 0; - for (int i = range.x; i < range.y; i++) { - if (!font_main->has_char(i)) { - total_chars--; - } - - if (selected_chars.has(i)) { - selected_count++; - } - } - - if (selected_count == total_chars) { - item->set_checked(0, true); - } else if (selected_count > 0) { - item->set_indeterminate(0, true); - } else { - item->set_checked(0, false); - } -} - -void DynamicFontImportSettings::_range_edited() { - TreeItem *item = glyph_tree->get_selected(); - ERR_FAIL_NULL(item); - Vector2i range = item->get_metadata(0); - _range_update(range.x, range.y); -} - -void DynamicFontImportSettings::_range_selected() { - TreeItem *item = glyph_tree->get_selected(); - if (item) { - Vector2i range = item->get_metadata(0); - _edit_range(range.x, range.y); - } -} - -void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { - glyph_table->clear(); - - TreeItem *root = glyph_table->create_item(); - ERR_FAIL_NULL(root); - - Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")); - Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color"), SNAME("Editor")); - scol.a = 1.f; - - TreeItem *item = nullptr; - int col = 0; - - for (int32_t c = p_start; c <= p_end; c++) { - if (col == 0) { - item = glyph_table->create_item(root); - ERR_FAIL_NULL(item); - item->set_text(0, _pad_zeros(String::num_int64(c, 16))); - item->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT); - item->set_selectable(0, false); - item->set_custom_bg_color(0, glyph_table->get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); - } - if (font_main->has_char(c)) { - item->set_text(col + 1, String::chr(c)); - item->set_custom_color(col + 1, Color(1, 1, 1)); - if (selected_chars.has(c) || (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, c)))) { - item->set_custom_color(col + 1, fcol); - item->set_custom_bg_color(col + 1, scol); - } else { - item->clear_custom_color(col + 1); - item->clear_custom_bg_color(col + 1); - } - } else { - item->set_custom_bg_color(col + 1, glyph_table->get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); - } - item->set_metadata(col + 1, c); - item->set_text_alignment(col + 1, HORIZONTAL_ALIGNMENT_CENTER); - item->set_selectable(col + 1, true); - item->set_custom_font(col + 1, font_main); - item->set_custom_font_size(col + 1, get_theme_font_size(SNAME("font_size")) * 2); - - col++; - if (col == 16) { - col = 0; - } - } - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); -} - -bool DynamicFontImportSettings::_char_update(int32_t p_char) { - if (selected_chars.has(p_char)) { - selected_chars.erase(p_char); - return false; - } else if (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, p_char))) { - selected_glyphs.erase(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, p_char)); - return false; - } else { - selected_chars.insert(p_char); - return true; - } - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); -} - -void DynamicFontImportSettings::_range_update(int32_t p_start, int32_t p_end) { - bool all_selected = true; - for (int32_t i = p_start; i <= p_end; i++) { - if (font_main->has_char(i)) { - if (font_main->get_data(0).is_valid()) { - all_selected = all_selected && (selected_chars.has(i) || (font_main->get_data(0).is_valid() && selected_glyphs.has(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, i)))); - } else { - all_selected = all_selected && selected_chars.has(i); - } - } - } - for (int32_t i = p_start; i <= p_end; i++) { - if (font_main->has_char(i)) { - if (!all_selected) { - selected_chars.insert(i); - } else { - selected_chars.erase(i); - if (font_main->get_data(0).is_valid()) { - selected_glyphs.erase(font_main->get_data(0)->get_glyph_index(get_theme_font_size(SNAME("font_size")) * 2, i)); - } - } - } - } - _edit_range(p_start, p_end); - - TreeItem *item = glyph_tree->get_selected(); - ERR_FAIL_NULL(item); - item->set_checked(0, !all_selected); -} - -/*************************************************************************/ -/* Page 5 callbacks: CMetadata override */ -/*************************************************************************/ - -void DynamicFontImportSettings::_lang_add() { - locale_select->popup_locale_dialog(); -} - -void DynamicFontImportSettings::_lang_add_item(const String &p_locale) { - TreeItem *lang_item = lang_list->create_item(lang_list_root); - ERR_FAIL_NULL(lang_item); - - lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - lang_item->set_editable(0, true); - lang_item->set_checked(0, false); - lang_item->set_text(1, p_locale); - lang_item->set_editable(1, true); - lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - lang_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); -} - -void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id) { - TreeItem *lang_item = (TreeItem *)p_item; - ERR_FAIL_NULL(lang_item); - - lang_list_root->remove_child(lang_item); - memdelete(lang_item); -} - -void DynamicFontImportSettings::_ot_add() { - menu_ot->set_position(ot_list->get_screen_transform().xform(ot_list->get_local_mouse_position())); - menu_ot->set_size(Vector2(1, 1)); - menu_ot->popup(); -} - -void DynamicFontImportSettings::_ot_add_item(int p_option) { - String name = TS->tag_to_name(p_option); - for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { - if (ot_item->get_text(0) == name) { - return; - } - } - TreeItem *ot_item = ot_list->create_item(ot_list_root); - ERR_FAIL_NULL(ot_item); - - ot_item->set_text(0, name); - ot_item->set_editable(0, false); - ot_item->set_text(1, "1"); - ot_item->set_editable(1, true); - ot_item->add_button(2, ot_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); -} - -void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id) { - TreeItem *ot_item = (TreeItem *)p_item; - ERR_FAIL_NULL(ot_item); - - ot_list_root->remove_child(ot_item); - memdelete(ot_item); -} - -void DynamicFontImportSettings::_script_add() { - menu_scripts->set_position(script_list->get_screen_position() + script_list->get_local_mouse_position()); - menu_scripts->reset_size(); - menu_scripts->popup(); -} - -void DynamicFontImportSettings::_script_add_item(int p_option) { - TreeItem *script_item = script_list->create_item(script_list_root); - ERR_FAIL_NULL(script_item); - - script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - script_item->set_editable(0, true); - script_item->set_checked(0, false); - script_item->set_text(1, script_codes[p_option]); - script_item->set_editable(1, true); - script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - script_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); -} - -void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id) { - TreeItem *script_item = (TreeItem *)p_item; - ERR_FAIL_NULL(script_item); - - script_list_root->remove_child(script_item); - memdelete(script_item); -} - -/*************************************************************************/ -/* Common */ -/*************************************************************************/ - -DynamicFontImportSettings *DynamicFontImportSettings::singleton = nullptr; - -String DynamicFontImportSettings::_pad_zeros(const String &p_hex) const { - int len = CLAMP(5 - p_hex.length(), 0, 5); - return String("0").repeat(len) + p_hex; -} - -void DynamicFontImportSettings::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import)); - } else if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - } -} - -void DynamicFontImportSettings::_re_import() { - Map main_settings; - - main_settings["antialiased"] = import_settings_data->get("antialiased"); - main_settings["multichannel_signed_distance_field"] = import_settings_data->get("multichannel_signed_distance_field"); - main_settings["msdf_pixel_range"] = import_settings_data->get("msdf_pixel_range"); - main_settings["msdf_size"] = import_settings_data->get("msdf_size"); - main_settings["force_autohinter"] = import_settings_data->get("force_autohinter"); - main_settings["hinting"] = import_settings_data->get("hinting"); - main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning"); - main_settings["oversampling"] = import_settings_data->get("oversampling"); - main_settings["compress"] = import_settings_data->get("compress"); - - Vector variations; - for (TreeItem *vars_item = vars_list_root->get_first_child(); vars_item; vars_item = vars_item->get_next()) { - String variation; - Ref import_variation_data = vars_item->get_metadata(0); - ERR_FAIL_NULL(import_variation_data); - - String name = vars_item->get_text(0); - variation += ("name=" + name); - for (Map::Element *E = import_variation_data->settings.front(); E; E = E->next()) { - if (!variation.is_empty()) { - variation += ","; - } - variation += (String(E->key()) + "=" + String(E->get())); - } - variations.push_back(variation); - } - main_settings["preload/configurations"] = variations; - - Vector langs_enabled; - Vector langs_disabled; - for (TreeItem *lang_item = lang_list_root->get_first_child(); lang_item; lang_item = lang_item->get_next()) { - bool selected = lang_item->is_checked(0); - String name = lang_item->get_text(1); - if (selected) { - langs_enabled.push_back(name); - } else { - langs_disabled.push_back(name); - } - } - main_settings["support_overrides/language_enabled"] = langs_enabled; - main_settings["support_overrides/language_disabled"] = langs_disabled; - - Vector scripts_enabled; - Vector scripts_disabled; - for (TreeItem *script_item = script_list_root->get_first_child(); script_item; script_item = script_item->get_next()) { - bool selected = script_item->is_checked(0); - String name = script_item->get_text(1); - if (selected) { - scripts_enabled.push_back(name); - } else { - scripts_disabled.push_back(name); - } - } - main_settings["support_overrides/script_enabled"] = scripts_enabled; - main_settings["support_overrides/script_disabled"] = scripts_disabled; - - if (!selected_chars.is_empty()) { - Vector ranges; - char32_t start = selected_chars.front()->get(); - for (Set::Element *E = selected_chars.front()->next(); E; E = E->next()) { - if (E->prev() && ((E->prev()->get() + 1) != E->get())) { - ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); - start = E->get(); - } - } - ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(selected_chars.back()->get(), 16)); - main_settings["preload/char_ranges"] = ranges; - } - - if (!selected_glyphs.is_empty()) { - Vector ranges; - int32_t start = selected_glyphs.front()->get(); - for (Set::Element *E = selected_glyphs.front()->next(); E; E = E->next()) { - if (E->prev() && ((E->prev()->get() + 1) != E->get())) { - ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(E->prev()->get(), 16)); - start = E->get(); - } - } - ranges.push_back(String("0x") + String::num_int64(start, 16) + String("-0x") + String::num_int64(selected_glyphs.back()->get(), 16)); - main_settings["preload/glyph_ranges"] = ranges; - } - - Dictionary ot_ov; - for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { - String tag = ot_item->get_text(0); - int32_t value = ot_item->get_text(1).to_int(); - ot_ov[tag] = value; - } - main_settings["opentype_feature_overrides"] = ot_ov; - - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("Import settings:"); - for (Map::Element *E = main_settings.front(); E; E = E->next()) { - print_line(String(" ") + String(E->key()).utf8().get_data() + " == " + String(E->get()).utf8().get_data()); - } - } - - EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(base_path, "font_data_dynamic", main_settings); -} - -void DynamicFontImportSettings::open_settings(const String &p_path) { - // Load base font data. - Vector data = FileAccess::get_file_as_array(p_path); - - // Load font for preview. - Ref dfont_prev; - dfont_prev.instantiate(); - dfont_prev->set_data(data); - - font_preview.instantiate(); - font_preview->add_data(dfont_prev); - - String sample; - static const String sample_base = U"12漢字ԱբΑαАбΑαאבابܐܒހށआআਆઆଆஆఆಆആආกิກິༀကႠა한글ሀᎣᐁᚁᚠᜀᜠᝀᝠកᠠᤁᥐAb😀"; - for (int i = 0; i < sample_base.length(); i++) { - if (dfont_prev->has_char(sample_base[i])) { - sample += sample_base[i]; - } - } - if (sample.is_empty()) { - sample = dfont_prev->get_supported_chars().substr(0, 6); - } - font_preview_label->set_text(sample); - - // Load second copy of font with MSDF disabled for the glyph table and metadata extraction. - Ref dfont_main; - dfont_main.instantiate(); - dfont_main->set_data(data); - dfont_main->set_multichannel_signed_distance_field(false); - - font_main.instantiate(); - font_main->add_data(dfont_main); - text_edit->add_theme_font_override("font", font_main); - - base_path = p_path; - - inspector_vars->edit(nullptr); - inspector_general->edit(nullptr); - - int gww = get_theme_font(SNAME("font"))->get_string_size("00000", get_theme_font_size(SNAME("font_size"))).x + 50; - glyph_table->set_column_custom_minimum_width(0, gww); - - glyph_table->clear(); - vars_list->clear(); - lang_list->clear(); - script_list->clear(); - ot_list->clear(); - - selected_chars.clear(); - selected_glyphs.clear(); - text_edit->set_text(String()); - - vars_list_root = vars_list->create_item(); - lang_list_root = lang_list->create_item(); - script_list_root = script_list->create_item(); - ot_list_root = ot_list->create_item(); - - options_variations.clear(); - Dictionary var_list = dfont_main->get_supported_variation_list(); - for (int i = 0; i < var_list.size(); i++) { - int32_t tag = var_list.get_key_at_index(i); - Vector3i value = var_list.get_value_at_index(i); - options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, TS->tag_to_name(tag), PROPERTY_HINT_RANGE, itos(value.x) + "," + itos(value.y) + ",1"), value.z)); - } - options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "0,127,1"), 16)); - options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,127,1"), 0)); - options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "extra_spacing_glyph"), 0)); - options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "extra_spacing_space"), 0)); - - import_settings_data->defaults.clear(); - for (List::Element *E = options_general.front(); E; E = E->next()) { - import_settings_data->defaults[E->get().option.name] = E->get().default_value; - } - - Ref config; - config.instantiate(); - ERR_FAIL_NULL(config); - - Error err = config->load(p_path + ".import"); - print_verbose("Loading import settings:"); - if (err == OK) { - List keys; - config->get_section_keys("params", &keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); - print_verbose(String(" ") + key + " == " + String(config->get_value("params", key))); - if (key == "preload/char_ranges") { - Vector ranges = config->get_value("params", key); - for (int i = 0; i < ranges.size(); i++) { - int32_t start, end; - Vector tokens = ranges[i].split("-"); - if (tokens.size() == 2) { - if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start) || !ResourceImporterDynamicFont::_decode_range(tokens[1], end)) { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - } else if (tokens.size() == 1) { - if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start)) { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - end = start; - } else { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - for (int32_t j = start; j <= end; j++) { - selected_chars.insert(j); - } - } - } else if (key == "preload/glyph_ranges") { - Vector ranges = config->get_value("params", key); - for (int i = 0; i < ranges.size(); i++) { - int32_t start, end; - Vector tokens = ranges[i].split("-"); - if (tokens.size() == 2) { - if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start) || !ResourceImporterDynamicFont::_decode_range(tokens[1], end)) { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - } else if (tokens.size() == 1) { - if (!ResourceImporterDynamicFont::_decode_range(tokens[0], start)) { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - end = start; - } else { - WARN_PRINT("Invalid range: \"" + ranges[i] + "\""); - continue; - } - for (int32_t j = start; j <= end; j++) { - selected_glyphs.insert(j); - } - } - } else if (key == "preload/configurations") { - Vector variations = config->get_value("params", key); - for (int i = 0; i < variations.size(); i++) { - TreeItem *vars_item = vars_list->create_item(vars_list_root); - ERR_FAIL_NULL(vars_item); - - vars_item->set_text(0, TTR("Configuration") + " " + itos(i)); - vars_item->set_editable(0, true); - vars_item->add_button(1, vars_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove Variation")); - vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); - - Ref import_variation_data_custom; - import_variation_data_custom.instantiate(); - import_variation_data_custom->owner = this; - ERR_FAIL_NULL(import_variation_data_custom); - - for (List::Element *F = options_variations.front(); F; F = F->next()) { - import_variation_data_custom->defaults[F->get().option.name] = F->get().default_value; - } - - import_variation_data_custom->options = options_variations; - - vars_item->set_metadata(0, import_variation_data_custom); - Vector variation_tags = variations[i].split(","); - for (int j = 0; j < variation_tags.size(); j++) { - Vector tokens = variation_tags[j].split("="); - if (tokens[0] == "name") { - vars_item->set_text(0, tokens[1]); - } else if (tokens[0] == "size" || tokens[0] == "outline_size" || tokens[0] == "extra_spacing_space" || tokens[0] == "extra_spacing_glyph") { - import_variation_data_custom->set(tokens[0], tokens[1].to_int()); - } else { - import_variation_data_custom->set(tokens[0], tokens[1].to_float()); - } - } - } - } else if (key == "support_overrides/language_enabled") { - PackedStringArray _langs = config->get_value("params", key); - for (int i = 0; i < _langs.size(); i++) { - TreeItem *lang_item = lang_list->create_item(lang_list_root); - ERR_FAIL_NULL(lang_item); - - lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - lang_item->set_editable(0, true); - lang_item->set_checked(0, true); - lang_item->set_text(1, _langs[i]); - lang_item->set_editable(1, true); - lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - } - } else if (key == "support_overrides/language_disabled") { - PackedStringArray _langs = config->get_value("params", key); - for (int i = 0; i < _langs.size(); i++) { - TreeItem *lang_item = lang_list->create_item(lang_list_root); - ERR_FAIL_NULL(lang_item); - - lang_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - lang_item->set_editable(0, true); - lang_item->set_checked(0, false); - lang_item->set_text(1, _langs[i]); - lang_item->set_editable(1, true); - lang_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - } - } else if (key == "support_overrides/script_enabled") { - PackedStringArray _scripts = config->get_value("params", key); - for (int i = 0; i < _scripts.size(); i++) { - TreeItem *script_item = script_list->create_item(script_list_root); - ERR_FAIL_NULL(script_item); - - script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - script_item->set_editable(0, true); - script_item->set_checked(0, true); - script_item->set_text(1, _scripts[i]); - script_item->set_editable(1, true); - script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - } - } else if (key == "support_overrides/script_disabled") { - PackedStringArray _scripts = config->get_value("params", key); - for (int i = 0; i < _scripts.size(); i++) { - TreeItem *script_item = script_list->create_item(script_list_root); - ERR_FAIL_NULL(script_item); - - script_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - script_item->set_editable(0, true); - script_item->set_checked(0, false); - script_item->set_text(1, _scripts[i]); - script_item->set_editable(1, true); - script_item->add_button(2, lang_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - } - } else if (key == "opentype_feature_overrides") { - Dictionary features = config->get_value("params", key); - for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { - TreeItem *ot_item = ot_list->create_item(ot_list_root); - ERR_FAIL_NULL(ot_item); - int32_t value = features[*ftr]; - if (ftr->get_type() == Variant::STRING) { - ot_item->set_text(0, *ftr); - } else { - ot_item->set_text(0, TS->tag_to_name(*ftr)); - } - ot_item->set_editable(0, false); - ot_item->set_text(1, itos(value)); - ot_item->set_editable(1, true); - ot_item->add_button(2, ot_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_VAR, false, TTR("Remove")); - ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); - } - } else { - Variant value = config->get_value("params", key); - import_settings_data->defaults[key] = value; - } - } - } - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); - - import_settings_data->options = options_general; - inspector_general->edit(import_settings_data.ptr()); - import_settings_data->notify_property_list_changed(); - - if (font_preview->get_data_count() > 0) { - font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased")); - font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field")); - font_preview->get_data(0)->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range")); - font_preview->get_data(0)->set_msdf_size(import_settings_data->get("msdf_size")); - font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); - font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); - font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); - font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); - } - font_preview_label->add_theme_font_override("font", font_preview); - font_preview_label->update(); - - menu_ot->clear(); - menu_ot_ss->clear(); - menu_ot_cv->clear(); - menu_ot_cu->clear(); - bool have_ss = false; - bool have_cv = false; - bool have_cu = false; - Dictionary features = font_preview->get_feature_list(); - for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { - String ftr_name = TS->tag_to_name(*ftr); - if (ftr_name.begins_with("stylistic_set_")) { - menu_ot_ss->add_item(ftr_name.capitalize(), (int32_t)*ftr); - have_ss = true; - } else if (ftr_name.begins_with("character_variant_")) { - menu_ot_cv->add_item(ftr_name.capitalize(), (int32_t)*ftr); - have_cv = true; - } else if (ftr_name.begins_with("custom_")) { - menu_ot_cu->add_item(ftr_name.replace("custom_", ""), (int32_t)*ftr); - have_cu = true; - } else { - menu_ot->add_item(ftr_name.capitalize(), (int32_t)*ftr); - } - } - if (have_ss) { - menu_ot->add_submenu_item(RTR("Stylistic Sets"), "SSMenu"); - } - if (have_cv) { - menu_ot->add_submenu_item(RTR("Character Variants"), "CVMenu"); - } - if (have_cu) { - menu_ot->add_submenu_item(RTR("Custom"), "CUMenu"); - } - - _variations_validate(); - - popup_centered_ratio(); - - set_title(vformat(TTR("Advanced Import Settings for '%s'"), base_path.get_file())); -} - -DynamicFontImportSettings *DynamicFontImportSettings::get_singleton() { - return singleton; -} - -DynamicFontImportSettings::DynamicFontImportSettings() { - singleton = this; - - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); - options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "compress", PROPERTY_HINT_NONE, ""), false)); - - // Popup menus - - locale_select = memnew(EditorLocaleDialog); - locale_select->connect("locale_selected", callable_mp(this, &DynamicFontImportSettings::_lang_add_item)); - add_child(locale_select); - - menu_scripts = memnew(PopupMenu); - menu_scripts->set_name("Script"); - script_codes = TranslationServer::get_singleton()->get_all_scripts(); - for (int i = 0; i < script_codes.size(); i++) { - menu_scripts->add_item(TranslationServer::get_singleton()->get_script_name(script_codes[i]) + " (" + script_codes[i] + ")", i); - } - add_child(menu_scripts); - menu_scripts->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_script_add_item)); - - menu_ot = memnew(PopupMenu); - add_child(menu_ot); - menu_ot->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); - - menu_ot_cv = memnew(PopupMenu); - menu_ot_cv->set_name("CVMenu"); - menu_ot->add_child(menu_ot_cv); - menu_ot_cv->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); - - menu_ot_ss = memnew(PopupMenu); - menu_ot_ss->set_name("SSMenu"); - menu_ot->add_child(menu_ot_ss); - menu_ot_ss->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); - - menu_ot_cu = memnew(PopupMenu); - menu_ot_cu->set_name("CUMenu"); - menu_ot->add_child(menu_ot_cu); - menu_ot_cu->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); - - Color warn_color = (EditorNode::get_singleton()) ? EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")) : Color(1, 1, 0); - - // Root layout - - VBoxContainer *root_vb = memnew(VBoxContainer); - add_child(root_vb); - - main_pages = memnew(TabContainer); - main_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL); - main_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL); - root_vb->add_child(main_pages); - - label_warn = memnew(Label); - label_warn->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - label_warn->set_text(""); - root_vb->add_child(label_warn); - label_warn->add_theme_color_override("font_color", warn_color); - label_warn->hide(); - - // Page 1 layout: Rendering Options - - VBoxContainer *page1_vb = memnew(VBoxContainer); - page1_vb->set_meta("_tab_name", TTR("Rendering options")); - main_pages->add_child(page1_vb); - - page1_description = memnew(Label); - page1_description->set_text(TTR("Select font rendering options:")); - page1_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page1_vb->add_child(page1_description); - - HSplitContainer *page1_hb = memnew(HSplitContainer); - page1_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); - page1_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page1_vb->add_child(page1_hb); - - font_preview_label = memnew(Label); - font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); - font_preview_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - font_preview_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); - font_preview_label->set_autowrap_mode(Label::AUTOWRAP_ARBITRARY); - font_preview_label->set_clip_text(true); - font_preview_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); - font_preview_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page1_hb->add_child(font_preview_label); - - inspector_general = memnew(EditorInspector); - inspector_general->set_v_size_flags(Control::SIZE_EXPAND_FILL); - inspector_general->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE)); - inspector_general->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_main_prop_changed)); - page1_hb->add_child(inspector_general); - - // Page 2 layout: Configurations - VBoxContainer *page2_vb = memnew(VBoxContainer); - page2_vb->set_meta("_tab_name", TTR("Sizes and variations")); - main_pages->add_child(page2_vb); - - page2_description = memnew(Label); - page2_description->set_text(TTR("Add font size, variation coordinates, and extra spacing combinations to pre-render:")); - page2_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page2_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); - page2_vb->add_child(page2_description); - - HSplitContainer *page2_hb = memnew(HSplitContainer); - page2_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); - page2_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page2_vb->add_child(page2_hb); - - VBoxContainer *page2_side_vb = memnew(VBoxContainer); - page2_hb->add_child(page2_side_vb); - - HBoxContainer *page2_hb_vars = memnew(HBoxContainer); - page2_side_vb->add_child(page2_hb_vars); - - label_vars = memnew(Label); - page2_hb_vars->add_child(label_vars); - label_vars->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - label_vars->set_h_size_flags(Control::SIZE_EXPAND_FILL); - label_vars->set_text(TTR("Configuration:")); - - add_var = memnew(Button); - page2_hb_vars->add_child(add_var); - add_var->set_tooltip(TTR("Add configuration")); - add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_var->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_variation_add)); - - vars_list = memnew(Tree); - page2_side_vb->add_child(vars_list); - vars_list->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); - vars_list->set_hide_root(true); - vars_list->set_columns(2); - vars_list->set_column_expand(0, true); - vars_list->set_column_custom_minimum_width(0, 80 * EDSCALE); - vars_list->set_column_expand(1, false); - vars_list->set_column_custom_minimum_width(1, 50 * EDSCALE); - vars_list->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_variation_selected)); - vars_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_variation_remove)); - vars_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - inspector_vars = memnew(EditorInspector); - inspector_vars->set_v_size_flags(Control::SIZE_EXPAND_FILL); - inspector_vars->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_variation_changed)); - page2_hb->add_child(inspector_vars); - - // Page 3 layout: Text to select glyphs - VBoxContainer *page3_vb = memnew(VBoxContainer); - page3_vb->set_meta("_tab_name", TTR("Glyphs from the text")); - main_pages->add_child(page3_vb); - - page3_description = memnew(Label); - page3_description->set_text(TTR("Enter a text to shape and add all required glyphs to pre-render list:")); - page3_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page3_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); - page3_vb->add_child(page3_description); - - HBoxContainer *ot_hb = memnew(HBoxContainer); - page3_vb->add_child(ot_hb); - ot_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - Label *label_ed_ftr = memnew(Label); - ot_hb->add_child(label_ed_ftr); - label_ed_ftr->set_text(TTR("OpenType features:")); - - ftr_edit = memnew(LineEdit); - ot_hb->add_child(ftr_edit); - ftr_edit->connect("text_changed", callable_mp(this, &DynamicFontImportSettings::_change_text_opts)); - ftr_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - Label *label_ed_lang = memnew(Label); - ot_hb->add_child(label_ed_lang); - label_ed_lang->set_text(TTR("Text language:")); - - lang_edit = memnew(LineEdit); - ot_hb->add_child(lang_edit); - lang_edit->connect("text_changed", callable_mp(this, &DynamicFontImportSettings::_change_text_opts)); - lang_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - text_edit = memnew(TextEdit); - page3_vb->add_child(text_edit); - text_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL); - text_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - HBoxContainer *text_hb = memnew(HBoxContainer); - page3_vb->add_child(text_hb); - text_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - label_glyphs = memnew(Label); - text_hb->add_child(label_glyphs); - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(0)); - label_glyphs->set_custom_minimum_size(Size2(50 * EDSCALE, 0)); - - Button *btn_fill = memnew(Button); - text_hb->add_child(btn_fill); - btn_fill->set_text(TTR("Shape text and add glyphs")); - btn_fill->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_glyph_text_selected)); - - Button *btn_clear = memnew(Button); - text_hb->add_child(btn_clear); - btn_clear->set_text(TTR("Clear glyph list")); - btn_clear->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_glyph_clear)); - - // Page 4 layout: Character map - VBoxContainer *page4_vb = memnew(VBoxContainer); - page4_vb->set_meta("_tab_name", TTR("Glyphs from the character map")); - main_pages->add_child(page4_vb); - - page4_description = memnew(Label); - page4_description->set_text(TTR("Add or remove additional glyphs from the character map to pre-render list:\nNote: Some stylistic alternatives and glyph variants do not have one-to-one correspondence to character, and not shown in this map, use \"Glyphs from the text\" to add these.")); - page4_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page4_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); - page4_vb->add_child(page4_description); - - HSplitContainer *glyphs_split = memnew(HSplitContainer); - glyphs_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); - glyphs_split->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page4_vb->add_child(glyphs_split); - - glyph_table = memnew(Tree); - glyphs_split->add_child(glyph_table); - glyph_table->set_custom_minimum_size(Size2((30 * 16 + 100) * EDSCALE, 0)); - glyph_table->set_columns(17); - glyph_table->set_column_expand(0, false); - glyph_table->set_hide_root(true); - glyph_table->set_allow_reselect(true); - glyph_table->set_select_mode(Tree::SELECT_SINGLE); - glyph_table->connect("item_activated", callable_mp(this, &DynamicFontImportSettings::_glyph_selected)); - glyph_table->set_column_titles_visible(true); - for (int i = 0; i < 16; i++) { - glyph_table->set_column_title(i + 1, String::num_int64(i, 16)); - } - glyph_table->add_theme_style_override("selected", glyph_table->get_theme_stylebox(SNAME("bg"))); - glyph_table->add_theme_style_override("selected_focus", glyph_table->get_theme_stylebox(SNAME("bg"))); - glyph_table->add_theme_constant_override("hseparation", 0); - glyph_table->set_h_size_flags(Control::SIZE_EXPAND_FILL); - glyph_table->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - glyph_tree = memnew(Tree); - glyphs_split->add_child(glyph_tree); - glyph_tree->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); - glyph_tree->set_columns(2); - glyph_tree->set_hide_root(true); - glyph_tree->set_column_expand(0, false); - glyph_tree->set_column_expand(1, true); - glyph_tree->set_column_custom_minimum_width(0, 120 * EDSCALE); - glyph_tree->connect("item_activated", callable_mp(this, &DynamicFontImportSettings::_range_edited)); - glyph_tree->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_range_selected)); - glyph_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); - glyph_root = glyph_tree->create_item(); - for (int i = 0; !unicode_ranges[i].name.is_empty(); i++) { - _add_glyph_range_item(unicode_ranges[i].start, unicode_ranges[i].end, unicode_ranges[i].name); - } - - // Page 4 layout: Metadata override - VBoxContainer *page5_vb = memnew(VBoxContainer); - page5_vb->set_meta("_tab_name", TTR("Metadata override")); - main_pages->add_child(page5_vb); - - page5_description = memnew(Label); - page5_description->set_text(TTR("Add or remove language and script support overrides, to control fallback font selection order:")); - page5_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); - page5_description->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); - page5_vb->add_child(page5_description); - - HBoxContainer *hb_lang = memnew(HBoxContainer); - page5_vb->add_child(hb_lang); - - label_langs = memnew(Label); - label_langs->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - label_langs->set_h_size_flags(Control::SIZE_EXPAND_FILL); - label_langs->set_text(TTR("Language support overrides")); - hb_lang->add_child(label_langs); - - add_lang = memnew(Button); - hb_lang->add_child(add_lang); - add_lang->set_tooltip(TTR("Add language override")); - add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_lang->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_lang_add)); - - lang_list = memnew(Tree); - page5_vb->add_child(lang_list); - lang_list->set_hide_root(true); - lang_list->set_columns(3); - lang_list->set_column_expand(0, false); // Check - lang_list->set_column_custom_minimum_width(0, 50 * EDSCALE); - lang_list->set_column_expand(1, true); - lang_list->set_column_custom_minimum_width(1, 80 * EDSCALE); - lang_list->set_column_expand(2, false); - lang_list->set_column_custom_minimum_width(2, 50 * EDSCALE); - lang_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_lang_remove)); - lang_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - HBoxContainer *hb_script = memnew(HBoxContainer); - page5_vb->add_child(hb_script); - - label_script = memnew(Label); - label_script->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - label_script->set_h_size_flags(Control::SIZE_EXPAND_FILL); - label_script->set_text(TTR("Script support overrides")); - hb_script->add_child(label_script); - - add_script = memnew(Button); - hb_script->add_child(add_script); - add_script->set_tooltip(TTR("Add script override")); - add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_script->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_script_add)); - - script_list = memnew(Tree); - page5_vb->add_child(script_list); - script_list->set_hide_root(true); - script_list->set_columns(3); - script_list->set_column_expand(0, false); - script_list->set_column_custom_minimum_width(0, 50 * EDSCALE); - script_list->set_column_expand(1, true); - script_list->set_column_custom_minimum_width(1, 80 * EDSCALE); - script_list->set_column_expand(2, false); - script_list->set_column_custom_minimum_width(2, 50 * EDSCALE); - script_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_script_remove)); - script_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - HBoxContainer *hb_ot = memnew(HBoxContainer); - page5_vb->add_child(hb_ot); - - label_ot = memnew(Label); - label_ot->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - label_ot->set_h_size_flags(Control::SIZE_EXPAND_FILL); - label_ot->set_text(TTR("OpenType feature overrides")); - hb_ot->add_child(label_ot); - - add_ot = memnew(Button); - hb_ot->add_child(add_ot); - add_ot->set_tooltip(TTR("Add feature override")); - add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - add_ot->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add)); - - ot_list = memnew(Tree); - page5_vb->add_child(ot_list); - ot_list->set_hide_root(true); - ot_list->set_columns(3); - ot_list->set_column_expand(0, true); - ot_list->set_column_custom_minimum_width(0, 80 * EDSCALE); - ot_list->set_column_expand(1, true); - ot_list->set_column_custom_minimum_width(1, 80 * EDSCALE); - ot_list->set_column_expand(2, false); - ot_list->set_column_custom_minimum_width(2, 50 * EDSCALE); - ot_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_remove)); - ot_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - // Common - - import_settings_data.instantiate(); - import_settings_data->owner = this; - - get_ok_button()->set_text(TTR("Reimport")); - get_cancel_button()->set_text(TTR("Close")); -} diff --git a/editor/import/dynamicfont_import_settings.h b/editor/import/dynamicfont_import_settings.h deleted file mode 100644 index 8892e20ae6..0000000000 --- a/editor/import/dynamicfont_import_settings.h +++ /dev/null @@ -1,182 +0,0 @@ -/*************************************************************************/ -/* dynamicfont_import_settings.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef FONTDATA_IMPORT_SETTINGS_H -#define FONTDATA_IMPORT_SETTINGS_H - -#include "editor/import/resource_importer_dynamicfont.h" - -#include "scene/gui/dialogs.h" -#include "scene/gui/item_list.h" -#include "scene/gui/option_button.h" -#include "scene/gui/split_container.h" -#include "scene/gui/subviewport_container.h" -#include "scene/gui/tab_container.h" -#include "scene/gui/text_edit.h" -#include "scene/gui/tree.h" - -#include "scene/resources/font.h" -#include "servers/text_server.h" - -class DynamicFontImportSettingsData; -class EditorFileDialog; -class EditorInspector; -class EditorLocaleDialog; - -class DynamicFontImportSettings : public ConfirmationDialog { - GDCLASS(DynamicFontImportSettings, ConfirmationDialog) - friend class DynamicFontImportSettingsData; - - enum ItemButton { - BUTTON_ADD_VAR, - BUTTON_REMOVE_VAR, - }; - - static DynamicFontImportSettings *singleton; - - String base_path; - - Ref import_settings_data; - List options_variations; - List options_general; - - EditorLocaleDialog *locale_select; - Vector script_codes; - - // Root layout - Label *label_warn = nullptr; - TabContainer *main_pages = nullptr; - - // Page 1 layout: Rendering Options - Label *page1_description = nullptr; - Label *font_preview_label = nullptr; - EditorInspector *inspector_general = nullptr; - - void _main_prop_changed(const String &p_edited_property); - - // Page 2 layout: Configurations - Label *page2_description = nullptr; - Label *label_vars = nullptr; - Button *add_var = nullptr; - Tree *vars_list = nullptr; - TreeItem *vars_list_root = nullptr; - EditorInspector *inspector_vars = nullptr; - - void _variation_add(); - void _variation_selected(); - void _variation_remove(Object *p_item, int p_column, int p_id); - void _variation_changed(const String &p_edited_property); - void _variations_validate(); - - // Page 3 layout: Text to select glyphs - Label *page3_description = nullptr; - Label *label_glyphs = nullptr; - TextEdit *text_edit = nullptr; - LineEdit *ftr_edit = nullptr; - LineEdit *lang_edit = nullptr; - - void _change_text_opts(); - void _glyph_text_selected(); - void _glyph_clear(); - - // Page 4 layout: Character map - Label *page4_description = nullptr; - Tree *glyph_table = nullptr; - Tree *glyph_tree = nullptr; - TreeItem *glyph_root = nullptr; - - void _glyph_selected(); - void _range_edited(); - void _range_selected(); - void _edit_range(int32_t p_start, int32_t p_end); - bool _char_update(int32_t p_char); - void _range_update(int32_t p_start, int32_t p_end); - - // Page 5 layout: Metadata override - Label *page5_description = nullptr; - Button *add_lang = nullptr; - Button *add_script = nullptr; - Button *add_ot = nullptr; - - PopupMenu *menu_scripts = nullptr; - PopupMenu *menu_ot = nullptr; - PopupMenu *menu_ot_ss = nullptr; - PopupMenu *menu_ot_cv = nullptr; - PopupMenu *menu_ot_cu = nullptr; - - Tree *lang_list = nullptr; - TreeItem *lang_list_root = nullptr; - Label *label_langs = nullptr; - - Tree *script_list = nullptr; - TreeItem *script_list_root = nullptr; - Label *label_script = nullptr; - - Tree *ot_list = nullptr; - TreeItem *ot_list_root = nullptr; - Label *label_ot = nullptr; - - void _lang_add(); - void _lang_add_item(const String &p_locale); - void _lang_remove(Object *p_item, int p_column, int p_id); - - void _script_add(); - void _script_add_item(int p_option); - void _script_remove(Object *p_item, int p_column, int p_id); - - void _ot_add(); - void _ot_add_item(int p_option); - void _ot_remove(Object *p_item, int p_column, int p_id); - - // Common - - void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name); - - Ref font_preview; - Ref font_main; - - Set selected_chars; - Set selected_glyphs; - - void _re_import(); - - String _pad_zeros(const String &p_hex) const; - -protected: - void _notification(int p_what); - -public: - void open_settings(const String &p_path); - static DynamicFontImportSettings *get_singleton(); - - DynamicFontImportSettings(); -}; - -#endif // FONTDATA_IMPORT_SETTINGS_H diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 16b68bcc22..46d15e8989 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -29,13 +29,11 @@ /*************************************************************************/ #include "resource_importer_bitmask.h" -#include "core/io/config_file.h" + #include "core/io/image.h" #include "core/io/image_loader.h" -#include "editor/editor_file_system.h" -#include "editor/editor_node.h" +#include "core/io/resource_saver.h" #include "scene/resources/bit_map.h" -#include "scene/resources/texture.h" String ResourceImporterBitMap::get_importer_name() const { return "bitmap"; diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index e5cf1facff..6dd6843171 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -31,11 +31,8 @@ #ifndef RESOURCE_IMPORTER_BITMASK_H #define RESOURCE_IMPORTER_BITMASK_H -#include "core/io/image.h" #include "core/io/resource_importer.h" -class StreamBitMap; - class ResourceImporterBitMap : public ResourceImporter { GDCLASS(ResourceImporterBitMap, ResourceImporter); diff --git a/editor/import/resource_importer_dynamic_font.cpp b/editor/import/resource_importer_dynamic_font.cpp new file mode 100644 index 0000000000..70fc87ea3f --- /dev/null +++ b/editor/import/resource_importer_dynamic_font.cpp @@ -0,0 +1,314 @@ +/*************************************************************************/ +/* resource_importer_dynamic_font.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "resource_importer_dynamic_font.h" + +#include "core/io/file_access.h" +#include "core/io/resource_saver.h" +#include "editor/import/dynamic_font_import_settings.h" +#include "scene/resources/font.h" +#include "servers/text_server.h" + +#include "modules/modules_enabled.gen.h" // For freetype. + +String ResourceImporterDynamicFont::get_importer_name() const { + return "font_data_dynamic"; +} + +String ResourceImporterDynamicFont::get_visible_name() const { + return "Font Data (Dynamic Font)"; +} + +void ResourceImporterDynamicFont::get_recognized_extensions(List *p_extensions) const { + if (p_extensions) { +#ifdef MODULE_FREETYPE_ENABLED + p_extensions->push_back("ttf"); + p_extensions->push_back("otf"); + p_extensions->push_back("woff"); + //p_extensions->push_back("woff2"); + p_extensions->push_back("pfb"); + p_extensions->push_back("pfm"); +#endif + } +} + +String ResourceImporterDynamicFont::get_save_extension() const { + return "fontdata"; +} + +String ResourceImporterDynamicFont::get_resource_type() const { + return "FontData"; +} + +bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const Map &p_options) const { + if (p_option == "msdf_pixel_range" && !bool(p_options["multichannel_signed_distance_field"])) { + return false; + } + if (p_option == "msdf_size" && !bool(p_options["multichannel_signed_distance_field"])) { + return false; + } + if (p_option == "oversampling" && bool(p_options["multichannel_signed_distance_field"])) { + return false; + } + if (p_option == "subpixel_positioning" && bool(p_options["multichannel_signed_distance_field"])) { + return false; + } + return true; +} + +int ResourceImporterDynamicFont::get_preset_count() const { + return PRESET_MAX; +} + +String ResourceImporterDynamicFont::get_preset_name(int p_idx) const { + switch (p_idx) { + case PRESET_DYNAMIC: + return TTR("Dynamically rendered TrueType/OpenType font"); + case PRESET_MSDF: + return TTR("Prerendered multichannel(+true) signed distance field"); + default: + return String(); + } +} + +void ResourceImporterDynamicFont::get_import_options(const String &p_path, List *r_options, int p_preset) const { + bool msdf = p_preset == PRESET_MSDF; + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), (msdf) ? true : false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48)); + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); + r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "opentype_feature_overrides"), Dictionary())); + + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/char_ranges"), Vector())); + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/glyph_ranges"), Vector())); + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/configurations"), Vector())); + + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/language_enabled"), Vector())); + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/language_disabled"), Vector())); + + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/script_enabled"), Vector())); + r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/script_disabled"), Vector())); +} + +bool ResourceImporterDynamicFont::_decode_variation(const String &p_token, Dictionary &r_variations, Vector2i &r_size, String &r_name, Vector2i &r_spacing) { + Vector tokens = p_token.split("="); + if (tokens.size() == 2) { + if (tokens[0] == "name") { + r_name = tokens[1]; + } else if (tokens[0] == "size") { + r_size.x = tokens[1].to_int(); + } else if (tokens[0] == "outline_size") { + r_size.y = tokens[1].to_int(); + } else if (tokens[0] == "spacing_space") { + r_spacing.x = tokens[1].to_int(); + } else if (tokens[0] == "spacing_glyph") { + r_spacing.y = tokens[1].to_int(); + } else { + r_variations[tokens[0]] = tokens[1].to_float(); + } + return true; + } else { + WARN_PRINT("Invalid variation: '" + p_token + "'."); + return false; + } +} + +bool ResourceImporterDynamicFont::_decode_range(const String &p_token, int32_t &r_pos) { + if (p_token.begins_with("U+") || p_token.begins_with("u+") || p_token.begins_with("0x")) { + // Unicode character hex index. + r_pos = p_token.substr(2).hex_to_int(); + return true; + } else if (p_token.length() == 3 && p_token[0] == '\'' && p_token[2] == '\'') { + // Unicode character. + r_pos = p_token.unicode_at(1); + return true; + } else if (p_token.is_numeric()) { + // Unicode character decimal index. + r_pos = p_token.to_int(); + return true; + } else { + return false; + } +} + +bool ResourceImporterDynamicFont::has_advanced_options() const { + return true; +} +void ResourceImporterDynamicFont::show_advanced_options(const String &p_path) { + DynamicFontImportSettings::get_singleton()->open_settings(p_path); +} + +Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { + print_verbose("Importing dynamic font from: " + p_source_file); + + bool antialiased = p_options["antialiased"]; + bool msdf = p_options["multichannel_signed_distance_field"]; + int px_range = p_options["msdf_pixel_range"]; + int px_size = p_options["msdf_size"]; + Dictionary ot_ov = p_options["opentype_feature_overrides"]; + + bool autohinter = p_options["force_autohinter"]; + int hinting = p_options["hinting"]; + int subpixel_positioning = p_options["subpixel_positioning"]; + real_t oversampling = p_options["oversampling"]; + + // Load base font data. + Vector data = FileAccess::get_file_as_array(p_source_file); + + // Create font. + Ref font; + font.instantiate(); + font->set_data(data); + font->set_antialiased(antialiased); + font->set_multichannel_signed_distance_field(msdf); + font->set_msdf_pixel_range(px_range); + font->set_msdf_size(px_size); + font->set_opentype_feature_overrides(ot_ov); + font->set_fixed_size(0); + font->set_force_autohinter(autohinter); + font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning); + font->set_hinting((TextServer::Hinting)hinting); + font->set_oversampling(oversampling); + + Vector lang_en = p_options["support_overrides/language_enabled"]; + for (int i = 0; i < lang_en.size(); i++) { + font->set_language_support_override(lang_en[i], true); + } + + Vector lang_dis = p_options["support_overrides/language_disabled"]; + for (int i = 0; i < lang_dis.size(); i++) { + font->set_language_support_override(lang_dis[i], false); + } + + Vector scr_en = p_options["support_overrides/script_enabled"]; + for (int i = 0; i < scr_en.size(); i++) { + font->set_script_support_override(scr_en[i], true); + } + + Vector scr_dis = p_options["support_overrides/script_disabled"]; + for (int i = 0; i < scr_dis.size(); i++) { + font->set_script_support_override(scr_dis[i], false); + } + + Vector variations = p_options["preload/configurations"]; + Vector char_ranges = p_options["preload/char_ranges"]; + Vector gl_ranges = p_options["preload/glyph_ranges"]; + + for (int i = 0; i < variations.size(); i++) { + String name; + Dictionary var; + Vector2i size = Vector2(16, 0); + Vector2i spacing; + + Vector variation_tags = variations[i].split(","); + for (int j = 0; j < variation_tags.size(); j++) { + if (!_decode_variation(variation_tags[j], var, size, name, spacing)) { + WARN_PRINT(vformat(TTR("Invalid variation: \"%s\""), variations[i])); + continue; + } + } + RID conf = font->find_cache(var); + + for (int j = 0; j < char_ranges.size(); j++) { + int32_t start, end; + Vector tokens = char_ranges[j].split("-"); + if (tokens.size() == 2) { + if (!_decode_range(tokens[0], start) || !_decode_range(tokens[1], end)) { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); + continue; + } + } else if (tokens.size() == 1) { + if (!_decode_range(tokens[0], start)) { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); + continue; + } + end = start; + } else { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); + continue; + } + + // Preload character ranges for each variations / sizes. + print_verbose(vformat(TTR("Pre-rendering range U+%s...%s from configuration \"%s\" (%d / %d)..."), String::num_int64(start, 16), String::num_int64(end, 16), name, i + 1, variations.size())); + TS->font_render_range(conf, size, start, end); + } + + for (int j = 0; j < gl_ranges.size(); j++) { + int32_t start, end; + Vector tokens = gl_ranges[j].split("-"); + if (tokens.size() == 2) { + if (!_decode_range(tokens[0], start) || !_decode_range(tokens[1], end)) { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); + continue; + } + } else if (tokens.size() == 1) { + if (!_decode_range(tokens[0], start)) { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); + continue; + } + end = start; + } else { + WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); + continue; + } + + // Preload glyph range for each variations / sizes. + print_verbose(vformat(TTR("Pre-rendering glyph range 0x%s...%s from configuration \"%s\" (%d / %d)..."), String::num_int64(start, 16), String::num_int64(end, 16), name, i + 1, variations.size())); + for (int32_t k = start; k <= end; k++) { + TS->font_render_glyph(conf, size, k); + } + } + + TS->font_set_spacing(conf, size.x, TextServer::SPACING_SPACE, spacing.x); + TS->font_set_spacing(conf, size.x, TextServer::SPACING_GLYPH, spacing.y); + } + + int flg = ResourceSaver::SaverFlags::FLAG_BUNDLE_RESOURCES | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; + if ((bool)p_options["compress"]) { + flg |= ResourceSaver::SaverFlags::FLAG_COMPRESS; + } + + print_verbose("Saving to: " + p_save_path + ".fontdata"); + Error err = ResourceSaver::save(p_save_path + ".fontdata", font, flg); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save font to file \"" + p_save_path + ".res\"."); + print_verbose("Done saving to: " + p_save_path + ".fontdata"); + return OK; +} + +ResourceImporterDynamicFont::ResourceImporterDynamicFont() { +} diff --git a/editor/import/resource_importer_dynamic_font.h b/editor/import/resource_importer_dynamic_font.h new file mode 100644 index 0000000000..2761b418e1 --- /dev/null +++ b/editor/import/resource_importer_dynamic_font.h @@ -0,0 +1,69 @@ +/*************************************************************************/ +/* resource_importer_dynamic_font.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef RESOURCE_IMPORTER_DYNAMIC_FONT_H +#define RESOURCE_IMPORTER_DYNAMIC_FONT_H + +#include "core/io/resource_importer.h" + +class ResourceImporterDynamicFont : public ResourceImporter { + GDCLASS(ResourceImporterDynamicFont, ResourceImporter); + + enum Presets { + PRESET_DYNAMIC, + PRESET_MSDF, + PRESET_MAX + }; + +public: + static bool _decode_range(const String &p_token, int32_t &r_pos); + static bool _decode_variation(const String &p_token, Dictionary &r_variations, Vector2i &r_size, String &r_name, Vector2i &r_spacing); + + virtual String get_importer_name() const override; + virtual String get_visible_name() const override; + virtual void get_recognized_extensions(List *p_extensions) const override; + virtual String get_save_extension() const override; + virtual String get_resource_type() const override; + + virtual int get_preset_count() const override; + virtual String get_preset_name(int p_idx) const override; + + virtual void get_import_options(const String &p_path, List *r_options, int p_preset = 0) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map &p_options) const override; + + bool has_advanced_options() const override; + void show_advanced_options(const String &p_path) override; + + virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; + + ResourceImporterDynamicFont(); +}; + +#endif // RESOURCE_IMPORTER_DYNAMIC_FONT_H diff --git a/editor/import/resource_importer_dynamicfont.cpp b/editor/import/resource_importer_dynamicfont.cpp deleted file mode 100644 index 42be76ba12..0000000000 --- a/editor/import/resource_importer_dynamicfont.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/*************************************************************************/ -/* resource_importer_dynamicfont.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "resource_importer_dynamicfont.h" - -#include "core/io/file_access.h" -#include "core/io/resource_saver.h" -#include "dynamicfont_import_settings.h" -#include "editor/editor_node.h" - -#include "modules/modules_enabled.gen.h" // For freetype. - -String ResourceImporterDynamicFont::get_importer_name() const { - return "font_data_dynamic"; -} - -String ResourceImporterDynamicFont::get_visible_name() const { - return "Font Data (Dynamic Font)"; -} - -void ResourceImporterDynamicFont::get_recognized_extensions(List *p_extensions) const { - if (p_extensions) { -#ifdef MODULE_FREETYPE_ENABLED - p_extensions->push_back("ttf"); - p_extensions->push_back("otf"); - p_extensions->push_back("woff"); - //p_extensions->push_back("woff2"); - p_extensions->push_back("pfb"); - p_extensions->push_back("pfm"); -#endif - } -} - -String ResourceImporterDynamicFont::get_save_extension() const { - return "fontdata"; -} - -String ResourceImporterDynamicFont::get_resource_type() const { - return "FontData"; -} - -bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const Map &p_options) const { - if (p_option == "msdf_pixel_range" && !bool(p_options["multichannel_signed_distance_field"])) { - return false; - } - if (p_option == "msdf_size" && !bool(p_options["multichannel_signed_distance_field"])) { - return false; - } - if (p_option == "oversampling" && bool(p_options["multichannel_signed_distance_field"])) { - return false; - } - if (p_option == "subpixel_positioning" && bool(p_options["multichannel_signed_distance_field"])) { - return false; - } - return true; -} - -int ResourceImporterDynamicFont::get_preset_count() const { - return PRESET_MAX; -} - -String ResourceImporterDynamicFont::get_preset_name(int p_idx) const { - switch (p_idx) { - case PRESET_DYNAMIC: - return TTR("Dynamically rendered TrueType/OpenType font"); - case PRESET_MSDF: - return TTR("Prerendered multichannel(+true) signed distance field"); - default: - return String(); - } -} - -void ResourceImporterDynamicFont::get_import_options(const String &p_path, List *r_options, int p_preset) const { - bool msdf = p_preset == PRESET_MSDF; - - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), (msdf) ? true : false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48)); - - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); - r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); - - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "opentype_feature_overrides"), Dictionary())); - - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/char_ranges"), Vector())); - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/glyph_ranges"), Vector())); - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/configurations"), Vector())); - - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/language_enabled"), Vector())); - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/language_disabled"), Vector())); - - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/script_enabled"), Vector())); - r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "support_overrides/script_disabled"), Vector())); -} - -bool ResourceImporterDynamicFont::_decode_variation(const String &p_token, Dictionary &r_variations, Vector2i &r_size, String &r_name, Vector2i &r_spacing) { - Vector tokens = p_token.split("="); - if (tokens.size() == 2) { - if (tokens[0] == "name") { - r_name = tokens[1]; - } else if (tokens[0] == "size") { - r_size.x = tokens[1].to_int(); - } else if (tokens[0] == "outline_size") { - r_size.y = tokens[1].to_int(); - } else if (tokens[0] == "spacing_space") { - r_spacing.x = tokens[1].to_int(); - } else if (tokens[0] == "spacing_glyph") { - r_spacing.y = tokens[1].to_int(); - } else { - r_variations[tokens[0]] = tokens[1].to_float(); - } - return true; - } else { - WARN_PRINT("Invalid variation: '" + p_token + "'."); - return false; - } -} - -bool ResourceImporterDynamicFont::_decode_range(const String &p_token, int32_t &r_pos) { - if (p_token.begins_with("U+") || p_token.begins_with("u+") || p_token.begins_with("0x")) { - // Unicode character hex index. - r_pos = p_token.substr(2).hex_to_int(); - return true; - } else if (p_token.length() == 3 && p_token[0] == '\'' && p_token[2] == '\'') { - // Unicode character. - r_pos = p_token.unicode_at(1); - return true; - } else if (p_token.is_numeric()) { - // Unicode character decimal index. - r_pos = p_token.to_int(); - return true; - } else { - return false; - } -} - -bool ResourceImporterDynamicFont::has_advanced_options() const { - return true; -} -void ResourceImporterDynamicFont::show_advanced_options(const String &p_path) { - DynamicFontImportSettings::get_singleton()->open_settings(p_path); -} - -Error ResourceImporterDynamicFont::import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { - print_verbose("Importing dynamic font from: " + p_source_file); - - bool antialiased = p_options["antialiased"]; - bool msdf = p_options["multichannel_signed_distance_field"]; - int px_range = p_options["msdf_pixel_range"]; - int px_size = p_options["msdf_size"]; - Dictionary ot_ov = p_options["opentype_feature_overrides"]; - - bool autohinter = p_options["force_autohinter"]; - int hinting = p_options["hinting"]; - int subpixel_positioning = p_options["subpixel_positioning"]; - real_t oversampling = p_options["oversampling"]; - - // Load base font data. - Vector data = FileAccess::get_file_as_array(p_source_file); - - // Create font. - Ref font; - font.instantiate(); - font->set_data(data); - font->set_antialiased(antialiased); - font->set_multichannel_signed_distance_field(msdf); - font->set_msdf_pixel_range(px_range); - font->set_msdf_size(px_size); - font->set_opentype_feature_overrides(ot_ov); - font->set_fixed_size(0); - font->set_force_autohinter(autohinter); - font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning); - font->set_hinting((TextServer::Hinting)hinting); - font->set_oversampling(oversampling); - - Vector lang_en = p_options["support_overrides/language_enabled"]; - for (int i = 0; i < lang_en.size(); i++) { - font->set_language_support_override(lang_en[i], true); - } - - Vector lang_dis = p_options["support_overrides/language_disabled"]; - for (int i = 0; i < lang_dis.size(); i++) { - font->set_language_support_override(lang_dis[i], false); - } - - Vector scr_en = p_options["support_overrides/script_enabled"]; - for (int i = 0; i < scr_en.size(); i++) { - font->set_script_support_override(scr_en[i], true); - } - - Vector scr_dis = p_options["support_overrides/script_disabled"]; - for (int i = 0; i < scr_dis.size(); i++) { - font->set_script_support_override(scr_dis[i], false); - } - - Vector variations = p_options["preload/configurations"]; - Vector char_ranges = p_options["preload/char_ranges"]; - Vector gl_ranges = p_options["preload/glyph_ranges"]; - - for (int i = 0; i < variations.size(); i++) { - String name; - Dictionary var; - Vector2i size = Vector2(16, 0); - Vector2i spacing; - - Vector variation_tags = variations[i].split(","); - for (int j = 0; j < variation_tags.size(); j++) { - if (!_decode_variation(variation_tags[j], var, size, name, spacing)) { - WARN_PRINT(vformat(TTR("Invalid variation: \"%s\""), variations[i])); - continue; - } - } - RID conf = font->find_cache(var); - - for (int j = 0; j < char_ranges.size(); j++) { - int32_t start, end; - Vector tokens = char_ranges[j].split("-"); - if (tokens.size() == 2) { - if (!_decode_range(tokens[0], start) || !_decode_range(tokens[1], end)) { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); - continue; - } - } else if (tokens.size() == 1) { - if (!_decode_range(tokens[0], start)) { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); - continue; - } - end = start; - } else { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), char_ranges[j])); - continue; - } - - // Preload character ranges for each variations / sizes. - print_verbose(vformat(TTR("Pre-rendering range U+%s...%s from configuration \"%s\" (%d / %d)..."), String::num_int64(start, 16), String::num_int64(end, 16), name, i + 1, variations.size())); - TS->font_render_range(conf, size, start, end); - } - - for (int j = 0; j < gl_ranges.size(); j++) { - int32_t start, end; - Vector tokens = gl_ranges[j].split("-"); - if (tokens.size() == 2) { - if (!_decode_range(tokens[0], start) || !_decode_range(tokens[1], end)) { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); - continue; - } - } else if (tokens.size() == 1) { - if (!_decode_range(tokens[0], start)) { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); - continue; - } - end = start; - } else { - WARN_PRINT(vformat(TTR("Invalid range: \"%s\""), gl_ranges[j])); - continue; - } - - // Preload glyph range for each variations / sizes. - print_verbose(vformat(TTR("Pre-rendering glyph range 0x%s...%s from configuration \"%s\" (%d / %d)..."), String::num_int64(start, 16), String::num_int64(end, 16), name, i + 1, variations.size())); - for (int32_t k = start; k <= end; k++) { - TS->font_render_glyph(conf, size, k); - } - } - - TS->font_set_spacing(conf, size.x, TextServer::SPACING_SPACE, spacing.x); - TS->font_set_spacing(conf, size.x, TextServer::SPACING_GLYPH, spacing.y); - } - - int flg = ResourceSaver::SaverFlags::FLAG_BUNDLE_RESOURCES | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; - if ((bool)p_options["compress"]) { - flg |= ResourceSaver::SaverFlags::FLAG_COMPRESS; - } - - print_verbose("Saving to: " + p_save_path + ".fontdata"); - Error err = ResourceSaver::save(p_save_path + ".fontdata", font, flg); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save font to file \"" + p_save_path + ".res\"."); - print_verbose("Done saving to: " + p_save_path + ".fontdata"); - return OK; -} - -ResourceImporterDynamicFont::ResourceImporterDynamicFont() { -} diff --git a/editor/import/resource_importer_dynamicfont.h b/editor/import/resource_importer_dynamicfont.h deleted file mode 100644 index a55d639e10..0000000000 --- a/editor/import/resource_importer_dynamicfont.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************/ -/* resource_importer_dynamicfont.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef RESOURCE_IMPORTER_FONT_DATA_H -#define RESOURCE_IMPORTER_FONT_DATA_H - -#include "core/io/resource_importer.h" -#include "scene/resources/font.h" -#include "servers/text_server.h" - -class ResourceImporterDynamicFont : public ResourceImporter { - GDCLASS(ResourceImporterDynamicFont, ResourceImporter); - - enum Presets { - PRESET_DYNAMIC, - PRESET_MSDF, - PRESET_MAX - }; - -public: - static bool _decode_range(const String &p_token, int32_t &r_pos); - static bool _decode_variation(const String &p_token, Dictionary &r_variations, Vector2i &r_size, String &r_name, Vector2i &r_spacing); - - virtual String get_importer_name() const override; - virtual String get_visible_name() const override; - virtual void get_recognized_extensions(List *p_extensions) const override; - virtual String get_save_extension() const override; - virtual String get_resource_type() const override; - - virtual int get_preset_count() const override; - virtual String get_preset_name(int p_idx) const override; - - virtual void get_import_options(const String &p_path, List *r_options, int p_preset = 0) const override; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map &p_options) const override; - - bool has_advanced_options() const override; - void show_advanced_options(const String &p_path) override; - - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; - - ResourceImporterDynamicFont(); -}; - -#endif // RESOURCE_IMPORTER_FONTDATA_H diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 3ecf084ab1..767e2a7fad 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -31,6 +31,7 @@ #include "import_defaults_editor.h" #include "core/config/project_settings.h" +#include "core/io/resource_importer.h" #include "editor/action_map_editor.h" #include "editor/editor_autoload_settings.h" #include "editor/editor_plugin_settings.h" diff --git a/editor/import_defaults_editor.h b/editor/import_defaults_editor.h index 8eb6584b1e..ed94fe6156 100644 --- a/editor/import_defaults_editor.h +++ b/editor/import_defaults_editor.h @@ -32,6 +32,7 @@ #define IMPORT_DEFAULTS_EDITOR_H #include "scene/gui/box_container.h" +#include "scene/gui/button.h" #include "scene/gui/option_button.h" class ImportDefaultsEditorSettings; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 6df8dab8e7..087e51b0cb 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -33,7 +33,7 @@ #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" -#include "editor/plugins/animation_player_editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" InspectorDock *InspectorDock::singleton = nullptr; diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 97c53ff63e..27552407bd 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -31,15 +31,17 @@ #ifndef INSPECTOR_DOCK_H #define INSPECTOR_DOCK_H -#include "editor/animation_track_editor.h" #include "editor/create_dialog.h" #include "editor/editor_data.h" #include "editor/editor_inspector.h" #include "editor/editor_path.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" +#include "scene/gui/dialogs.h" +#include "scene/gui/line_edit.h" +#include "scene/gui/menu_button.h" +#include "scene/gui/tree.h" -class EditorNode; class EditorFileDialog; class InspectorDock : public VBoxContainer { diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 0c7b160db4..c0e7c1be2e 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -35,7 +35,6 @@ #include "scene/2d/polygon_2d.h" #include "scene/gui/box_container.h" -class EditorNode; class CanvasItemEditor; class AbstractPolygon2DEditor : public HBoxContainer { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index a52f901e5f..b1b905a3f5 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -40,7 +40,6 @@ #include "scene/gui/popup.h" #include "scene/gui/tree.h" -class EditorNode; class ProgressBar; class EditorFileDialog; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index a273debefb..28b1126102 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -35,7 +35,6 @@ #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/os/keyboard.h" -#include "editor/animation_track_editor.h" #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 8f469dd32f..446c4d2f0e 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -31,6 +31,7 @@ #ifndef ANIMATION_PLAYER_EDITOR_PLUGIN_H #define ANIMATION_PLAYER_EDITOR_PLUGIN_H +#include "editor/animation_track_editor.h" #include "editor/editor_plugin.h" #include "scene/animation/animation_player.h" #include "scene/gui/dialogs.h" @@ -39,9 +40,7 @@ #include "scene/gui/texture_button.h" #include "scene/gui/tree.h" -class EditorNode; class EditorFileDialog; -class AnimationTrackEditor; class AnimationPlayerEditorPlugin; class AnimationPlayerEditor : public VBoxContainer { diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index b739bf8b3c..5442584a40 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -39,8 +39,8 @@ #include "scene/gui/popup.h" #include "scene/gui/tree.h" -class EditorNode; class EditorFileDialog; + class AnimationTreeNodeEditorPlugin : public VBoxContainer { GDCLASS(AnimationTreeNodeEditorPlugin, VBoxContainer); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index f2c4ca3d5e..7ab9fa05f7 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -36,6 +36,7 @@ #include "core/version.h" #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/project_settings_editor.h" diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h index 3decc348f4..2478210430 100644 --- a/editor/plugins/audio_stream_editor_plugin.h +++ b/editor/plugins/audio_stream_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/gui/color_rect.h" #include "scene/resources/texture.h" -class EditorNode; class AudioStreamEditor : public ColorRect { GDCLASS(AudioStreamEditor, ColorRect); diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp index 3b0d57da0a..9e551ae0ed 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp @@ -30,6 +30,8 @@ #include "audio_stream_randomizer_editor_plugin.h" +#include "editor/editor_node.h" + void AudioStreamRandomizerEditorPlugin::edit(Object *p_object) { } diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.h b/editor/plugins/audio_stream_randomizer_editor_plugin.h index 8d0630947a..7e509dc670 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.h +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.h @@ -31,7 +31,6 @@ #ifndef AUDIO_STREAM_RANDOMIZER_EDITOR_PLUGIN_H #define AUDIO_STREAM_RANDOMIZER_EDITOR_PLUGIN_H -#include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "servers/audio/audio_stream.h" diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h index 50dcc0900f..c1f71d3b1b 100644 --- a/editor/plugins/camera_3d_editor_plugin.h +++ b/editor/plugins/camera_3d_editor_plugin.h @@ -34,8 +34,6 @@ #include "editor/editor_plugin.h" #include "scene/3d/camera_3d.h" -class EditorNode; - class Camera3DEditor : public Control { GDCLASS(Camera3DEditor, Control); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index eacaa61f96..6c1b18acf4 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -42,7 +42,6 @@ #include "scene/gui/texture_rect.h" #include "scene/main/canvas_item.h" -class EditorNode; class EditorData; class CanvasItemEditorViewport; class ViewPanner; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index fddae88220..033ea3db93 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -32,10 +32,8 @@ #define COLLISION_SHAPE_2D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" - #include "scene/2d/collision_shape_2d.h" -class EditorNode; class CanvasItemEditor; class CollisionShape2DEditor : public Control { diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 8d2ba1bbaf..e6f267673c 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -30,6 +30,7 @@ #include "control_editor_plugin.h" +#include "editor/editor_node.h" #include "editor/plugins/canvas_item_editor_plugin.h" void ControlPositioningWarning::_update_warning() { diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h index 93073a3595..bbbada2b3f 100644 --- a/editor/plugins/control_editor_plugin.h +++ b/editor/plugins/control_editor_plugin.h @@ -31,9 +31,7 @@ #ifndef CONTROL_EDITOR_PLUGIN_H #define CONTROL_EDITOR_PLUGIN_H -#include "editor/editor_node.h" #include "editor/editor_plugin.h" - #include "scene/gui/box_container.h" #include "scene/gui/check_box.h" #include "scene/gui/control.h" diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h index 54a27146c3..b10ed73e38 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.h +++ b/editor/plugins/cpu_particles_2d_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/2d/cpu_particles_2d.h" #include "scene/gui/box_container.h" -class EditorNode; class EditorPlugin; class SpinBox; class EditorFileDialog; diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index f03b272633..0501936574 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -34,8 +34,6 @@ #include "editor/plugins/gpu_particles_3d_editor_plugin.h" #include "scene/3d/cpu_particles_3d.h" -class EditorNode; - class CPUParticles3DEditor : public GPUParticles3DEditorBase { GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase); diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index fe2aa52d1f..4aba2fffd0 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -35,8 +35,6 @@ #include "editor/editor_resource_preview.h" #include "scene/resources/curve.h" -class EditorNode; - // Edits a y(x) curve class CurveEditor : public Control { GDCLASS(CurveEditor, Control); diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index aa71ae0413..32f58c6931 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -36,6 +36,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/fileserver/editor_file_server.h" +#include "editor/plugins/script_editor_plugin.h" #include "scene/gui/menu_button.h" DebuggerEditorPlugin::DebuggerEditorPlugin(MenuButton *p_debug_menu) { diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h index 9ac3115c6a..c024526285 100644 --- a/editor/plugins/debugger_editor_plugin.h +++ b/editor/plugins/debugger_editor_plugin.h @@ -33,7 +33,6 @@ #include "editor/editor_plugin.h" -class EditorNode; class EditorFileServer; class MenuButton; class PopupMenu; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 5dd92d3c3f..b8556220d2 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -34,7 +34,7 @@ #include "core/io/file_access_memory.h" #include "core/io/resource_loader.h" #include "core/os/os.h" -#include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "scene/resources/bit_map.h" diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index dd64918d41..803f03f17e 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -31,9 +31,8 @@ #ifndef EDITORPREVIEWPLUGINS_H #define EDITORPREVIEWPLUGINS_H -#include "editor/editor_resource_preview.h" - #include "core/templates/safe_refcount.h" +#include "editor/editor_resource_preview.h" void post_process_preview(Ref p_image); diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp index e86b38fd0e..e14304a2c8 100644 --- a/editor/plugins/font_editor_plugin.cpp +++ b/editor/plugins/font_editor_plugin.cpp @@ -30,7 +30,6 @@ #include "font_editor_plugin.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" void FontDataPreview::_notification(int p_what) { diff --git a/editor/plugins/font_editor_plugin.h b/editor/plugins/font_editor_plugin.h index c55346aa4c..3f0700d880 100644 --- a/editor/plugins/font_editor_plugin.h +++ b/editor/plugins/font_editor_plugin.h @@ -35,8 +35,6 @@ #include "scene/resources/font.h" #include "scene/resources/text_line.h" -class EditorNode; - class FontDataPreview : public Control { GDCLASS(FontDataPreview, Control); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 0f4a906f04..f94ce632e9 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/box_container.h" #include "scene/gui/spin_box.h" -class EditorNode; class EditorFileDialog; class GPUParticles2DEditorPlugin : public EditorPlugin { diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index 879260d5e3..39aa596ece 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/gpu_particles_3d.h" #include "scene/gui/spin_box.h" -class EditorNode; class SceneTreeDialog; class GPUParticles3DEditorBase : public Control { diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h index 4677e0bc86..f6e4fd3dec 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/gpu_particles_collision_3d.h" #include "scene/resources/material.h" -class EditorNode; struct EditorProgress; class EditorFileDialog; diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h index 41bfff3c27..9857ea018d 100644 --- a/editor/plugins/gradient_editor_plugin.h +++ b/editor/plugins/gradient_editor_plugin.h @@ -34,8 +34,6 @@ #include "editor/editor_plugin.h" #include "scene/gui/gradient_edit.h" -class EditorNode; - class GradientEditor : public GradientEdit { GDCLASS(GradientEditor, GradientEdit); diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index 9f4f9a5646..b4a7081ebc 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -30,8 +30,6 @@ #include "input_event_editor_plugin.h" -#include "editor/editor_node.h" - void InputEventConfigContainer::_bind_methods() { } diff --git a/editor/plugins/input_event_editor_plugin.h b/editor/plugins/input_event_editor_plugin.h index 9e8746895f..ab948462ab 100644 --- a/editor/plugins/input_event_editor_plugin.h +++ b/editor/plugins/input_event_editor_plugin.h @@ -33,8 +33,7 @@ #include "editor/action_map_editor.h" #include "editor/editor_inspector.h" - -class EditorNode; +#include "editor/editor_plugin.h" class InputEventConfigContainer : public HBoxContainer { GDCLASS(InputEventConfigContainer, HBoxContainer); diff --git a/editor/plugins/lightmap_gi_editor_plugin.h b/editor/plugins/lightmap_gi_editor_plugin.h index 99f85279e9..e658230181 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.h +++ b/editor/plugins/lightmap_gi_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/lightmap_gi.h" #include "scene/resources/material.h" -class EditorNode; struct EditorProgress; class EditorFileDialog; diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 5b4af6ba46..9c6247d59b 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -31,17 +31,15 @@ #ifndef MATERIAL_EDITOR_PLUGIN_H #define MATERIAL_EDITOR_PLUGIN_H -#include "editor/property_editor.h" -#include "scene/resources/primitive_meshes.h" - #include "editor/editor_plugin.h" +#include "editor/property_editor.h" #include "scene/3d/camera_3d.h" #include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/gui/color_rect.h" #include "scene/resources/material.h" +#include "scene/resources/primitive_meshes.h" -class EditorNode; class SubViewportContainer; class MaterialEditor : public Control { diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index b8e7868ccc..8711559dbf 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -30,7 +30,6 @@ #include "mesh_editor_plugin.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" void MeshEditor::gui_input(const Ref &p_event) { diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index fc5139b62a..37464c98fe 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -38,8 +38,6 @@ #include "scene/gui/subviewport_container.h" #include "scene/resources/material.h" -class EditorNode; - class MeshEditor : public SubViewportContainer { GDCLASS(MeshEditor, SubViewportContainer); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h index e489b7adde..9c59c5fb9f 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.h +++ b/editor/plugins/mesh_instance_3d_editor_plugin.h @@ -35,8 +35,6 @@ #include "scene/3d/mesh_instance_3d.h" #include "scene/gui/spin_box.h" -class EditorNode; - class MeshInstance3DEditor : public Control { GDCLASS(MeshInstance3DEditor, Control); diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h index 7b1676a8f8..6bc992869b 100644 --- a/editor/plugins/mesh_library_editor_plugin.h +++ b/editor/plugins/mesh_library_editor_plugin.h @@ -34,7 +34,6 @@ #include "editor/editor_plugin.h" #include "scene/resources/mesh_library.h" -class EditorNode; class EditorFileDialog; class ConfirmationDialog; class MenuButton; diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h index eaa4b4cc5e..846e6d17f3 100644 --- a/editor/plugins/multimesh_editor_plugin.h +++ b/editor/plugins/multimesh_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/gui/slider.h" #include "scene/gui/spin_box.h" -class EditorNode; class SceneTreeDialog; class MultiMeshEditor : public Control { diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index a374d9158e..9e92a1e9b3 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -47,7 +47,6 @@ #include "scene/resources/fog_material.h" #include "scene/resources/sky_material.h" -class EditorNode; class EditorData; class Node3DEditor; class Node3DEditorViewport; diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.h b/editor/plugins/occluder_instance_3d_editor_plugin.h index 5bc2d95542..24f31b2ea8 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.h +++ b/editor/plugins/occluder_instance_3d_editor_plugin.h @@ -35,8 +35,6 @@ #include "scene/3d/occluder_instance_3d.h" #include "scene/resources/material.h" -class EditorNode; -struct EditorProgress; class EditorFileDialog; class OccluderInstance3DEditorPlugin : public EditorPlugin { diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index 2c6be5179d..719b9ecc7c 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -30,9 +30,6 @@ #include "ot_features_plugin.h" -#include "editor/editor_node.h" -#include "editor/editor_scale.h" - void OpenTypeFeaturesEditor::_value_changed(double val) { if (setting) { return; diff --git a/editor/plugins/ot_features_plugin.h b/editor/plugins/ot_features_plugin.h index 5eb10c9c08..8c38d888de 100644 --- a/editor/plugins/ot_features_plugin.h +++ b/editor/plugins/ot_features_plugin.h @@ -34,8 +34,6 @@ #include "editor/editor_plugin.h" #include "editor/editor_properties.h" -class EditorNode; - /*************************************************************************/ class OpenTypeFeaturesEditor : public EditorProperty { diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index 220131c983..926a859f8b 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/2d/path_2d.h" #include "scene/gui/separator.h" -class EditorNode; class CanvasItemEditor; class Path2DEditor : public HBoxContainer { diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 97c602360a..3c6ca65437 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -37,8 +37,6 @@ #include "scene/3d/path_3d.h" #include "scene/gui/separator.h" -class EditorNode; - class Path3DGizmo : public EditorNode3DGizmo { GDCLASS(Path3DGizmo, EditorNode3DGizmo); diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index eecb5f9385..e815a9c9f6 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -30,9 +30,7 @@ #include "physical_bone_3d_editor_plugin.h" -#include "editor/editor_node.h" #include "editor/plugins/node_3d_editor_plugin.h" -#include "scene/3d/physics_body_3d.h" void PhysicalBone3DEditor::_bind_methods() { } diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h index 75548d902b..4051644b54 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.h +++ b/editor/plugins/physical_bone_3d_editor_plugin.h @@ -36,8 +36,6 @@ #include "scene/gui/box_container.h" #include "scene/gui/button.h" -class EditorNode; - class PhysicalBone3DEditor : public Object { GDCLASS(PhysicalBone3DEditor, Object); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 4c1c11ebff..22b79921bb 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -30,13 +30,11 @@ #include "polygon_2d_editor_plugin.h" -#include "canvas_item_editor_plugin.h" -#include "core/input/input.h" -#include "core/io/file_access.h" +#include "core/input/input_event.h" #include "core/math/geometry_2d.h" -#include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/plugins/canvas_item_editor_plugin.h" #include "scene/2d/skeleton_2d.h" #include "scene/gui/menu_button.h" #include "scene/gui/scroll_container.h" diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 387c3bb12b..0a5def902c 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -33,11 +33,11 @@ #include "editor/plugins/abstract_polygon_2d_editor.h" -class ViewPanner; -class ScrollContainer; -class Panel; class HSlider; +class Panel; +class ScrollContainer; class SpinBox; +class ViewPanner; class Polygon2DEditor : public AbstractPolygon2DEditor { GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor); diff --git a/editor/plugins/polygon_3d_editor_plugin.h b/editor/plugins/polygon_3d_editor_plugin.h index 537440150a..e92dcaf319 100644 --- a/editor/plugins/polygon_3d_editor_plugin.h +++ b/editor/plugins/polygon_3d_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/3d/mesh_instance_3d.h" #include "scene/resources/immediate_mesh.h" -class EditorNode; class CanvasItemEditor; class Polygon3DEditor : public HBoxContainer { diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp index aaae6554d7..604cbcd103 100644 --- a/editor/plugins/replication_editor_plugin.cpp +++ b/editor/plugins/replication_editor_plugin.cpp @@ -30,6 +30,7 @@ #include "replication_editor_plugin.h" +#include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/inspector_dock.h" #include "scene/gui/dialogs.h" diff --git a/editor/plugins/replication_editor_plugin.h b/editor/plugins/replication_editor_plugin.h index e7f2ecd151..46274d188c 100644 --- a/editor/plugins/replication_editor_plugin.h +++ b/editor/plugins/replication_editor_plugin.h @@ -31,7 +31,6 @@ #ifndef REPLICATION_EDITOR_PLUGIN_H #define REPLICATION_EDITOR_PLUGIN_H -#include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "scene/resources/scene_replication_config.h" diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h index 087c26e19d..8e81239f1b 100644 --- a/editor/plugins/resource_preloader_editor_plugin.h +++ b/editor/plugins/resource_preloader_editor_plugin.h @@ -36,8 +36,6 @@ #include "scene/gui/tree.h" #include "scene/main/resource_preloader.h" -class EditorNode; -struct EditorProgress; class EditorFileDialog; class ResourcePreloaderEditor : public PanelContainer { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 07e818a0c1..a99e269d46 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -47,8 +47,6 @@ #include "scene/main/timer.h" #include "scene/resources/text_file.h" -class EditorNode; -struct EditorProgress; class EditorFileDialog; class EditorSyntaxHighlighter : public SyntaxHighlighter { diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h index b6f6f8aaa1..004dac7b05 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.h +++ b/editor/plugins/skeleton_2d_editor_plugin.h @@ -35,8 +35,6 @@ #include "scene/2d/skeleton_2d.h" #include "scene/gui/spin_box.h" -class EditorNode; - class Skeleton2DEditor : public Control { GDCLASS(Skeleton2DEditor, Control); diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index e1f75a6ab1..2dbb552428 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/3d/skeleton_3d.h" #include "scene/resources/immediate_mesh.h" -class EditorNode; class EditorInspectorPluginSkeleton; class Joint; class PhysicalBone3D; diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h index ec5d3114b0..f71e788232 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.h +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h @@ -33,7 +33,6 @@ #include "editor/editor_plugin.h" -class EditorNode; class SkeletonIK3D; class SkeletonIK3DEditorPlugin : public EditorPlugin { diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index 87241cad63..3e4cc17cdd 100644 --- a/editor/plugins/sprite_2d_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -35,8 +35,6 @@ #include "scene/2d/sprite_2d.h" #include "scene/gui/spin_box.h" -class EditorNode; - class Sprite2DEditor : public Control { GDCLASS(Sprite2DEditor, Control); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 9d65cafd2a..461c8dd41a 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -43,8 +43,6 @@ #include "scene/gui/texture_rect.h" #include "scene/gui/tree.h" -class EditorNode; -struct EditorProgress; class EditorFileDialog; class SpriteFramesEditor : public HSplitContainer { diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index f024a8c7d8..a3cbaf527e 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -30,7 +30,6 @@ #include "style_box_editor_plugin.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index bfec9401d2..bdebebbe1c 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -37,8 +37,6 @@ #include "scene/gui/texture_rect.h" #include "scene/resources/style_box.h" -class EditorNode; - class StyleBoxPreview : public VBoxContainer { GDCLASS(StyleBoxPreview, VBoxContainer); diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index 93cb51efe3..c8bb0cd56f 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -30,8 +30,6 @@ #include "sub_viewport_preview_editor_plugin.h" -#include "editor/editor_node.h" - bool EditorInspectorPluginSubViewportPreview::can_handle(Object *p_object) { return Object::cast_to(p_object) != nullptr; } diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.h b/editor/plugins/sub_viewport_preview_editor_plugin.h index 6089bcbf41..269553ffb1 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.h +++ b/editor/plugins/sub_viewport_preview_editor_plugin.h @@ -35,8 +35,6 @@ #include "editor/plugins/texture_editor_plugin.h" #include "scene/main/viewport.h" -class EditorNode; - class EditorInspectorPluginSubViewportPreview : public EditorInspectorPluginTexture { GDCLASS(EditorInspectorPluginSubViewportPreview, EditorInspectorPluginTexture); diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h index 607360ec15..1d65073c98 100644 --- a/editor/plugins/text_control_editor_plugin.h +++ b/editor/plugins/text_control_editor_plugin.h @@ -43,8 +43,6 @@ /*************************************************************************/ -class EditorNode; - class TextControlEditor : public HBoxContainer { GDCLASS(TextControlEditor, HBoxContainer); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 7b81269d20..880cbeffba 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -30,11 +30,6 @@ #include "texture_3d_editor_plugin.h" -#include "core/config/project_settings.h" -#include "core/io/resource_loader.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" - void Texture3DEditor::_texture_rect_draw() { texture_rect->draw_rect(Rect2(Point2(), texture_rect->get_size()), Color(1, 1, 1, 1)); } diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h index 5912b24328..d418032477 100644 --- a/editor/plugins/texture_3d_editor_plugin.h +++ b/editor/plugins/texture_3d_editor_plugin.h @@ -36,8 +36,6 @@ #include "scene/resources/shader.h" #include "scene/resources/texture.h" -class EditorNode; - class Texture3DEditor : public Control { GDCLASS(Texture3DEditor, Control); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index ac40b4afb3..17fe4fdc50 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -30,7 +30,6 @@ #include "texture_editor_plugin.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" TextureRect *TexturePreview::get_texture_display() { diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 1e2a37b1a3..9beada556c 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -34,8 +34,6 @@ #include "editor/editor_plugin.h" #include "scene/resources/texture.h" -class EditorNode; - class TexturePreview : public MarginContainer { GDCLASS(TexturePreview, MarginContainer); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index d18d45ff86..22f4cebf2e 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -30,11 +30,6 @@ #include "texture_layered_editor_plugin.h" -#include "core/config/project_settings.h" -#include "core/io/resource_loader.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" - void TextureLayeredEditor::gui_input(const Ref &p_event) { ERR_FAIL_COND(p_event.is_null()); diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h index 991e81b967..1c59ec4db0 100644 --- a/editor/plugins/texture_layered_editor_plugin.h +++ b/editor/plugins/texture_layered_editor_plugin.h @@ -36,8 +36,6 @@ #include "scene/resources/shader.h" #include "scene/resources/texture.h" -class EditorNode; - class TextureLayeredEditor : public Control { GDCLASS(TextureLayeredEditor, Control); diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index 3bfc9d3e16..041742c28a 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" -class EditorNode; class ViewPanner; class TextureRegionEditor : public VBoxContainer { diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index ad409bfc11..7c1b0cda3e 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -44,7 +44,6 @@ #include "scene/gui/tree.h" #include "scene/resources/theme.h" -class EditorNode; class EditorFileDialog; class ThemeItemImportTree : public VBoxContainer { diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index ab93198903..48111df399 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -38,8 +38,6 @@ #include "scene/gui/scroll_container.h" #include "scene/resources/theme.h" -class EditorNode; - class ThemeEditorPreview : public VBoxContainer { GDCLASS(ThemeEditorPreview, VBoxContainer); diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h index 6fc1a3b7e0..6cf555247d 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.h +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -32,13 +32,11 @@ #define ATLAS_MERGING_DIALOG_H #include "editor/editor_properties.h" - #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" #include "scene/gui/texture_rect.h" #include "scene/resources/tile_set.h" -class EditorNode; class EditorFileDialog; class AtlasMergingDialog : public ConfirmationDialog { diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index 49e8cacac8..d09061015f 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -46,7 +46,6 @@ #include "scene/gui/tab_bar.h" #include "scene/gui/tree.h" -class EditorNode; class UndoRedo; class TileMapEditorPlugin : public Object { diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.h b/editor/plugins/tiles/tile_proxies_manager_dialog.h index 4c8741c660..3f1461391e 100644 --- a/editor/plugins/tiles/tile_proxies_manager_dialog.h +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.h @@ -32,13 +32,10 @@ #define TILE_PROXIES_MANAGER_DIALOG_H #include "editor/editor_properties.h" - #include "scene/2d/tile_map.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" -class EditorNode; - class TileProxiesManagerDialog : public ConfirmationDialog { GDCLASS(TileProxiesManagerDialog, ConfirmationDialog); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index f0c8367d57..4a90b821f8 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -37,7 +37,6 @@ #include "scene/gui/split_container.h" #include "scene/resources/tile_set.h" -class EditorNode; class TileSet; class TileSetAtlasSourceEditor : public HBoxContainer { diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 9ca50497af..97b342c6a7 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -33,6 +33,7 @@ #include "tile_data_editors.h" #include "tiles_editor_plugin.h" +#include "editor/editor_file_system.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h index bc4e975c8d..8904e8524a 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h @@ -37,7 +37,6 @@ #include "scene/gui/item_list.h" #include "scene/resources/tile_set.h" -class EditorNode; class UndoRedo; class TileSetScenesCollectionSourceEditor : public HBoxContainer { diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index b00b8f83a4..02beba971b 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -35,13 +35,13 @@ #include "editor/plugins/curve_editor_plugin.h" #include "editor/property_editor.h" #include "scene/gui/button.h" +#include "scene/gui/code_edit.h" #include "scene/gui/graph_edit.h" #include "scene/gui/popup.h" +#include "scene/gui/rich_text_label.h" #include "scene/gui/tree.h" #include "scene/resources/visual_shader.h" -class EditorNode; - class VisualShaderNodePlugin : public RefCounted { GDCLASS(VisualShaderNodePlugin, RefCounted); diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h index fb1e0e05d0..67bd1d5105 100644 --- a/editor/plugins/voxel_gi_editor_plugin.h +++ b/editor/plugins/voxel_gi_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/voxel_gi.h" #include "scene/resources/material.h" -class EditorNode; class EditorFileDialog; struct EditorProgress; diff --git a/editor/project_export.h b/editor/project_export.h index 0f0f0ed83c..569563ba55 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -52,7 +52,6 @@ #include "scene/gui/tree.h" #include "scene/main/timer.h" -class EditorNode; class EditorFileDialog; class ProjectExportDialog : public ConfirmationDialog { diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 9d02fb10bd..c9747795f0 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -37,9 +37,11 @@ #include "core/object/undo_redo.h" #include "editor/scene_tree_editor.h" #include "scene/gui/check_box.h" +#include "scene/gui/check_button.h" #include "scene/gui/dialogs.h" #include "scene/gui/option_button.h" #include "scene/gui/spin_box.h" +#include "scene/gui/tab_container.h" class RenameDialog : public ConfirmationDialog { GDCLASS(RenameDialog, ConfirmationDialog); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 056a154f19..db78546fd3 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -54,6 +54,9 @@ #include "servers/rendering_server.h" #include "modules/modules_enabled.gen.h" // For regex. +#ifdef MODULE_REGEX_ENABLED +#include "editor/rename_dialog.h" +#endif // MODULE_REGEX_ENABLED void SceneTreeDock::_nodes_drag_begin() { if (restore_script_editor_on_drag) { diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index d4fda11e97..2a98c469dc 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -35,7 +35,6 @@ #include "editor/editor_data.h" #include "editor/groups_editor.h" #include "editor/quick_open.h" -#include "editor/rename_dialog.h" #include "editor/reparent_dialog.h" #include "editor/script_create_dialog.h" #include "scene/animation/animation_player.h" @@ -48,8 +47,10 @@ #include "scene_tree_editor.h" #include "modules/modules_enabled.gen.h" // For regex. +#ifdef MODULE_REGEX_ENABLED +class RenameDialog; +#endif // MODULE_REGEX_ENABLED -class EditorNode; class ShaderCreateDialog; class SceneTreeDock : public VBoxContainer { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index f5c46f883d..c10dd2e2de 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -38,6 +38,7 @@ #include "editor/node_dock.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" #include "scene/gui/label.h" #include "scene/main/window.h" #include "scene/resources/packed_scene.h" diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 82305c4073..c60c253a65 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -37,8 +37,8 @@ #include "editor/create_dialog.h" #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/editor_settings.h" void ScriptCreateDialog::_notification(int p_what) { switch (p_what) { diff --git a/main/main.cpp b/main/main.cpp index 38e380568d..21199fe227 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -81,6 +81,7 @@ #include "editor/doc_data_class_path.gen.h" #include "editor/doc_tools.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_settings.h" #include "editor/editor_translation.h" #include "editor/progress_dialog.h" diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 2440ef392e..66c8ab7b37 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -29,7 +29,9 @@ /*************************************************************************/ #ifdef TOOLS_ENABLED + #include "gdnative_library_editor_plugin.h" + #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h index 2e4b483ea7..797695366c 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ b/modules/gdnative/gdnative_library_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/gui/menu_button.h" #include "scene/gui/tree.h" -class EditorNode; class EditorFileDialog; class GDNativeLibraryEditor : public Control { @@ -114,5 +113,7 @@ public: GDNativeLibraryEditorPlugin(); }; -#endif + +#endif // TOOLS_ENABLED + #endif // GDNATIVE_LIBRARY_EDITOR_PLUGIN_H diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 10e466f096..a25f14becd 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/slider.h" #include "scene/gui/spin_box.h" -class EditorNode; class Node3DEditorPlugin; class GridMapEditor : public VBoxContainer { diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index c0cd18e29d..7c2cb2e260 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -36,7 +36,7 @@ #ifdef TOOLS_ENABLED #include "core/version.h" -#include "editor/editor_settings.h" +#include "editor/editor_paths.h" #endif #ifdef ANDROID_ENABLED diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 52d5379e8b..61c3cefc7a 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -50,7 +50,6 @@ #ifdef TOOLS_ENABLED #include "editor/editor_node.h" -#include "editor/editor_settings.h" #endif #include "modules/modules_enabled.gen.h" // For csg, gridmap. diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp index cf0111ee7c..563c12eec4 100644 --- a/modules/visual_script/editor/visual_script_property_selector.cpp +++ b/modules/visual_script/editor/visual_script_property_selector.cpp @@ -38,7 +38,6 @@ #include "core/os/keyboard.h" #include "editor/doc_tools.h" #include "editor/editor_feature_profile.h" -#include "editor/editor_node.h" #include "editor/editor_scale.h" #include "scene/main/node.h" #include "scene/main/window.h" diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 23b5c5e4e5..aa4b394965 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -32,6 +32,9 @@ #include "export_plugin.h" +#include "core/os/os.h" +#include "editor/editor_settings.h" + void register_android_exporter() { String exe_ext; if (OS::get_singleton()->get_name() == "Windows") { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 464488967e..2c431028b0 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -30,7 +30,25 @@ #include "export_plugin.h" +#include "gradle_export_util.h" + +#include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" +#include "core/io/image_loader.h" +#include "core/io/json.h" +#include "core/io/marshalls.h" +#include "core/version.h" +#include "drivers/png/png_driver_common.h" +#include "editor/editor_log.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" +#include "editor/editor_settings.h" +#include "main/splash.gen.h" +#include "platform/android/logo.gen.h" +#include "platform/android/run_icon.gen.h" + +#include static const char *android_perms[] = { "ACCESS_CHECKIN_PROPERTIES", diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index c158a273d2..a4eb608b19 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -28,28 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "core/config/project_settings.h" -#include "core/io/dir_access.h" -#include "core/io/file_access.h" -#include "core/io/image_loader.h" -#include "core/io/json.h" -#include "core/io/marshalls.h" +#include "godot_plugin_config.h" + #include "core/io/zip_io.h" #include "core/os/os.h" -#include "core/templates/safe_refcount.h" -#include "core/version.h" -#include "drivers/png/png_driver_common.h" #include "editor/editor_export.h" -#include "editor/editor_log.h" -#include "editor/editor_settings.h" -#include "main/splash.gen.h" -#include "platform/android/logo.gen.h" -#include "platform/android/run_icon.gen.h" - -#include "godot_plugin_config.h" -#include "gradle_export_util.h" - -#include const String SPLASH_CONFIG_XML_CONTENT = R"SPLASH( diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp index d40ba2320a..c7e503732d 100644 --- a/platform/javascript/export/export_plugin.cpp +++ b/platform/javascript/export/export_plugin.cpp @@ -31,7 +31,6 @@ #include "export_plugin.h" #include "core/config/project_settings.h" -#include "editor/editor_node.h" Error EditorExportPlatformJavaScript::_extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa) { FileAccess *src_f = nullptr; diff --git a/platform/javascript/export/export_plugin.h b/platform/javascript/export/export_plugin.h index 8d4307548c..d17fd2f674 100644 --- a/platform/javascript/export/export_plugin.h +++ b/platform/javascript/export/export_plugin.h @@ -37,14 +37,13 @@ #include "core/io/tcp_server.h" #include "core/io/zip_io.h" #include "editor/editor_export.h" +#include "editor/editor_node.h" #include "main/splash.gen.h" #include "platform/javascript/logo.gen.h" #include "platform/javascript/run_icon.gen.h" #include "export_server.h" -class EditorNode; - class EditorExportPlatformJavaScript : public EditorExportPlatform { GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform); diff --git a/platform/javascript/export/export_server.h b/platform/javascript/export/export_server.h index 1380f34ad7..1b908ad9b0 100644 --- a/platform/javascript/export/export_server.h +++ b/platform/javascript/export/export_server.h @@ -36,7 +36,7 @@ #include "core/io/tcp_server.h" #include "core/io/zip_io.h" #include "editor/editor_export.h" -#include "editor/editor_node.h" +#include "editor/editor_paths.h" class EditorHTTPServer : public RefCounted { private: diff --git a/platform/osx/export/codesign.cpp b/platform/osx/export/codesign.cpp index 8d1d147196..1a2ad2bee6 100644 --- a/platform/osx/export/codesign.cpp +++ b/platform/osx/export/codesign.cpp @@ -35,7 +35,9 @@ #include "plist.h" #include "core/os/os.h" +#include "editor/editor_paths.h" #include "editor/editor_settings.h" + #include "modules/modules_enabled.gen.h" // For regex. #include diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp index 4d5c0a827a..17861f24d2 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/osx/export/export_plugin.cpp @@ -28,11 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "modules/modules_enabled.gen.h" // For regex. +#include "export_plugin.h" #include "codesign.h" + #include "editor/editor_node.h" -#include "export_plugin.h" +#include "editor/editor_paths.h" + +#include "modules/modules_enabled.gen.h" // For regex. void EditorExportPlatformOSX::get_preset_features(const Ref &p_preset, List *r_features) { if (p_preset->get("texture_format/s3tc")) { diff --git a/platform/uwp/export/app_packager.cpp b/platform/uwp/export/app_packager.cpp index c7b3bc9854..e7978ff74d 100644 --- a/platform/uwp/export/app_packager.cpp +++ b/platform/uwp/export/app_packager.cpp @@ -31,6 +31,7 @@ #include "app_packager.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) { unsigned char hash[32]; diff --git a/platform/uwp/export/export_plugin.h b/platform/uwp/export/export_plugin.h index eab958534a..4c2d25e533 100644 --- a/platform/uwp/export/export_plugin.h +++ b/platform/uwp/export/export_plugin.h @@ -41,6 +41,7 @@ #include "core/version.h" #include "editor/editor_export.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "thirdparty/minizip/unzip.h" #include "thirdparty/minizip/zip.h" diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 1cbe3adb3c..9297aeea08 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -33,12 +33,7 @@ #include "core/os/keyboard.h" #include "core/string/print_string.h" #include "core/string/translation.h" -#include "line_edit.h" - -#ifdef TOOLS_ENABLED -#include "editor/editor_node.h" -#include "scene/main/window.h" // Only used to check for more modals when dimming the editor. -#endif +#include "scene/gui/line_edit.h" // AcceptDialog -- cgit v1.2.3