Merge pull request #384 from westonCoder/add-ambient-sound

Fix Save Load Current Sound Problem
This commit is contained in:
lambertjamesd 2023-10-27 08:25:59 -06:00 committed by GitHub
commit 92056d5e4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 10 deletions

View file

@ -2,7 +2,7 @@ operators:
[]
cutscenes:
INTRO:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- play_animation player player_intro
- play_animation glass_cover_0 glass_cover_0_open
- play_animation glass_cover_1 glass_cover_1_open

View file

@ -2,7 +2,7 @@ operators:
[]
cutscenes:
START:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- delay 1
- start_cutscene portal_loop
- set_signal FIRST_ELEVATOR

View file

@ -1,6 +1,6 @@
cutscenes:
INTRO:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- q_sound SOUNDS_02_PART1_ENTRY_1 CH_GLADOS PORTAL_02_PART1_ENTRY_1
- q_sound SOUNDS_02_PART1_ENTRY_2 CH_GLADOS PORTAL_02_PART1_ENTRY_2
- delay 2

View file

@ -17,7 +17,7 @@ cutscenes:
- wait_for_signal horizontal_activiate 2
- q_sound 03_PART2_PLATFORM_ACTIVATED_1 CH_GLADOS PORTAL_03_PART2_PLATFORM_ACTIVATED_1
INTRO:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- save_checkpoint 0
- open_portal ground_portal 0
- q_sound SOUNDS_03_PART1_ENTRY_1 CH_GLADOS PORTAL_03_PART1_ENTRY_1

View file

@ -2,7 +2,7 @@ cutscenes:
SUCCESS:
- q_sound SOUNDS_04_PART1_SUCCESS_1 CH_GLADOS PORTAL_04_PART1_SUCCESS_1
INTRO_CUTSCENE:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- q_sound SOUNDS_04_PART1_ENTRY_1 CH_GLADOS PORTAL_04_PART1_ENTRY_1
- wait_for_channel CH_GLADOS
- q_sound PORTAL_PROCEDURAL_JIGGLE_BONE CH_MUSIC SubtitleKeyNone

View file

@ -2,7 +2,7 @@ operators:
[]
cutscenes:
INTRO_CUTSCENE:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- set_signal cube_dropper
- open_portal portal_0 0
- q_sound SOUNDS_05_PART1_ENTRY_1 CH_GLADOS PORTAL_05_PART1_ENTRY_1

View file

@ -8,7 +8,7 @@ cutscenes:
- play_animation piston_top piston_top_0
- play_animation piston_bottom piston_bottom_0
FIRST_ROOM:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- q_sound SOUNDS_06_PART1_ENTRY_1 CH_GLADOS PORTAL_06_PART1_ENTRY_1
- delay 2
- rumble 2

View file

@ -21,7 +21,7 @@ cutscenes:
DROWN_PLAYER:
- kill_player water
START:
- play_sound AMBIENCE_BASE 0.2 0.5
- q_sound AMBIENCE_BASE CH_AMBIENT SubtitleKeyNone 0.55
- delay 1
- start_cutscene portal_loop
- start_cutscene platform_ferry

View file

@ -41,10 +41,15 @@ struct QueuedSound* gCutsceneNextFreeSound;
struct QueuedSound* gCutsceneSoundQueues[CH_COUNT];
ALSndId gCutsceneCurrentSound[CH_COUNT];
u16 gCutsceneCurrentSoundId[CH_COUNT];
u16 gCutsceneCurrentSubtitleId[CH_COUNT];
float gCutsceneCurrentVolume[CH_COUNT];
float gCutsceneChannelPitch[CH_COUNT] = {
[CH_GLADOS] = 0.5f,
[CH_MUSIC] = 0.5f,
[CH_AMBIENT] = 0.5f
};
void cutsceneRunnerCancel(struct CutsceneRunner* runner);
@ -62,6 +67,9 @@ void cutsceneRunnerReset() {
for (int i = 0; i < CH_COUNT; ++i) {
gCutsceneSoundQueues[i] = NULL;
gCutsceneCurrentSound[i] = SOUND_ID_NONE;
gCutsceneCurrentSoundId[i] = SOUND_ID_NONE;
gCutsceneCurrentSubtitleId[i] = SubtitleKeyNone;
gCutsceneCurrentVolume[i] = 0.0f;
}
struct CutsceneRunner* current = gRunningCutscenes;
@ -463,6 +471,8 @@ void cutscenesUpdateSounds() {
subtitleType = SubtitleTypeCloseCaption;
}else if (i == CH_MUSIC){
soundType = SoundTypeMusic;
}else if (i == CH_AMBIENT){
soundType = SoundTypeAll;
}
if (!soundPlayerIsPlaying(gCutsceneCurrentSound[i])) {
@ -470,7 +480,12 @@ void cutscenesUpdateSounds() {
struct QueuedSound* curr = gCutsceneSoundQueues[i];
gCutsceneCurrentSound[i] = soundPlayerPlay(curr->soundId, curr->volume, gCutsceneChannelPitch[i], NULL, NULL, soundType);
hudShowSubtitle(&gScene.hud, curr->subtitleId, subtitleType);
gCutsceneCurrentSoundId[i] = curr->soundId;
gCutsceneCurrentSubtitleId[i] = curr->subtitleId;
gCutsceneCurrentVolume[i] = curr->volume;
if (curr->subtitleId != SubtitleKeyNone){
hudShowSubtitle(&gScene.hud, curr->subtitleId, subtitleType);
}
gCutsceneSoundQueues[i] = curr->next;
@ -483,6 +498,9 @@ void cutscenesUpdateSounds() {
}
gCutsceneCurrentSound[i] = SOUND_ID_NONE;
gCutsceneCurrentSoundId[i] = SOUND_ID_NONE;
gCutsceneCurrentSubtitleId[i] = SubtitleKeyNone;
gCutsceneCurrentVolume[i] = 0.0f;
}
}
}
@ -609,6 +627,20 @@ void cutsceneSerializeWrite(struct Serializer* serializer, SerializeAction actio
action(serializer, &gTriggeredCutscenes, sizeof(gTriggeredCutscenes));
for (int i = 0; i < CH_COUNT; ++i) {
s16 curr = gCutsceneCurrentSound[i];
action(serializer, &curr, sizeof(curr));
u16 currId = gCutsceneCurrentSoundId[i];
action(serializer, &currId, sizeof(currId));
u16 subtitleId = gCutsceneCurrentSubtitleId[i];
action(serializer, &subtitleId, sizeof(subtitleId));
u8 volume = (u8)(clampf(gCutsceneCurrentVolume[i], 0.0f, 1.0f) * 255.0f);
action(serializer, &volume, sizeof(volume));
}
for (int i = 0; i < CH_COUNT; ++i) {
struct QueuedSound* curr = gCutsceneSoundQueues[i];
@ -639,6 +671,27 @@ void cutsceneSerializeRead(struct Serializer* serializer) {
serializeRead(serializer, &gTriggeredCutscenes, sizeof (gTriggeredCutscenes));
for (int i = 0; i < CH_COUNT; ++i) {
s16 curr;
serializeRead(serializer, &curr, sizeof(curr));
gCutsceneCurrentSound[i] = curr;
u16 currId;
serializeRead(serializer, &currId, sizeof(currId));
gCutsceneCurrentSoundId[i] = currId;
u16 subtitleId;
serializeRead(serializer, &subtitleId, sizeof(subtitleId));
gCutsceneCurrentSubtitleId[i] = subtitleId;
u8 volume;
serializeRead(serializer, &volume, sizeof(volume));
gCutsceneCurrentVolume[i] = volume * (1.0f / 255.0f);
if (curr != SOUND_ID_NONE){
cutsceneQueueSound(gCutsceneCurrentSoundId[i], gCutsceneCurrentVolume[i], i, gCutsceneCurrentSubtitleId[i]);
}
}
for (int i = 0; i < CH_COUNT; ++i) {
s16 nextId;
serializeRead(serializer, &nextId, sizeof(nextId));

View file

@ -69,8 +69,9 @@ enum CutscenePromptType {
#define CH_NONE 0xFF
#define CH_GLADOS 0
#define CH_MUSIC 1
#define CH_AMBIENT 2
#define CH_COUNT 2
#define CH_COUNT 3
struct CutsceneStep {
enum CutsceneStepType type;