reworked progress structure
authorkoda
Fri, 03 Jul 2009 23:45:07 +0000
changeset 2222 2e98698b76aa
parent 2221 ef52dae4130b
child 2223 e009fee03c96
reworked progress structure
hedgewars/uKeys.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
share/hedgewars/Data/Graphics/Progress.png
--- a/hedgewars/uKeys.pas	Fri Jul 03 22:02:13 2009 +0000
+++ b/hedgewars/uKeys.pas	Fri Jul 03 23:45:07 2009 +0000
@@ -35,7 +35,7 @@
 var KbdKeyPressed: boolean;
 
 implementation
-uses SDLh, uTeams, uConsole, uMisc;
+uses SDLh, uTeams, uConsole, uMisc, uStore;
 const KeyNumber = 1024;
 type TKeyboardState = array[0..cKeyMaxIndex] of Byte;
 
@@ -110,8 +110,9 @@
 TryDo(i < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(i) + ')', true);
 
 for t:= 0 to Pred(i) do
-    tkbd[i]:= pkbd^[i]
-
+    tkbd[i]:= pkbd^[i];
+	
+	AddProgress;
 end;
 
 procedure InitKbdKeyTable;
--- a/hedgewars/uSound.pas	Fri Jul 03 22:02:13 2009 +0000
+++ b/hedgewars/uSound.pas	Fri Jul 03 23:45:07 2009 +0000
@@ -74,7 +74,7 @@
 
 implementation
 
-uses uMisc, uConsole;
+uses uMisc, uConsole, uStore;
 
 const chanTPU = 12;
 var	lastChan: array [TSound] of LongInt;
@@ -148,6 +148,8 @@
 				else
 					WriteLnToConsole(msgOK)
 				end;
+				
+AddProgress;
 end;
 
 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack);
--- a/hedgewars/uStore.pas	Fri Jul 03 22:02:13 2009 +0000
+++ b/hedgewars/uStore.pas	Fri Jul 03 23:45:07 2009 +0000
@@ -258,6 +258,7 @@
     tmpsurf: PSDL_Surface;
     i: LongInt;
 begin
+
 for fi:= Low(THWFont) to High(THWFont) do
 	with Fontz[fi] do
 		begin
@@ -268,7 +269,6 @@
 		TTF_SetFontStyle(Handle, style);
 		WriteLnToConsole(msgOK)
 		end;
-AddProgress;
 
 WriteNames(fnt16);
 MakeCrossHairs;
@@ -312,7 +312,7 @@
 		NameTex:= Surface2Tex(tmpsurf);
 		SDL_FreeSurface(tmpsurf)
 		end;
-
+		
 for i:= Low(CountTexz) to High(CountTexz) do
 	begin
 	tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), $FFFFFF);
@@ -324,6 +324,7 @@
 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
 {$ENDIF}
+AddProgress;
 end;
 
 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
@@ -515,8 +516,10 @@
 
 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
 var r: TSDL_Rect;
+var flag: integer = 0;
 begin
-r.x:= 0;
+if flag = 0 then r.x:= 0
+else r.x := 0;
 r.w:= SpritesData[Sprite].Width;
 r.y:= Frame * SpritesData[Sprite].Height;
 r.h:= SpritesData[Sprite].Height;
@@ -939,7 +942,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 var ProgrTex: PTexture = nil;
     Step: integer = 0;
-
+	squaresize : LongInt;
+	numsquares : integer;
 procedure AddProgress;
 var r: TSDL_Rect;
     texsurf: PSDL_Surface;
@@ -949,22 +953,25 @@
    WriteToConsole(msgLoading + 'progress sprite: ');
    texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent);
    ProgrTex:= Surface2Tex(texsurf);
-   SDL_FreeSurface(texsurf)
+   SDL_FreeSurface(texsurf);
+   squaresize:= ProgrTex^.w shr 1;
+   numsquares:= ProgrTex^.h div squaresize;
    end;
 
 glClear(GL_COLOR_BUFFER_BIT);
 glEnable(GL_TEXTURE_2D);
-r.x:= 0;
-r.w:= ProgrTex^.w;
-r.h:= ProgrTex^.w;
-r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w;
-DrawFromRect( -ProgrTex^.w div 2,
-             (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex);
+if Step < numsquares then r.x:= 0
+else r.x:= squaresize;
+r.y:= (Step mod numsquares) * squaresize;
+r.w:= squaresize;
+r.h:= squaresize;
+DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
 glDisable(GL_TEXTURE_2D);
 SDL_GL_SwapBuffers();
 inc(Step);
 end;
 
+
 procedure FinishProgress;
 begin
 WriteLnToConsole('Freeing progress surface... ');
Binary file share/hedgewars/Data/Graphics/Progress.png has changed