mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-30 04:13:43 +01:00
tmp
This commit is contained in:
parent
48e442a9fd
commit
da73feacf4
59 changed files with 2115 additions and 3428 deletions
|
|
@ -19,6 +19,8 @@ public enum ColorId
|
|||
|
||||
public static class Colors
|
||||
{
|
||||
public const uint PressEnterWarningBg = 0xFF202080;
|
||||
|
||||
public static (uint DefaultColor, string Name, string Description) Data( this ColorId color )
|
||||
=> color switch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ public partial class ModFileSystemSelector
|
|||
public uint Color;
|
||||
}
|
||||
|
||||
private const StringComparison IgnoreCase = StringComparison.InvariantCultureIgnoreCase;
|
||||
private readonly IReadOnlySet< Mod > _newMods = new HashSet< Mod >();
|
||||
private LowerString _modFilter = LowerString.Empty;
|
||||
private int _filterType = -1;
|
||||
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
|
||||
private const StringComparison IgnoreCase = StringComparison.InvariantCultureIgnoreCase;
|
||||
private readonly IReadOnlySet< Mod2 > _newMods = new HashSet< Mod2 >();
|
||||
private LowerString _modFilter = LowerString.Empty;
|
||||
private int _filterType = -1;
|
||||
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
|
||||
|
||||
private void SetFilterTooltip()
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ public partial class ModFileSystemSelector
|
|||
// Folders have default state and are filtered out on the direct string instead of the other options.
|
||||
// If any filter is set, they should be hidden by default unless their children are visible,
|
||||
// or they contain the path search string.
|
||||
protected override bool ApplyFiltersAndState( FileSystem< Mod >.IPath path, out ModState state )
|
||||
protected override bool ApplyFiltersAndState( FileSystem< Mod2 >.IPath path, out ModState state )
|
||||
{
|
||||
if( path is ModFileSystemA.Folder f )
|
||||
{
|
||||
|
|
@ -88,21 +88,21 @@ public partial class ModFileSystemSelector
|
|||
}
|
||||
|
||||
// Apply the string filters.
|
||||
private bool ApplyStringFilters( ModFileSystemA.Leaf leaf, Mod mod )
|
||||
private bool ApplyStringFilters( ModFileSystemA.Leaf leaf, Mod2 mod )
|
||||
{
|
||||
return _filterType switch
|
||||
{
|
||||
-1 => false,
|
||||
0 => !( leaf.FullName().Contains( _modFilter.Lower, IgnoreCase ) || mod.Meta.Name.Contains( _modFilter ) ),
|
||||
1 => !mod.Meta.Name.Contains( _modFilter ),
|
||||
2 => !mod.Meta.Author.Contains( _modFilter ),
|
||||
0 => !( leaf.FullName().Contains( _modFilter.Lower, IgnoreCase ) || mod.Name.Contains( _modFilter ) ),
|
||||
1 => !mod.Name.Contains( _modFilter ),
|
||||
2 => !mod.Author.Contains( _modFilter ),
|
||||
3 => !mod.LowerChangedItemsString.Contains( _modFilter ),
|
||||
_ => false, // Should never happen
|
||||
};
|
||||
}
|
||||
|
||||
// Only get the text color for a mod if no filters are set.
|
||||
private uint GetTextColor( Mod mod, ModSettings? settings, ModCollection collection )
|
||||
private uint GetTextColor( Mod2 mod, ModSettings2? settings, ModCollection collection )
|
||||
{
|
||||
if( _newMods.Contains( mod ) )
|
||||
{
|
||||
|
|
@ -130,14 +130,14 @@ public partial class ModFileSystemSelector
|
|||
: ColorId.HandledConflictMod.Value();
|
||||
}
|
||||
|
||||
private bool CheckStateFilters( Mod mod, ModSettings? settings, ModCollection collection, ref ModState state )
|
||||
private bool CheckStateFilters( Mod2 mod, ModSettings2? settings, ModCollection collection, ref ModState state )
|
||||
{
|
||||
var isNew = _newMods.Contains( mod );
|
||||
// Handle mod details.
|
||||
if( CheckFlags( mod.Resources.ModFiles.Count, ModFilter.HasNoFiles, ModFilter.HasFiles )
|
||||
|| CheckFlags( mod.Meta.FileSwaps.Count, ModFilter.HasNoFileSwaps, ModFilter.HasFileSwaps )
|
||||
|| CheckFlags( mod.Resources.MetaManipulations.Count, ModFilter.HasNoMetaManipulations, ModFilter.HasMetaManipulations )
|
||||
|| CheckFlags( mod.Meta.HasGroupsWithConfig ? 1 : 0, ModFilter.HasNoConfig, ModFilter.HasConfig )
|
||||
if( CheckFlags( mod.TotalFileCount, ModFilter.HasNoFiles, ModFilter.HasFiles )
|
||||
|| CheckFlags( mod.TotalSwapCount, ModFilter.HasNoFileSwaps, ModFilter.HasFileSwaps )
|
||||
|| CheckFlags( mod.TotalManipulations, ModFilter.HasNoMetaManipulations, ModFilter.HasMetaManipulations )
|
||||
|| CheckFlags( mod.HasOptions ? 1 : 0, ModFilter.HasNoConfig, ModFilter.HasConfig )
|
||||
|| CheckFlags( isNew ? 1 : 0, ModFilter.NotNew, ModFilter.IsNew ) )
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ using Penumbra.Mods;
|
|||
|
||||
namespace Penumbra.UI.Classes;
|
||||
|
||||
public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, ModFileSystemSelector.ModState >
|
||||
public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod2, ModFileSystemSelector.ModState >
|
||||
{
|
||||
public ModSettings SelectedSettings { get; private set; } = ModSettings.Empty;
|
||||
public ModSettings2 SelectedSettings { get; private set; } = ModSettings2.Empty;
|
||||
public ModCollection SelectedSettingCollection { get; private set; } = ModCollection.Empty;
|
||||
|
||||
public ModFileSystemSelector( ModFileSystemA fileSystem, IReadOnlySet<Mod> newMods )
|
||||
public ModFileSystemSelector( ModFileSystemA fileSystem, IReadOnlySet< Mod2 > newMods )
|
||||
: base( fileSystem )
|
||||
{
|
||||
_newMods = newMods;
|
||||
|
|
@ -29,13 +29,19 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
AddButton( DeleteModButton, 1000 );
|
||||
SetFilterTooltip();
|
||||
|
||||
Penumbra.CollectionManager.CollectionChanged += OnCollectionChange;
|
||||
Penumbra.CollectionManager.CollectionChanged += OnCollectionChange;
|
||||
Penumbra.CollectionManager.Current.ModSettingChanged += OnSettingChange;
|
||||
Penumbra.CollectionManager.Current.InheritanceChanged += OnInheritanceChange;
|
||||
Penumbra.ModManager.ModDiscoveryStarted += StoreCurrentSelection;
|
||||
Penumbra.ModManager.ModDiscoveryFinished += RestoreLastSelection;
|
||||
OnCollectionChange( ModCollection.Type.Current, null, Penumbra.CollectionManager.Current, null );
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
Penumbra.ModManager.ModDiscoveryStarted -= StoreCurrentSelection;
|
||||
Penumbra.ModManager.ModDiscoveryFinished -= RestoreLastSelection;
|
||||
Penumbra.CollectionManager.Current.ModSettingChanged -= OnSettingChange;
|
||||
Penumbra.CollectionManager.Current.InheritanceChanged -= OnInheritanceChange;
|
||||
Penumbra.CollectionManager.CollectionChanged -= OnCollectionChange;
|
||||
|
|
@ -54,11 +60,11 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
protected override uint FolderLineColor
|
||||
=> ColorId.FolderLine.Value();
|
||||
|
||||
protected override void DrawLeafName( FileSystem< Mod >.Leaf leaf, in ModState state, bool selected )
|
||||
protected override void DrawLeafName( FileSystem< Mod2 >.Leaf leaf, in ModState state, bool selected )
|
||||
{
|
||||
var flags = selected ? ImGuiTreeNodeFlags.Selected | LeafFlags : LeafFlags;
|
||||
using var c = ImRaii.PushColor( ImGuiCol.Text, state.Color );
|
||||
using var _ = ImRaii.TreeNode( leaf.Value.Meta.Name, flags );
|
||||
using var _ = ImRaii.TreeNode( leaf.Value.Name, flags );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,7 +132,7 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
}
|
||||
|
||||
// Automatic cache update functions.
|
||||
private void OnSettingChange( ModSettingChange type, int modIdx, int oldValue, string? optionName, bool inherited )
|
||||
private void OnSettingChange( ModSettingChange type, int modIdx, int oldValue, int groupIdx, bool inherited )
|
||||
{
|
||||
// TODO: maybe make more efficient
|
||||
SetFilterDirty();
|
||||
|
|
@ -169,13 +175,32 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
{
|
||||
if( newSelection == null )
|
||||
{
|
||||
SelectedSettings = ModSettings.Empty;
|
||||
SelectedSettings = ModSettings2.Empty;
|
||||
SelectedSettingCollection = ModCollection.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
( var settings, SelectedSettingCollection ) = Penumbra.CollectionManager.Current[ newSelection.Value.Index ];
|
||||
SelectedSettings = settings ?? ModSettings.Empty;
|
||||
SelectedSettings = settings ?? ModSettings2.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
// Keep selections across rediscoveries if possible.
|
||||
private string _lastSelectedDirectory = string.Empty;
|
||||
|
||||
private void StoreCurrentSelection()
|
||||
{
|
||||
_lastSelectedDirectory = Selected?.BasePath.FullName ?? string.Empty;
|
||||
ClearSelection();
|
||||
}
|
||||
|
||||
private void RestoreLastSelection()
|
||||
{
|
||||
if( _lastSelectedDirectory.Length > 0 )
|
||||
{
|
||||
SelectedLeaf = ( ModFileSystemA.Leaf? )FileSystem.Root.GetAllDescendants( SortMode.Lexicographical )
|
||||
.FirstOrDefault( l => l is ModFileSystemA.Leaf m && m.Value.BasePath.FullName == _lastSelectedDirectory );
|
||||
_lastSelectedDirectory = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Penumbra/UI/ConfigWindow.CollectionsTab.cs
Normal file
22
Penumbra/UI/ConfigWindow.CollectionsTab.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System.Numerics;
|
||||
using OtterGui.Raii;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
public void DrawCollectionsTab()
|
||||
{
|
||||
using var tab = ImRaii.TabItem( "Collections" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##CollectionsTab", -Vector2.One );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Penumbra/UI/ConfigWindow.DebugTab.cs
Normal file
35
Penumbra/UI/ConfigWindow.DebugTab.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System.Numerics;
|
||||
using OtterGui.Raii;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
#if DEBUG
|
||||
private const bool DefaultVisibility = true;
|
||||
#else
|
||||
private const bool DefaultVisibility = false;
|
||||
#endif
|
||||
|
||||
public bool DebugTabVisible = DefaultVisibility;
|
||||
|
||||
public void DrawDebugTab()
|
||||
{
|
||||
if( !DebugTabVisible )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var tab = ImRaii.TabItem( "Debug" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##DebugTab", -Vector2.One );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Penumbra/UI/ConfigWindow.EffectiveTab.cs
Normal file
27
Penumbra/UI/ConfigWindow.EffectiveTab.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Numerics;
|
||||
using OtterGui.Raii;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
public void DrawEffectiveChangesTab()
|
||||
{
|
||||
if( !Penumbra.Config.ShowAdvanced )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var tab = ImRaii.TabItem( "Effective Changes" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##EffectiveChangesTab", -Vector2.One );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,13 +2,19 @@ using System.Numerics;
|
|||
using ImGuiNET;
|
||||
using Lumina.Data.Parsing;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Penumbra.GameData.ByteString;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.UI.Custom;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class SettingsInterface
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
internal static unsafe void Text( Utf8String s )
|
||||
{
|
||||
ImGuiNative.igTextUnformatted( s.Path, s.Path + s.Length );
|
||||
}
|
||||
|
||||
internal void DrawChangedItem( string name, object? data, float itemIdOffset = 0 )
|
||||
{
|
||||
var ret = ImGui.Selectable( name ) ? MouseButton.Left : MouseButton.None;
|
||||
22
Penumbra/UI/ConfigWindow.ModsTab.cs
Normal file
22
Penumbra/UI/ConfigWindow.ModsTab.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System.Numerics;
|
||||
using OtterGui.Raii;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
public void DrawModsTab()
|
||||
{
|
||||
using var tab = ImRaii.TabItem( "Mods" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##ModsTab", -Vector2.One );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Penumbra/UI/ConfigWindow.ResourceTab.cs
Normal file
27
Penumbra/UI/ConfigWindow.ResourceTab.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Numerics;
|
||||
using OtterGui.Raii;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
public void DrawResourceManagerTab()
|
||||
{
|
||||
if( !DebugTabVisible )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var tab = ImRaii.TabItem( "Resource Manager" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##ResourceManagerTab", -Vector2.One );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
317
Penumbra/UI/ConfigWindow.SettingsTab.cs
Normal file
317
Penumbra/UI/ConfigWindow.SettingsTab.cs
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using ImGuiNET;
|
||||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using Penumbra.GameData.ByteString;
|
||||
using Penumbra.UI.Classes;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
private string _newModDirectory = string.Empty;
|
||||
|
||||
private static bool DrawPressEnterWarning( string old )
|
||||
{
|
||||
using var color = ImRaii.PushColor( ImGuiCol.Button, Colors.PressEnterWarningBg );
|
||||
var w = new Vector2( ImGui.CalcItemWidth(), 0 );
|
||||
return ImGui.Button( $"Press Enter or Click Here to Save (Current Directory: {old})", w );
|
||||
}
|
||||
|
||||
private static void DrawOpenDirectoryButton( int id, DirectoryInfo directory, bool condition )
|
||||
{
|
||||
using var _ = ImRaii.PushId( id );
|
||||
var ret = ImGui.Button( "Open Directory" );
|
||||
ImGuiUtil.HoverTooltip( "Open this directory in your configured file explorer." );
|
||||
if( ret && condition && Directory.Exists( directory.FullName ) )
|
||||
{
|
||||
Process.Start( new ProcessStartInfo( directory.FullName )
|
||||
{
|
||||
UseShellExecute = true,
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawRootFolder()
|
||||
{
|
||||
using var group = ImRaii.Group();
|
||||
ImGui.SetNextItemWidth( _inputTextWidth.X );
|
||||
var save = ImGui.InputText( "Root Directory", ref _newModDirectory, 255, ImGuiInputTextFlags.EnterReturnsTrue );
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "This is where Penumbra will store your extracted mod files.\n"
|
||||
+ "TTMP files are not copied, just extracted.\n"
|
||||
+ "This directory needs to be accessible and you need write access here.\n"
|
||||
+ "It is recommended that this directory is placed on a fast hard drive, preferably an SSD.\n"
|
||||
+ "It should also be placed near the root of a logical drive - the shorter the total path to this folder, the better.\n"
|
||||
+ "Definitely do not place it in your Dalamud directory or any sub-directory thereof." );
|
||||
ImGui.SameLine();
|
||||
DrawOpenDirectoryButton( 0, Penumbra.ModManager.BasePath, Penumbra.ModManager.Valid );
|
||||
group.Dispose();
|
||||
|
||||
if( Penumbra.Config.ModDirectory == _newModDirectory || _newModDirectory.Length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( save || DrawPressEnterWarning( Penumbra.Config.ModDirectory ) )
|
||||
{
|
||||
Penumbra.ModManager.DiscoverMods( _newModDirectory );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DrawRediscoverButton()
|
||||
{
|
||||
if( ImGui.Button( "Rediscover Mods" ) )
|
||||
{
|
||||
Penumbra.ModManager.DiscoverMods();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "Force Penumbra to completely re-scan your root directory as if it was restarted." );
|
||||
}
|
||||
|
||||
private void DrawEnabledBox()
|
||||
{
|
||||
var enabled = Penumbra.Config.EnableMods;
|
||||
if( ImGui.Checkbox( "Enable Mods", ref enabled ) )
|
||||
{
|
||||
_penumbra.SetEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawShowAdvancedBox()
|
||||
{
|
||||
var showAdvanced = Penumbra.Config.ShowAdvanced;
|
||||
if( ImGui.Checkbox( "Show Advanced Settings", ref showAdvanced ) )
|
||||
{
|
||||
Penumbra.Config.ShowAdvanced = showAdvanced;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "Enable some advanced options in this window and in the mod selector.\n"
|
||||
+ "This is required to enable manually editing any mod information." );
|
||||
}
|
||||
|
||||
private void DrawFolderSortType()
|
||||
{
|
||||
// TODO provide all options
|
||||
var foldersFirst = Penumbra.Config.SortFoldersFirst;
|
||||
if( ImGui.Checkbox( "Sort Mod-Folders Before Mods", ref foldersFirst ) )
|
||||
{
|
||||
Penumbra.Config.SortFoldersFirst = foldersFirst;
|
||||
Selector.SetFilterDirty();
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker(
|
||||
"Prioritizes all mod-folders in the mod-selector in the Installed Mods tab so that folders come before single mods, instead of being sorted completely alphabetically" );
|
||||
}
|
||||
|
||||
private void DrawScaleModSelectorBox()
|
||||
{
|
||||
// TODO set scale
|
||||
var scaleModSelector = Penumbra.Config.ScaleModSelector;
|
||||
if( ImGui.Checkbox( "Scale Mod Selector With Window Size", ref scaleModSelector ) )
|
||||
{
|
||||
Penumbra.Config.ScaleModSelector = scaleModSelector;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker(
|
||||
"Instead of keeping the mod-selector in the Installed Mods tab a fixed width, this will let it scale with the total size of the Penumbra window." );
|
||||
}
|
||||
|
||||
private void DrawDisableSoundStreamingBox()
|
||||
{
|
||||
var tmp = Penumbra.Config.DisableSoundStreaming;
|
||||
if( ImGui.Checkbox( "Disable Audio Streaming", ref tmp ) && tmp != Penumbra.Config.DisableSoundStreaming )
|
||||
{
|
||||
Penumbra.Config.DisableSoundStreaming = tmp;
|
||||
Penumbra.Config.Save();
|
||||
if( tmp )
|
||||
{
|
||||
_penumbra.MusicManager.DisableStreaming();
|
||||
}
|
||||
else
|
||||
{
|
||||
_penumbra.MusicManager.EnableStreaming();
|
||||
}
|
||||
|
||||
Penumbra.ModManager.DiscoverMods();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker(
|
||||
"Disable streaming in the games audio engine.\n"
|
||||
+ "If you do not disable streaming, you can not replace sound files in the game (*.scd files), they will be ignored by Penumbra.\n\n"
|
||||
+ "Only touch this if you experience sound problems.\n"
|
||||
+ "If you toggle this, make sure no modified or to-be-modified sound file is currently playing or was recently playing, else you might crash." );
|
||||
}
|
||||
|
||||
|
||||
private void DrawEnableHttpApiBox()
|
||||
{
|
||||
var http = Penumbra.Config.EnableHttpApi;
|
||||
if( ImGui.Checkbox( "Enable HTTP API", ref http ) )
|
||||
{
|
||||
if( http )
|
||||
{
|
||||
_penumbra.CreateWebServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_penumbra.ShutdownWebServer();
|
||||
}
|
||||
|
||||
Penumbra.Config.EnableHttpApi = http;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker(
|
||||
"Enables other applications, e.g. Anamnesis, to use some Penumbra functions, like requesting redraws." );
|
||||
}
|
||||
|
||||
private static void DrawReloadResourceButton()
|
||||
{
|
||||
if( ImGui.Button( "Reload Resident Resources" ) )
|
||||
{
|
||||
Penumbra.ResidentResources.Reload();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "Reload some specific files that the game keeps in memory at all times.\n"
|
||||
+ "You usually should not need to do this." );
|
||||
}
|
||||
|
||||
private void DrawEnableFullResourceLoggingBox()
|
||||
{
|
||||
var tmp = Penumbra.Config.EnableFullResourceLogging;
|
||||
if( ImGui.Checkbox( "Enable Full Resource Logging", ref tmp ) && tmp != Penumbra.Config.EnableFullResourceLogging )
|
||||
{
|
||||
if( tmp )
|
||||
{
|
||||
Penumbra.ResourceLoader.EnableFullLogging();
|
||||
}
|
||||
else
|
||||
{
|
||||
Penumbra.ResourceLoader.DisableFullLogging();
|
||||
}
|
||||
|
||||
Penumbra.Config.EnableFullResourceLogging = tmp;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "[DEBUG] Enable the logging of all ResourceLoader events indiscriminately." );
|
||||
}
|
||||
|
||||
private void DrawEnableDebugModeBox()
|
||||
{
|
||||
var tmp = Penumbra.Config.DebugMode;
|
||||
if( ImGui.Checkbox( "Enable Debug Mode", ref tmp ) && tmp != Penumbra.Config.DebugMode )
|
||||
{
|
||||
if( tmp )
|
||||
{
|
||||
Penumbra.ResourceLoader.EnableDebug();
|
||||
}
|
||||
else
|
||||
{
|
||||
Penumbra.ResourceLoader.DisableDebug();
|
||||
}
|
||||
|
||||
Penumbra.Config.DebugMode = tmp;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "[DEBUG] Enable the Debug Tab and Resource Manager Tab as well as some additional data collection." );
|
||||
}
|
||||
|
||||
private void DrawRequestedResourceLogging()
|
||||
{
|
||||
var tmp = Penumbra.Config.EnableResourceLogging;
|
||||
if( ImGui.Checkbox( "Enable Requested Resource Logging", ref tmp ) )
|
||||
{
|
||||
_penumbra.ResourceLogger.SetState( tmp );
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker( "Log all game paths FFXIV requests to the plugin log.\n"
|
||||
+ "You can filter the logged paths for those containing the entered string or matching the regex, if the entered string compiles to a valid regex.\n"
|
||||
+ "Red boundary indicates invalid regex." );
|
||||
ImGui.SameLine();
|
||||
var tmpString = Penumbra.Config.ResourceLoggingFilter;
|
||||
using var color = ImRaii.PushColor( ImGuiCol.Border, 0xFF0000B0, !_penumbra.ResourceLogger.ValidRegex );
|
||||
using var style = ImRaii.PushStyle( ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale, !_penumbra.ResourceLogger.ValidRegex );
|
||||
if( ImGui.InputTextWithHint( "##ResourceLogFilter", "Filter...", ref tmpString, Utf8GamePath.MaxGamePathLength ) )
|
||||
{
|
||||
_penumbra.ResourceLogger.SetFilter( tmpString );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAdvancedSettings()
|
||||
{
|
||||
DrawRequestedResourceLogging();
|
||||
DrawDisableSoundStreamingBox();
|
||||
DrawEnableHttpApiBox();
|
||||
DrawReloadResourceButton();
|
||||
DrawEnableDebugModeBox();
|
||||
DrawEnableFullResourceLoggingBox();
|
||||
}
|
||||
|
||||
public void DrawSettingsTab()
|
||||
{
|
||||
using var tab = ImRaii.TabItem( "Settings" );
|
||||
if( !tab )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var child = ImRaii.Child( "##SettingsTab", -Vector2.One, false );
|
||||
if( !child )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawRootFolder();
|
||||
|
||||
DrawRediscoverButton();
|
||||
|
||||
ImGui.Dummy( _verticalSpace );
|
||||
DrawEnabledBox();
|
||||
|
||||
ImGui.Dummy( _verticalSpace );
|
||||
DrawFolderSortType();
|
||||
DrawScaleModSelectorBox();
|
||||
DrawShowAdvancedBox();
|
||||
|
||||
if( Penumbra.Config.ShowAdvanced )
|
||||
{
|
||||
DrawAdvancedSettings();
|
||||
}
|
||||
|
||||
if( ImGui.CollapsingHeader( "Colors" ) )
|
||||
{
|
||||
foreach( var color in Enum.GetValues< ColorId >() )
|
||||
{
|
||||
var (defaultColor, name, description) = color.Data();
|
||||
var currentColor = Penumbra.Config.Colors.TryGetValue( color, out var current ) ? current : defaultColor;
|
||||
if( ImGuiUtil.ColorPicker( name, description, currentColor, c => Penumbra.Config.Colors[ color ] = c, defaultColor ) )
|
||||
{
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
Penumbra/UI/ConfigWindow.cs
Normal file
68
Penumbra/UI/ConfigWindow.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using OtterGui.Raii;
|
||||
using Penumbra.Mods;
|
||||
using Penumbra.UI.Classes;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public sealed partial class ConfigWindow : Window, IDisposable
|
||||
{
|
||||
private readonly Penumbra _penumbra;
|
||||
public readonly ModFileSystemSelector Selector;
|
||||
|
||||
public ConfigWindow( Penumbra penumbra )
|
||||
: base( GetLabel() )
|
||||
{
|
||||
_penumbra = penumbra;
|
||||
Selector = new ModFileSystemSelector( _penumbra.ModFileSystem, new HashSet< Mod2 >() ); // TODO
|
||||
Dalamud.PluginInterface.UiBuilder.DisableGposeUiHide = true;
|
||||
Dalamud.PluginInterface.UiBuilder.DisableCutsceneUiHide = true;
|
||||
Dalamud.PluginInterface.UiBuilder.DisableUserUiHide = true;
|
||||
RespectCloseHotkey = true;
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
MinimumSize = new Vector2( 1024, 768 ),
|
||||
MaximumSize = new Vector2( 4096, 2160 ),
|
||||
};
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
using var bar = ImRaii.TabBar( string.Empty, ImGuiTabBarFlags.NoTooltip );
|
||||
SetupSizes();
|
||||
DrawSettingsTab();
|
||||
DrawModsTab();
|
||||
DrawCollectionsTab();
|
||||
DrawEffectiveChangesTab();
|
||||
DrawDebugTab();
|
||||
DrawResourceManagerTab();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Selector.Dispose();
|
||||
}
|
||||
|
||||
private static string GetLabel()
|
||||
{
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "";
|
||||
return version.Length == 0
|
||||
? "Penumbra###PenumbraConfigWindow"
|
||||
: $"Penumbra v{version}###PenumbraConfigWindow";
|
||||
}
|
||||
|
||||
private Vector2 _verticalSpace;
|
||||
private Vector2 _inputTextWidth;
|
||||
|
||||
private void SetupSizes()
|
||||
{
|
||||
_verticalSpace = new Vector2( 0, 20f * ImGuiHelpers.GlobalScale );
|
||||
_inputTextWidth = new Vector2( 450f * ImGuiHelpers.GlobalScale, 0 );
|
||||
}
|
||||
}
|
||||
|
|
@ -5,38 +5,33 @@ using ImGuiScene;
|
|||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class SettingsInterface
|
||||
public class LaunchButton : IDisposable
|
||||
{
|
||||
private class ManageModsButton : IDisposable
|
||||
private readonly ConfigWindow _configWindow;
|
||||
private readonly TextureWrap? _icon;
|
||||
private readonly TitleScreenMenu.TitleScreenMenuEntry? _entry;
|
||||
|
||||
public LaunchButton( ConfigWindow ui )
|
||||
{
|
||||
private readonly SettingsInterface _base;
|
||||
private readonly TextureWrap? _icon;
|
||||
private readonly TitleScreenMenu.TitleScreenMenuEntry? _entry;
|
||||
_configWindow = ui;
|
||||
|
||||
public ManageModsButton( SettingsInterface ui )
|
||||
_icon = Dalamud.PluginInterface.UiBuilder.LoadImage( Path.Combine( Dalamud.PluginInterface.AssemblyLocation.DirectoryName!,
|
||||
"tsmLogo.png" ) );
|
||||
if( _icon != null )
|
||||
{
|
||||
_base = ui;
|
||||
|
||||
_icon = Dalamud.PluginInterface.UiBuilder.LoadImage( Path.Combine( Dalamud.PluginInterface.AssemblyLocation.DirectoryName!,
|
||||
"tsmLogo.png" ) );
|
||||
if( _icon != null )
|
||||
{
|
||||
_entry = Dalamud.TitleScreenMenu.AddEntry( "Manage Penumbra", _icon, OnTriggered );
|
||||
}
|
||||
_entry = Dalamud.TitleScreenMenu.AddEntry( "Manage Penumbra", _icon, OnTriggered );
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggered()
|
||||
{
|
||||
_base.FlipVisibility();
|
||||
}
|
||||
private void OnTriggered()
|
||||
=> _configWindow.Toggle();
|
||||
|
||||
public void Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
_icon?.Dispose();
|
||||
if( _entry != null )
|
||||
{
|
||||
_icon?.Dispose();
|
||||
if( _entry != null )
|
||||
{
|
||||
Dalamud.TitleScreenMenu.RemoveEntry( _entry );
|
||||
}
|
||||
Dalamud.TitleScreenMenu.RemoveEntry( _entry );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class SettingsInterface : IDisposable
|
||||
{
|
||||
private const float DefaultVerticalSpace = 20f;
|
||||
|
||||
private static readonly Vector2 AutoFillSize = new(-1, -1);
|
||||
private static readonly Vector2 ZeroVector = new(0, 0);
|
||||
|
||||
private readonly Penumbra _penumbra;
|
||||
|
||||
private readonly ManageModsButton _manageModsButton;
|
||||
private readonly SettingsMenu _menu;
|
||||
|
||||
public SettingsInterface( Penumbra penumbra )
|
||||
{
|
||||
_penumbra = penumbra;
|
||||
_manageModsButton = new ManageModsButton( this );
|
||||
_menu = new SettingsMenu( this );
|
||||
|
||||
Dalamud.PluginInterface.UiBuilder.DisableGposeUiHide = true;
|
||||
Dalamud.PluginInterface.UiBuilder.Draw += Draw;
|
||||
Dalamud.PluginInterface.UiBuilder.OpenConfigUi += OpenConfig;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_manageModsButton.Dispose();
|
||||
_menu.InstalledTab.Selector.Cache.Dispose();
|
||||
Dalamud.PluginInterface.UiBuilder.Draw -= Draw;
|
||||
Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig;
|
||||
}
|
||||
|
||||
private void OpenConfig()
|
||||
=> _menu.Visible = true;
|
||||
|
||||
public void FlipVisibility()
|
||||
=> _menu.Visible = !_menu.Visible;
|
||||
|
||||
public void MakeDebugTabVisible()
|
||||
=> _menu.DebugTabVisible = true;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
_menu.Draw();
|
||||
}
|
||||
|
||||
private void ReloadMods()
|
||||
{
|
||||
_menu.InstalledTab.Selector.ClearSelection();
|
||||
Penumbra.ModManager.DiscoverMods( Penumbra.Config.ModDirectory );
|
||||
_menu.InstalledTab.Selector.Cache.TriggerListReset();
|
||||
}
|
||||
|
||||
public void ResetDefaultCollection()
|
||||
=> _menu.CollectionsTab.UpdateDefaultIndex();
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
using Penumbra.UI.Custom;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class SettingsInterface
|
||||
{
|
||||
private class SettingsMenu
|
||||
{
|
||||
public static float InputTextWidth
|
||||
=> 450 * ImGuiHelpers.GlobalScale;
|
||||
|
||||
private const string PenumbraSettingsLabel = "PenumbraSettings";
|
||||
|
||||
public static readonly Vector2 MinSettingsSize = new(800, 450);
|
||||
public static readonly Vector2 MaxSettingsSize = new(69420, 42069);
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
private readonly TabSettings _settingsTab;
|
||||
private readonly TabImport _importTab;
|
||||
private readonly TabBrowser _browserTab;
|
||||
private readonly TabEffective _effectiveTab;
|
||||
private readonly TabChangedItems _changedItems;
|
||||
internal readonly TabCollections CollectionsTab;
|
||||
internal readonly TabInstalled InstalledTab;
|
||||
|
||||
public SettingsMenu( SettingsInterface ui )
|
||||
{
|
||||
_base = ui;
|
||||
_settingsTab = new TabSettings( _base );
|
||||
_importTab = new TabImport( _base );
|
||||
_browserTab = new TabBrowser();
|
||||
InstalledTab = new TabInstalled( _base, _importTab.NewMods );
|
||||
CollectionsTab = new TabCollections( InstalledTab.Selector );
|
||||
_effectiveTab = new TabEffective();
|
||||
_changedItems = new TabChangedItems( _base );
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
private const bool DefaultVisibility = true;
|
||||
#else
|
||||
private const bool DefaultVisibility = false;
|
||||
#endif
|
||||
public bool Visible = DefaultVisibility;
|
||||
public bool DebugTabVisible = DefaultVisibility;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if( !Visible )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints( MinSettingsSize, MaxSettingsSize );
|
||||
#if DEBUG
|
||||
var ret = ImGui.Begin( _base._penumbra.PluginDebugTitleStr, ref Visible );
|
||||
#else
|
||||
var ret = ImGui.Begin( _base._penumbra.Name, ref Visible );
|
||||
#endif
|
||||
using var raii = ImGuiRaii.DeferredEnd( ImGui.End );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.BeginTabBar( PenumbraSettingsLabel );
|
||||
raii.Push( ImGui.EndTabBar );
|
||||
|
||||
_settingsTab.Draw();
|
||||
CollectionsTab.Draw();
|
||||
_importTab.Draw();
|
||||
|
||||
if( Penumbra.ModManager.Valid && !_importTab.IsImporting() )
|
||||
{
|
||||
_browserTab.Draw();
|
||||
InstalledTab.Draw();
|
||||
_changedItems.Draw();
|
||||
if( Penumbra.Config.ShowAdvanced )
|
||||
{
|
||||
_effectiveTab.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
if( DebugTabVisible )
|
||||
{
|
||||
_base.DrawDebugTab();
|
||||
_base.DrawResourceManagerTab();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue