|
Aegis2D
Modular C++26 2D game engine for networked games
|
Loads a list of resources in the background, telling how far it is. More...
#include <aegis2d/core/preloader.hpp>
Public Member Functions | |
| Preloader (ResourceCache< Resource > &cache, std::vector< std::string > names) | |
| Starts loading at once, in its own thread. | |
| Preloader (const Preloader &)=delete | |
| Preloader & | operator= (const Preloader &)=delete |
| Preloader (Preloader &&)=delete | |
| Preloader & | operator= (Preloader &&)=delete |
| ~Preloader ()=default | |
| Waits for the loading thread. | |
| std::size_t | total () const noexcept |
| Names to load in all. | |
| std::size_t | processed () const noexcept |
| Names dealt with so far, loaded or failed. | |
| float | progress () const noexcept |
| How far the loading is. | |
| bool | done () const noexcept |
| Tells whether every name was dealt with. | |
| void | wait () |
| Waits until every name is dealt with. | |
| std::vector< PreloadFailure > | failures () const |
| The resources that could not be loaded. | |
| ResourceCache< Resource >::Handle | handle (std::string_view name) const |
| The kept handle of a loaded name. | |
| void | release () |
| Lets go of the kept handles, once the game holds its own. | |
Loads a list of resources in the background, telling how far it is.
The preloader starts its own thread at once: each name is loaded through the cache (ResourceCache's calls are safe between threads) and its handle kept, so the resources stay cached until release(). The game thread draws a loading screen from progress() and done(); a loader's exception is recorded in failures() and the rest still loads. The cache must outlive the preloader, whose destructor waits for the thread.
|
inline |
Starts loading at once, in its own thread.
| cache | Cache the resources are loaded through, and stay in. |
| names | Names to load, in this order; an empty list is done at once. |
|
delete |
|
delete |
|
default |
Waits for the loading thread.
|
inlinenoexcept |
Tells whether every name was dealt with.
true once the list is through; failures() then says what went wrong.
|
inline |
The resources that could not be loaded.
|
inline |
The kept handle of a loaded name.
| name | A name of the list. |
|
delete |
|
delete |
|
inlinenoexcept |
Names dealt with so far, loaded or failed.
|
inlinenoexcept |
How far the loading is.
|
inline |
Lets go of the kept handles, once the game holds its own.
Resources nothing else uses are freed, as ResourceCache does.
|
inlinenoexcept |
Names to load in all.
|
inline |
Waits until every name is dealt with.