From be8cb6af8ca6ef5ef412c21b3f83bdf17f03f422 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 21 Mar 2021 14:41:46 +0800 Subject: [PATCH] Fix project icon size in Project Manager --- editor/editor_themes.cpp | 21 +++++++++++++-------- editor/editor_themes.h | 3 +++ editor/project_manager.cpp | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 5ede89c3394..ad6277b8f15 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -246,15 +246,8 @@ void editor_register_and_generate_icons(Ref p_theme, bool p_dark_theme = // Generate icons. if (!p_only_thumbs) { for (int i = 0; i < editor_icons_count; i++) { - float icon_scale = EDSCALE; - - // Always keep the DefaultProjectIcon at the default size - if (strcmp(editor_icons_names[i], "DefaultProjectIcon") == 0) { - icon_scale = 1.0f; - } - const int is_exception = exceptions.has(editor_icons_names[i]); - const Ref icon = editor_generate_icon(i, !is_exception, icon_scale); + const Ref icon = editor_generate_icon(i, !is_exception); p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon); } @@ -1358,3 +1351,15 @@ Ref create_custom_theme(const Ref p_theme) { return theme; } + +Ref create_unscaled_default_project_icon() { +#ifdef SVG_ENABLED + for (int i = 0; i < editor_icons_count; i++) { + // ESCALE should never affect size of the icon + if (strcmp(editor_icons_names[i], "DefaultProjectIcon") == 0) { + return editor_generate_icon(i, false, 1.0); + } + } +#endif + return Ref(memnew(ImageTexture)); +} diff --git a/editor/editor_themes.h b/editor/editor_themes.h index 1d674f78dff..b43be40af82 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -31,10 +31,13 @@ #ifndef EDITOR_THEMES_H #define EDITOR_THEMES_H +#include "scene/resources/texture.h" #include "scene/resources/theme.h" Ref create_editor_theme(Ref p_theme = NULL); Ref create_custom_theme(Ref p_theme = NULL); +Ref create_unscaled_default_project_icon(); + #endif diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 69f9b763d77..0e93b75d033 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -504,7 +504,7 @@ private: if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector(), false) != OK) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { - ResourceSaver::save(dir.plus_file("icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); + ResourceSaver::save(dir.plus_file("icon.png"), create_unscaled_default_project_icon()); FileAccess *f = FileAccess::open(dir.plus_file("default_env.tres"), FileAccess::WRITE); if (!f) {