Эх сурвалжийг харах

[c] Added event volume and balance, see #1171.

badlogic 7 жил өмнө
parent
commit
7e1a0c172d

+ 4 - 4
examples/export/runtimes.sh

@@ -161,8 +161,8 @@ cp -f ../raptor/export/raptor-pro.skel ../../spine-sfml/c/data/
 cp -f ../raptor/export/raptor.atlas ../../spine-sfml/c/data/
 cp -f ../raptor/export/raptor.atlas ../../spine-sfml/c/data/
 cp -f ../raptor/export/raptor.png ../../spine-sfml/c/data/
 cp -f ../raptor/export/raptor.png ../../spine-sfml/c/data/
 
 
-cp -f ../spineboy/export/spineboy-ess.json ../../spine-sfml/c/data/
-cp -f ../spineboy/export/spineboy-ess.skel ../../spine-sfml/c/data/
+cp -f ../spineboy/export/spineboy-pro.json ../../spine-sfml/c/data/
+cp -f ../spineboy/export/spineboy-pro.skel ../../spine-sfml/c/data/
 cp -f ../spineboy/export/spineboy.atlas ../../spine-sfml/c/data/
 cp -f ../spineboy/export/spineboy.atlas ../../spine-sfml/c/data/
 cp -f ../spineboy/export/spineboy.png ../../spine-sfml/c/data/
 cp -f ../spineboy/export/spineboy.png ../../spine-sfml/c/data/
 
 
@@ -206,8 +206,8 @@ cp -f ../raptor/export/raptor-pro.skel ../../spine-sfml/cpp/data/
 cp -f ../raptor/export/raptor.atlas ../../spine-sfml/cpp/data/
 cp -f ../raptor/export/raptor.atlas ../../spine-sfml/cpp/data/
 cp -f ../raptor/export/raptor.png ../../spine-sfml/cpp/data/
 cp -f ../raptor/export/raptor.png ../../spine-sfml/cpp/data/
 
 
-cp -f ../spineboy/export/spineboy-ess.json ../../spine-sfml/cpp/data/
-cp -f ../spineboy/export/spineboy-ess.skel ../../spine-sfml/cpp/data/
+cp -f ../spineboy/export/spineboy-pro.json ../../spine-sfml/cpp/data/
+cp -f ../spineboy/export/spineboy-pro.skel ../../spine-sfml/cpp/data/
 cp -f ../spineboy/export/spineboy.atlas ../../spine-sfml/cpp/data/
 cp -f ../spineboy/export/spineboy.atlas ../../spine-sfml/cpp/data/
 cp -f ../spineboy/export/spineboy.png ../../spine-sfml/cpp/data/
 cp -f ../spineboy/export/spineboy.png ../../spine-sfml/cpp/data/
 
 

+ 5 - 1
spine-c/spine-c/include/spine/Event.h

@@ -44,6 +44,8 @@ typedef struct spEvent {
 	int intValue;
 	int intValue;
 	float floatValue;
 	float floatValue;
 	const char* stringValue;
 	const char* stringValue;
+	float volume;
+	float balance;
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 	spEvent() :
 	spEvent() :
@@ -51,7 +53,9 @@ typedef struct spEvent {
 		time(0),
 		time(0),
 		intValue(0),
 		intValue(0),
 		floatValue(0),
 		floatValue(0),
-		stringValue(0) {
+		stringValue(0),
+		volume(0),
+		balance(0) {
 	}
 	}
 #endif
 #endif
 } spEvent;
 } spEvent;

+ 5 - 1
spine-c/spine-c/include/spine/EventData.h

@@ -43,6 +43,8 @@ typedef struct spEventData {
 	float floatValue;
 	float floatValue;
 	const char* stringValue;
 	const char* stringValue;
 	const char* audioPath;
 	const char* audioPath;
+	float volume;
+	float balance;
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 	spEventData() :
 	spEventData() :
@@ -50,7 +52,9 @@ typedef struct spEventData {
 		intValue(0),
 		intValue(0),
 		floatValue(0),
 		floatValue(0),
 		stringValue(0),
 		stringValue(0),
-		audioPath(0) {
+		audioPath(0),
+		volume(0),
+		balance(0) {
 	}
 	}
 #endif
 #endif
 } spEventData;
 } spEventData;

+ 8 - 0
spine-c/spine-c/src/spine/SkeletonBinary.c

@@ -592,6 +592,10 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
 				event->stringValue = readString(input);
 				event->stringValue = readString(input);
 			else
 			else
 				MALLOC_STR(event->stringValue, eventData->stringValue);
 				MALLOC_STR(event->stringValue, eventData->stringValue);
+			if (eventData->audioPath) {
+				event->volume = readFloat(input);
+				event->balance = readFloat(input);
+			}
 			spEventTimeline_setFrame(timeline, i, event);
 			spEventTimeline_setFrame(timeline, i, event);
 		}
 		}
 		spTimelineArray_add(timelines, (spTimeline*)timeline);
 		spTimelineArray_add(timelines, (spTimeline*)timeline);
@@ -1075,6 +1079,10 @@ spSkeletonData* spSkeletonBinary_readSkeletonData (spSkeletonBinary* self, const
 		eventData->floatValue = readFloat(input);
 		eventData->floatValue = readFloat(input);
 		eventData->stringValue = readString(input);
 		eventData->stringValue = readString(input);
 		eventData->audioPath = readString(input);
 		eventData->audioPath = readString(input);
+		if (eventData->audioPath) {
+			eventData->volume = readFloat(input);
+			eventData->balance = readFloat(input);
+		}
 		skeletonData->events[i] = eventData;
 		skeletonData->events[i] = eventData;
 	}
 	}
 
 

+ 11 - 0
spine-c/spine-c/src/spine/SkeletonJson.c

@@ -502,6 +502,10 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
 			event->floatValue = Json_getFloat(valueMap, "float", eventData->floatValue);
 			event->floatValue = Json_getFloat(valueMap, "float", eventData->floatValue);
 			stringValue = Json_getString(valueMap, "string", eventData->stringValue);
 			stringValue = Json_getString(valueMap, "string", eventData->stringValue);
 			if (stringValue) MALLOC_STR(event->stringValue, stringValue);
 			if (stringValue) MALLOC_STR(event->stringValue, stringValue);
+			if (eventData->audioPath) {
+				event->volume = Json_getFloat(valueMap, "volume", 1);
+				event->balance = Json_getFloat(valueMap, "volume", 0);
+			}
 			spEventTimeline_setFrame(timeline, frameIndex, event);
 			spEventTimeline_setFrame(timeline, frameIndex, event);
 		}
 		}
 		animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
 		animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
@@ -1081,6 +1085,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
 	if (events) {
 	if (events) {
 		Json *eventMap;
 		Json *eventMap;
 		const char* stringValue;
 		const char* stringValue;
+		const char* audioPath;
 		skeletonData->eventsCount = events->size;
 		skeletonData->eventsCount = events->size;
 		skeletonData->events = MALLOC(spEventData*, events->size);
 		skeletonData->events = MALLOC(spEventData*, events->size);
 		for (eventMap = events->child, i = 0; eventMap; eventMap = eventMap->next, ++i) {
 		for (eventMap = events->child, i = 0; eventMap; eventMap = eventMap->next, ++i) {
@@ -1089,6 +1094,12 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
 			eventData->floatValue = Json_getFloat(eventMap, "float", 0);
 			eventData->floatValue = Json_getFloat(eventMap, "float", 0);
 			stringValue = Json_getString(eventMap, "string", 0);
 			stringValue = Json_getString(eventMap, "string", 0);
 			if (stringValue) MALLOC_STR(eventData->stringValue, stringValue);
 			if (stringValue) MALLOC_STR(eventData->stringValue, stringValue);
+			audioPath = Json_getString(eventMap, "audio", 0);
+			if (audioPath) {
+				MALLOC_STR(eventData->audioPath, audioPath);
+				eventData->volume = Json_getFloat(eventMap, "volume", 1);
+				eventData->balance = Json_getFloat(eventMap, "balance", 0);
+			}
 			skeletonData->events[i] = eventData;
 			skeletonData->events[i] = eventData;
 		}
 		}
 	}
 	}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
spine-sfml/c/data/spineboy-ess.json


BIN
spine-sfml/c/data/spineboy-ess.skel


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
spine-sfml/c/data/spineboy-pro.json


BIN
spine-sfml/c/data/spineboy-pro.skel


+ 3 - 3
spine-sfml/c/example/main.cpp

@@ -60,8 +60,8 @@ void callback (AnimationState* state, EventType type, TrackEntry* entry, Event*
 		printf("%d dispose: %s\n", entry->trackIndex, animationName);
 		printf("%d dispose: %s\n", entry->trackIndex, animationName);
 		break;
 		break;
 	case ANIMATION_EVENT:
 	case ANIMATION_EVENT:
-		printf("%d event: %s, %s: %d, %f, %s\n", entry->trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
-				event->stringValue);
+		printf("%d event: %s, %s: %d, %f, %s %f %f\n", entry->trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
+				event->stringValue, event->volume, event->balance);
 		break;
 		break;
 	}
 	}
 	fflush(stdout);
 	fflush(stdout);
@@ -442,13 +442,13 @@ void test (SkeletonData* skeletonData, Atlas* atlas) {
 
 
 int main () {
 int main () {
 	testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
 	testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
+	testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy.atlas", 0.6f);
 	testcase(stretchyman, "data/stretchyman-stretchy-ik.json", "data/stretchyman-stretchy-ik.skel", "data/stretchyman.atlas", 0.6f);
 	testcase(stretchyman, "data/stretchyman-stretchy-ik.json", "data/stretchyman-stretchy-ik.skel", "data/stretchyman.atlas", 0.6f);
 	testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
 	testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
 	testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
 	testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
 	testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f);
 	testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f);
 	testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f);
 	testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f);
 	testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
 	testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
-	testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
 	testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f);
 	testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f);
 	testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f);
 	testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f);
 	return 0;
 	return 0;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
spine-sfml/cpp/data/spineboy-ess.json


BIN
spine-sfml/cpp/data/spineboy-ess.skel


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
spine-sfml/cpp/data/spineboy-pro.json


BIN
spine-sfml/cpp/data/spineboy-pro.skel


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно