Add texture filter toggle

This commit is contained in:
Jarrod Doyle 2024-09-08 19:18:44 +01:00
parent 80f121bfde
commit d434e2c13f
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 17 additions and 1 deletions

View File

@ -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<Tree>("%FolderTree");
_searchBar = GetNode<LineEdit>("%SearchBar");
@ -40,10 +42,12 @@ public partial class TextureBrowser : Node
_textureList = GetNode<HFlowContainer>("%TextureList");
_previewTexture = GetNode<TextureRect>("%PreviewTexture");
_texturePath = GetNode<LineEdit>("%PathBox");
_filterOptions = GetNode<OptionButton>("%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;
}
}

View File

@ -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