Skip to content

Commit

Permalink
Fix boot splash loading when path is UID
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Nov 15, 2024
1 parent 98ddec4 commit d734340
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions core/io/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2611,25 +2611,23 @@ Image::AlphaMode Image::detect_alpha() const {
}

Error Image::load(const String &p_path) {
String path = ResourceUID::ensure_path(p_path);
#ifdef DEBUG_ENABLED
if (path.begins_with("res://") && ResourceLoader::exists(path)) {
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path));
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path));
}
#endif
return ImageLoader::load_image(ResourceUID::ensure_path(p_path), this);
return ImageLoader::load_image(p_path, this);
}

Ref<Image> Image::load_from_file(const String &p_path) {
String path = ResourceUID::ensure_path(p_path);
#ifdef DEBUG_ENABLED
if (path.begins_with("res://") && ResourceLoader::exists(path)) {
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path));
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path));
}
#endif
Ref<Image> image;
image.instantiate();
Error err = ImageLoader::load_image(path, image);
Error err = ImageLoader::load_image(p_path, image);
if (err != OK) {
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Failed to load image. Error %d", err));
}
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5428,7 +5428,7 @@ void EditorNode::redo() {

bool EditorNode::ensure_main_scene(bool p_from_native) {
pick_main_scene->set_meta("from_native", p_from_native); // Whether from play button or native run.
String main_scene = GLOBAL_GET("application/run/main_scene");
String main_scene = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));

if (main_scene.is_empty()) {
current_menu_option = -1;
Expand Down
4 changes: 2 additions & 2 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,7 @@ void Main::setup_boot_logo() {

if (show_logo) { //boot logo!
const bool boot_logo_image = GLOBAL_DEF_BASIC("application/boot_splash/show_image", true);
const String boot_logo_path = String(GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"), String())).strip_edges();
const String boot_logo_path = ResourceUID::ensure_path(GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"), String())).strip_edges();
const bool boot_logo_scale = GLOBAL_DEF_BASIC("application/boot_splash/fullsize", true);
const bool boot_logo_filter = GLOBAL_DEF_BASIC("application/boot_splash/use_filter", true);

Expand Down Expand Up @@ -4221,7 +4221,7 @@ int Main::start() {
}
#endif

String icon_path = GLOBAL_GET("application/config/icon");
const String icon_path = ResourceUID::ensure_path(GLOBAL_GET("application/config/icon"));
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_ICON) && !icon_path.is_empty() && !has_icon) {
Ref<Image> icon;
icon.instantiate();
Expand Down

0 comments on commit d734340

Please sign in to comment.