From fbacfccd13b06785e827002f4c436aebf8d75dde Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 8 Sep 2024 19:47:01 +0100 Subject: [PATCH] Set file size text --- project/code/TMV/UI/TextureBrowser.cs | 6 ++++++ project/scenes/asset_browser/asset_browser.tscn | 1 + 2 files changed, 7 insertions(+) diff --git a/project/code/TMV/UI/TextureBrowser.cs b/project/code/TMV/UI/TextureBrowser.cs index f7437f8..93f5e0b 100644 --- a/project/code/TMV/UI/TextureBrowser.cs +++ b/project/code/TMV/UI/TextureBrowser.cs @@ -28,6 +28,7 @@ public partial class TextureBrowser : Node private OptionButton _filterOptions; private LineEdit _fileType; private LineEdit _resolutionBox; + private LineEdit _fileSizeBox; private string _searchFilterPrefix = ""; @@ -48,6 +49,7 @@ public partial class TextureBrowser : Node _filterOptions = GetNode("%FilterOptions"); _fileType = GetNode("%FileTypeBox"); _resolutionBox = GetNode("%ResolutionBox"); + _fileSizeBox = GetNode("%FileSizeBox"); _searchBar.TextChanged += ApplySearchFilter; _sortMenu.GetPopup().IdPressed += ApplySortMode; @@ -132,8 +134,12 @@ public partial class TextureBrowser : Node _previewTexture.Texture = texture; _texturePath.Text = name; _fileType.Text = Path.GetExtension(path).ToUpper(); + var resolution = texture.GetSize(); _resolutionBox.Text = $"{resolution.X}x{resolution.Y}"; + + var fileInfo = new FileInfo(path); + _fileSizeBox.Text = $"{(fileInfo.Length / 1000.0f).ToString("0.0")} kb"; } private void ApplySearchFilter(string filter) diff --git a/project/scenes/asset_browser/asset_browser.tscn b/project/scenes/asset_browser/asset_browser.tscn index 09021eb..49119f2 100644 --- a/project/scenes/asset_browser/asset_browser.tscn +++ b/project/scenes/asset_browser/asset_browser.tscn @@ -297,6 +297,7 @@ layout_mode = 2 text = "File Size" [node name="FileSizeBox" type="LineEdit" parent="TabContainer/Textures/VBoxContainer/HSplitContainer/HSplitContainer/Preview/VBoxContainer/PanelContainer/MarginContainer/Details"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 editable = false