mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-13 14:21:11 +01:00
Fixed custom font support in the editor's text editor module.
This commit is contained in:
parent
b9a0b8253f
commit
2a0b2b696a
@ -73,7 +73,9 @@ void TextEditorSettings::remove_opened_file(const int index, ItemList *fileconta
|
|||||||
for (int i = 0; i < arr.size(); ++i) {
|
for (int i = 0; i < arr.size(); ++i) {
|
||||||
Array a = arr[i];
|
Array a = arr[i];
|
||||||
|
|
||||||
if (a.size() < 2) {
|
if (a.size() < 1) {
|
||||||
|
arr.remove(i);
|
||||||
|
--i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,14 +87,12 @@ void TextEditorSettings::remove_opened_file(const int index, ItemList *fileconta
|
|||||||
|
|
||||||
EditorSettings::get_singleton()->set_project_metadata("file_editor", "files", arr);
|
EditorSettings::get_singleton()->set_project_metadata("file_editor", "files", arr);
|
||||||
|
|
||||||
/*
|
|
||||||
Dictionary fonts_dict = EditorSettings::get_singleton()->get_project_metadata("file_editor", "file_fonts", Dictionary());
|
Dictionary fonts_dict = EditorSettings::get_singleton()->get_project_metadata("file_editor", "file_fonts", Dictionary());
|
||||||
|
|
||||||
if (fonts_dict.has(f)) {
|
if (fonts_dict.has(f)) {
|
||||||
fonts_dict.erase(f);
|
fonts_dict.erase(f);
|
||||||
EditorSettings::get_singleton()->set_project_metadata("file_editor", "file_fonts", fonts_dict);
|
EditorSettings::get_singleton()->set_project_metadata("file_editor", "file_fonts", fonts_dict);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array TextEditorSettings::load_opened_files() {
|
Array TextEditorSettings::load_opened_files() {
|
||||||
@ -112,23 +112,26 @@ Array TextEditorSettings::load_opened_files() {
|
|||||||
k.push_back(a[0]);
|
k.push_back(a[0]);
|
||||||
k.push_back(a[1]);
|
k.push_back(a[1]);
|
||||||
|
|
||||||
/*
|
if (fonts_dict.has(a[1])) {
|
||||||
if (fonts_dict.has(a[2])) {
|
k.push_back(fonts_dict[a[1]]);
|
||||||
k.push_back(fonts_dict[a[2]]);
|
|
||||||
} else {
|
} else {
|
||||||
k.push_back("null");
|
k.push_back("null");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
keys.append(k);
|
keys.append(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ERR_PRINT(Variant(keys));
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorSettings::store_editor_fonts(const String &file_name, const String &font_path) {
|
void TextEditorSettings::store_editor_fonts(const String &file_path, const String &font_path) {
|
||||||
Dictionary fonts_dict = EditorSettings::get_singleton()->get_project_metadata("file_editor", "file_fonts", Dictionary());
|
Dictionary fonts_dict = EditorSettings::get_singleton()->get_project_metadata("file_editor", "file_fonts", Dictionary());
|
||||||
fonts_dict[file_name] = font_path;
|
fonts_dict[file_path] = font_path;
|
||||||
|
|
||||||
|
ERR_PRINT(Variant(fonts_dict));
|
||||||
|
|
||||||
EditorSettings::get_singleton()->set_project_metadata("file_editor", "file_fonts", fonts_dict);
|
EditorSettings::get_singleton()->set_project_metadata("file_editor", "file_fonts", fonts_dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ void TextFileEditor::_on_font_selected(const String &font_path) {
|
|||||||
current_editor->set_font(font_path);
|
current_editor->set_font(font_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
_text_editor_settings->store_editor_fonts(current_file_path.get_file(), font_path);
|
_text_editor_settings->store_editor_fonts(current_file_path, font_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFileEditor::_on_fileitem_pressed(const int index) {
|
void TextFileEditor::_on_fileitem_pressed(const int index) {
|
||||||
@ -250,14 +250,9 @@ void TextFileEditor::open_file(const String &path, const String &font) {
|
|||||||
current_file_path = path;
|
current_file_path = path;
|
||||||
TextEditorVanillaEditor *vanilla_editor = open_in_vanillaeditor(path);
|
TextEditorVanillaEditor *vanilla_editor = open_in_vanillaeditor(path);
|
||||||
|
|
||||||
/*
|
if (font != "null") {
|
||||||
Ref<Font> edf = vanilla_editor->get("custom_fonts/font");
|
|
||||||
|
|
||||||
//TODO this logic seems wrong
|
|
||||||
if (font != "null" && edf.is_valid()) {
|
|
||||||
vanilla_editor->set_font(font);
|
vanilla_editor->set_font(font);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
generate_file_item(path, vanilla_editor);
|
generate_file_item(path, vanilla_editor);
|
||||||
|
|
||||||
@ -783,11 +778,11 @@ void TextFileEditor::_notification(int p_what) {
|
|||||||
for (int i = 0; i < opened_files.size(); ++i) {
|
for (int i = 0; i < opened_files.size(); ++i) {
|
||||||
Array opened_file = opened_files[i];
|
Array opened_file = opened_files[i];
|
||||||
|
|
||||||
if (opened_file.size() < 2) {
|
if (opened_file.size() < 3) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file(opened_file[0], opened_file[1]);
|
open_file(opened_file[1], opened_file[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_list->set_filters(EXTENSIONS);
|
file_list->set_filters(EXTENSIONS);
|
||||||
|
Loading…
Reference in New Issue
Block a user