App::Thumbnail_cImportExport class

A class related with the .PNG files of creations.

It can be used to get the path to the My Spore Creations folder:

eastl::string16 path;
ThumbnailImportExport.GetFolderPath(TypeIDs::crt, path);
// Now path is something like 'C:\Users\...\My Documents\My Spore Creations\Creatures'

You can also use it to save a Resource::ResourceObject into a .png with Thumbnail_cImportExport::SavePNG()

Base classes

class IUnmanagedMessageListener
Same as App::IMessageListener, but this one does not use ref-counting.

Public static functions

static auto Get() -> Thumbnail_cImportExport*

Public functions

auto GetFolderPath(uint32_t creationType, eastl::string16& dst) -> bool
Gets the filepath of the folder where the .PNGs of the creation type are stored.
auto FolderPathFromLocale(uint32_t instanceID, eastl::string16& dst, uint32_t tableID = 0xFFFFFFFF) -> bool
Used to obtain a path from a locale file, by default 0x19F76D11.locale, similar to the one that would return GetFolderPath()
auto SavePNG(Resource::ResourceObject* pResource, RenderWare::Raster* pImage, Resource::Database* database, bool forceReplace = false, bool disableSteganography = false) -> bool
Encodes the given resource into a .png image and saves it, both in the given package and in the "My Spore Creations" in the user Documents folder.
auto ImportPNG(const char16_t* path, ResourceKey& key) -> bool
Reads the PNG file from the given file path, and adds the creation found within to the Sporepedia if it hasn't been added yet.
auto DecodePNG(IO::IStream* stream, ThumbnailDecodedMetadata& dstMetadata, IStreamPtr& dstDataStream) -> bool
Extracts information from a PNG file.
auto SaveFilePaths() -> bool
Saves the file paths information that keeps track of which PNGs have been loaded.
auto ImportDirectoryPNGs(const eastl::string16& directoryPath, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount) -> bool
Scans a disk directory, and tries to imports all PNG creations found there that were not already in the system.

Public variables

eastl::hash_map<eastl::string16, ResourceKey> mPngPathToKey
lowercase
eastl::hash_map<ResourceKey, eastl::string16> mKeyToPngPath
uint32_t mMachineId
eastl::hash_map<int, int> field_48
eastl::hash_map<int, int> field_68
PngEncoder mPngEncoder
int field_F8
int field_FC
int field_100
eastl::string16 mCellsPath
eastl::string16 mCreaturesPath
eastl::string16 mBuildingsPath
eastl::string16 mPlantsPath
eastl::string16 mVehiclesPath
eastl::string16 mUFOsPath
eastl::string16 mCityMusicPath
eastl::string16 mScenariosPath
int field_184

Function documentation

bool App::Thumbnail_cImportExport::GetFolderPath(uint32_t creationType, eastl::string16& dst)

Gets the filepath of the folder where the .PNGs of the creation type are stored.

Parameters
creationType One of the types in TypeIDs, such as 'crt', 'bld',...
dst out The eastl::string where the path will be written.

The path will end in a slash '/'

bool App::Thumbnail_cImportExport::SavePNG(Resource::ResourceObject* pResource, RenderWare::Raster* pImage, Resource::Database* database, bool forceReplace = false, bool disableSteganography = false)

Encodes the given resource into a .png image and saves it, both in the given package and in the "My Spore Creations" in the user Documents folder.

Parameters
pResource The resource object to encode inside the PNG. It will be encoded using the appropriate Resource::IResourceFactory
pImage The raster that is written as the image
database The Database that contains the pollen metadata, and where the PNG will be saved
forceReplace [Optional] If false (by default), if the .png already exists in the folder, it will try writing variants like (1), (2),...
disableSteganography [Optional] If false (by default), the data in the .png will be stored in a special way meant to save space.
Returns true on success, false if something failed.

In the package, the image will be saved using the same ResourceKey as the resource, but with a TypeIDs::png type. The function expects a TypeIDs::pollen_metadata file to exist in that same folder, which will be used to write the metadata (name, description, author, etc) of the creation.

bool App::Thumbnail_cImportExport::ImportPNG(const char16_t* path, ResourceKey& key)

Reads the PNG file from the given file path, and adds the creation found within to the Sporepedia if it hasn't been added yet.

Parameters
path The full path to the file being read.
key Resource key to the creation being read.
Returns 'true' on success, 'false' if something failed.

bool App::Thumbnail_cImportExport::DecodePNG(IO::IStream* stream, ThumbnailDecodedMetadata& dstMetadata, IStreamPtr& dstDataStream)

Extracts information from a PNG file.

Parameters
stream
dstMetadata out
dstDataStream out
Returns true on success, false if something failed

It extracts both the metadata, and the data encoded within the image.

bool App::Thumbnail_cImportExport::SaveFilePaths()

Saves the file paths information that keeps track of which PNGs have been loaded.

Returns true on success, false if something failed

It saves it in file 0x473C3E6!0x473C3E6.0x473C3E6 of Resource::SaveAreaID::Server (Pollination.package)

bool App::Thumbnail_cImportExport::ImportDirectoryPNGs(const eastl::string16& directoryPath, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount)

Scans a disk directory, and tries to imports all PNG creations found there that were not already in the system.

Parameters
directoryPath The path of the directory to scan
dstSkippedPaths out A list of paths that were skipped because they were already in mPngPathToKey or too many files were loaded
dstCount out The number of PNGs that were imported is added to this value
Returns True if some PNG was loaded, false otherwise

For each file path, it will check if it is aloready in mPngPathToKey (lowercase); if it isn't, it will call ImportPNG() on it, and add its entry to mPngPathToKey and mKeyToPngPath It uses dstCount to keep track of how many files have been loaded; it loads a maximum of 500