From c70ad3a1dd44fa7a0230caa1e1613ade61ef319b Mon Sep 17 00:00:00 2001 From: binarymaster Date: Sat, 30 Sep 2017 23:33:22 +0300 Subject: [PATCH] Add Texture: Show texture/animation stats http://doom2d.org/forum/viewtopic.php?f=12&t=2350 --- src/editor/f_addresource_texture.lfm | 14 +++++++++++--- src/editor/f_addresource_texture.pas | 20 ++++++++++++++++++-- src/editor/g_language.pas | 6 ++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/editor/f_addresource_texture.lfm b/src/editor/f_addresource_texture.lfm index bc6af2d..19f7b19 100644 --- a/src/editor/f_addresource_texture.lfm +++ b/src/editor/f_addresource_texture.lfm @@ -56,7 +56,7 @@ inherited AddTextureForm: TAddTextureForm object bAddTexture: TButton[9] Left = 160 Height = 25 - Top = 272 + Top = 269 Width = 81 Caption = 'Добавить' Default = True @@ -66,7 +66,7 @@ inherited AddTextureForm: TAddTextureForm object bClose: TButton[10] Left = 248 Height = 25 - Top = 272 + Top = 269 Width = 81 Caption = 'Закрыть' OnClick = bCloseClick @@ -75,10 +75,18 @@ inherited AddTextureForm: TAddTextureForm object bAddClose: TButton[11] Left = 336 Height = 25 - Top = 272 + Top = 269 Width = 121 Caption = 'Добавить и закрыть' OnClick = bAddCloseClick TabOrder = 9 end + object lStats: TLabel[12] + Left = 6 + Height = 13 + Top = 274 + Width = 149 + AutoSize = False + ParentColor = False + end end diff --git a/src/editor/f_addresource_texture.pas b/src/editor/f_addresource_texture.pas index 86566cf..df0b555 100644 --- a/src/editor/f_addresource_texture.pas +++ b/src/editor/f_addresource_texture.pas @@ -10,7 +10,11 @@ uses StdCtrls, ExtCtrls, utils, Imaging, ImagingTypes, ImagingUtility; type + + { TAddTextureForm } + TAddTextureForm = class (TAddResourceForm) + lStats: TLabel; PanelTexPreview: TPanel; iPreview: TImage; eTextureName: TEdit; @@ -35,6 +39,7 @@ type var AddTextureForm: TAddTextureForm; + NumFrames: Integer = 0; function IsAnim(Res: String): Boolean; function GetFrame(Res: String; var Data: Pointer; var DataLen: Integer; @@ -142,7 +147,7 @@ begin Exit; end; -// Ищем в них описание анимации - "AINM": +// Ищем в них описание анимации - "ANIM": ok := False; for a := 0 to High(Resources) do if Resources[a] = 'ANIM' then @@ -335,6 +340,7 @@ begin // Читаем лист текстур: WAD.GetResource('TEXTURES', config.ReadStr('', 'resource', ''), TextureData, Len); + NumFrames := config.ReadInt('', 'framecount', 0); if (TextureData <> nil) and (WAD.GetLastError = DFWAD_NOERROR) then @@ -394,6 +400,7 @@ procedure TAddTextureForm.FormActivate(Sender: TObject); begin Inherited; + lStats.Caption := ''; cbWADList.Items.Add(_lc[I_WAD_SPECIAL_TEXS]); eTextureName.Text := ''; @@ -407,10 +414,12 @@ procedure TAddTextureForm.lbResourcesListClick(Sender: TObject); var Texture: TBitMap; wad: String; + Anim: Boolean; begin Inherited; + lStats.Caption := ''; if lbResourcesList.ItemIndex = -1 then Exit; if FResourceName = '' then @@ -422,13 +431,20 @@ begin if wad = _lc[I_WAD_SPECIAL_TEXS] then Exit; - if IsAnim(FFullResourceName) then + Anim := IsAnim(FFullResourceName); + if Anim then Texture := ShowAnim(FFullResourceName) else Texture := ShowTGATexture(FFullResourceName); if Texture = nil then Exit; + + if Anim then + lStats.Caption := Format(_lc[I_CAP_ANIMATION], [Texture.Width, Texture.Height, NumFrames]) + else + lStats.Caption := Format(_lc[I_CAP_TEXTURE], [Texture.Width, Texture.Height]); + iPreview.Canvas.FillRect(iPreview.Canvas.ClipRect); iPreview.Canvas.CopyRect(Texture.Canvas.ClipRect, Texture.Canvas, Texture.Canvas.ClipRect); Texture.Free(); diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index e1f7638..c38feac 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -416,6 +416,8 @@ Type I_CAP_SELECT, I_CAP_OPEN, I_CAP_REMOVE, + I_CAP_TEXTURE, + I_CAP_ANIMATION, I_CTRL_PROP_KEY, I_CTRL_PROP_VALUE, @@ -1436,6 +1438,10 @@ Const 'Открыть карту'), ('CAP REMOVE', 'Remove Map', 'Удалить карту'), + ('CAP TEXTURE', 'Texture: %dx%d', + 'Текстура: %dx%d'), + ('CAP ANIMATION', 'Animation: %dx%d, %d frames', + 'Анимация: %dx%d, %d кадров'), ('CTRL PROP KEY', 'Property', 'Свойство'), -- 2.29.2