Skip to content

Commit 7345808

Browse files
committed
Replace confusing PNG with MIP (Model-in-Picture) in Thumbnail_cImportExport
1 parent 063e800 commit 7345808

3 files changed

Lines changed: 38 additions & 30 deletions

File tree

Spore ModAPI/SourceCode/App/App.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ namespace App
2525
auto_METHOD(Thumbnail_cImportExport, bool, FolderPathFromLocale,
2626
Args(uint32_t instanceID, eastl::string16& dst, uint32_t tableID), Args(instanceID, dst, tableID));
2727

28-
auto_METHOD(Thumbnail_cImportExport, bool, SavePNG,
28+
auto_METHOD(Thumbnail_cImportExport, bool, SaveMIP,
2929
Args(Resource::ResourceObject* pResource, RenderWare::Raster* pImage, Resource::Database* pDBPF,
3030
bool forceReplace, bool disableSteganography),
3131
Args(pResource, pImage, pDBPF, forceReplace, disableSteganography));
3232

33-
auto_METHOD(Thumbnail_cImportExport, bool, ImportPNG,
33+
auto_METHOD(Thumbnail_cImportExport, bool, ImportMIP,
3434
Args(const char16_t* path, ResourceKey& key), Args(path, key));
3535

36-
auto_METHOD(Thumbnail_cImportExport, bool, DecodePNG,
36+
auto_METHOD(Thumbnail_cImportExport, bool, DecodeMIP,
3737
Args(IO::IStream* stream, ThumbnailDecodedMetadata& dstMetadata, IStreamPtr& dstDataStream),
3838
Args(stream, dstMetadata, dstDataStream));
3939

4040
auto_METHOD_(Thumbnail_cImportExport, bool, SaveFilePaths);
4141

42-
auto_METHOD(Thumbnail_cImportExport, bool, ImportDirectoryPNGs,
42+
auto_METHOD(Thumbnail_cImportExport, bool, ImportDirectoryMIPs,
4343
Args(const eastl::string16& path, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount),
4444
Args(path, dstSkippedPaths, dstCount));
4545

46-
auto_METHOD(PngEncoder, bool, EncodePNG,
47-
Args(IO::IStream* stream, int mode),
48-
Args(stream, mode));
46+
auto_METHOD(MIPEncoder, bool, WriteImageToStream,
47+
Args(IO::IStream* stream, App::MIPEncoder::Format format),
48+
Args(stream, format));
4949

5050

5151
auto_STATIC_METHOD_(cIDGenerator, cIDGenerator*, Get);

Spore ModAPI/SourceCode/DLL/AddressesApp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,16 @@ namespace App
407407
DefineAddress(Get, SelectAddress(0x5F7750, 0x5F79C0));
408408
DefineAddress(GetFolderPath, SelectAddress(0x5F9140, 0x5F92C0));
409409
DefineAddress(FolderPathFromLocale, SelectAddress(0x5F9220, 0x5F93A0));
410-
DefineAddress(SavePNG, SelectAddress(0x5FA7E0, 0x5FA960));
411-
DefineAddress(ImportPNG, SelectAddress(0x5FC240, 0x5FC3C0));
412-
DefineAddress(DecodePNG, SelectAddress(0x5FBA10, 0x5FBB90));
410+
DefineAddress(SaveMIP, SelectAddress(0x5FA7E0, 0x5FA960));
411+
DefineAddress(ImportMIP, SelectAddress(0x5FC240, 0x5FC3C0));
412+
DefineAddress(DecodeMIP, SelectAddress(0x5FBA10, 0x5FBB90));
413413
DefineAddress(SaveFilePaths, SelectAddress(0x5F89C0, 0x5F8B60));
414-
DefineAddress(ImportDirectoryPNGs, SelectAddress(0x5FC900, 0x5FCA80));
414+
DefineAddress(ImportDirectoryMIPs, SelectAddress(0x5FC900, 0x5FCA80));
415415
}
416416

417-
namespace Addresses(PngEncoder)
417+
namespace Addresses(MIPEncoder)
418418
{
419-
DefineAddress(EncodePNG, SelectAddress(0x68E660, 0x68e190));
419+
DefineAddress(WriteImageToStream, SelectAddress(0x68E660, 0x68e190));
420420
}
421421

422422
namespace Addresses(cLocaleManager)

Spore ModAPI/Spore/App/Thumbnail_cImportExport.h

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313

1414
namespace App
1515
{
16-
struct PngEncoder {
16+
struct MIPEncoder {
17+
18+
enum Format {
19+
kImageFormatPNG,
20+
kImageFormatTGA,
21+
kImageFormatBMP
22+
};
23+
24+
bool WriteImageToStream(IO::IStream* outputStream, Format format);
25+
1726

18-
bool EncodePNG(IO::IStream* outputStream, int mode);
1927

2028
/* 00h */ eastl::vector<int> mPixelBuf;
2129
/* 14h */ uint32_t mnImageWidth;
@@ -39,7 +47,7 @@ namespace App
3947
/* 58h */ eastl::vector<int8_t> mData;
4048
/* 6Ch */ int field_6C;
4149
};
42-
ASSERT_SIZE(PngEncoder, 0x70);
50+
ASSERT_SIZE(MIPEncoder, 0x70);
4351

4452
struct ThumbnailDecodedMetadata
4553
{
@@ -83,11 +91,11 @@ namespace App
8391
/// @param[out] dst The eastl::string where the path will be written.
8492
bool GetFolderPath(uint32_t creationType, eastl::string16& dst);
8593

86-
/// Used to obtain a path from a locale file, by default `0x19F76D11.locale`, similar to the one that would
94+
/// Used to obtain a path from a locale file, by default `SaveDataFolders.locale`, similar to the one that would
8795
/// return GetFolderPath()
8896
bool FolderPathFromLocale(uint32_t instanceID, eastl::string16& dst, uint32_t tableID = 0xFFFFFFFF);
8997

90-
/// Encodes the given resource into a `.png` image and saves it, both in the given package and in the
98+
/// Encodes the given resource into a `.png` Model-in-Picture and saves it, both in the given package and in the
9199
/// "My Spore Creations" in the user Documents folder.
92100
///
93101
/// In the package, the image will be saved using the same ResourceKey as the resource, but with a TypeIDs::png type.
@@ -100,21 +108,21 @@ namespace App
100108
/// @param forceReplace [Optional] If false (by default), if the `.png` already exists in the folder, it will try writing variants like `(1)`, `(2)`,...
101109
/// @param disableSteganography [Optional] If false (by default), the data in the `.png` will be stored in a special way meant to save space.
102110
/// @returns `true` on success, `false` if something failed.
103-
bool SavePNG(Resource::ResourceObject* pResource, RenderWare::Raster* pImage, Resource::Database* database,
111+
bool SaveMIP(Resource::ResourceObject* pResource, RenderWare::Raster* pImage, Resource::Database* database,
104112
bool forceReplace = false, bool disableSteganography = false);
105113

106114
/// 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.
107115
///
108116
/// @param path The full path to the file being read.
109117
/// @param key Resource key to the creation being read.
110118
/// @returns 'true' on success, 'false' if something failed.
111-
bool ImportPNG(const char16_t* path, ResourceKey& key);
119+
bool ImportMIP(const char16_t* path, ResourceKey& key);
112120

113-
/// Extracts information from a PNG file. It extracts both the metadata, and the data encoded within the image.
121+
/// Extracts information from a Model-in-Picture PNG file. It extracts both the metadata, and the data encoded within the image.
114122
/// @param[out] dstMetadata
115123
/// @param[out] dstDataStream
116124
/// @returns true on success, false if something failed
117-
bool DecodePNG(IO::IStream* stream, ThumbnailDecodedMetadata& dstMetadata, IStreamPtr& dstDataStream);
125+
bool DecodeMIP(IO::IStream* stream, ThumbnailDecodedMetadata& dstMetadata, IStreamPtr& dstDataStream);
118126

119127
/// Saves the file paths information that keeps track of which PNGs have been loaded.
120128
/// It saves it in file `0x473C3E6!0x473C3E6.0x473C3E6` of Resource::SaveAreaID::Server (`Pollination.package`)
@@ -129,7 +137,7 @@ namespace App
129137
/// @param[out] dstSkippedPaths A list of paths that were skipped because they were already in mPngPathToKey or too many files were loaded
130138
/// @param[out] dstCount The number of PNGs that were imported is added to this value
131139
/// @returns True if some PNG was loaded, false otherwise
132-
bool ImportDirectoryPNGs(const eastl::string16& directoryPath, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount);
140+
bool ImportDirectoryMIPs(const eastl::string16& directoryPath, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount);
133141

134142
static Thumbnail_cImportExport* Get();
135143

@@ -140,7 +148,7 @@ namespace App
140148
/* 44h */ uint32_t mMachineId; // not initialized
141149
/* 48h */ eastl::hash_map<int, int> field_48;
142150
/* 68h */ eastl::hash_map<int, int> field_68;
143-
/* 88h */ PngEncoder mPngEncoder;
151+
/* 88h */ MIPEncoder mMipEncoder;
144152
/* F8h */ ResourceKey mCurImage;
145153
/* 104h */ eastl::string16 mCellsPath;
146154
/* 114h */ eastl::string16 mCreaturesPath;
@@ -159,15 +167,15 @@ namespace App
159167
DeclareAddress(Get);
160168
DeclareAddress(GetFolderPath);
161169
DeclareAddress(FolderPathFromLocale);
162-
DeclareAddress(SavePNG);
163-
DeclareAddress(ImportPNG);
164-
DeclareAddress(DecodePNG); // 0x5FBA10 0x5FBB90
170+
DeclareAddress(SaveMIP);
171+
DeclareAddress(ImportMIP);
172+
DeclareAddress(DecodeMIP); // 0x5FBA10 0x5FBB90
165173
DeclareAddress(SaveFilePaths); // 0x5F89C0 0x5F8B60
166-
DeclareAddress(ImportDirectoryPNGs); // 0x5FC900 0x5FCA80
174+
DeclareAddress(ImportDirectoryMIPs); // 0x5FC900 0x5FCA80
167175
}
168176

169-
namespace Addresses(PngEncoder)
177+
namespace Addresses(MIPEncoder)
170178
{
171-
DeclareAddress(EncodePNG); // 0x68E660 0x68e190
179+
DeclareAddress(WriteImageToStream); // 0x68E660 0x68e190
172180
}
173181
}

0 commit comments

Comments
 (0)