--- a/QTfrontend/binds.h Tue Sep 26 20:25:42 2006 +0000
+++ b/QTfrontend/binds.h Wed Sep 27 20:13:29 2006 +0000
@@ -37,7 +37,7 @@
#include <QString>
#include <QtGlobal>
-#define BINDS_NUMBER 26
+#define BINDS_NUMBER 28
struct BindAction
{
@@ -72,6 +72,8 @@
{"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), false},
{"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), false},
{"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), true},
+ {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), false},
+ {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), false},
{"fullscr", "f", QT_TRANSLATE_NOOP("binds", "change mode"), false},
{"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), false},
{"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), true}
--- a/QTfrontend/game.cpp Tue Sep 26 20:25:42 2006 +0000
+++ b/QTfrontend/game.cpp Wed Sep 27 20:13:29 2006 +0000
@@ -257,6 +257,7 @@
arguments << (config->vid_Fullscreen() ? "1" : "0");
arguments << (config->isSoundEnabled() ? "1" : "0");
arguments << tr("en.txt");
+ arguments << "128";
process->start(bindir->absolutePath() + "/hwengine", arguments);
}
--- a/hedgewars/CCHandlers.inc Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/CCHandlers.inc Wed Sep 27 20:13:29 2006 +0000
@@ -402,3 +402,23 @@
SDL_ShowCursor(0)
end;
+procedure chVolUp_p(var s: shortstring);
+begin
+cVolumeDelta:= 3
+end;
+
+procedure chVolUp_m(var s: shortstring);
+begin
+cVolumeDelta:= 0
+end;
+
+procedure chVolDown_p(var s: shortstring);
+begin
+cVolumeDelta:= -3
+end;
+
+procedure chVolDown_m(var s: shortstring);
+begin
+cVolumeDelta:= 0
+end;
+
--- a/hedgewars/SDLh.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/SDLh.pas Wed Sep 27 20:13:29 2006 +0000
@@ -274,6 +274,8 @@
SDL_MixerLibName = 'libSDL_mixer.so';
{$ENDIF}
+const MIX_MAX_VOLUME = 128;
+
type PMixChunk = ^TMixChunk;
TMixChunk = record
allocated: Longword;
@@ -302,9 +304,11 @@
function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
+function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName;
function Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
-function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName;
procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName;
procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName;
--- a/hedgewars/hwengine.dpr Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/hwengine.dpr Wed Sep 27 20:13:29 2006 +0000
@@ -185,7 +185,7 @@
AddFileLog(inttostr(i) + ': ' + ParamStr(i));
{$ENDIF}
case ParamCount of
- 7: begin
+ 8: begin
val(ParamStr(1), cScreenWidth, c);
val(ParamStr(2), cScreenHeight, c);
cBitsStr:= ParamStr(3);
@@ -194,6 +194,7 @@
cFullScreen:= ParamStr(5) = '1';
isSoundEnabled:= ParamStr(6) = '1';
cLocaleFName:= ParamStr(7);
+ val(ParamStr(8), cInitVolume, c);
end;
2: begin
val(ParamStr(1), ipcPort, c);
--- a/hedgewars/uConsole.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uConsole.pas Wed Sep 27 20:13:29 2006 +0000
@@ -312,6 +312,10 @@
RegisterVariable('ljump' , vtCommand, @chLJump , false);
RegisterVariable('hjump' , vtCommand, @chHJump , false);
RegisterVariable('fullscr' , vtCommand, @chFullScr , true );
+RegisterVariable('+volup' , vtCommand, @chVolUp_p , true );
+RegisterVariable('-volup' , vtCommand, @chVolUp_m , true );
+RegisterVariable('+voldown', vtCommand, @chVolDown_p , true );
+RegisterVariable('-voldown', vtCommand, @chVolDown_m , true );
finalization
FreeVariablesList
--- a/hedgewars/uConsts.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uConsts.pas Wed Sep 27 20:13:29 2006 +0000
@@ -61,7 +61,7 @@
amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch,
amBaseballBat);
THWFont = (fnt16, fntBig);
- TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpNetSay);
+ TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpNetSay, capgrpVolume);
THHFont = record
Handle: PTTF_Font;
Height: integer;
--- a/hedgewars/uMisc.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uMisc.pas Wed Sep 27 20:13:29 2006 +0000
@@ -81,6 +81,8 @@
cFullScreen : boolean = true;
cLocaleFName : shortstring = 'en.txt';
cSeed : shortstring = '';
+ cInitVolume : integer = 128;
+ cVolumeDelta : integer = 0;
const
cMaxPower = 1500;
--- a/hedgewars/uSound.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uSound.pas Wed Sep 27 20:13:29 2006 +0000
@@ -42,11 +42,13 @@
procedure PlaySound(snd: TSound);
procedure PlayMusic;
procedure StopTPUSound;
+function ChangeVolume(voldelta: integer): integer;
implementation
uses uMisc, uConsole;
const chanTPU = 12;
var Mus: PMixMusic;
+ Volume: integer;
procedure InitSound;
begin
@@ -58,7 +60,11 @@
if isSoundEnabled then WriteLnToConsole(msgOK)
else WriteLnToConsole(msgFailed);
Mix_AllocateChannels(Succ(chanTPU));
-Mix_VolumeMusic(48)
+Mix_VolumeMusic(48);
+
+Volume:= cInitVolume;
+if Volume < 0 then Volume:= 0;
+Volume:= Mix_Volume(-1, Volume)
end;
procedure ReleaseSound;
@@ -112,4 +118,12 @@
Mix_PlayMusic(Mus, -1)
end;
+function ChangeVolume(voldelta: integer): integer;
+begin
+inc(Volume, voldelta);
+if Volume < 0 then Volume:= 0;
+Volume:= Mix_Volume(-1, Volume);
+Result:= Volume * 100 div MIX_MAX_VOLUME
+end;
+
end.
--- a/hedgewars/uWorld.pas Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uWorld.pas Wed Sep 27 20:13:29 2006 +0000
@@ -51,16 +51,16 @@
bSelected: boolean = false;
implementation
-uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale;
+uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound;
const RealTicks: Longword = 0;
Frames: Longword = 0;
FPS: Longword = 0;
CountTicks: Longword = 0;
+ SoundTimerTicks: Longword = 0;
prevPoint: TPoint = (X: 0; Y: 0);
type TCaptionStr = record
Surf: PSDL_Surface;
- StorePos: Longword;
Group: TCapGroup;
EndTime: LongWord;
end;
@@ -169,6 +169,7 @@
r: TSDL_Rect;
team: PTeam;
tdx, tdy: Double;
+ s: string[15];
procedure DrawRepeated(spr: TSprite; Shift: integer);
var i, w: integer;
@@ -391,11 +392,22 @@
Frames:= 0;
CountTicks:= 0;
end;
-if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface)
+if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface);
+
+inc(SoundTimerTicks, Lag);
+if SoundTimerTicks >= 50 then
+ begin
+ SoundTimerTicks:= 0;
+ if cVolumeDelta <> 0 then
+ begin
+ str(ChangeVolume(cVolumeDelta), s);
+ AddCaption(Format('Volume %1%', s), $FFFFFF, capgrpVolume)
+ end
+ end
end;
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
-var i, t, m, k: LongWord;
+var i, m: LongWord;
begin
if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
i:= 0;
@@ -424,13 +436,8 @@
while (m < cMaxCaptions)and(Captions[m].EndTime > 0) do inc(m)
end;
-k:= 0;
-for i:= 0 to Pred(cMaxCaptions) do
- for t:= 0 to Pred(cMaxCaptions) do
- if (Captions[t].EndTime > 0) and (Captions[t].StorePos = k) then inc(k);
Captions[m].Surf:= RenderString(s, Color, fntBig);
-Captions[m].StorePos:= k;
Captions[m].Group:= Group;
Captions[m].EndTime:= RealTicks + 1200
end;