equal
deleted
inserted
replaced
45 |
45 |
46 // MUSIC |
46 // MUSIC |
47 |
47 |
48 // Obvious music commands for music track |
48 // Obvious music commands for music track |
49 procedure SetMusic(enabled: boolean); // Enable/disable music. |
49 procedure SetMusic(enabled: boolean); // Enable/disable music. |
50 procedure SetMusicName(musicname: shortstring); // Enable/disable music and set name of the file to play. |
50 procedure SetMusicName(musicname: shortstring); // Set name of the file to play. |
51 procedure PlayMusic; // Play music from the start. |
51 procedure PlayMusic; // Play music from the start. |
52 procedure PauseMusic; // Pause music. |
52 procedure PauseMusic; // Pause music. |
53 procedure ResumeMusic; // Resume music from pause point. |
53 procedure ResumeMusic; // Resume music from pause point. |
54 procedure ChangeMusic(musicname: shortstring); // Replaces music track with musicname and plays it. |
54 procedure ChangeMusic(musicname: shortstring); // Replaces music track with musicname and plays it. |
55 procedure StopMusic; // Stops and releases the current track. |
55 procedure StopMusic; // Stops and releases the current track. |
93 |
93 |
94 |
94 |
95 // MISC |
95 // MISC |
96 |
96 |
97 // Set the initial volume |
97 // Set the initial volume |
98 procedure SetVolume(volume: LongInt); |
98 procedure SetVolume(vol: LongInt); |
99 |
99 |
100 // Modifies the sound volume of the game by voldelta and returns the new volume level. |
100 // Modifies the sound volume of the game by voldelta and returns the new volume level. |
101 function ChangeVolume(voldelta: LongInt): LongInt; |
101 function ChangeVolume(voldelta: LongInt): LongInt; |
102 |
102 |
103 // Returns a pointer to the voicepack with the given name. |
103 // Returns a pointer to the voicepack with the given name. |
112 cInitVolume: LongInt; |
112 cInitVolume: LongInt; |
113 previousVolume: LongInt; // cached volume value |
113 previousVolume: LongInt; // cached volume value |
114 lastChan: array [TSound] of LongInt; |
114 lastChan: array [TSound] of LongInt; |
115 voicepacks: array[0..cMaxTeams] of TVoicepack; |
115 voicepacks: array[0..cMaxTeams] of TVoicepack; |
116 defVoicepack: PVoicepack; |
116 defVoicepack: PVoicepack; |
117 Mus: PMixMusic = nil; // music pointer |
117 Mus: PMixMusic; // music pointer |
118 MusicFN: shortstring; // music file name |
118 MusicFN: shortstring; // music file name |
119 isMusicEnabled: boolean; |
119 isMusicEnabled: boolean; |
120 isSoundEnabled: boolean; |
120 isSoundEnabled: boolean; |
121 isSEBackup: boolean; |
121 isSEBackup: boolean; |
122 |
122 |
443 WriteLnToConsole(msgOK); |
443 WriteLnToConsole(msgOK); |
444 |
444 |
445 SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false) |
445 SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false) |
446 end; |
446 end; |
447 |
447 |
448 procedure SetVolume(volume: LongInt); |
448 procedure SetVolume(vol: LongInt); |
449 begin |
449 begin |
450 cInitVolume:= volume; |
450 cInitVolume:= vol; |
451 end; |
451 end; |
452 |
452 |
453 function ChangeVolume(voldelta: LongInt): LongInt; |
453 function ChangeVolume(voldelta: LongInt): LongInt; |
454 begin |
454 begin |
455 ChangeVolume:= 0; |
455 ChangeVolume:= 0; |
456 if (not isSoundEnabled) or (voldelta = 0) then |
456 if (not isSoundEnabled) or ((voldelta = 0) and not (cInitVolume = 0)) then |
457 exit; |
457 exit; |
458 |
458 |
459 inc(Volume, voldelta); |
459 inc(Volume, voldelta); |
460 if Volume < 0 then |
460 if Volume < 0 then |
461 Volume:= 0; |
461 Volume:= 0; |
492 end; |
492 end; |
493 |
493 |
494 procedure MuteAudio; |
494 procedure MuteAudio; |
495 begin |
495 begin |
496 if (not isSoundEnabled) then |
496 if (not isSoundEnabled) then |
497 exit; |
497 exit; |
498 |
498 |
499 if (isAudioMuted) then |
499 if (isAudioMuted) then |
500 begin |
500 begin |
501 ResumeMusic; |
501 ResumeMusic; |
502 ChangeVolume(previousVolume); |
502 ChangeVolume(previousVolume); |
512 end; |
512 end; |
513 |
513 |
514 procedure SetMusic(enabled: boolean); |
514 procedure SetMusic(enabled: boolean); |
515 begin |
515 begin |
516 isMusicEnabled:= enabled; |
516 isMusicEnabled:= enabled; |
517 MusicFN:= ''; |
|
518 end; |
517 end; |
519 |
518 |
520 procedure SetMusicName(musicname: shortstring); |
519 procedure SetMusicName(musicname: shortstring); |
521 begin |
520 begin |
522 isMusicEnabled:= not (musicname = ''); |
|
523 MusicFN:= musicname; |
521 MusicFN:= musicname; |
524 end; |
522 end; |
525 |
523 |
526 procedure PauseMusic; |
524 procedure PauseMusic; |
527 begin |
525 begin |
585 begin |
583 begin |
586 RegisterVariable('voicepack', @chVoicepack, false); |
584 RegisterVariable('voicepack', @chVoicepack, false); |
587 RegisterVariable('mute' , @chMute , true ); |
585 RegisterVariable('mute' , @chMute , true ); |
588 |
586 |
589 MusicFN:=''; |
587 MusicFN:=''; |
|
588 Mus:= nil; |
|
589 isMusicEnabled:= true; |
|
590 isSoundEnabled:= true; |
590 isAudioMuted:= false; |
591 isAudioMuted:= false; |
591 isSEBackup:= isSoundEnabled; |
592 isSEBackup:= isSoundEnabled; |
592 Volume:= 0; |
593 Volume:= 0; |
|
594 cInitVolume:= 100; |
593 defVoicepack:= AskForVoicepack('Default'); |
595 defVoicepack:= AskForVoicepack('Default'); |
594 |
596 |
595 for i:= Low(TSound) to High(TSound) do |
597 for i:= Low(TSound) to High(TSound) do |
596 lastChan[i]:= -1; |
598 lastChan[i]:= -1; |
597 |
599 |
600 if voicepacks[t].name <> '' then |
602 if voicepacks[t].name <> '' then |
601 for i:= Low(TSound) to High(TSound) do |
603 for i:= Low(TSound) to High(TSound) do |
602 voicepacks[t].chunks[i]:= nil; |
604 voicepacks[t].chunks[i]:= nil; |
603 |
605 |
604 (* on MOBILE SDL_mixer has to be compiled against Tremor (USE_OGG_TREMOR) |
606 (* on MOBILE SDL_mixer has to be compiled against Tremor (USE_OGG_TREMOR) |
605 or sound files bigger than 32k will lockup the game*) |
607 or sound files bigger than 32k will lockup the game *) |
606 for i:= Low(TSound) to High(TSound) do |
608 for i:= Low(TSound) to High(TSound) do |
607 defVoicepack^.chunks[i]:= nil; |
609 defVoicepack^.chunks[i]:= nil; |
608 |
610 |
609 end; |
611 end; |
610 |
612 |
611 procedure freeModule; |
613 procedure freeModule; |
612 begin |
614 begin |
613 if isSoundEnabled then |
615 if isSoundEnabled then |
614 ReleaseSound(true); |
616 ReleaseSound(true); |
615 // koda still needs to fix this properly. when he rearranged things, he made these variables get |
|
616 // reset after argparsers picks them up |
|
617 isMusicEnabled:= true; |
|
618 isSoundEnabled:= true; |
|
619 cInitVolume:= 100; |
|
620 end; |
617 end; |
621 |
618 |
622 end. |
619 end. |
623 |
620 |