From 0a71be4731e4d6561f987267e22a2003eee2c4b8 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 8 Sep 2024 19:24:21 +0100 Subject: [PATCH] Set File Type text --- project/code/TMV/UI/TextureBrowser.cs | 8 ++++++-- project/scenes/asset_browser/asset_browser.tscn | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/project/code/TMV/UI/TextureBrowser.cs b/project/code/TMV/UI/TextureBrowser.cs index 64d4ed4..f94a4a2 100644 --- a/project/code/TMV/UI/TextureBrowser.cs +++ b/project/code/TMV/UI/TextureBrowser.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text.RegularExpressions; using Godot; @@ -25,6 +26,7 @@ public partial class TextureBrowser : Node private TextureRect _previewTexture; private LineEdit _texturePath; private OptionButton _filterOptions; + private LineEdit _fileType; private string _searchFilterPrefix = ""; @@ -43,6 +45,7 @@ public partial class TextureBrowser : Node _previewTexture = GetNode("%PreviewTexture"); _texturePath = GetNode("%PathBox"); _filterOptions = GetNode("%FilterOptions"); + _fileType = GetNode("%FileTypeBox"); _searchBar.TextChanged += ApplySearchFilter; _sortMenu.GetPopup().IdPressed += ApplySortMode; @@ -114,7 +117,7 @@ public partial class TextureBrowser : Node mouseEvent.Pressed && mouseEvent.ButtonIndex == MouseButton.Left) { - SetPreviewTexture(name, texture); + SetPreviewTexture(name, texture, path); } }; @@ -122,10 +125,11 @@ public partial class TextureBrowser : Node } } - private void SetPreviewTexture(string name, Texture2D texture) + private void SetPreviewTexture(string name, Texture2D texture, string path) { _previewTexture.Texture = texture; _texturePath.Text = name; + _fileType.Text = Path.GetExtension(path).ToUpper(); } private void ApplySearchFilter(string filter) diff --git a/project/scenes/asset_browser/asset_browser.tscn b/project/scenes/asset_browser/asset_browser.tscn index a0a5db2..a94d201 100644 --- a/project/scenes/asset_browser/asset_browser.tscn +++ b/project/scenes/asset_browser/asset_browser.tscn @@ -277,6 +277,7 @@ layout_mode = 2 text = "File Type" [node name="FileTypeBox" 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