SuperTux / supertux

SuperTux source code
https://supertux.org
GNU General Public License v3.0
2.5k stars 479 forks source link

Reloading resources from "Debug" menu #2928

Open Vankata453 opened 5 months ago

Vankata453 commented 5 months ago

The new "Reload Resources" option in the "Debug" menu allows for reloading all fonts, textures, sprites and tilesets.

Additionally:

Closes #2901.

tylerandari13 commented 4 months ago

My train of thought to test this was to load the game, and remove an image. If it works then it should display a missing texture, because the images are no longer there, which resulted in this:

[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:84 Image '/res/industrial/gfx-enemy/duker/duker-body.png' doesn't exist. Attempting to load ".deprecated" version.
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:439 Couldn't load texture '/res/industrial/gfx-enemy/duker/duker-body.png' (now using dummy texture): Couldn't open '/res/industrial/gfx-enemy/duker/duker-body.deprecated.png': not found
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:84 Image '/res/industrial/gfx-enemy/duker/duker-end.png' doesn't exist. Attempting to load ".deprecated" version.
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:439 Couldn't load texture '/res/industrial/gfx-enemy/duker/duker-end.png' (now using dummy texture): Couldn't open '/res/industrial/gfx-enemy/duker/duker-end.deprecated.png': not found
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:84 Image '/res/industrial/gfx-enemy/duker/duker-head.png' doesn't exist. Attempting to load ".deprecated" version.
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:439 Couldn't load texture '/res/industrial/gfx-enemy/duker/duker-head.png' (now using dummy texture): Couldn't open '/res/industrial/gfx-enemy/duker/duker-head.deprecated.png': not found
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:84 Image '/res/industrial/gfx-enemy/duker/duker-head.png' doesn't exist. Attempting to load ".deprecated" version.
[WARNING] /home/tylerandari12/STcompilation/supertux/src/video/texture_manager.cpp:376 Couldn't load texture '/res/industrial/gfx-enemy/duker/duker-head.png' (now using dummy texture): Couldn't open '/res/industrial/gfx-enemy/duker/duker-head.deprecated.png': not found
[FATAL] /home/tylerandari12/STcompilation/supertux/src/supertux/main.cpp:745 Unexpected exception: Cannot load image.

(The game closed after this was printed.)

duker-body.png, duker-end.png, and duker-head.png are the three images I removed so i could test. duker-head.png was the only image on a scripted object. Im not sure why the other two also tried to load.

I found another thing, which Im not sure if its related directly to this PR, but I might as well mention it. When this happened I thought "Well that sucks, but if I open the game again I should be able to add the images back in after opening and hit reload resources to make them appear.", but when I opened the level again, the scripted object which had the image was not there at all. I closed the game, added the images back in, and reopened the level, and the scripted object was back again.

Vankata453 commented 4 months ago

duker-body.png, duker-end.png, and duker-head.png are the three images I removed so i could test. duker-head.png was the only image on a scripted object. Im not sure why the other two also tried to load.

It reloads everything loaded since the start of the game.

I found another thing, which Im not sure if its related directly to this PR, but I might as well mention it. When this happened I thought "Well that sucks, but if I open the game again I should be able to add the images back in after opening and hit reload resources to make them appear.", but when I opened the level again, the scripted object which had the image was not there at all. I closed the game, added the images back in, and reopened the level, and the scripted object was back again.

Doesn't matter where the script object is, the resource is loaded into the game separately in its own manager.

Vankata453 commented 2 months ago

It's not, because it's supposed to do that too. Will look into it.

Vankata453 commented 1 month ago

TTF fonts now properly reload.