# HG changeset patch # User unc0rr # Date 1231797461 0 # Node ID 209cf0e2fc36c41bae3a6a5ab92a962db26a93a6 # Parent 16f687fc18e34f7cc455e61b4819eab968b786f2 Finish voicepacks support in engine (not tested though) diff -r 16f687fc18e3 -r 209cf0e2fc36 QTfrontend/team.cpp --- a/QTfrontend/team.cpp Mon Jan 12 21:49:41 2009 +0000 +++ b/QTfrontend/team.cpp Mon Jan 12 21:57:41 2009 +0000 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2007 Andrey Korotaev + * Copyright (c) 2005-2007, 2009 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 16f687fc18e3 -r 209cf0e2fc36 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Mon Jan 12 21:49:41 2009 +0000 +++ b/hedgewars/CCHandlers.inc Mon Jan 12 21:57:41 2009 +0000 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2008 Andrey Korotaev + * Copyright (c) 2004-2009 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 16f687fc18e3 -r 209cf0e2fc36 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Mon Jan 12 21:49:41 2009 +0000 +++ b/hedgewars/uConsts.pas Mon Jan 12 21:57:41 2009 +0000 @@ -276,7 +276,7 @@ 'Locale', // ptLocale 'Graphics/AmmoMenu', // ptAmmoMenu 'Graphics/Hedgehog', // ptHedgehog - 'Sounds/voices/Default', // ptVoices + 'Sounds/voices', // ptVoices 'Graphics/Hats' // ptHats ); @@ -473,54 +473,53 @@ Soundz: array[TSound] of record FileName: String[19]; Path : TPathType; - id : PMixChunk; end = ( - (FileName: 'grenadeimpact.ogg'; Path: ptSounds; id: nil),// sndGrenadeImpact - (FileName: 'explosion.ogg'; Path: ptSounds; id: nil),// sndExplosion - (FileName: 'throwpowerup.ogg'; Path: ptSounds; id: nil),// sndThrowPowerUp - (FileName: 'throwrelease.ogg'; Path: ptSounds; id: nil),// sndThrowRelease - (FileName: 'splash.ogg'; Path: ptSounds; id: nil),// sndSplash - (FileName: 'shotgunreload.ogg'; Path: ptSounds; id: nil),// sndShotgunReload - (FileName: 'shotgunfire.ogg'; Path: ptSounds; id: nil),// sndShotgunFire - (FileName: 'graveimpact.ogg'; Path: ptSounds; id: nil),// sndGraveImpact - (FileName: 'minetick.ogg'; Path: ptSounds; id: nil),// sndMineTicks - (FileName: 'pickhammer.ogg'; Path: ptSounds; id: nil),// sndPickhammer - (FileName: 'gun.ogg'; Path: ptSounds; id: nil),// sndGun - (FileName: 'ufo.ogg'; Path: ptSounds; id: nil),// sndUFO - (FileName: 'Jump1.ogg'; Path: ptVoices; id: nil),// sndJump1 - (FileName: 'Jump2.ogg'; Path: ptVoices; id: nil),// sndJump2 - (FileName: 'Jump3.ogg'; Path: ptVoices; id: nil),// sndJump3 - (FileName: 'Yessir.ogg'; Path: ptVoices; id: nil),// sndYesSir - (FileName: 'Laugh.ogg'; Path: ptVoices; id: nil),// sndLaugh - (FileName: 'Illgetyou.ogg'; Path: ptVoices; id: nil),// sndIllGetYou - (FileName: 'Incoming.ogg'; Path: ptVoices; id: nil),// sndIncoming - (FileName: 'Missed.ogg'; Path: ptVoices; id: nil),// sndMissed - (FileName: 'Stupid.ogg'; Path: ptVoices; id: nil),// sndStupid - (FileName: 'Firstblood.ogg'; Path: ptVoices; id: nil),// sndFirstBlood - (FileName: 'Boring.ogg'; Path: ptVoices; id: nil),// sndBoring - (FileName: 'Byebye.ogg'; Path: ptVoices; id: nil),// sndByeBye - (FileName: 'Sameteam.ogg'; Path: ptVoices; id: nil),// sndSameTeam - (FileName: 'Nutter.ogg'; Path: ptVoices; id: nil),// sndNutter - (FileName:'Reinforcements.ogg'; Path: ptVoices; id: nil),// sndReinforce - (FileName: 'Traitor.ogg'; Path: ptVoices; id: nil),// sndTraitor - (FileName:'Youllregretthat.ogg';Path: ptVoices; id: nil),// sndRegret - (FileName: 'Enemydown.ogg'; Path: ptVoices; id: nil),// sndEnemyDown - (FileName: 'Coward.ogg'; Path: ptVoices; id: nil),// sndCoward - (FileName: 'Hurry.ogg'; Path: ptVoices; id: nil),// sndHurry - (FileName: 'Watchit.ogg'; Path: ptVoices; id: nil),// sndWatchIt - (FileName: 'Kamikaze.ogg'; Path: ptVoices; id: nil),// sndKamikaze - (FileName: 'cake2.ogg'; Path: ptSounds; id: nil),// sndCake - (FileName: 'Ow1.ogg'; Path: ptVoices; id: nil),// sndOw1 - (FileName: 'Ow4.ogg'; Path: ptVoices; id: nil),// sndOw4 - (FileName: 'Firepunch1.ogg'; Path: ptSounds; id: nil),// sndFirepunch1 - (FileName: 'Firepunch2.ogg'; Path: ptSounds; id: nil),// sndFirepunch2 - (FileName: 'Firepunch3.ogg'; Path: ptSounds; id: nil),// sndFirepunch3 - (FileName: 'Firepunch4.ogg'; Path: ptSounds; id: nil),// sndFirepunch4 - (FileName: 'Firepunch5.ogg'; Path: ptSounds; id: nil),// sndFirepunch5 - (FileName: 'Firepunch6.ogg'; Path: ptSounds; id: nil),// sndFirepunch6 - (FileName: 'Melon.ogg'; Path: ptSounds; id: nil),// sndMelon - (FileName: 'Hellish.ogg'; Path: ptSounds; id: nil),// sndHellish - (FileName: 'Yoohoo.ogg'; Path: ptSounds; id: nil) // sndYoohoo + (FileName: 'grenadeimpact.ogg'; Path: ptSounds),// sndGrenadeImpact + (FileName: 'explosion.ogg'; Path: ptSounds),// sndExplosion + (FileName: 'throwpowerup.ogg'; Path: ptSounds),// sndThrowPowerUp + (FileName: 'throwrelease.ogg'; Path: ptSounds),// sndThrowRelease + (FileName: 'splash.ogg'; Path: ptSounds),// sndSplash + (FileName: 'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload + (FileName: 'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire + (FileName: 'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact + (FileName: 'minetick.ogg'; Path: ptSounds),// sndMineTicks + (FileName: 'pickhammer.ogg'; Path: ptSounds),// sndPickhammer + (FileName: 'gun.ogg'; Path: ptSounds),// sndGun + (FileName: 'ufo.ogg'; Path: ptSounds),// sndUFO + (FileName: 'Jump1.ogg'; Path: ptVoices),// sndJump1 + (FileName: 'Jump2.ogg'; Path: ptVoices),// sndJump2 + (FileName: 'Jump3.ogg'; Path: ptVoices),// sndJump3 + (FileName: 'Yessir.ogg'; Path: ptVoices),// sndYesSir + (FileName: 'Laugh.ogg'; Path: ptVoices),// sndLaugh + (FileName: 'Illgetyou.ogg'; Path: ptVoices),// sndIllGetYou + (FileName: 'Incoming.ogg'; Path: ptVoices),// sndIncoming + (FileName: 'Missed.ogg'; Path: ptVoices),// sndMissed + (FileName: 'Stupid.ogg'; Path: ptVoices),// sndStupid + (FileName: 'Firstblood.ogg'; Path: ptVoices),// sndFirstBlood + (FileName: 'Boring.ogg'; Path: ptVoices),// sndBoring + (FileName: 'Byebye.ogg'; Path: ptVoices),// sndByeBye + (FileName: 'Sameteam.ogg'; Path: ptVoices),// sndSameTeam + (FileName: 'Nutter.ogg'; Path: ptVoices),// sndNutter + (FileName:'Reinforcements.ogg'; Path: ptVoices),// sndReinforce + (FileName: 'Traitor.ogg'; Path: ptVoices),// sndTraitor + (FileName:'Youllregretthat.ogg';Path: ptVoices),// sndRegret + (FileName: 'Enemydown.ogg'; Path: ptVoices),// sndEnemyDown + (FileName: 'Coward.ogg'; Path: ptVoices),// sndCoward + (FileName: 'Hurry.ogg'; Path: ptVoices),// sndHurry + (FileName: 'Watchit.ogg'; Path: ptVoices),// sndWatchIt + (FileName: 'Kamikaze.ogg'; Path: ptVoices),// sndKamikaze + (FileName: 'cake2.ogg'; Path: ptSounds),// sndCake + (FileName: 'Ow1.ogg'; Path: ptVoices),// sndOw1 + (FileName: 'Ow4.ogg'; Path: ptVoices),// sndOw4 + (FileName: 'Firepunch1.ogg'; Path: ptSounds),// sndFirepunch1 + (FileName: 'Firepunch2.ogg'; Path: ptSounds),// sndFirepunch2 + (FileName: 'Firepunch3.ogg'; Path: ptSounds),// sndFirepunch3 + (FileName: 'Firepunch4.ogg'; Path: ptSounds),// sndFirepunch4 + (FileName: 'Firepunch5.ogg'; Path: ptSounds),// sndFirepunch5 + (FileName: 'Firepunch6.ogg'; Path: ptSounds),// sndFirepunch6 + (FileName: 'Melon.ogg'; Path: ptSounds),// sndMelon + (FileName: 'Hellish.ogg'; Path: ptSounds),// sndHellish + (FileName: 'Yoohoo.ogg'; Path: ptSounds) // sndYoohoo ); Ammoz: array [TAmmoType] of record diff -r 16f687fc18e3 -r 209cf0e2fc36 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Mon Jan 12 21:49:41 2009 +0000 +++ b/hedgewars/uSound.pas Mon Jan 12 21:57:41 2009 +0000 @@ -34,7 +34,9 @@ procedure PlayMusic; procedure StopSound(snd: TSound); function ChangeVolume(voldelta: LongInt): LongInt; + function AskForVoicepack(name: shortstring): Pointer; +procedure SetVoicePack(vp: PVoicePack); var MusicFN: shortstring = ''; @@ -46,6 +48,8 @@ Volume: LongInt; lastChan: array [TSound] of LongInt; voicepacks: array[0..cMaxTeams] of TVoicepack; + defVoicepack: PVoicepack; + currentVP: PVoicepack; function AskForVoicepack(name: shortstring): Pointer; var i: Longword; @@ -61,6 +65,11 @@ AskForVoicepack:= @voicepacks[i] end; +procedure SetVoicePack(vp: PVoicePack); +begin +currentVP:= vp +end; + procedure InitSound; begin if not isSoundEnabled then exit; @@ -80,9 +89,13 @@ procedure ReleaseSound; var i: TSound; + t: Longword; begin -for i:= Low(TSound) to High(TSound) do - Mix_FreeChunk(Soundz[i].id); +for t:= 0 to cMaxTeams do + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if voicepacks[t].chunks[i] <> nil then + Mix_FreeChunk(voicepacks[t].chunks[i]); Mix_FreeMusic(Mus); Mix_CloseAudio @@ -90,19 +103,37 @@ procedure SoundLoad; var i: TSound; - s: shortstring; + s: shortstring; + t: Longword; begin if not isSoundEnabled then exit; -AskForVoicepack('Default'); + +defVoicepack:= AskForVoicepack('Default'); +SetVoicePack(defVoicepack); for i:= Low(TSound) to High(TSound) do - begin - s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(Soundz[i].id <> nil, msgFailed, true); - WriteLnToConsole(msgOK); - end; + if Soundz[i].Path <> ptVoices then + begin + s:= Pathz[Soundz[i].Path] + '/Default/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); + WriteLnToConsole(msgOK); + end; + +for t:= 0 to cMaxTeams do + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if Soundz[i].Path = ptVoices then + begin + s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + if voicepacks[t].chunks[i] = nil then + WriteLnToConsole(msgFailed) + else + WriteLnToConsole(msgOK) + end; end; procedure PlaySound(snd: TSound; infinite: boolean); @@ -110,7 +141,11 @@ begin if (not isSoundEnabled) or fastUntilLag then exit; if infinite then loops:= -1 else loops:= 0; -lastChan[snd]:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1) + +if currentVP^.chunks[snd] <> nil then + lastChan[snd]:= Mix_PlayChannelTimed(-1, currentVP^.chunks[snd], loops, -1) +else + lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1) end; procedure StopSound(snd: TSound);