restored volumen control (hoorray)
authorkoda
Wed, 19 Aug 2009 15:17:21 +0000
changeset 2327 4832b77ec958
parent 2326 0ddf641fddee
child 2328 e74f2db28b21
restored volumen control (hoorray)
hedgewars/uConsts.pas
hedgewars/uMisc.pas
hedgewars/uSound.pas
share/hedgewars/Data/Sounds/shutterclick.ogg
--- a/hedgewars/uConsts.pas	Wed Aug 19 13:49:47 2009 +0000
+++ b/hedgewars/uConsts.pas	Wed Aug 19 15:17:21 2009 +0000
@@ -93,7 +93,7 @@
 			sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6,
 			sndMelon, sndHellish, sndYoohoo, sndRCPlane, sndWhipCrack,
 			sndRideOfTheValkyries, sndDenied, sndPlaced, sndBaseballBat, 
-			sndVaporize, sndWarp, sndSuddenDeath, sndMortar);
+			sndVaporize, sndWarp, sndSuddenDeath, sndMortar, sndShutter);
 
 	TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
 			amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip,
@@ -664,7 +664,8 @@
 			(FileName:                'steam.ogg'; Path: ptSounds),// sndVaporize
 			(FileName:                 'warp.ogg'; Path: ptSounds),// sndWarp
 			(FileName:          'suddendeath.ogg'; Path: ptSounds),// sndSuddenDeath
-			(FileName:               'mortar.ogg'; Path: ptSounds) // sndMortar
+			(FileName:               'mortar.ogg'; Path: ptSounds),// sndMortar
+			(FileName:         'shutterclick.ogg'; Path: ptSounds) // sndShutter			
 			);
 
 	Ammoz: array [TAmmoType] of record
--- a/hedgewars/uMisc.pas	Wed Aug 19 13:49:47 2009 +0000
+++ b/hedgewars/uMisc.pas	Wed Aug 19 15:17:21 2009 +0000
@@ -162,7 +162,7 @@
     TargetPoint: TPoint = (X: NoPointX; Y: 0);
 
 implementation
-uses uConsole, uStore, uIO, Math, uRandom;
+uses uConsole, uStore, uIO, Math, uRandom, uSound;
 var KBnum: Longword = 0;
 {$IFDEF DEBUGFILE}
 var f: textfile;
@@ -522,6 +522,7 @@
 	size: Longword;
 	f: file;
 begin
+playSound(sndShutter, false, nil);
 head[6]:= cScreenWidth;
 head[7]:= cScreenHeight;
 
--- a/hedgewars/uSound.pas	Wed Aug 19 13:49:47 2009 +0000
+++ b/hedgewars/uSound.pas	Wed Aug 19 15:17:21 2009 +0000
@@ -79,7 +79,8 @@
 uses uMisc, uConsole;
 
 const chanTPU = 12;
-var	lastChan: array [TSound] of LongInt;
+var	Volume: LongInt;
+	lastChan: array [TSound] of LongInt;
 	voicepacks: array[0..cMaxTeams] of TVoicepack;
 	defVoicepack: PVoicepack;
 	Mus: LongInt = 0;
@@ -106,6 +107,9 @@
 isSoundEnabled:= openal_init(numSounds);
 if isSoundEnabled then WriteLnToConsole(msgOK)
                   else WriteLnToConsole(msgFailed);
+
+Volume:=0;
+ChangeVolume(cInitVolume);
 end;
 
 procedure ReleaseSound;
@@ -115,7 +119,6 @@
 end;
 
 procedure SoundLoad;
-const volume = 60;
 var i: TSound;
 	s: shortstring;
 	t: Longword;
@@ -130,7 +133,6 @@
 		s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
 		WriteToConsole(msgLoading + s + ' ');
 		defVoicepack^.chunks[i]:= openal_loadfile (Str2PChar(s));
-		openal_setvolume(defVoicepack^.chunks[i],volume);
 		TryDo(defVoicepack^.chunks[i] >= 0, msgFailed, true);
 		WriteLnToConsole(msgOK);
 		end;
@@ -143,7 +145,6 @@
 				s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName;
 				WriteToConsole(msgLoading + s + ' ');
 				voicepacks[t].chunks[i]:= openal_loadfile (Str2PChar(s));
-				openal_setvolume(voicepacks[t].chunks[i],volume);
 				if voicepacks[t].chunks[i] < 0 then
 					WriteLnToConsole(msgFailed)
 				else
@@ -202,7 +203,7 @@
 TryDo(Mus >= 0, msgFailed, false);
 WriteLnToConsole(msgOK);
 
-openal_setvolume(Mus, 60);
+//openal_setvolume(Mus, cInitVolume-40);
 openal_fadein(Mus, 20);
 openal_toggleloop(Mus);
 end;
@@ -210,7 +211,14 @@
 function ChangeVolume(voldelta: LongInt): LongInt;
 begin
 if not isSoundEnabled then exit(0);
-openal_setglobalvolume(voldelta);
+
+inc(Volume, voldelta);
+if Volume < 0 then Volume:= 0;
+if Volume > 100 then Volume:= 100;
+
+openal_setglobalvolume(Volume);
+if isMusicEnabled then openal_setvolume(Mus, Volume shr 1);
+ChangeVolume:= Volume;
 end;
 
 procedure PauseMusic;
Binary file share/hedgewars/Data/Sounds/shutterclick.ogg has changed