mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 14:23:43 +01:00
Fix stupid file existence check, improve texture file selector.
This commit is contained in:
parent
5c81970558
commit
cadaafb887
2 changed files with 37 additions and 14 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
|
|
@ -130,17 +131,19 @@ public sealed class Texture : IDisposable
|
|||
|
||||
Path = path;
|
||||
Clean();
|
||||
if( path.Length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( !File.Exists( path ) )
|
||||
throw new FileNotFoundException();
|
||||
|
||||
var _ = System.IO.Path.GetExtension( Path ) switch
|
||||
{
|
||||
".dds" => LoadDds(),
|
||||
".png" => LoadPng(),
|
||||
".tex" => LoadTex(),
|
||||
_ => throw new Exception($"Extension {System.IO.Path.GetExtension( Path )} unknown."),
|
||||
_ => throw new Exception( $"Extension {System.IO.Path.GetExtension( Path )} unknown." ),
|
||||
};
|
||||
Loaded?.Invoke( true );
|
||||
}
|
||||
|
|
@ -202,21 +205,41 @@ public sealed class Texture : IDisposable
|
|||
|
||||
private string? _tmpPath;
|
||||
|
||||
public void PathSelectBox( string label, string tooltip, IEnumerable< string > paths )
|
||||
public void PathSelectBox( string label, string tooltip, IEnumerable< (string, bool) > paths, int skipPrefix )
|
||||
{
|
||||
ImGui.SetNextItemWidth( -0.0001f );
|
||||
var startPath = Path.Length > 0 ? Path : "Choose a modded texture here...";
|
||||
var startPath = Path.Length > 0 ? Path : "Choose a modded texture from this mod here...";
|
||||
using var combo = ImRaii.Combo( label, startPath );
|
||||
if( combo )
|
||||
{
|
||||
foreach( var (path, idx) in paths.WithIndex() )
|
||||
foreach( var ((path, game), idx) in paths.WithIndex() )
|
||||
{
|
||||
if( game )
|
||||
{
|
||||
if( !Dalamud.GameData.FileExists( path ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if( !File.Exists( path ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using var id = ImRaii.PushId( idx );
|
||||
if( ImGui.Selectable( path, path == startPath ) && path != startPath )
|
||||
using( var color = ImRaii.PushColor( ImGuiCol.Text, ColorId.FolderExpanded.Value(), game ) )
|
||||
{
|
||||
var p = game ? $"--> {path}" : path[ skipPrefix.. ];
|
||||
if( ImGui.Selectable( p, path == startPath ) && path != startPath )
|
||||
{
|
||||
Load( path );
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiUtil.HoverTooltip( game
|
||||
? "This is a game path and refers to an unmanipulated file from your game data."
|
||||
: "This is a path to a modded file on your file system." );
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiUtil.HoverTooltip( tooltip );
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ public partial class ModEditWindow
|
|||
|
||||
tex.PathInputBox( "##input", "Import Image...", "Can import game paths as well as your own files.", _mod!.ModPath.FullName,
|
||||
_dialogManager );
|
||||
var files = _editor!.TexFiles.Select( f => f.File.FullName )
|
||||
.Concat( _editor.TexFiles.SelectMany( f => f.SubModUsage.Select( p => p.Item2.ToString() ) ) );
|
||||
var files = _editor!.TexFiles.SelectMany( f => f.SubModUsage.Select( p => (p.Item2.ToString(), true) )
|
||||
.Prepend( (f.File.FullName, false )));
|
||||
tex.PathSelectBox( "##combo", "Select the textures included in this mod on your drive or the ones they replace from the game files.",
|
||||
files );
|
||||
files, _mod.ModPath.FullName.Length + 1 );
|
||||
|
||||
if( tex == _left )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue