Explorar o código

Use .sound as metadata resource

Daniele Bartolini %!s(int64=11) %!d(string=hai) anos
pai
achega
ec226f454b
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      engine/resource/sound_resource.cpp

+ 9 - 1
engine/resource/sound_resource.cpp

@@ -35,6 +35,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "os.h"
 #include "os.h"
 #include "sound_resource.h"
 #include "sound_resource.h"
 #include "string_utils.h"
 #include "string_utils.h"
+#include "json_parser.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -106,7 +107,14 @@ namespace sound_resource
 	{
 	{
 		const uint32_t VERSION = 1;
 		const uint32_t VERSION = 1;
 
 
-		Buffer sound = opts.read(path);
+		Buffer buf = opts.read(path);
+		JSONParser json(array::begin(buf));
+		JSONElement root = json.root();
+
+		DynamicString name;
+		root.key("source").to_string(name);
+
+		Buffer sound = opts.read(name.c_str());
 		const WAVHeader* wav = (const WAVHeader*)array::begin(sound);
 		const WAVHeader* wav = (const WAVHeader*)array::begin(sound);
 		const char* wavdata = (const char*) (wav + 1);
 		const char* wavdata = (const char*) (wav + 1);