Add resources within the executable
Currently, the executable does not include the resources within itself: it needs to be able to find the files with the resources. It does so by using relative paths.
A drawback of this, is that the executable cannot be copied from location A to B: if the exe is copied to a new folder, the resources need to copied as well (or linked to). This makes building BnB more difficult for the newbies as well.
An alternative is to use the Qt resource sytem (doc here). Using that system, resource files are bundled with the executable and resource file can be called by name, such as :/music.ogg
.
- Add a Qt resource file called
BlipNBlup.qrc
- Add the resources to it, using the same hierarchy as the folder structure
- Adapt the
ResourceMaster
class to use these internal resources. If that fails, use the approach of [1].
There is a test that should pass:
void TestResourceMaster()
{
#ifdef FIX_ISSUE_13
// Resources/Samples/Jump.ogg must be found
{
Context context;
ResourceMaster m(&context);
assert(m.GetSample("Jump"));
}
#endif
}
Notes
- [1] We did something similar to a Qt unfriendly library, SFML, in which we copied the in-exe resources to the expected relative paths (example here). It was clumsy, but convenient.
- [2] Frode did some research: https://doc.qt.io/qt-5/rcc.html and https://discourse.urho3d.io/t/solved-including-static-resources-in-executable/1550/5
Edited by Richel Bilderbeek