DEADSOFTWARE

render: hide panel textures into render
[d2df-sdl.git] / src / game / g_panel.pas
index 854a15c512c5d4b089440b34a8d54bef1cb14684..fa4429256576dd18b109dd5ddaf4fbfe9871ac28 100644 (file)
@@ -23,16 +23,16 @@ uses
   MAPDEF, g_textures, xdynrec;
 
 type
-  TAddTextureArray = Array of
-    record
-      Texture: Cardinal;
-      Anim: Boolean;
-    end;
+  TAddTextureArray = array of record
+    Texture: Cardinal; // Textures[Texture]
+    Anim: Boolean;
+  end;
 
   ATextureID = array of record
+    Texture: Cardinal; // Textures[Texture]
     case Anim: Boolean of
-      False: (Tex: Cardinal);
-      True:  (AnTex: TAnimation);
+      False: ();
+      True:  (AnTex: TAnimationState);
   end;
 
   PPanel = ^TPanel;
@@ -41,8 +41,6 @@ type
     const
   private
     mGUID: Integer; // will be assigned in "g_map.pas"
-    FTextureWidth:    Word;
-    FTextureHeight:   Word;
     FAlpha:           Byte;
     FBlending:        Boolean;
     FTextureIDs:      ATextureID;
@@ -189,8 +187,6 @@ type
 
     (* private state *)
     property Alpha: Byte read FAlpha;
-    property TextureWidth: Word read FTextureWidth;
-    property TextureHeight: Word read FTextureHeight;
     property Blending: Boolean read FBlending;
     property TextureIDs: ATextureID read FTextureIDs;
 
@@ -222,7 +218,7 @@ var
 implementation
 
 uses
-  e_texture, g_basic, g_map, g_game, g_gfx, g_weapons, g_triggers,
+  g_basic, g_map, g_game, g_gfx, g_weapons, g_triggers,
   g_console, g_language, g_monsters, g_player, g_grid, e_log, geom, utils, xstreams;
 
 const
@@ -309,6 +305,8 @@ begin
     SetLength(FTextureIDs, 1);
     FTextureIDs[0].Anim := False;
 
+{
+    // !!! set this
     case PanelRec.PanelType of
       PANEL_WATER:
         FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_WATER);
@@ -317,6 +315,7 @@ begin
       PANEL_ACID2:
         FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID2);
     end;
+}
 
     FCurTexture := 0;
     Exit;
@@ -334,19 +333,14 @@ begin
 
   for i := 0 to Length(FTextureIDs)-1 do
   begin
+    FTextureIDs[i].Texture := AddTextures[i].Texture;
     FTextureIDs[i].Anim := AddTextures[i].Anim;
     if FTextureIDs[i].Anim then
-      begin // Àíèìèðîâàííàÿ òåêñòóðà
-        FTextureIDs[i].AnTex :=
-           TAnimation.Create(Textures[AddTextures[i].Texture].FramesID,
-                             True, Textures[AddTextures[i].Texture].Speed);
-        FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
-        FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
-      end
-    else
-      begin // Îáû÷íàÿ òåêñòóðà
-        FTextureIDs[i].Tex := Textures[AddTextures[i].Texture].TextureID;
-      end;
+    begin // Àíèìèðîâàííàÿ òåêñòóðà
+      FTextureIDs[i].AnTex := TAnimationState.Create(True, Textures[AddTextures[i].Texture].Speed, Textures[AddTextures[i].Texture].FramesCount);
+      FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
+      FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
+    end
   end;
 
 // Òåêñòóð íåñêîëüêî - íóæíî ñîõðàíÿòü òåêóùóþ:
@@ -359,15 +353,11 @@ begin
   if ({PanelRec.TextureNum}tnum > High(Textures)) then
   begin
     e_WriteLog(Format('WTF?! tnum is out of limits! (%d : %d)', [tnum, High(Textures)]), TMsgType.Warning);
-    FTextureWidth := 2;
-    FTextureHeight := 2;
     FAlpha := 0;
     FBlending := ByteBool(0);
   end
   else if not g_Map_IsSpecialTexture(Textures[{PanelRec.TextureNum}tnum].TextureName) then
   begin
-    FTextureWidth := Textures[{PanelRec.TextureNum}tnum].Width;
-    FTextureHeight := Textures[{PanelRec.TextureNum}tnum].Height;
     FAlpha := PanelRec.Alpha;
     FBlending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
   end;
@@ -889,14 +879,20 @@ end;
 function TPanel.GetTextureID(): DWORD;
 begin
   Result := LongWord(TEXTURE_NONE);
-
-  if (FCurTexture >= 0) then
-  begin
+//  if (FCurTexture >= 0) then
+//  begin
+//    if FTextureIDs[FCurTexture].Anim then
+//      Result := Textures[FTextureIDs[FCurTexture].Texture].FramesID
+//    else
+//      Result := Textures[FTextureIDs[FCurTexture].Texture].TextureID
+{
+    // !!! old behavior
     if FTextureIDs[FCurTexture].Anim then
       Result := FTextureIDs[FCurTexture].AnTex.FramesID
     else
       Result := FTextureIDs[FCurTexture].Tex;
-  end;
+}
+//  end
 end;
 
 function TPanel.GetTextureCount(): Integer;