| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/resource_importer.h" |
| 34 |
|
| 35 |
#include "scene/gui/dialogs.h" |
| 36 |
#include "scene/gui/tab_container.h" |
| 37 |
#include "scene/gui/text_edit.h" |
| 38 |
#include "scene/gui/tree.h" |
| 39 |
#include "scene/resources/font.h" |
| 40 |
|
| 41 |
class DynamicFontImportSettingsDialog; |
| 42 |
|
| 43 |
class DynamicFontImportSettingsData : public RefCounted { |
| 44 |
GDCLASS(DynamicFontImportSettingsData, RefCounted) |
| 45 |
friend class DynamicFontImportSettingsDialog; |
| 46 |
|
| 47 |
HashMap<StringName, Variant> settings; |
| 48 |
HashMap<StringName, Variant> defaults; |
| 49 |
List<ResourceImporter::ImportOption> options; |
| 50 |
DynamicFontImportSettingsDialog *owner = nullptr; |
| 51 |
|
| 52 |
HashSet<char32_t> selected_chars; |
| 53 |
HashSet<int32_t> selected_glyphs; |
| 54 |
|
| 55 |
Ref<FontFile> fd; |
| 56 |
|
| 57 |
public: |
| 58 |
bool _set(const StringName &p_name, const Variant &p_value); |
| 59 |
bool _get(const StringName &p_name, Variant &r_ret) const; |
| 60 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 61 |
|
| 62 |
Ref<FontFile> get_font() const; |
| 63 |
}; |
| 64 |
|
| 65 |
class EditorFileDialog; |
| 66 |
class EditorInspector; |
| 67 |
class EditorLocaleDialog; |
| 68 |
|
| 69 |
class DynamicFontImportSettingsDialog : public ConfirmationDialog { |
| 70 |
GDCLASS(DynamicFontImportSettingsDialog, ConfirmationDialog) |
| 71 |
friend class DynamicFontImportSettingsData; |
| 72 |
|
| 73 |
enum ItemButton { |
| 74 |
BUTTON_ADD_VAR, |
| 75 |
BUTTON_REMOVE_VAR, |
| 76 |
}; |
| 77 |
|
| 78 |
static DynamicFontImportSettingsDialog *singleton; |
| 79 |
|
| 80 |
String base_path; |
| 81 |
|
| 82 |
Ref<DynamicFontImportSettingsData> import_settings_data; |
| 83 |
List<ResourceImporter::ImportOption> options_variations; |
| 84 |
List<ResourceImporter::ImportOption> options_general; |
| 85 |
|
| 86 |
bool is_pixel = false; |
| 87 |
|
| 88 |
|
| 89 |
Label *label_warn = nullptr; |
| 90 |
TabContainer *main_pages = nullptr; |
| 91 |
|
| 92 |
|
| 93 |
Label *page1_description = nullptr; |
| 94 |
Label *font_name_label = nullptr; |
| 95 |
Label *font_preview_label = nullptr; |
| 96 |
EditorInspector *inspector_general = nullptr; |
| 97 |
|
| 98 |
void _main_prop_changed(const String &p_edited_property); |
| 99 |
|
| 100 |
|
| 101 |
Label *page2_description = nullptr; |
| 102 |
Label *label_vars = nullptr; |
| 103 |
Button *add_var = nullptr; |
| 104 |
Tree *vars_list = nullptr; |
| 105 |
TreeItem *vars_list_root = nullptr; |
| 106 |
EditorInspector *inspector_vars = nullptr; |
| 107 |
|
| 108 |
void _variation_add(); |
| 109 |
void _variation_selected(); |
| 110 |
void _variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button); |
| 111 |
void _variation_changed(const String &p_edited_property); |
| 112 |
void _variations_validate(); |
| 113 |
|
| 114 |
TabContainer *preload_pages = nullptr; |
| 115 |
|
| 116 |
Label *label_glyphs = nullptr; |
| 117 |
void _glyph_clear(); |
| 118 |
void _glyph_update_lbl(); |
| 119 |
|
| 120 |
|
| 121 |
Label *page2_0_description = nullptr; |
| 122 |
Tree *locale_tree = nullptr; |
| 123 |
TreeItem *locale_root = nullptr; |
| 124 |
Button *btn_fill_locales = nullptr; |
| 125 |
|
| 126 |
void _locale_edited(); |
| 127 |
void _process_locales(); |
| 128 |
|
| 129 |
|
| 130 |
Label *page2_1_description = nullptr; |
| 131 |
TextEdit *text_edit = nullptr; |
| 132 |
EditorInspector *inspector_text = nullptr; |
| 133 |
Button *btn_fill = nullptr; |
| 134 |
|
| 135 |
List<ResourceImporter::ImportOption> options_text; |
| 136 |
Ref<DynamicFontImportSettingsData> text_settings_data; |
| 137 |
|
| 138 |
void _change_text_opts(); |
| 139 |
void _glyph_text_selected(); |
| 140 |
|
| 141 |
|
| 142 |
Label *page2_2_description = nullptr; |
| 143 |
Tree *glyph_table = nullptr; |
| 144 |
Tree *glyph_tree = nullptr; |
| 145 |
TreeItem *glyph_root = nullptr; |
| 146 |
|
| 147 |
void _glyph_selected(); |
| 148 |
void _range_edited(); |
| 149 |
void _range_selected(); |
| 150 |
void _edit_range(int32_t p_start, int32_t p_end); |
| 151 |
bool _char_update(int32_t p_char); |
| 152 |
void _range_update(int32_t p_start, int32_t p_end); |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name); |
| 157 |
|
| 158 |
Ref<FontFile> font_preview; |
| 159 |
Ref<FontFile> font_main; |
| 160 |
|
| 161 |
void _re_import(); |
| 162 |
|
| 163 |
String _pad_zeros(const String &p_hex) const; |
| 164 |
|
| 165 |
protected: |
| 166 |
void _notification(int p_what); |
| 167 |
|
| 168 |
public: |
| 169 |
void open_settings(const String &p_path); |
| 170 |
static DynamicFontImportSettingsDialog *get_singleton(); |
| 171 |
|
| 172 |
DynamicFontImportSettingsDialog(); |
| 173 |
}; |