mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Add Overview mode to file redirection edit.
This commit is contained in:
parent
d6c0362404
commit
7a7093369f
4 changed files with 95 additions and 57 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
||||||
Subproject commit 69a8ee3ae21480123881bc93ac0458671e7d0c46
|
Subproject commit f137f521c588472247510a3fd4183bd651477618
|
||||||
|
|
@ -276,8 +276,8 @@ public partial class ModCollection
|
||||||
case SelectType.Multi:
|
case SelectType.Multi:
|
||||||
{
|
{
|
||||||
foreach( var (option, _) in group.WithIndex()
|
foreach( var (option, _) in group.WithIndex()
|
||||||
.OrderByDescending( p => group.OptionPriority( p.Item2 ) )
|
.Where( p => ( ( 1 << p.Item2 ) & config ) != 0 )
|
||||||
.Where( p => ( ( 1 << p.Item2 ) & config ) != 0 ) )
|
.OrderByDescending( p => group.OptionPriority( p.Item2 ) ) )
|
||||||
{
|
{
|
||||||
AddSubMod( option, mod );
|
AddSubMod( option, mod );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
|
|
@ -11,20 +10,23 @@ using OtterGui.Classes;
|
||||||
using OtterGui.Raii;
|
using OtterGui.Raii;
|
||||||
using Penumbra.GameData.ByteString;
|
using Penumbra.GameData.ByteString;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
using Penumbra.Util;
|
|
||||||
|
|
||||||
namespace Penumbra.UI.Classes;
|
namespace Penumbra.UI.Classes;
|
||||||
|
|
||||||
public partial class ModEditWindow
|
public partial class ModEditWindow
|
||||||
{
|
{
|
||||||
private readonly HashSet< Mod.Editor.FileRegistry > _selectedFiles = new(256);
|
private readonly HashSet< Mod.Editor.FileRegistry > _selectedFiles = new(256);
|
||||||
private LowerString _fileFilter = LowerString.Empty;
|
private LowerString _fileFilter = LowerString.Empty;
|
||||||
private bool _showGamePaths = true;
|
private bool _showGamePaths = true;
|
||||||
private string _gamePathEdit = string.Empty;
|
private string _gamePathEdit = string.Empty;
|
||||||
private int _fileIdx = -1;
|
private int _fileIdx = -1;
|
||||||
private int _pathIdx = -1;
|
private int _pathIdx = -1;
|
||||||
private int _folderSkip = 0;
|
private int _folderSkip = 0;
|
||||||
private bool _overviewMode = false;
|
private bool _overviewMode = false;
|
||||||
|
private LowerString _fileOverviewFilter1 = LowerString.Empty;
|
||||||
|
private LowerString _fileOverviewFilter2 = LowerString.Empty;
|
||||||
|
private LowerString _fileOverviewFilter3 = LowerString.Empty;
|
||||||
|
|
||||||
|
|
||||||
private bool CheckFilter( Mod.Editor.FileRegistry registry )
|
private bool CheckFilter( Mod.Editor.FileRegistry registry )
|
||||||
=> _fileFilter.IsEmpty || registry.File.FullName.Contains( _fileFilter.Lower, StringComparison.OrdinalIgnoreCase );
|
=> _fileFilter.IsEmpty || registry.File.FullName.Contains( _fileFilter.Lower, StringComparison.OrdinalIgnoreCase );
|
||||||
|
|
@ -43,6 +45,15 @@ public partial class ModEditWindow
|
||||||
DrawOptionSelectHeader();
|
DrawOptionSelectHeader();
|
||||||
DrawButtonHeader();
|
DrawButtonHeader();
|
||||||
|
|
||||||
|
if( _overviewMode )
|
||||||
|
{
|
||||||
|
DrawFileManagementOverview();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawFileManagementNormal();
|
||||||
|
}
|
||||||
|
|
||||||
using var child = ImRaii.Child( "##files", -Vector2.One, true );
|
using var child = ImRaii.Child( "##files", -Vector2.One, true );
|
||||||
if( !child )
|
if( !child )
|
||||||
{
|
{
|
||||||
|
|
@ -50,66 +61,77 @@ public partial class ModEditWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
if( _overviewMode )
|
if( _overviewMode )
|
||||||
|
{
|
||||||
DrawFilesOverviewMode();
|
DrawFilesOverviewMode();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
DrawFilesNormalMode();
|
DrawFilesNormalMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawFilesOverviewMode()
|
private void DrawFilesOverviewMode()
|
||||||
{
|
{
|
||||||
using var list = ImRaii.Table( "##table", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit );
|
var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
|
||||||
|
var skips = ImGuiClip.GetNecessarySkips( height );
|
||||||
|
|
||||||
|
using var list = ImRaii.Table( "##table", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV, -Vector2.One );
|
||||||
|
|
||||||
if( !list )
|
if( !list )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var width = ImGui.GetContentRegionAvail().X / 8;
|
||||||
|
|
||||||
|
ImGui.TableSetupColumn( "##file", ImGuiTableColumnFlags.WidthFixed, width * 3 );
|
||||||
|
ImGui.TableSetupColumn( "##path", ImGuiTableColumnFlags.WidthFixed, width * 3 + ImGui.GetStyle().FrameBorderSize );
|
||||||
|
ImGui.TableSetupColumn( "##option", ImGuiTableColumnFlags.WidthFixed, width * 2 );
|
||||||
|
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
void Draw( Mod.Editor.FileRegistry registry )
|
|
||||||
|
var files = _editor!.AvailableFiles.SelectMany( f =>
|
||||||
{
|
{
|
||||||
if( registry.SubModUsage.Count == 0 )
|
var file = f.RelPath.ToString();
|
||||||
|
return f.SubModUsage.Count == 0
|
||||||
|
? Enumerable.Repeat( ( file, "Unused", string.Empty, 0x40000080u ), 1 )
|
||||||
|
: f.SubModUsage.Select( s => ( file, s.Item2.ToString(), s.Item1.FullName,
|
||||||
|
_editor.CurrentOption == s.Item1 && _mod!.HasOptions ? 0x40008000u : 0u ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
void DrawLine( (string, string, string, uint) data )
|
||||||
|
{
|
||||||
|
using var id = ImRaii.PushId( idx++ );
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if( data.Item4 != 0 )
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId( idx++ );
|
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, data.Item4 );
|
||||||
ImGui.TableNextColumn();
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40000080 );
|
|
||||||
ImGui.Selectable( registry.RelPath.ToString() );
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40000080 );
|
|
||||||
ImGui.TextUnformatted( "Unused" );
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40000080 );
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
ImGuiUtil.CopyOnClickSelectable( data.Item1 );
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if( data.Item4 != 0 )
|
||||||
{
|
{
|
||||||
foreach( var (mod, path) in registry.SubModUsage )
|
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, data.Item4 );
|
||||||
{
|
|
||||||
using var id = ImRaii.PushId( idx++ );
|
|
||||||
var color = mod == _editor.CurrentOption && _mod!.HasOptions;
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
if( color )
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40008000 );
|
|
||||||
ImGui.Selectable( registry.RelPath.ToString() );
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
if( color )
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40008000 );
|
|
||||||
ImGui.Selectable( path.ToString() );
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
if( color )
|
|
||||||
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, 0x40008000 );
|
|
||||||
ImGui.TextUnformatted( mod.Name );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGuiUtil.CopyOnClickSelectable( data.Item2 );
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if( data.Item4 != 0 )
|
||||||
|
{
|
||||||
|
ImGui.TableSetBgColor( ImGuiTableBgTarget.CellBg, data.Item4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiUtil.CopyOnClickSelectable( data.Item3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Filter( Mod.Editor.FileRegistry registry )
|
bool Filter( (string, string, string, uint) data )
|
||||||
{
|
=> _fileOverviewFilter1.IsContained( data.Item1 )
|
||||||
return true;
|
&& _fileOverviewFilter2.IsContained( data.Item2 )
|
||||||
}
|
&& _fileOverviewFilter3.IsContained( data.Item3 );
|
||||||
|
|
||||||
var skips = ImGuiClip.GetNecessarySkips( ImGui.GetTextLineHeight() );
|
var end = ImGuiClip.FilteredClippedDraw( files, skips, Filter, DrawLine );
|
||||||
var end = ImGuiClip.FilteredClippedDraw( _editor!.AvailableFiles, skips, Filter, Draw, 0 );
|
ImGuiClip.DrawEndDummy( end, height );
|
||||||
ImGuiClip.DrawEndDummy( end, ImGui.GetTextLineHeight() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawFilesNormalMode()
|
private void DrawFilesNormalMode()
|
||||||
|
|
@ -136,7 +158,7 @@ public partial class ModEditWindow
|
||||||
using var indent = ImRaii.PushIndent( 50f );
|
using var indent = ImRaii.PushIndent( 50f );
|
||||||
for( var j = 0; j < registry.SubModUsage.Count; ++j )
|
for( var j = 0; j < registry.SubModUsage.Count; ++j )
|
||||||
{
|
{
|
||||||
var (subMod, gamePath) = registry.SubModUsage[j];
|
var (subMod, gamePath) = registry.SubModUsage[ j ];
|
||||||
if( subMod != _editor.CurrentOption )
|
if( subMod != _editor.CurrentOption )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -313,11 +335,10 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGui.Checkbox( "Overview Mode", ref _overviewMode );
|
ImGui.Checkbox( "Overview Mode", ref _overviewMode );
|
||||||
if( _overviewMode )
|
}
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void DrawFileManagementNormal()
|
||||||
|
{
|
||||||
ImGui.SetNextItemWidth( 250 * ImGuiHelpers.GlobalScale );
|
ImGui.SetNextItemWidth( 250 * ImGuiHelpers.GlobalScale );
|
||||||
LowerString.InputWithHint( "##filter", "Filter paths...", ref _fileFilter, Utf8GamePath.MaxGamePathLength );
|
LowerString.InputWithHint( "##filter", "Filter paths...", ref _fileFilter, Utf8GamePath.MaxGamePathLength );
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -350,4 +371,22 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
ImGuiUtil.RightAlign( $"{_selectedFiles.Count} / {_editor!.AvailableFiles.Count} Files Selected" );
|
ImGuiUtil.RightAlign( $"{_selectedFiles.Count} / {_editor!.AvailableFiles.Count} Files Selected" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawFileManagementOverview()
|
||||||
|
{
|
||||||
|
using var style = ImRaii.PushStyle( ImGuiStyleVar.FrameRounding, 0 )
|
||||||
|
.Push( ImGuiStyleVar.ItemSpacing, Vector2.Zero )
|
||||||
|
.Push( ImGuiStyleVar.FrameBorderSize, ImGui.GetStyle().ChildBorderSize );
|
||||||
|
|
||||||
|
var width = ImGui.GetContentRegionAvail().X / 8;
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth( width * 3 );
|
||||||
|
LowerString.InputWithHint( "##fileFilter", "Filter file...", ref _fileOverviewFilter1, Utf8GamePath.MaxGamePathLength );
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.SetNextItemWidth( width * 3 );
|
||||||
|
LowerString.InputWithHint( "##pathFilter", "Filter path...", ref _fileOverviewFilter2, Utf8GamePath.MaxGamePathLength );
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.SetNextItemWidth( width * 2 );
|
||||||
|
LowerString.InputWithHint( "##optionFilter", "Filter option...", ref _fileOverviewFilter3, Utf8GamePath.MaxGamePathLength );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,6 @@ using Penumbra.Interop.Structs;
|
||||||
using Penumbra.Meta.Files;
|
using Penumbra.Meta.Files;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
using Penumbra.Util;
|
|
||||||
|
|
||||||
namespace Penumbra.UI.Classes;
|
namespace Penumbra.UI.Classes;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue