Engine:
authorsmxx
Sun, 31 Jan 2010 22:52:42 +0000
changeset 2735 f2008d0ce3f8
parent 2734 fb9ad1587054
child 2736 cc04e98dd535
Engine: + Play sound when switching hogs + Save screenshots to home directory instead of working directory + Use Windows bitmap format for screenshots under Win32 (more common and better supported) * Fix compiler warnings
hedgewars/GSHandlers.inc
hedgewars/hwengine.pas
hedgewars/uConsts.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Sounds/switchhog.ogg
--- a/hedgewars/GSHandlers.inc	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Jan 31 22:52:42 2010 +0000
@@ -1731,6 +1731,8 @@
 	RemoveGearFromList(HHGear);
 	InsertGearToList(HHGear);
 
+	PlaySound(sndSwitchHog, false, nil);
+	
 	repeat
 		CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber);
 	until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
--- a/hedgewars/hwengine.pas	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/hwengine.pas	Sun Jan 31 22:52:42 2010 +0000
@@ -57,6 +57,8 @@
 	uLandTexture in 'uLandTexture.pas'
 	{$IFDEF IPHONEOS}
 	, PascalExports in 'PascalExports.pas'
+	{$ELSE}
+	, sysutils
 	{$ENDIF}
 	;
 
@@ -141,8 +143,8 @@
 	if flagMakeCapture then
 	begin
 		flagMakeCapture:= false;
-		s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.tga';
-		WriteLnToConsole('Saving ' + s);
+		s:= 'hw_' + FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now()) + inttostr(GameTicks);
+		WriteLnToConsole('Saving ' + s + '...');
 		MakeScreenshot(s);
 		//SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1)
 	end;
--- a/hedgewars/uConsts.pas	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/uConsts.pas	Sun Jan 31 22:52:42 2010 +0000
@@ -106,7 +106,7 @@
 			sndVaporize, sndWarp, sndSuddenDeath, sndMortar, sndShutter,
 			sndHomerun, sndMolotov, sndWalking, sndCover, sndUhOh,
 			sndOops, sndNooo, sndHello, sndRopeShot, sndRopeAttach,
-			sndRopeRelease);
+			sndRopeRelease, sndSwitchHog);
 
 	TAmmoType  = (amNothing, amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
 			amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip,
@@ -662,7 +662,7 @@
 			Interval: Longword;
 			cmd: String[20];
 			Voice: TSound;
-			VoiceDelay: ShortInt;
+			VoiceDelay: LongWord;
 			end = (
 			(Sprite:   sprKowtow; FramesCount: 12; Interval: 125; cmd: '/rollup'; Voice: sndNone; VoiceDelay: 0),
 			(Sprite:      sprSad; FramesCount: 14; Interval: 125; cmd: '/sad'; Voice: sndNone; VoiceDelay: 0),
@@ -745,7 +745,8 @@
 			(FileName:                'Hello.ogg'; Path: ptVoices),// sndHello
 			(FileName:                         ''; Path: ptSounds),// sndRopeShot
 			(FileName:                         ''; Path: ptSounds),// sndRopeAttach
-			(FileName:                         ''; Path: ptSounds) // sndRopeRelease
+			(FileName:                         ''; Path: ptSounds),// sndRopeRelease
+			(FileName:            'switchhog.ogg'; Path: ptSounds) // sndSwitchHog
 			);
 
 	Ammoz: array [TAmmoType] of record
--- a/hedgewars/uMisc.pas	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/uMisc.pas	Sun Jan 31 22:52:42 2010 +0000
@@ -155,7 +155,7 @@
 function  RectToStr(Rect: TSDL_Rect): shortstring;
 {$ENDIF}
 {$IFNDEF IPHONEOS}
-procedure MakeScreenshot(s: shortstring);
+procedure MakeScreenshot(filename: shortstring);
 {$ENDIF}
 
 implementation
@@ -493,26 +493,72 @@
 end;
 
 {$IFNDEF IPHONEOS}
-procedure MakeScreenshot(s: shortstring);
-const head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24);
+procedure MakeScreenshot(filename: shortstring);
 var p: Pointer;
 	size: Longword;
 	f: file;
+{$IFNDEF WIN32}
+	// TGA Header
+	head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24);
+{$ELSE}
+	// Windows Bitmap Header
+	head: array[0..53] of Byte = (
+	$42, $4D, // identifier ("BM")
+	0, 0, 0, 0, // file size
+	0, 0, 0, 0, // reserved
+	54, 0, 0, 0, // starting offset
+	40, 0, 0, 0, // header size
+	0, 0, 0, 0, // width
+	0, 0, 0, 0, // height
+	1, 0, // color planes
+	24, 0, // bit depth
+	0, 0, 0, 0, // compression method (uncompressed)
+	0, 0, 0, 0, // image size
+	96, 0, 0, 0, // horizontal resolution
+	96, 0, 0, 0, // vertical resolution
+	0, 0, 0, 0, // number of colors (all)
+	0, 0, 0, 0 // number of important colors
+	);
+{$ENDIF}
 begin
 playSound(sndShutter, false, nil);
-head[6]:= cScreenWidth;
-head[7]:= cScreenHeight;
 
 size:= cScreenWidth * cScreenHeight * 3;
 p:= GetMem(size);
 
+// update header information and file name
+{$IFNDEF WIN32}
+filename:= ParamStr(1) + '/' + filename + '.tga';
+
+head[6]:= cScreenWidth;
+head[7]:= cScreenHeight;
+{$ELSE}
+filename:= ParamStr(1) + '/' + filename + '.bmp';
+
+head[$02]:= (size + 54) and $ff;
+head[$03]:= ((size + 54) shr 8) and $ff;
+head[$04]:= ((size + 54) shr 16) and $ff;
+head[$05]:= ((size + 54) shr 24) and $ff;
+head[$12]:= cScreenWidth and $ff;
+head[$13]:= (cScreenWidth shr 8) and $ff;
+head[$14]:= (cScreenWidth shr 16) and $ff;
+head[$15]:= (cScreenWidth shr 24) and $ff;
+head[$16]:= cScreenHeight and $ff;
+head[$17]:= (cScreenHeight shr 8) and $ff;
+head[$18]:= (cScreenHeight shr 16) and $ff;
+head[$19]:= (cScreenHeight shr 24) and $ff;
+head[$22]:= size and $ff;
+head[$23]:= (size shr 8) and $ff;
+head[$24]:= (size shr 16) and $ff;
+head[$25]:= (size shr 24) and $ff;
+{$ENDIF}
 
 //remember that opengles operates on a single surface, so GL_FRONT *should* be implied
 glReadBuffer(GL_FRONT);
 glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p);
 
 {$I-}
-Assign(f, s);
+Assign(f, filename);
 Rewrite(f, 1);
 if IOResult = 0 then
 	begin
--- a/hedgewars/uStore.pas	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/uStore.pas	Sun Jan 31 22:52:42 2010 +0000
@@ -82,11 +82,11 @@
 implementation
 uses uMisc, uConsole, uLand, uLocale, uWorld{$IFDEF IPHONEOS}, PascalExports{$ENDIF};
 
-type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel);
+type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
 
 var HHTexture: PTexture;
     MaxTextureSize: Integer;
-    {$IFNDEF IPHONEOS}cGPUVendor: TGPUVendor;{$ENDIF}
+    cGPUVendor: TGPUVendor;
 
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
@@ -1133,6 +1133,16 @@
 	else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
 		cGPUVendor:= gvIntel;
 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
+{$ELSE}
+	cGPUVendor:= gvApple;
+{$ENDIF}
+
+{$IFDEF DEBUGFILE}
+	if cGPUVendor = gvUnknown then
+		AddFileLog('OpenGL Warning - unknown hardware vendor; please report');
+{$ELSE}
+	// just avoid 'never used' compiler warning for now
+	if cGPUVendor = gvUnknown then cGPUVendor:= gvUnknown;
 {$ENDIF}
 
 	// set view port to whole window
--- a/hedgewars/uWorld.pas	Sun Jan 31 22:43:09 2010 +0000
+++ b/hedgewars/uWorld.pas	Sun Jan 31 22:52:42 2010 +0000
@@ -654,7 +654,7 @@
 case Group of
 	capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200
 	else
-	Captions[Group].EndTime:= RealTicks + 1400 + Captions[Group].Tex^.w*3;
+	Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;
 	end;
 end;
 
Binary file share/hedgewars/Data/Sounds/switchhog.ogg has changed