# HG changeset patch # User unc0rr # Date 1290347611 -10800 # Node ID 883b979697e4a10c56fa1c923ec9a932bf52aa45 # Parent 95e27e12d0e969a73e9dcaed00f210330c7d7363 uCaptions diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/CMakeLists.txt Sun Nov 21 16:53:31 2010 +0300 @@ -43,6 +43,7 @@ uAIAmmoTests.pas uAIMisc.pas uAmmos.pas + uCaptions.pas uChat.pas uCollisions.pas uCommands.pas diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/hwengine.pas Sun Nov 21 16:53:31 2010 +0300 @@ -31,7 +31,7 @@ uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions, uMobile, - sysutils, uTypes, uVariables, uCommands, uUtils; + sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions; var isTerminated: boolean = false; alsoShutdownFrontend: boolean = false; @@ -354,6 +354,7 @@ uTeams.initModule; uVisualGears.initModule; uWorld.initModule; + uCaptions.initModule; end; end; @@ -361,6 +362,7 @@ begin if complete then begin + uCaptions.freeModule; uWorld.freeModule; uVisualGears.freeModule; uTeams.freeModule; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uAmmos.pas Sun Nov 21 16:53:31 2010 +0300 @@ -47,7 +47,7 @@ var StoreCnt: Longword; implementation -uses uWorld, uLocale, uMobile, uVariables, uCommands, uUtils, uIO; +uses uLocale, uMobile, uVariables, uCommands, uUtils, uIO, uCaptions; type TAmmoCounts = array[TAmmoType] of Longword; var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uCaptions.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uCaptions.pas Sun Nov 21 16:53:31 2010 +0300 @@ -0,0 +1,75 @@ +unit uCaptions; + +interface +uses uTypes; + +procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); +procedure DrawCaptions; + +procedure initModule; +procedure freeModule; + +implementation +uses uTextures, uRenderUtils, uVariables, uRender, uConsts; + +type TCaptionStr = record + Tex: PTexture; + EndTime: LongWord; + end; +var + Captions: array[TCapGroup] of TCaptionStr; + +procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); +begin + if Captions[Group].Tex <> nil then + FreeTexture(Captions[Group].Tex); + Captions[Group].Tex:= nil; + + Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); + + case Group of + capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 + else + Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; + end; +end; + +procedure DrawCaptions; +var + grp: TCapGroup; + offset: LongInt; +begin + {$IFDEF IPHONEOS} + offset:= 40; + {$ELSE} + if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then + offset:= 48 + else + offset:= 8; + {$ENDIF} + + for grp:= Low(TCapGroup) to High(TCapGroup) do + with Captions[grp] do + if Tex <> nil then + begin + DrawCentered(0, offset, Tex); + inc(offset, Tex^.h + 2); + if EndTime <= RealTicks then + begin + FreeTexture(Tex); + Tex:= nil; + EndTime:= 0 + end; + end; +end; + +procedure initModule; +begin + FillChar(Captions, sizeof(Captions), 0) +end; + +procedure freeModule; +begin +end; + +end. diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uGears.pas Sun Nov 21 16:53:31 2010 +0300 @@ -44,9 +44,9 @@ implementation -uses uWorld, uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, +uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, - uCommands, uUtils, uTextures, uRenderUtils, uGearsRender; + uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions; procedure DeleteGear(Gear: PGear); forward; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uScript.pas Sun Nov 21 16:53:31 2010 +0300 @@ -55,7 +55,8 @@ uVariables, uCommands, uUtils, - uIO; + uIO, + uCaptions; var luaState : Plua_State; ScriptAmmoLoadout : shortstring; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uStats.pas --- a/hedgewars/uStats.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uStats.pas Sun Nov 21 16:53:31 2010 +0300 @@ -35,7 +35,7 @@ procedure SendStats; implementation -uses uTeams, uSound, uLocale, uWorld, uVariables, uUtils, uIO; +uses uTeams, uSound, uLocale, uVariables, uUtils, uIO, uCaptions; var DamageGiven : Longword = 0; DamageClan : Longword = 0; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uTeams.pas Sun Nov 21 16:53:31 2010 +0300 @@ -37,7 +37,7 @@ function GetTeamStatString(p: PTeam): shortstring; implementation -uses uWorld, uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO; +uses uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO, uCaptions; const MaxTeamHealth: LongInt = 0; diff -r 95e27e12d0e9 -r 883b979697e4 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Nov 21 01:26:31 2010 -0500 +++ b/hedgewars/uWorld.pas Sun Nov 21 16:53:31 2010 +0300 @@ -27,7 +27,6 @@ procedure InitWorld; procedure DrawWorld(Lag: LongInt); -procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); procedure HideMission; procedure ShakeCamera(amount: LongWord); @@ -49,16 +48,10 @@ uUtils, uTextures, uRender, - uRenderUtils + uCaptions ; -type TCaptionStr = record - Tex: PTexture; - EndTime: LongWord; - end; - var cWaveWidth, cWaveHeight: LongInt; - Captions: array[TCapGroup] of TCaptionStr; AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt; tmpSurface: PSDL_Surface; fpsTexture: PTexture; @@ -537,10 +530,9 @@ var i, t: LongInt; r: TSDL_Rect; tdx, tdy: Double; - grp: TCapGroup; s: string[15]; highlight: Boolean; - offset, offsetX, offsetY, ScreenBottom: LongInt; + offsetX, offsetY, ScreenBottom: LongInt; VertexBuffer: array [0..3] of TVertex2f; begin if not isPaused then @@ -741,26 +733,7 @@ {$ENDIF} // Captions -{$IFDEF IPHONEOS} -offset:= 40; -{$ELSE} -if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 -else offset:= 8; -{$ENDIF} - - for grp:= Low(TCapGroup) to High(TCapGroup) do - with Captions[grp] do - if Tex <> nil then - begin - DrawCentered(0, offset, Tex); - inc(offset, Tex^.h + 2); - if EndTime <= RealTicks then - begin - FreeTexture(Tex); - Tex:= nil; - EndTime:= 0 - end; - end; +DrawCaptions; // Teams Healths for t:= 0 to Pred(TeamsCount) do @@ -1004,22 +977,6 @@ isFirstFrame:= false end; -procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); -begin -//if Group in [capgrpGameState] then WriteLnToConsole(s); - if Captions[Group].Tex <> nil then - FreeTexture(Captions[Group].Tex); - Captions[Group].Tex:= nil; - - Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); - - case Group of - capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 - else - Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; - end; -end; - procedure MoveCamera; var EdgesDist, wdy: LongInt; PrevSentPointTime: LongWord = 0; @@ -1184,8 +1141,6 @@ missionTimer:= 0; missionTex:= nil; cOffsetY:= 0; - - FillChar(Captions, sizeof(Captions), 0) end; procedure freeModule;