diff options
author | kobewi <kobewi4e@gmail.com> | 2021-12-02 13:01:49 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-01-13 12:29:05 +0100 |
commit | f524ddebd5bc4ff727b53ad44ec474753ea444bd (patch) | |
tree | 3ac6866d0dea169967c2dc08582ba032ae12ecf8 /editor | |
parent | 28174d531b7128f0281fc2b88da2f4962fd3513e (diff) |
Make script type distinguishable by icon
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 13 |
2 files changed, 23 insertions, 2 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index caaac2c7d3..cc7630e01e 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1771,6 +1771,7 @@ struct _ScriptEditorItemData { String name; String sort_key; Ref<Texture2D> icon; + bool tool = false; int index = 0; String tooltip; bool used = false; @@ -1894,6 +1895,7 @@ void ScriptEditor::_update_script_colors() { int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size"); Color hot_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + hot_color.set_s(hot_color.get_s() * 0.9); Color cold_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); for (int i = 0; i < script_list->get_item_count(); i++) { @@ -1953,6 +1955,7 @@ void ScriptEditor::_update_script_names() { se->set_meta("_edit_res_path", path); } String name = se->get_name(); + Ref<Script> scr = se->get_edited_resource(); _ScriptEditorItemData sd; sd.icon = icon; @@ -1962,6 +1965,9 @@ void ScriptEditor::_update_script_names() { sd.used = used.has(se->get_edited_resource()); sd.category = 0; sd.ref = se; + if (scr.is_valid()) { + sd.tool = scr->is_tool(); + } switch (sort_by) { case SORT_BY_NAME: { @@ -2081,8 +2087,14 @@ void ScriptEditor::_update_script_names() { } } + Color tool_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + tool_color.set_s(tool_color.get_s() * 1.5); for (int i = 0; i < sedata_filtered.size(); i++) { script_list->add_item(sedata_filtered[i].name, sedata_filtered[i].icon); + if (sedata_filtered[i].tool) { + script_list->set_item_icon_modulate(script_list->get_item_count() - 1, tool_color); + } + int index = script_list->get_item_count() - 1; script_list->set_item_tooltip(index, sedata_filtered[i].tooltip); script_list->set_item_metadata(index, sedata_filtered[i].index); /* Saving as metadata the script's index in the tab container and not the filtered one */ diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index d5af7c5b38..cc685ca899 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -396,8 +396,17 @@ String ScriptTextEditor::get_name() { } Ref<Texture2D> ScriptTextEditor::get_theme_icon() { - if (get_parent_control() && get_parent_control()->has_theme_icon(script->get_class(), "EditorIcons")) { - return get_parent_control()->get_theme_icon(script->get_class(), "EditorIcons"); + if (get_parent_control()) { + String icon_name = script->get_class(); + if (script->is_built_in()) { + icon_name += "Internal"; + } + + if (get_parent_control()->has_theme_icon(icon_name, "EditorIcons")) { + return get_parent_control()->get_theme_icon(icon_name, "EditorIcons"); + } else if (get_parent_control()->has_theme_icon(script->get_class(), "EditorIcons")) { + return get_parent_control()->get_theme_icon(script->get_class(), "EditorIcons"); + } } return Ref<Texture2D>(); |