* add optional soundtypes keyword of .game config, affecting file types shown in sound browsing dialog

This commit is contained in:
Garux 2021-05-07 16:30:52 +03:00
parent 9eefda4fc5
commit 72248bd95f
2 changed files with 20 additions and 2 deletions

View File

@ -323,7 +323,7 @@ const char* browse_sound( GtkWidget* parent, const char* filepath ){
}
}
const char* filename = file_dialog( parent, true, "Open Wav File", buffer.c_str(), "sound" );
const char* filename = file_dialog( parent, true, "Open Sound File", buffer.c_str(), "sound" );
if ( filename != 0 ) {
const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
if ( relative == filename ) {

View File

@ -221,13 +221,31 @@ public:
}
};
#include "stream/stringstream.h"
void SoundTypes_register(){
const char *names = GlobalRadiant().getGameDescriptionKeyValue( "soundtypes" );
if( string_empty( names ) ){
names = "wav";
}
else if( string_equal( names, "*" ) ){
names = "wav ogg mp3";
}
StringTokeniser tokeniser( names );
const char* name;
while( !string_empty( name = tokeniser.getToken() ) )
{
GlobalFiletypes().addType( "sound", name, filetype_t( StringOutputStream()( name, " sound files" ), StringOutputStream()( "*.", name ) ) );
}
}
class Radiant : public TypeSystemRef
{
public:
Radiant(){
Preferences_Init();
GlobalFiletypes().addType( "sound", "wav", filetype_t( "PCM sound files", "*.wav" ) );
SoundTypes_register();
Selection_construct();
HomePaths_Construct();