From d434e2c13fbf6cce866fa594a4387f3bd48a4962 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 8 Sep 2024 19:18:44 +0100 Subject: [PATCH] Add texture filter toggle --- project/code/TMV/UI/TextureBrowser.cs | 17 ++++++++++++++++- project/scenes/asset_browser/asset_browser.tscn | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/project/code/TMV/UI/TextureBrowser.cs b/project/code/TMV/UI/TextureBrowser.cs index a0fd3c1..64d4ed4 100644 --- a/project/code/TMV/UI/TextureBrowser.cs +++ b/project/code/TMV/UI/TextureBrowser.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -23,6 +24,7 @@ public partial class TextureBrowser : Node private HFlowContainer _textureList; private TextureRect _previewTexture; private LineEdit _texturePath; + private OptionButton _filterOptions; private string _searchFilterPrefix = ""; @@ -30,7 +32,7 @@ public partial class TextureBrowser : Node { // !HACK TEMP Context.Instance.PathManager.Init("/stuff/Games/thief/drive_c/GOG Games/TG ND 1.27 (MAPPING)/"); - Context.Instance.CampaignName = "Endless Rain"; + Context.Instance.CampaignName = "TheBlackParade_1_0"; _folderTree = GetNode("%FolderTree"); _searchBar = GetNode("%SearchBar"); @@ -40,10 +42,12 @@ public partial class TextureBrowser : Node _textureList = GetNode("%TextureList"); _previewTexture = GetNode("%PreviewTexture"); _texturePath = GetNode("%PathBox"); + _filterOptions = GetNode("%FilterOptions"); _searchBar.TextChanged += ApplySearchFilter; _sortMenu.GetPopup().IdPressed += ApplySortMode; _folderTree.ItemSelected += SetActiveFolder; + _filterOptions.ItemSelected += SetPreviewTextureFilter; BuildFolderTree(); BuildTextureList(); // TODO: This should be triggered on folder change @@ -166,4 +170,15 @@ public partial class TextureBrowser : Node _searchFilterPrefix = Regex.Escape(selectedFolder).Replace("/", "\\/"); ApplySearchFilter(_searchBar.Text); } + + private void SetPreviewTextureFilter(long idx) + { + var filterMode = idx switch + { + 0 => CanvasItem.TextureFilterEnum.LinearWithMipmaps, + 1 => CanvasItem.TextureFilterEnum.NearestWithMipmaps, + _ => throw new InvalidOperationException(), + }; + _previewTexture.TextureFilter = filterMode; + } } diff --git a/project/scenes/asset_browser/asset_browser.tscn b/project/scenes/asset_browser/asset_browser.tscn index 706ed52..a0a5db2 100644 --- a/project/scenes/asset_browser/asset_browser.tscn +++ b/project/scenes/asset_browser/asset_browser.tscn @@ -218,6 +218,7 @@ layout_mode = 2 text = "Texture Filter" [node name="FilterOptions" type="OptionButton" parent="TabContainer/Textures/VBoxContainer/HSplitContainer/HSplitContainer/Preview/VBoxContainer/PanelContainer/MarginContainer/Details"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 selected = 0