From: DeaDDooMER Date: Wed, 13 Apr 2022 18:39:02 +0000 (+0300) Subject: panels: use TAnimState X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=afc01019e1701d11e50c4747b8ee8366cf60b6f4;p=d2df-sdl.git panels: use TAnimState --- diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index 17543ac..b9c94ca 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -31,7 +31,7 @@ type Texture: Cardinal; // Textures[Texture] case Anim: Boolean of False: (); - True: (AnTex: TAnimationState); + True: (AnTex: TAnimState); end; PPanel = ^TPanel; @@ -365,7 +365,7 @@ begin FTextureIDs[i].Anim := Textures[AddTextures[i].Texture].FramesCount > 0; if FTextureIDs[i].Anim then begin // Àíèìèðîâàííàÿ òåêñòóðà - FTextureIDs[i].AnTex := TAnimationState.Create(True, Textures[AddTextures[i].Texture].Speed, Textures[AddTextures[i].Texture].FramesCount); + FTextureIDs[i].AnTex := TAnimState.Create(True, Textures[AddTextures[i].Texture].Speed, Textures[AddTextures[i].Texture].FramesCount); end end; @@ -395,7 +395,7 @@ var begin for i := 0 to High(FTextureIDs) do if FTextureIDs[i].Anim then - FTextureIDs[i].AnTex.Free(); + FTextureIDs[i].AnTex.Invalidate; SetLength(FTextureIDs, 0); Inherited; @@ -609,7 +609,7 @@ begin if (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) and - (FTextureIDs[FCurTexture].AnTex <> nil) and + (FTextureIDs[FCurTexture].AnTex.IsValid()) and (FAlpha < 255) then begin FTextureIDs[FCurTexture].AnTex.Update(); @@ -884,7 +884,7 @@ procedure TPanel.SetFrame(Frame: Integer; Count: Byte); begin if Enabled and (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) and - (FTextureIDs[FCurTexture].AnTex <> nil) and + (FTextureIDs[FCurTexture].AnTex.IsValid()) and (Width > 0) and (Height > 0) and (FAlpha < 255) then begin FCurFrame := ClampInt(Frame, 0, FTextureIDs[FCurTexture].AnTex.TotalFrames - 1); @@ -923,7 +923,7 @@ begin // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó: if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then begin - if (FTextureIDs[FCurTexture].AnTex = nil) then + if (FTextureIDs[FCurTexture].AnTex.IsInvalid()) then begin g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]); Exit; @@ -949,7 +949,7 @@ begin // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó: if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then begin - if (FTextureIDs[FCurTexture].AnTex = nil) then + if (FTextureIDs[FCurTexture].AnTex.IsInvalid()) then begin g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]); Exit; @@ -987,7 +987,7 @@ begin Result := Length(FTextureIDs); if Enabled and (FCurTexture >= 0) then if (FTextureIDs[FCurTexture].Anim) and - (FTextureIDs[FCurTexture].AnTex <> nil) and + (FTextureIDs[FCurTexture].AnTex.IsValid()) and (Width > 0) and (Height > 0) and (FAlpha < 255) then Result := Result + 100; end; @@ -1023,7 +1023,7 @@ begin // Àíèìèðîâàíà ëè òåêóùàÿ òåêñòóðà if (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) then begin - assert(FTextureIDs[FCurTexture].AnTex <> nil, 'TPanel.SaveState: No animation object'); + assert(FTextureIDs[FCurTexture].AnTex.IsValid(), 'TPanel.SaveState: No animation object'); anim := true; end else @@ -1083,7 +1083,7 @@ begin // Åñëè äà - çàãðóæàåì àíèìàöèþ Assert((FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) and - (FTextureIDs[FCurTexture].AnTex <> nil), + (FTextureIDs[FCurTexture].AnTex.IsValid()), 'TPanel.LoadState: No animation object'); FTextureIDs[FCurTexture].AnTex.LoadState(st, FAlpha, FBlending); end; diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas index a2f3d18..0339454 100644 --- a/src/game/opengl/r_map.pas +++ b/src/game/opengl/r_map.pas @@ -299,14 +299,14 @@ end; IsAnim := RenTextures[Texture].Anim; if IsAnim then begin - if p.TextureIDs[p.FCurTexture].AnTex <> nil then + if p.TextureIDs[p.FCurTexture].AnTex.IsValid() then begin FramesID := RenTextures[Texture].ID; w := RenTextures[Texture].Width; h := RenTextures[Texture].Height; for xx := 0 to tw div w - 1 do for yy := 0 to th div h - 1 do - r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * w, ty + yy * h, p.Alpha, TMirrorType.None, p.Blending); + r_AnimState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * w, ty + yy * h, p.Alpha, TMirrorType.None, p.Blending); end end else