mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-19 14:27:50 +01:00
Fixes regarding collection settings, change self-conflict behaviour by iterating through options instead of through files, button to clean up collection settings.
This commit is contained in:
parent
ac19a599ed
commit
d7214cd851
8 changed files with 279 additions and 56 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Windows.Forms;
|
||||
using Dalamud.Interface;
|
||||
|
|
@ -53,6 +54,15 @@ namespace Penumbra.UI.Custom
|
|||
}
|
||||
}
|
||||
|
||||
public static partial class ImGuiCustom
|
||||
{
|
||||
public static bool DisableButton( string label, bool condition )
|
||||
{
|
||||
using var alpha = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f, !condition );
|
||||
return ImGui.Button( label ) && condition;
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class ImGuiCustom
|
||||
{
|
||||
public static void PrintIcon( FontAwesomeIcon icon )
|
||||
|
|
|
|||
|
|
@ -87,13 +87,25 @@ namespace Penumbra.UI
|
|||
{
|
||||
if( _manager.Collections.AddCollection( _newCollectionName, settings ) )
|
||||
{
|
||||
_manager.Collections.SetCurrentCollection( _manager.Collections.Collections[ _newCollectionName ] );
|
||||
UpdateNames();
|
||||
SetCurrentCollection( _manager.Collections.Collections[_newCollectionName], true );
|
||||
}
|
||||
|
||||
_newCollectionName = string.Empty;
|
||||
}
|
||||
|
||||
private void DrawCleanCollectionButton()
|
||||
{
|
||||
if( ImGui.Button( "Clean Settings" ) )
|
||||
{
|
||||
var changes = ModFunctions.CleanUpCollection( _manager.Collections.CurrentCollection.Settings,
|
||||
_manager.BasePath.EnumerateDirectories() );
|
||||
_manager.Collections.CurrentCollection.UpdateSettings( forceSave: changes );
|
||||
}
|
||||
|
||||
ImGuiCustom.HoverTooltip( "Remove all stored settings for mods not currently available and fix invalid settings.\nUse at own risk." );
|
||||
}
|
||||
|
||||
private void DrawNewCollectionInput()
|
||||
{
|
||||
ImGui.InputTextWithHint( "##New Collection", "New Collection", ref _newCollectionName, 64 );
|
||||
|
|
@ -113,26 +125,31 @@ namespace Penumbra.UI
|
|||
|
||||
style.Pop();
|
||||
|
||||
if( _manager.Collections.Collections.Count > 1
|
||||
&& _manager.Collections.CurrentCollection.Name != ModCollection.DefaultCollection )
|
||||
var deleteCondition = _manager.Collections.Collections.Count > 1
|
||||
&& _manager.Collections.CurrentCollection.Name != ModCollection.DefaultCollection;
|
||||
ImGui.SameLine();
|
||||
if( ImGuiCustom.DisableButton( "Delete Current Collection", deleteCondition) )
|
||||
{
|
||||
_manager.Collections.RemoveCollection( _manager.Collections.CurrentCollection.Name );
|
||||
SetCurrentCollection( _manager.Collections.CurrentCollection, true );
|
||||
UpdateNames();
|
||||
}
|
||||
|
||||
if( Penumbra.Config.ShowAdvanced )
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if( ImGui.Button( "Delete Current Collection" ) )
|
||||
{
|
||||
_manager.Collections.RemoveCollection( _manager.Collections.CurrentCollection.Name );
|
||||
UpdateNames();
|
||||
}
|
||||
DrawCleanCollectionButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCurrentCollection( int idx )
|
||||
private void SetCurrentCollection( int idx, bool force )
|
||||
{
|
||||
if( idx == _currentCollectionIndex )
|
||||
if( !force && idx == _currentCollectionIndex )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_manager.Collections.SetCurrentCollection( _collections[ idx + 1 ] );
|
||||
_manager.Collections.SetCurrentCollection( _collections[idx + 1] );
|
||||
_currentCollectionIndex = idx;
|
||||
_selector.Cache.TriggerListReset();
|
||||
if( _selector.Mod != null )
|
||||
|
|
@ -141,12 +158,12 @@ namespace Penumbra.UI
|
|||
}
|
||||
}
|
||||
|
||||
public void SetCurrentCollection( ModCollection collection )
|
||||
public void SetCurrentCollection( ModCollection collection, bool force = false )
|
||||
{
|
||||
var idx = Array.IndexOf( _collections, collection ) - 1;
|
||||
if( idx >= 0 )
|
||||
{
|
||||
SetCurrentCollection( idx );
|
||||
SetCurrentCollection( idx, force );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +176,7 @@ namespace Penumbra.UI
|
|||
|
||||
if( combo )
|
||||
{
|
||||
SetCurrentCollection( index );
|
||||
SetCurrentCollection( index, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,18 +222,14 @@ namespace Penumbra.UI
|
|||
{
|
||||
ImGui.InputTextWithHint( "##New Character", "New Character Name", ref _newCharacterName, 32 );
|
||||
|
||||
using var style = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f, _newCharacterName.Length == 0 );
|
||||
|
||||
ImGui.SameLine();
|
||||
if( ImGui.Button( "Create New Character Collection" ) && _newCharacterName.Length > 0 )
|
||||
if( ImGuiCustom.DisableButton( "Create New Character Collection", _newCharacterName.Length > 0 ))
|
||||
{
|
||||
_manager.Collections.CreateCharacterCollection( _newCharacterName );
|
||||
_currentCharacterIndices[ _newCharacterName ] = 0;
|
||||
_newCharacterName = string.Empty;
|
||||
}
|
||||
|
||||
style.Pop();
|
||||
|
||||
ImGuiCustom.HoverTooltip(
|
||||
"A character collection will be used whenever you manually redraw a character with the Name you have set up.\n"
|
||||
+ "If you enable automatic character redraws in the Settings tab, penumbra will try to use Character collections for corresponding characters automatically.\n" );
|
||||
|
|
|
|||
|
|
@ -342,6 +342,34 @@ namespace Penumbra.UI
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawDebugTabMissingFiles()
|
||||
{
|
||||
if( !ImGui.CollapsingHeader( "Missing Files##Debug" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var manager = Service<ModManager>.Get();
|
||||
var cache = manager.Collections.CurrentCollection.Cache;
|
||||
if( cache == null || !ImGui.BeginTable( "##MissingFilesDebugList", 1, ImGuiTableFlags.RowBg, -Vector2.UnitX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTable );
|
||||
|
||||
foreach( var file in cache.MissingFiles )
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
if( ImGui.Selectable( file.FullName ) )
|
||||
{
|
||||
ImGui.SetClipboardText( file.FullName );
|
||||
}
|
||||
ImGuiCustom.HoverTooltip( "Click to copy to clipboard." );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDebugTab()
|
||||
{
|
||||
if( !ImGui.BeginTabItem( "Debug Tab" ) )
|
||||
|
|
@ -353,6 +381,8 @@ namespace Penumbra.UI
|
|||
|
||||
DrawDebugTabGeneral();
|
||||
ImGui.NewLine();
|
||||
DrawDebugTabMissingFiles();
|
||||
ImGui.NewLine();
|
||||
DrawDebugTabRedraw();
|
||||
ImGui.NewLine();
|
||||
DrawDebugTabPlayers();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue