From 72248bd95f4f132b16be96948c62f4321399fbab Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 7 May 2021 16:30:52 +0300 Subject: [PATCH] * add optional `soundtypes` keyword of .game config, affecting file types shown in sound browsing dialog --- radiant/entityinspector.cpp | 2 +- radiant/plugin.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index fddffa9e..b486922c 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -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 ) { diff --git a/radiant/plugin.cpp b/radiant/plugin.cpp index 987fdbc0..c5b88aac 100644 --- a/radiant/plugin.cpp +++ b/radiant/plugin.cpp @@ -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();