Skip to content

Commit

Permalink
Merge pull request #85807 from rakkarage/import-warning
Browse files Browse the repository at this point in the history
Add toaster notifications for import warnings.
  • Loading branch information
akien-mga committed Dec 12, 2023
2 parents 7f02f5b + 35444b2 commit d26a3f1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions editor/import/resource_importer_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/gui/editor_toaster.h"
#include "editor/import/resource_importer_texture_settings.h"
#include "scene/resources/compressed_texture.h"

Expand Down Expand Up @@ -108,13 +109,21 @@ void ResourceImporterTexture::update_imports() {
bool changed = false;

if (E.value.flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
print_line(vformat(TTR("%s: Texture detected as used as a normal map in 3D. Enabling red-green texture compression to reduce memory usage (blue channel is discarded)."), String(E.key)));
String message = vformat(TTR("%s: Texture detected as used as a normal map in 3D. Enabling red-green texture compression to reduce memory usage (blue channel is discarded)."), String(E.key));
#ifdef TOOLS_ENABLED
EditorToaster::get_singleton()->popup_str(message);
#endif
print_line(message);
cf->set_value("params", "compress/normal_map", 1);
changed = true;
}

if (E.value.flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) {
print_line(vformat(TTR("%s: Texture detected as used as a roughness map in 3D. Enabling roughness limiter based on the detected associated normal map at %s."), String(E.key), E.value.normal_path_for_roughness));
String message = vformat(TTR("%s: Texture detected as used as a roughness map in 3D. Enabling roughness limiter based on the detected associated normal map at %s."), String(E.key), E.value.normal_path_for_roughness);
#ifdef TOOLS_ENABLED
EditorToaster::get_singleton()->popup_str(message);
#endif
print_line(message);
cf->set_value("params", "roughness/mode", E.value.channel_for_roughness + 2);
cf->set_value("params", "roughness/src_normal", E.value.normal_path_for_roughness);
changed = true;
Expand All @@ -131,7 +140,11 @@ void ResourceImporterTexture::update_imports() {
cf->set_value("params", "compress/mode", COMPRESS_BASIS_UNIVERSAL);
compress_string = "Basis Universal";
}
print_line(vformat(TTR("%s: Texture detected as used in 3D. Enabling mipmap generation and setting the texture compression mode to %s."), String(E.key), compress_string));
String message = vformat(TTR("%s: Texture detected as used in 3D. Enabling mipmap generation and setting the texture compression mode to %s."), String(E.key), compress_string);
#ifdef TOOLS_ENABLED
EditorToaster::get_singleton()->popup_str(message);
#endif
print_line(message);
cf->set_value("params", "mipmaps/generate", true);
changed = true;
}
Expand Down

0 comments on commit d26a3f1

Please sign in to comment.