Skip to content

Commit

Permalink
Set default glTF export file name from NIF name
Browse files Browse the repository at this point in the history
  • Loading branch information
fo76utils committed Feb 8, 2025
1 parent 91356d3 commit e42114b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/lib/importex/gltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,29 @@ static QString getGltfFolder( const NifModel * nif )
return settings.value( "Spells//Extract File/Last File Path", QString() ).toString();
}

void exportGltf( const NifModel* nif, const Scene* scene, [[maybe_unused]] const QModelIndex& index )
void exportGltf( const NifModel * nif, const Scene * scene, [[maybe_unused]] const QModelIndex & index )
{
QString filename = QFileDialog::getSaveFileName(qApp->activeWindow(), tr("Choose a .glTF file for export"), getGltfFolder(nif), "glTF (*.gltf)");
QString filename = getGltfFolder( nif );
if ( auto w = qobject_cast< const NifSkope * >( nif->getWindow() ); w ) {
if ( auto nifPath = w->getCurrentFile(); !nifPath.isEmpty() ) {
if ( nifPath.endsWith( QLatin1StringView(".nif"), Qt::CaseInsensitive )
|| nifPath.endsWith( QLatin1StringView(".bto"), Qt::CaseInsensitive )
|| nifPath.endsWith( QLatin1StringView(".btr"), Qt::CaseInsensitive ) ) {
nifPath.chop( 4 );
}
#ifdef Q_OS_WIN32
nifPath.replace( QChar('\\'), QChar('/') );
#endif
nifPath.remove( 0, nifPath.lastIndexOf( QChar('/') ) + 1 );
if ( !nifPath.isEmpty() ) {
if ( !filename.isEmpty() && !filename.endsWith( QChar('/') ) )
filename.append( QChar('/') );
filename.append( nifPath );
filename.append( QLatin1StringView(".gltf") );
}
}
}
filename = QFileDialog::getSaveFileName(qApp->activeWindow(), tr("Choose a .glTF file for export"), filename, "glTF (*.gltf)");
bool useFullMatPaths;
int textureMipLevel;
if ( filename.isEmpty() ) {
Expand Down

0 comments on commit e42114b

Please sign in to comment.