Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sortByName to HlmsManager::saveMaterials #418

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions OgreMain/include/OgreHlmsJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ namespace Ogre
if texture name is "mytex.png" and additionalTextureExtension = ".dds"
then the actual texture saved will be "mytex.png.dds"
Leave it blank if you don't know what to put
@param sortByName
Use true if output JSON should have materials sorted alphabetically
by name (case sensitive).
*/
void saveMaterials( const Hlms *hlms, String &outString,
const String &additionalTextureExtension, bool sortByName = false );
Expand Down
5 changes: 4 additions & 1 deletion OgreMain/include/OgreHlmsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,12 @@ namespace Ogre
Hlms type. The type must be registered, otherwise it may crash.
@param filename
Valid file path.
@param sortByName
Use true if output JSON should have materials sorted alphabetically
by name (case sensitive).
*/
void saveMaterials( HlmsTypes hlmsType, const String &filename, HlmsJsonListener *listener,
const String &additionalTextureExtension );
const String &additionalTextureExtension, bool sortByName = false );

/** Saves a specific Hlms material at the given file location.
@param datablock
Expand Down
6 changes: 4 additions & 2 deletions OgreMain/src/OgreHlmsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,14 +874,16 @@ namespace Ogre
//-----------------------------------------------------------------------------------
void HlmsManager::saveMaterials( HlmsTypes hlmsType, const String &filename,
HlmsJsonListener *listener,
const String &additionalTextureExtension )
const String &additionalTextureExtension,
bool sortByName )
{
assert( hlmsType != HLMS_MAX );
assert( hlmsType != HLMS_LOW_LEVEL );

String jsonString;
HlmsJson hlmsJson( this, listener );
hlmsJson.saveMaterials( mRegisteredHlms[hlmsType], jsonString, additionalTextureExtension );
hlmsJson.saveMaterials( mRegisteredHlms[hlmsType], jsonString,
additionalTextureExtension, sortByName );

std::ofstream file( filename.c_str(), std::ios::binary | std::ios::out );
if( file.is_open() )
Expand Down
Loading