mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Applied a slightly expanded .editorconfig to all files, checked the changes and did some simple refactoring-suggestions.
This commit is contained in:
parent
b307a787db
commit
801d9e24cf
38 changed files with 1438 additions and 1055 deletions
|
|
@ -2,7 +2,7 @@
|
|||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
trim_trailing_whitespace=false
|
||||
trim_trailing_whitespace=true
|
||||
insert_final_newline=false
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
|
@ -10,6 +10,7 @@ indent_size=4
|
|||
# Microsoft .NET properties
|
||||
csharp_new_line_before_members_in_object_initializers=false
|
||||
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
|
||||
csharp_prefer_braces=true:none
|
||||
csharp_space_after_cast=false
|
||||
csharp_space_after_keywords_in_control_flow_statements=false
|
||||
csharp_space_between_method_call_parameter_list_parentheses=true
|
||||
|
|
@ -30,9 +31,26 @@ dotnet_style_qualification_for_property=false:suggestion
|
|||
dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
|
||||
|
||||
# ReSharper properties
|
||||
resharper_align_multiline_binary_expressions_chain=false
|
||||
resharper_align_multiline_calls_chain=false
|
||||
resharper_autodetect_indent_settings=true
|
||||
resharper_braces_redundant=true
|
||||
resharper_constructor_or_destructor_body=expression_body
|
||||
resharper_csharp_empty_block_style=together
|
||||
resharper_csharp_max_line_length=144
|
||||
resharper_csharp_space_within_array_access_brackets=true
|
||||
resharper_enforce_line_ending_style=true
|
||||
resharper_int_align_assignments=true
|
||||
resharper_int_align_comments=true
|
||||
resharper_int_align_fields=true
|
||||
resharper_int_align_invocations=false
|
||||
resharper_int_align_nested_ternary=true
|
||||
resharper_int_align_properties=false
|
||||
resharper_int_align_switch_expressions=true
|
||||
resharper_int_align_switch_sections=true
|
||||
resharper_int_align_variables=true
|
||||
resharper_local_function_body=expression_body
|
||||
resharper_method_or_operator_body=expression_body
|
||||
resharper_place_attribute_on_same_line=false
|
||||
resharper_space_after_cast=false
|
||||
resharper_space_within_checked_parentheses=true
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@ namespace Penumbra.API
|
|||
{
|
||||
private readonly Plugin _plugin;
|
||||
|
||||
public ModsController( Plugin plugin )
|
||||
{
|
||||
_plugin = plugin;
|
||||
}
|
||||
public ModsController( Plugin plugin ) => _plugin = plugin;
|
||||
|
||||
[Route( HttpVerbs.Get, "/mods" )]
|
||||
public object GetMods()
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ namespace Penumbra
|
|||
{
|
||||
public IntPtr Handle { get; set; }
|
||||
|
||||
public DialogHandle( IntPtr handle )
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
public DialogHandle( IntPtr handle ) => Handle = handle;
|
||||
}
|
||||
|
||||
public class HiddenForm : Form
|
||||
|
|
@ -52,9 +49,9 @@ namespace Penumbra
|
|||
|
||||
public HiddenForm( CommonDialog form, IWin32Window owner, TaskCompletionSource< DialogResult > taskSource )
|
||||
{
|
||||
this._form = form;
|
||||
this._owner = owner;
|
||||
this._taskSource = taskSource;
|
||||
_form = form;
|
||||
_owner = owner;
|
||||
_taskSource = taskSource;
|
||||
|
||||
Opacity = 0;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ namespace Penumbra.Extensions
|
|||
/// <typeparam name="TField">The type of the underlying field</typeparam>
|
||||
/// <returns>A delegate that will return a reference to a particular field - zero copy</returns>
|
||||
/// <exception cref="MissingFieldException"></exception>
|
||||
private static RefGet< TObject, TField > CreateRefGetter< TObject, TField >( string fieldName ) where TField : unmanaged
|
||||
private static RefGet< TObject, TField > CreateRefGetter< TObject, TField >( string fieldName )
|
||||
where TField : unmanaged
|
||||
{
|
||||
const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ namespace Penumbra.Game
|
|||
public unsafe delegate void* UnloadPlayerResourcesPrototype( IntPtr pResourceManager );
|
||||
|
||||
|
||||
public LoadPlayerResourcesPrototype LoadPlayerResources { get; private set; }
|
||||
public UnloadPlayerResourcesPrototype UnloadPlayerResources { get; private set; }
|
||||
public LoadPlayerResourcesPrototype LoadPlayerResources { get; }
|
||||
public UnloadPlayerResourcesPrototype UnloadPlayerResources { get; }
|
||||
|
||||
// Object addresses
|
||||
private readonly IntPtr _playerResourceManagerAddress;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game.ClientState.Actors;
|
||||
using Dalamud.Game.ClientState.Actors.Types;
|
||||
|
||||
namespace Penumbra
|
||||
namespace Penumbra.Game
|
||||
{
|
||||
public static class RefreshActors
|
||||
{
|
||||
|
|
@ -25,30 +26,36 @@ namespace Penumbra
|
|||
Marshal.WriteInt32( renderModePtr, renderStatus & ~ModelInvisibilityFlag );
|
||||
}
|
||||
|
||||
if (actor.ObjectKind == Dalamud.Game.ClientState.Actors.ObjectKind.Player)
|
||||
if( actor.ObjectKind == ObjectKind.Player )
|
||||
{
|
||||
DrawObject( RenderTaskPlayerDelay );
|
||||
await Task.Delay( RenderTaskPlayerDelay );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawObject( RenderTaskOtherDelay );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void RedrawSpecific( ActorTable actors, string name )
|
||||
{
|
||||
if( name?.Length == 0 )
|
||||
{
|
||||
RedrawAll( actors );
|
||||
}
|
||||
|
||||
foreach (var actor in actors)
|
||||
if (actor.Name == name)
|
||||
foreach( var actor in actors.Where( A => A.Name == name ) )
|
||||
{
|
||||
Redraw( actor );
|
||||
}
|
||||
}
|
||||
|
||||
public static void RedrawAll( ActorTable actors )
|
||||
{
|
||||
foreach( var actor in actors )
|
||||
{
|
||||
Redraw( actor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,7 @@ namespace Penumbra.Importer
|
|||
{
|
||||
private readonly FileStream _fileStream;
|
||||
|
||||
public MagicTempFileStreamManagerAndDeleterFuckery( FileStream stream ) : base( stream )
|
||||
{
|
||||
_fileStream = stream;
|
||||
}
|
||||
public MagicTempFileStreamManagerAndDeleterFuckery( FileStream stream ) : base( stream ) => _fileStream = stream;
|
||||
|
||||
public new void Dispose()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,13 +87,19 @@ namespace Penumbra.Importer
|
|||
if( modRaw.Contains( "\"TTMPVersion\":" ) )
|
||||
{
|
||||
if( modPackFile.Extension != ".ttmp2" )
|
||||
{
|
||||
PluginLog.Warning( $"File {modPackFile.FullName} seems to be a V2 TTMP, but has the wrong extension." );
|
||||
}
|
||||
|
||||
ImportV2ModPack( modPackFile, extractedModPack, modRaw );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( modPackFile.Extension != ".ttmp" )
|
||||
{
|
||||
PluginLog.Warning( $"File {modPackFile.FullName} seems to be a V1 TTMP, but has the wrong extension." );
|
||||
}
|
||||
|
||||
ImportV1ModPack( modPackFile, extractedModPack, modRaw );
|
||||
}
|
||||
}
|
||||
|
|
@ -206,15 +212,17 @@ namespace Penumbra.Importer
|
|||
newModFolder.Create();
|
||||
|
||||
if( modList.SimpleModsList != null )
|
||||
{
|
||||
ExtractSimpleModList( newModFolder, modList.SimpleModsList, modData );
|
||||
}
|
||||
|
||||
if( modList.ModPackPages == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate through all pages
|
||||
foreach( var page in modList.ModPackPages)
|
||||
{
|
||||
foreach(var group in page.ModGroups)
|
||||
foreach( var group in modList.ModPackPages.SelectMany( page => page.ModGroups ) )
|
||||
{
|
||||
var groupFolder = new DirectoryInfo( Path.Combine( newModFolder.FullName, group.GroupName.ReplaceInvalidPathSymbols() ) );
|
||||
foreach( var option in group.OptionList )
|
||||
|
|
@ -222,9 +230,9 @@ namespace Penumbra.Importer
|
|||
var optionFolder = new DirectoryInfo( Path.Combine( groupFolder.FullName, option.Name.ReplaceInvalidPathSymbols() ) );
|
||||
ExtractSimpleModList( optionFolder, option.ModsJsons, modData );
|
||||
}
|
||||
|
||||
AddMeta( newModFolder, groupFolder, group, modMeta );
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(
|
||||
Path.Combine( newModFolder.FullName, "meta.json" ),
|
||||
|
|
@ -238,26 +246,29 @@ namespace Penumbra.Importer
|
|||
{
|
||||
SelectionType = group.SelectionType,
|
||||
GroupName = group.GroupName,
|
||||
Options = new List<Option>(),
|
||||
Options = new List< Option >()
|
||||
};
|
||||
foreach( var opt in group.OptionList )
|
||||
{
|
||||
var optio = new Option
|
||||
var option = new Option
|
||||
{
|
||||
OptionName = opt.Name,
|
||||
OptionDesc = String.IsNullOrEmpty(opt.Description) ? "" : opt.Description,
|
||||
OptionDesc = string.IsNullOrEmpty( opt.Description ) ? "" : opt.Description,
|
||||
OptionFiles = new Dictionary< string, HashSet< string > >()
|
||||
};
|
||||
var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name.ReplaceInvalidPathSymbols() ) );
|
||||
if (optDir.Exists)
|
||||
if( !optDir.Exists )
|
||||
{
|
||||
foreach( var file in optDir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
|
||||
{
|
||||
optio.AddFile(file.FullName.Substring(baseFolder.FullName.Length).TrimStart('\\'), file.FullName.Substring(optDir.FullName.Length).TrimStart('\\').Replace('\\','/'));
|
||||
option.AddFile( file.FullName.Substring( baseFolder.FullName.Length ).TrimStart( '\\' ),
|
||||
file.FullName.Substring( optDir.FullName.Length ).TrimStart( '\\' ).Replace( '\\', '/' ) );
|
||||
}
|
||||
}
|
||||
Inf.Options.Add( optio );
|
||||
|
||||
Inf.Options.Add( option );
|
||||
}
|
||||
|
||||
meta.Groups.Add( group.GroupName, Inf );
|
||||
}
|
||||
|
||||
|
|
@ -276,14 +287,8 @@ namespace Penumbra.Importer
|
|||
TotalProgress += wtf.LongCount();
|
||||
|
||||
// Extract each SimpleMod into the new mod folder
|
||||
foreach( var simpleMod in wtf )
|
||||
foreach( var simpleMod in wtf.Where( M => M != null ) )
|
||||
{
|
||||
if( simpleMod == null )
|
||||
{
|
||||
// do we increment here too???? can this even happen?????
|
||||
continue;
|
||||
}
|
||||
|
||||
ExtractMod( outDirectory, simpleMod, dataStream );
|
||||
CurrentProgress++;
|
||||
}
|
||||
|
|
@ -301,7 +306,9 @@ namespace Penumbra.Importer
|
|||
extractedFile.Directory?.Create();
|
||||
|
||||
if( extractedFile.FullName.EndsWith( "mdl" ) )
|
||||
{
|
||||
ProcessMdl( data.Data );
|
||||
}
|
||||
|
||||
File.WriteAllBytes( extractedFile.FullName, data.Data );
|
||||
}
|
||||
|
|
@ -326,10 +333,7 @@ namespace Penumbra.Importer
|
|||
mdl[ modelHeaderStart + modelHeaderLodOffset ] = 1;
|
||||
}
|
||||
|
||||
private static Stream GetStreamFromZipEntry( ZipFile file, ZipEntry entry )
|
||||
{
|
||||
return file.GetInputStream( entry );
|
||||
}
|
||||
private static Stream GetStreamFromZipEntry( ZipFile file, ZipEntry entry ) => file.GetInputStream( entry );
|
||||
|
||||
private static string GetStringFromZipEntry( ZipFile file, ZipEntry entry, Encoding encoding )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,14 +12,13 @@ namespace Penumbra.Models
|
|||
private readonly DirectoryInfo _baseDir;
|
||||
private readonly int _baseDirLength;
|
||||
private readonly ModMeta _mod;
|
||||
private SHA256 _hasher = null;
|
||||
private SHA256 _hasher;
|
||||
|
||||
private readonly Dictionary< long, List< FileInfo > > _filesBySize = new();
|
||||
|
||||
private ref SHA256 Sha()
|
||||
{
|
||||
if (_hasher == null)
|
||||
_hasher = SHA256.Create();
|
||||
_hasher ??= SHA256.Create();
|
||||
return ref _hasher;
|
||||
}
|
||||
|
||||
|
|
@ -38,41 +37,45 @@ namespace Penumbra.Models
|
|||
{
|
||||
var fileLength = file.Length;
|
||||
if( _filesBySize.TryGetValue( fileLength, out var files ) )
|
||||
{
|
||||
files.Add( file );
|
||||
}
|
||||
else
|
||||
_filesBySize[fileLength] = new(){ file };
|
||||
{
|
||||
_filesBySize[ fileLength ] = new List< FileInfo >() { file };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
foreach (var pair in _filesBySize)
|
||||
foreach( var pair in _filesBySize.Where( pair => pair.Value.Count >= 2 ) )
|
||||
{
|
||||
if (pair.Value.Count < 2)
|
||||
continue;
|
||||
|
||||
if( pair.Value.Count == 2 )
|
||||
{
|
||||
if( CompareFilesDirectly( pair.Value[ 0 ], pair.Value[ 1 ] ) )
|
||||
{
|
||||
ReplaceFile( pair.Value[ 0 ], pair.Value[ 1 ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var deleted = Enumerable.Repeat( false, pair.Value.Count ).ToArray();
|
||||
var hashes = pair.Value.Select( F => ComputeHash(F)).ToArray();
|
||||
var hashes = pair.Value.Select( ComputeHash ).ToArray();
|
||||
|
||||
for( var i = 0; i < pair.Value.Count; ++i )
|
||||
{
|
||||
if( deleted[ i ] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for( var j = i + 1; j < pair.Value.Count; ++j )
|
||||
{
|
||||
if (deleted[j])
|
||||
continue;
|
||||
|
||||
if (!CompareHashes(hashes[i], hashes[j]))
|
||||
if( deleted[ j ] || !CompareHashes( hashes[ i ], hashes[ j ] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ReplaceFile( pair.Value[ i ], pair.Value[ j ] );
|
||||
deleted[ j ] = true;
|
||||
|
|
@ -80,6 +83,7 @@ namespace Penumbra.Models
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClearEmptySubDirectories( _baseDir );
|
||||
}
|
||||
|
||||
|
|
@ -97,11 +101,15 @@ namespace Penumbra.Models
|
|||
{
|
||||
inOption = true;
|
||||
foreach( var value in values )
|
||||
{
|
||||
option.AddFile( relName1, value );
|
||||
}
|
||||
|
||||
option.OptionFiles.Remove( relName2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !inOption )
|
||||
{
|
||||
const string duplicates = "Duplicates";
|
||||
|
|
@ -111,34 +119,32 @@ namespace Penumbra.Models
|
|||
{
|
||||
GroupName = duplicates,
|
||||
SelectionType = SelectType.Single,
|
||||
Options = new()
|
||||
Options = new List< Option >()
|
||||
{
|
||||
new()
|
||||
{
|
||||
OptionName = "Required",
|
||||
OptionDesc = "",
|
||||
OptionFiles = new()
|
||||
OptionFiles = new Dictionary< string, HashSet< string > >()
|
||||
}
|
||||
}
|
||||
};
|
||||
_mod.Groups.Add( duplicates, info );
|
||||
}
|
||||
|
||||
_mod.Groups[ duplicates ].Options[ 0 ].AddFile( relName1, relName2.Replace( '\\', '/' ) );
|
||||
_mod.Groups[ duplicates ].Options[ 0 ].AddFile( relName1, relName1.Replace( '\\', '/' ) );
|
||||
}
|
||||
|
||||
PluginLog.Information( $"File {relName1} and {relName2} are identical. Deleting the second." );
|
||||
f2.Delete();
|
||||
}
|
||||
|
||||
public static bool CompareFilesDirectly( FileInfo f1, FileInfo f2 )
|
||||
{
|
||||
return File.ReadAllBytes(f1.FullName).SequenceEqual(File.ReadAllBytes(f2.FullName));
|
||||
}
|
||||
=> File.ReadAllBytes( f1.FullName ).SequenceEqual( File.ReadAllBytes( f2.FullName ) );
|
||||
|
||||
public static bool CompareHashes( byte[] f1, byte[] f2 )
|
||||
{
|
||||
return StructuralComparisons.StructuralEqualityComparer.Equals(f1, f2);
|
||||
}
|
||||
=> StructuralComparisons.StructuralEqualityComparer.Equals( f1, f2 );
|
||||
|
||||
public byte[] ComputeHash( FileInfo f )
|
||||
{
|
||||
|
|
@ -155,8 +161,10 @@ namespace Penumbra.Models
|
|||
{
|
||||
ClearEmptySubDirectories( subDir );
|
||||
if( subDir.GetFiles().Length == 0 && subDir.GetDirectories().Length == 0 )
|
||||
{
|
||||
subDir.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,10 @@ namespace Penumbra.Models
|
|||
{
|
||||
public enum SelectType
|
||||
{
|
||||
Single, Multi
|
||||
Single,
|
||||
Multi
|
||||
}
|
||||
|
||||
public struct Option
|
||||
{
|
||||
public string OptionName;
|
||||
|
|
@ -18,17 +20,22 @@ namespace Penumbra.Models
|
|||
public bool AddFile( string filePath, string gamePath )
|
||||
{
|
||||
if( OptionFiles.TryGetValue( filePath, out var set ) )
|
||||
{
|
||||
return set.Add( gamePath );
|
||||
else
|
||||
OptionFiles[filePath] = new(){ gamePath };
|
||||
}
|
||||
|
||||
OptionFiles[ filePath ] = new HashSet< string >() { gamePath };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public struct InstallerInfo {
|
||||
public struct InstallerInfo
|
||||
{
|
||||
public string GroupName;
|
||||
|
||||
[JsonConverter( typeof( Newtonsoft.Json.Converters.StringEnumConverter ) )]
|
||||
public SelectType SelectionType;
|
||||
|
||||
public List< Option > Options;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,8 +31,11 @@ namespace Penumbra.Models
|
|||
try
|
||||
{
|
||||
var meta = JsonConvert.DeserializeObject< ModMeta >( File.ReadAllText( filePath ) );
|
||||
meta.HasGroupWithConfig = meta.Groups != null && meta.Groups.Count > 0
|
||||
meta.HasGroupWithConfig =
|
||||
meta.Groups != null
|
||||
&& meta.Groups.Count > 0
|
||||
&& meta.Groups.Values.Any( G => G.SelectionType == SelectType.Multi || G.Options.Count > 1 );
|
||||
|
||||
return meta;
|
||||
}
|
||||
catch( Exception )
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@ namespace Penumbra.Mods
|
|||
public ResourceMod[] EnabledMods { get; set; }
|
||||
|
||||
|
||||
public ModCollection( DirectoryInfo basePath )
|
||||
{
|
||||
_basePath = basePath;
|
||||
}
|
||||
public ModCollection( DirectoryInfo basePath ) => _basePath = basePath;
|
||||
|
||||
public void Load( bool invertOrder = false )
|
||||
{
|
||||
|
|
@ -51,7 +48,7 @@ namespace Penumbra.Mods
|
|||
}
|
||||
#endif
|
||||
|
||||
ModSettings ??= new();
|
||||
ModSettings ??= new List< ModInfo >();
|
||||
var foundMods = new List< string >();
|
||||
|
||||
foreach( var modDir in _basePath.EnumerateDirectories() )
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ namespace Penumbra.Mods
|
|||
|
||||
private DirectoryInfo _basePath;
|
||||
|
||||
public ModManager( Plugin plugin )
|
||||
{
|
||||
_plugin = plugin;
|
||||
}
|
||||
public ModManager( Plugin plugin ) => _plugin = plugin;
|
||||
|
||||
public void DiscoverMods()
|
||||
{
|
||||
|
|
@ -114,7 +111,7 @@ namespace Penumbra.Mods
|
|||
mod.FileConflicts?.Clear();
|
||||
if( settings.Conf == null )
|
||||
{
|
||||
settings.Conf = new();
|
||||
settings.Conf = new Dictionary< string, int >();
|
||||
_plugin.ModManager.Mods.Save();
|
||||
}
|
||||
|
||||
|
|
@ -155,13 +152,14 @@ namespace Penumbra.Mods
|
|||
{
|
||||
var relativeFilePath = file.FullName.Substring( baseDir.Length ).TrimStart( '\\' );
|
||||
|
||||
bool doNotAdd = false;
|
||||
var doNotAdd = false;
|
||||
|
||||
HashSet< string > paths;
|
||||
foreach( var group in mod.Meta.Groups.Select( G => G.Value ) )
|
||||
{
|
||||
if( !settings.Conf.TryGetValue( group.GroupName, out var setting )
|
||||
|| ( group.SelectionType == SelectType.Single && settings.Conf[ group.GroupName ] >= group.Options.Count ) )
|
||||
|| group.SelectionType == SelectType.Single
|
||||
&& settings.Conf[ group.GroupName ] >= group.Options.Count )
|
||||
{
|
||||
settings.Conf[ group.GroupName ] = 0;
|
||||
_plugin.ModManager.Mods.Save();
|
||||
|
|
@ -169,10 +167,14 @@ namespace Penumbra.Mods
|
|||
}
|
||||
|
||||
if( group.Options.Count == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( group.SelectionType == SelectType.Multi )
|
||||
settings.Conf[ group.GroupName ] &= ( ( 1 << group.Options.Count ) - 1 );
|
||||
{
|
||||
settings.Conf[ group.GroupName ] &= ( 1 << group.Options.Count ) - 1;
|
||||
}
|
||||
|
||||
switch( group.SelectionType )
|
||||
{
|
||||
|
|
@ -183,15 +185,10 @@ namespace Penumbra.Mods
|
|||
}
|
||||
else
|
||||
{
|
||||
for( var i = 0; i < group.Options.Count; ++i )
|
||||
{
|
||||
if( i == setting )
|
||||
continue;
|
||||
if( group.Options[ i ].OptionFiles.ContainsKey( relativeFilePath ) )
|
||||
if( group.Options.Where( ( o, i ) => i != setting )
|
||||
.Any( option => option.OptionFiles.ContainsKey( relativeFilePath ) ) )
|
||||
{
|
||||
doNotAdd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +204,10 @@ namespace Penumbra.Mods
|
|||
}
|
||||
}
|
||||
else if( group.Options[ i ].OptionFiles.ContainsKey( relativeFilePath ) )
|
||||
{
|
||||
doNotAdd = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -216,7 +215,7 @@ namespace Penumbra.Mods
|
|||
|
||||
if( !doNotAdd )
|
||||
{
|
||||
AddFiles( new() { relativeFilePath.Replace( '\\', '/' ) }, out doNotAdd, file, registeredFiles, mod );
|
||||
AddFiles( new HashSet< string > { relativeFilePath.Replace( '\\', '/' ) }, out doNotAdd, file, registeredFiles, mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -258,6 +257,7 @@ namespace Penumbra.Mods
|
|||
PluginLog.Error( $"Could not delete the mod {mod.ModBasePath.Name}:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
DiscoverMods();
|
||||
}
|
||||
|
||||
|
|
@ -278,9 +278,7 @@ namespace Penumbra.Mods
|
|||
}
|
||||
|
||||
public string GetSwappedFilePath( string gameResourcePath )
|
||||
{
|
||||
return SwappedFiles.TryGetValue( gameResourcePath, out var swappedPath ) ? swappedPath : null;
|
||||
}
|
||||
=> SwappedFiles.TryGetValue( gameResourcePath, out var swappedPath ) ? swappedPath : null;
|
||||
|
||||
public string ResolveSwappedOrReplacementFilePath( string gameResourcePath )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ namespace Penumbra
|
|||
GameUtils.ReloadPlayerResources();
|
||||
|
||||
SettingsInterface = new SettingsInterface( this );
|
||||
|
||||
PluginInterface.UiBuilder.OnBuildUi += SettingsInterface.Draw;
|
||||
|
||||
PluginDebugTitleStr = $"{Name} - Debug Build";
|
||||
|
|
@ -123,9 +124,14 @@ namespace Penumbra
|
|||
case "redraw":
|
||||
{
|
||||
if( args.Length > 1 )
|
||||
{
|
||||
RefreshActors.RedrawSpecific( PluginInterface.ClientState.Actors, string.Join( " ", args.Skip( 1 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
RefreshActors.RedrawAll( PluginInterface.ClientState.Actors );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,9 @@ namespace Penumbra
|
|||
public void Enable()
|
||||
{
|
||||
if( IsEnabled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReadSqpackHook.Activate();
|
||||
GetResourceSyncHook.Activate();
|
||||
|
|
@ -208,7 +210,9 @@ namespace Penumbra
|
|||
public void Disable()
|
||||
{
|
||||
if( !IsEnabled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReadSqpackHook.Disable();
|
||||
GetResourceSyncHook.Disable();
|
||||
|
|
@ -220,7 +224,9 @@ namespace Penumbra
|
|||
public void Dispose()
|
||||
{
|
||||
if( IsEnabled )
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
|
||||
// ReadSqpackHook.Disable();
|
||||
// GetResourceSyncHook.Disable();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Penumbra.Structs
|
|||
{
|
||||
LoadUnpackedResource = 0,
|
||||
LoadFileResource = 1, // Shit in My Games uses this
|
||||
|
||||
// some shit here, the game does some jump if its < 0xA for other files for some reason but there's no impl, probs debug?
|
||||
LoadIndexResource = 0xA, // load index/index2
|
||||
LoadSqPackResource = 0xB
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ namespace Penumbra.UI
|
|||
|
||||
var effectiveSize = minSize;
|
||||
if( effectiveSize.X < 0 )
|
||||
{
|
||||
effectiveSize.X = ImGui.GetContentRegionAvail().X;
|
||||
}
|
||||
|
||||
// Ensure width.
|
||||
ImGui.Dummy(new(effectiveSize.X, 0));
|
||||
ImGui.Dummy( new Vector2( effectiveSize.X, 0 ) );
|
||||
// Ensure left half boundary width/distance.
|
||||
ImGui.Dummy( halfFrameHeight );
|
||||
|
||||
|
|
@ -44,9 +46,13 @@ namespace Penumbra.UI
|
|||
ImGui.SameLine();
|
||||
var ret = false;
|
||||
if( edit )
|
||||
ret = ImGuiCustom.ResizingTextInput(ref label, 1024);
|
||||
{
|
||||
ret = ResizingTextInput( ref label, 1024 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted( label );
|
||||
}
|
||||
|
||||
var labelMin = ImGui.GetItemRectMin();
|
||||
var labelMax = ImGui.GetItemRectMax();
|
||||
|
|
@ -76,10 +82,10 @@ namespace Penumbra.UI
|
|||
|
||||
public static void EndFramedGroup()
|
||||
{
|
||||
uint borderColor = ImGui.ColorConvertFloat4ToU32(ImGui.GetStyle().Colors[(int)ImGuiCol.Border]);
|
||||
Vector2 itemSpacing = ImGui.GetStyle().ItemSpacing;
|
||||
float frameHeight = ImGui.GetFrameHeight();
|
||||
Vector2 halfFrameHeight = new(ImGui.GetFrameHeight() / 2, 0);
|
||||
var borderColor = ImGui.ColorConvertFloat4ToU32( ImGui.GetStyle().Colors[ ( int )ImGuiCol.Border ] );
|
||||
var itemSpacing = ImGui.GetStyle().ItemSpacing;
|
||||
var frameHeight = ImGui.GetFrameHeight();
|
||||
var halfFrameHeight = new Vector2( ImGui.GetFrameHeight() / 2, 0 );
|
||||
|
||||
ImGui.PopItemWidth();
|
||||
|
||||
|
|
@ -108,13 +114,17 @@ namespace Penumbra.UI
|
|||
var frameMax = itemMax - new Vector2( halfFrame.X, 0 );
|
||||
|
||||
// Left
|
||||
DrawClippedRect(new(-float.MaxValue , -float.MaxValue ), new(currentLabelMin.X, float.MaxValue ), frameMin, frameMax, borderColor, halfFrame.X);
|
||||
DrawClippedRect( new Vector2( -float.MaxValue, -float.MaxValue ), new Vector2( currentLabelMin.X, float.MaxValue ), frameMin,
|
||||
frameMax, borderColor, halfFrame.X );
|
||||
// Right
|
||||
DrawClippedRect(new(currentLabelMax.X, -float.MaxValue ), new(float.MaxValue , float.MaxValue ), frameMin, frameMax, borderColor, halfFrame.X);
|
||||
DrawClippedRect( new Vector2( currentLabelMax.X, -float.MaxValue ), new Vector2( float.MaxValue, float.MaxValue ), frameMin,
|
||||
frameMax, borderColor, halfFrame.X );
|
||||
// Top
|
||||
DrawClippedRect(new(currentLabelMin.X, -float.MaxValue ), new(currentLabelMax.X, currentLabelMin.Y), frameMin, frameMax, borderColor, halfFrame.X);
|
||||
DrawClippedRect( new Vector2( currentLabelMin.X, -float.MaxValue ), new Vector2( currentLabelMax.X, currentLabelMin.Y ), frameMin,
|
||||
frameMax, borderColor, halfFrame.X );
|
||||
// Bottom
|
||||
DrawClippedRect(new(currentLabelMin.X, currentLabelMax.Y), new(currentLabelMax.X, float.MaxValue ), frameMin, frameMax, borderColor, halfFrame.X);
|
||||
DrawClippedRect( new Vector2( currentLabelMin.X, currentLabelMax.Y ), new Vector2( currentLabelMax.X, float.MaxValue ), frameMin,
|
||||
frameMax, borderColor, halfFrame.X );
|
||||
|
||||
ImGui.PopStyleVar( 2 );
|
||||
ImGui.SetWindowSize( new Vector2( ImGui.GetWindowSize().X + frameHeight, ImGui.GetWindowSize().Y ) );
|
||||
|
|
|
|||
|
|
@ -4,13 +4,16 @@ namespace Penumbra.UI
|
|||
{
|
||||
public static partial class ImGuiCustom
|
||||
{
|
||||
public static bool RenameableCombo(string label, ref int currentItem, ref string newName, string[] items, int numItems)
|
||||
public static bool RenameableCombo( string label, ref int currentItem, out string newName, string[] items, int numItems )
|
||||
{
|
||||
var ret = false;
|
||||
newName = "";
|
||||
var newOption = "";
|
||||
if (ImGui.BeginCombo(label, (numItems > 0) ? items[currentItem] : newOption))
|
||||
if( !ImGui.BeginCombo( label, numItems > 0 ? items[ currentItem ] : newOption ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( var i = 0; i < numItems; ++i )
|
||||
{
|
||||
var isSelected = i == currentItem;
|
||||
|
|
@ -22,9 +25,13 @@ namespace Penumbra.UI
|
|||
ret = true;
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if( isSelected )
|
||||
{
|
||||
ImGui.SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.InputText( $"##{label}_new", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
|
||||
{
|
||||
|
|
@ -33,10 +40,14 @@ namespace Penumbra.UI
|
|||
ret = true;
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if( numItems == 0 )
|
||||
{
|
||||
ImGui.SetItemDefaultFocus();
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,33 +8,42 @@ namespace Penumbra.UI
|
|||
public static bool InputOrText( bool editable, string label, ref string text, uint maxLength )
|
||||
{
|
||||
if( editable )
|
||||
{
|
||||
return ResizingTextInput( label, ref text, maxLength );
|
||||
}
|
||||
|
||||
ImGui.Text( text );
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ResizingTextInput(string label, ref string input, uint maxLength) => ResizingTextInputIntern(label, ref input, maxLength).Item1;
|
||||
public static bool ResizingTextInput( string label, ref string input, uint maxLength ) =>
|
||||
ResizingTextInputIntern( label, ref input, maxLength ).Item1;
|
||||
|
||||
public static bool ResizingTextInput( ref string input, uint maxLength )
|
||||
{
|
||||
var (ret, id) = ResizingTextInputIntern( $"##{input}", ref input, maxLength );
|
||||
if( ret )
|
||||
_textInputWidths.Remove(id);
|
||||
{
|
||||
TextInputWidths.Remove( id );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static (bool, uint) ResizingTextInputIntern( string label, ref string input, uint maxLength )
|
||||
{
|
||||
var id = ImGui.GetID( label );
|
||||
if (!_textInputWidths.TryGetValue(id, out var width))
|
||||
if( !TextInputWidths.TryGetValue( id, out var width ) )
|
||||
{
|
||||
width = ImGui.CalcTextSize( input ).X + 10;
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( width );
|
||||
var ret = ImGui.InputText( label, ref input, maxLength, ImGuiInputTextFlags.EnterReturnsTrue );
|
||||
_textInputWidths[id] = ImGui.CalcTextSize(input).X + 10;
|
||||
TextInputWidths[ id ] = ImGui.CalcTextSize( input ).X + 10;
|
||||
return ( ret, id );
|
||||
}
|
||||
|
||||
private static readonly Dictionary<uint, float> _textInputWidths = new();
|
||||
private static readonly Dictionary< uint, float > TextInputWidths = new();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,5 @@ namespace Penumbra.UI
|
|||
ImGui.Text( text );
|
||||
ImGui.SameLine( pos );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,8 @@ namespace Penumbra.UI
|
|||
private static readonly Vector2 WindowSize = new( Width, Height );
|
||||
private static readonly Vector2 WindowPosOffset = new( Padding + Width, Padding + Height );
|
||||
|
||||
private readonly ImGuiWindowFlags ButtonFlags = ImGuiWindowFlags.AlwaysAutoResize
|
||||
private const ImGuiWindowFlags ButtonFlags =
|
||||
ImGuiWindowFlags.AlwaysAutoResize
|
||||
| ImGuiWindowFlags.NoBackground
|
||||
| ImGuiWindowFlags.NoDecoration
|
||||
| ImGuiWindowFlags.NoMove
|
||||
|
|
@ -36,21 +37,27 @@ namespace Penumbra.UI
|
|||
|
||||
public void Draw()
|
||||
{
|
||||
if( !_condition.Any() && !_base._menu.Visible )
|
||||
if( _condition.Any() || _base._menu.Visible )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ss = ImGui.GetIO().DisplaySize;
|
||||
|
||||
ImGui.SetNextWindowPos( ss - WindowPosOffset, ImGuiCond.Always );
|
||||
|
||||
if( ImGui.Begin(MenuButtonsName, ButtonFlags) )
|
||||
if( !ImGui.Begin( MenuButtonsName, ButtonFlags ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.Button( MenuButtonLabel, WindowSize ) )
|
||||
{
|
||||
_base.FlipVisibility();
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,18 +23,27 @@ namespace Penumbra.UI
|
|||
|
||||
public void Draw()
|
||||
{
|
||||
if( _showDebugBar && ImGui.BeginMainMenuBar() )
|
||||
if( !_showDebugBar || !ImGui.BeginMainMenuBar() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.BeginMenu( MenuLabel ) )
|
||||
{
|
||||
if( ImGui.MenuItem( MenuItemToggle, SlashCommand, _base._menu.Visible ) )
|
||||
{
|
||||
_base.FlipVisibility();
|
||||
}
|
||||
|
||||
if( ImGui.MenuItem( MenuItemRediscover ) )
|
||||
{
|
||||
_base.ReloadMods();
|
||||
}
|
||||
#if DEBUG
|
||||
if( ImGui.MenuItem( MenuItemHide ) )
|
||||
{
|
||||
_showDebugBar = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ImGui.EndMenu();
|
||||
|
|
@ -45,4 +54,3 @@ namespace Penumbra.UI
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ namespace Penumbra.UI
|
|||
public SettingsInterface( Plugin plugin )
|
||||
{
|
||||
_plugin = plugin;
|
||||
_launchButton = new(this);
|
||||
_menuBar = new(this);
|
||||
_menu = new(this);
|
||||
_launchButton = new LaunchButton( this );
|
||||
_menuBar = new MenuBar( this );
|
||||
_menu = new SettingsMenu( this );
|
||||
}
|
||||
|
||||
public void FlipVisibility() => _menu.Visible = !_menu.Visible;
|
||||
|
|
@ -35,14 +35,14 @@ namespace Penumbra.UI
|
|||
|
||||
private void ReloadMods()
|
||||
{
|
||||
_menu._installedTab._selector.ResetModNamesLower();
|
||||
_menu._installedTab._selector.ClearSelection();
|
||||
_menu.InstalledTab.Selector.ResetModNamesLower();
|
||||
_menu.InstalledTab.Selector.ClearSelection();
|
||||
// create the directory if it doesn't exist
|
||||
Directory.CreateDirectory( _plugin.Configuration.CurrentCollection );
|
||||
|
||||
_plugin.ModManager.DiscoverMods( _plugin.Configuration.CurrentCollection );
|
||||
_menu._effectiveTab.RebuildFileList(_plugin.Configuration.ShowAdvanced);
|
||||
_menu._installedTab._selector.ResetModNamesLower();
|
||||
_menu.EffectiveTab.RebuildFileList( _plugin.Configuration.ShowAdvanced );
|
||||
_menu.InstalledTab.Selector.ResetModNamesLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,20 +13,20 @@ namespace Penumbra.UI
|
|||
private static readonly Vector2 MaxSettingsSize = new( 69420, 42069 );
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
public readonly TabSettings _settingsTab;
|
||||
public readonly TabImport _importTab;
|
||||
public readonly TabBrowser _browserTab;
|
||||
public readonly TabInstalled _installedTab;
|
||||
public readonly TabEffective _effectiveTab;
|
||||
private readonly TabSettings _settingsTab;
|
||||
private readonly TabImport _importTab;
|
||||
private readonly TabBrowser _browserTab;
|
||||
public readonly TabInstalled InstalledTab;
|
||||
public readonly TabEffective EffectiveTab;
|
||||
|
||||
public SettingsMenu( SettingsInterface ui )
|
||||
{
|
||||
_base = ui;
|
||||
_settingsTab = new(_base);
|
||||
_importTab = new(_base);
|
||||
_browserTab = new();
|
||||
_installedTab = new(_base);
|
||||
_effectiveTab = new(_base);
|
||||
_settingsTab = new TabSettings( _base );
|
||||
_importTab = new TabImport( _base );
|
||||
_browserTab = new TabBrowser();
|
||||
InstalledTab = new TabInstalled( _base );
|
||||
EffectiveTab = new TabEffective( _base );
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
|
@ -39,7 +39,9 @@ namespace Penumbra.UI
|
|||
public void Draw()
|
||||
{
|
||||
if( !Visible )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints( MinSettingsSize, MaxSettingsSize );
|
||||
#if DEBUG
|
||||
|
|
@ -48,7 +50,9 @@ namespace Penumbra.UI
|
|||
var ret = ImGui.Begin( _base._plugin.Name, ref Visible );
|
||||
#endif
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.BeginTabBar( PenumbraSettingsLabel );
|
||||
|
||||
|
|
@ -58,10 +62,12 @@ namespace Penumbra.UI
|
|||
if( !_importTab.IsImporting() )
|
||||
{
|
||||
_browserTab.Draw();
|
||||
_installedTab.Draw();
|
||||
InstalledTab.Draw();
|
||||
|
||||
if( _base._plugin.Configuration.ShowAdvanced )
|
||||
_effectiveTab.Draw();
|
||||
{
|
||||
EffectiveTab.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTabBar();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ namespace Penumbra.UI
|
|||
{
|
||||
var ret = ImGui.BeginTabItem( "Available Mods" );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.Text( "woah" );
|
||||
ImGui.EndTabItem();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ namespace Penumbra.UI
|
|||
private const float TextSizePadding = 5f;
|
||||
|
||||
private readonly ModManager _mods;
|
||||
private (string, string)[] _fileList = null;
|
||||
private float _maxGamePath = 0f;
|
||||
private (string, string)[] _fileList;
|
||||
private float _maxGamePath;
|
||||
|
||||
public TabEffective( SettingsInterface ui )
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ namespace Penumbra.UI
|
|||
if( advanced )
|
||||
{
|
||||
_fileList = _mods.ResolvedFiles.Select( P => ( P.Value.FullName, P.Key ) ).ToArray();
|
||||
_maxGamePath = ((_fileList.Length > 0) ? _fileList.Max( P => ImGui.CalcTextSize(P.Item2).X ) : 0f) + TextSizePadding;
|
||||
_maxGamePath = ( _fileList.Length > 0 ? _fileList.Max( P => ImGui.CalcTextSize( P.Item2 ).X ) : 0f ) + TextSizePadding;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -49,12 +49,16 @@ namespace Penumbra.UI
|
|||
{
|
||||
var ret = ImGui.BeginTabItem( LabelTab );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.ListBoxHeader( "##effective_files", AutoFillSize ) )
|
||||
{
|
||||
foreach( var file in _fileList )
|
||||
{
|
||||
DrawFileLine( file );
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ namespace Penumbra.UI
|
|||
{
|
||||
private const string LabelTab = "Import Mods";
|
||||
private const string LabelImportButton = "Import TexTools Modpacks";
|
||||
private const string FileTypeFilter = "TexTools TTMP Modpack (*.ttmp2)|*.ttmp*|All files (*.*)|*.*";
|
||||
private const string LabelFileDialog = "Pick one or more modpacks.";
|
||||
private const string LabelFileImportRunning = "Import in progress...";
|
||||
private const string FileTypeFilter = "TexTools TTMP Modpack (*.ttmp2)|*.ttmp*|All files (*.*)|*.*";
|
||||
private const string TooltipModpack1 = "Writing modpack to disk before extracting...";
|
||||
private const string FailedImport = "One or more of your modpacks failed to import.\nPlease submit a bug report.";
|
||||
|
||||
|
|
@ -74,6 +74,7 @@ namespace Penumbra.UI
|
|||
_texToolsImport = null;
|
||||
_base.ReloadMods();
|
||||
}
|
||||
|
||||
_isImportRunning = false;
|
||||
} );
|
||||
}
|
||||
|
|
@ -90,8 +91,11 @@ namespace Penumbra.UI
|
|||
{
|
||||
ImGui.Button( LabelFileImportRunning );
|
||||
|
||||
if( _texToolsImport != null )
|
||||
if( _texToolsImport == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch( _texToolsImport.State )
|
||||
{
|
||||
case ImporterState.None:
|
||||
|
|
@ -113,9 +117,8 @@ namespace Penumbra.UI
|
|||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFailedImportMessage()
|
||||
private static void DrawFailedImportMessage()
|
||||
{
|
||||
ImGui.PushStyleColor( ImGuiCol.Text, ColorRed );
|
||||
ImGui.Text( FailedImport );
|
||||
|
|
@ -126,15 +129,23 @@ namespace Penumbra.UI
|
|||
{
|
||||
var ret = ImGui.BeginTabItem( LabelTab );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !_isImportRunning )
|
||||
{
|
||||
DrawImportButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawImportProgress();
|
||||
}
|
||||
|
||||
if( _hasError )
|
||||
{
|
||||
DrawFailedImportMessage();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@ namespace Penumbra.UI
|
|||
{
|
||||
public partial class SettingsInterface
|
||||
{
|
||||
private partial class TabInstalled
|
||||
private class TabInstalled
|
||||
{
|
||||
private const string LabelTab = "Installed Mods";
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
public readonly Selector _selector;
|
||||
public readonly ModPanel _modPanel;
|
||||
public readonly Selector Selector;
|
||||
public readonly ModPanel ModPanel;
|
||||
|
||||
public TabInstalled( SettingsInterface ui )
|
||||
{
|
||||
_base = ui;
|
||||
_selector = new(_base);
|
||||
_modPanel = new(_base, _selector);
|
||||
Selector = new Selector( _base );
|
||||
ModPanel = new ModPanel( _base, Selector );
|
||||
}
|
||||
|
||||
private void DrawNoModsAvailable()
|
||||
private static void DrawNoModsAvailable()
|
||||
{
|
||||
ImGui.Text( "You don't have any mods :(" );
|
||||
ImGuiCustom.VerticalDistance( 20f );
|
||||
|
|
@ -33,20 +33,22 @@ namespace Penumbra.UI
|
|||
{
|
||||
var ret = ImGui.BeginTabItem( LabelTab );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( _base._plugin.ModManager.Mods != null )
|
||||
{
|
||||
_selector.Draw();
|
||||
Selector.Draw();
|
||||
ImGui.SameLine();
|
||||
_modPanel.Draw();
|
||||
ModPanel.Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawNoModsAvailable();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,15 @@ namespace Penumbra.UI
|
|||
public static void RemoveOrChange( this List< string > list, string newString, int idx )
|
||||
{
|
||||
if( newString?.Length == 0 )
|
||||
{
|
||||
list.RemoveAt( idx );
|
||||
}
|
||||
else
|
||||
{
|
||||
list[ idx ] = newString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SettingsInterface
|
||||
{
|
||||
|
|
@ -33,11 +37,14 @@ namespace Penumbra.UI
|
|||
private const string LabelFileSwapHeader = "##fileSwaps";
|
||||
private const string LabelFileListTab = "Files";
|
||||
private const string LabelFileListHeader = "##fileList";
|
||||
private const string TooltipFilesTab = "Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\nYellow files are restricted to some options.";
|
||||
private const string LabelGroupSelect = "##groupSelect";
|
||||
private const string LabelOptionSelect = "##optionSelect";
|
||||
private const string LabelConfigurationTab = "Configuration";
|
||||
|
||||
private const string TooltipFilesTab =
|
||||
"Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\n" +
|
||||
"Yellow files are restricted to some options.";
|
||||
|
||||
private const float TextSizePadding = 5f;
|
||||
private const float OptionSelectionWidth = 140f;
|
||||
private const float CheckMarkSize = 50f;
|
||||
|
|
@ -56,29 +63,48 @@ namespace Penumbra.UI
|
|||
|
||||
private (string name, bool selected, uint color, string relName)[] _fullFilenameList = null;
|
||||
|
||||
public void SelectGroup(int idx)
|
||||
private readonly Selector _selector;
|
||||
private readonly SettingsInterface _base;
|
||||
|
||||
private void SelectGroup( int idx )
|
||||
{
|
||||
_selectedGroupIndex = idx;
|
||||
if( _selectedGroupIndex >= Meta?.Groups?.Count )
|
||||
{
|
||||
_selectedGroupIndex = 0;
|
||||
}
|
||||
|
||||
if( Meta?.Groups?.Count > 0 )
|
||||
{
|
||||
_selectedGroup = Meta.Groups.ElementAt( _selectedGroupIndex ).Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedGroup = null;
|
||||
}
|
||||
public void SelectGroup() => SelectGroup(_selectedGroupIndex);
|
||||
}
|
||||
|
||||
public void SelectOption(int idx)
|
||||
private void SelectGroup() => SelectGroup( _selectedGroupIndex );
|
||||
|
||||
private void SelectOption( int idx )
|
||||
{
|
||||
_selectedOptionIndex = idx;
|
||||
if( _selectedOptionIndex >= _selectedGroup?.Options.Count )
|
||||
{
|
||||
_selectedOptionIndex = 0;
|
||||
}
|
||||
|
||||
if( _selectedGroup?.Options.Count > 0 )
|
||||
{
|
||||
_selectedOption = ( ( InstallerInfo )_selectedGroup ).Options[ _selectedOptionIndex ];
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedOption = null;
|
||||
}
|
||||
public void SelectOption() => SelectOption(_selectedOptionIndex);
|
||||
}
|
||||
|
||||
private void SelectOption() => SelectOption( _selectedOptionIndex );
|
||||
|
||||
public void ResetState()
|
||||
{
|
||||
|
|
@ -89,9 +115,6 @@ namespace Penumbra.UI
|
|||
SelectOption();
|
||||
}
|
||||
|
||||
|
||||
private readonly Selector _selector;
|
||||
private readonly SettingsInterface _base;
|
||||
public PluginDetails( SettingsInterface ui, Selector s )
|
||||
{
|
||||
_base = ui;
|
||||
|
|
@ -99,23 +122,28 @@ namespace Penumbra.UI
|
|||
ResetState();
|
||||
}
|
||||
|
||||
private ModInfo Mod { get{ return _selector.Mod(); } }
|
||||
private ModMeta Meta { get{ return Mod?.Mod?.Meta; } }
|
||||
private ModInfo Mod => _selector.Mod();
|
||||
private ModMeta Meta => Mod?.Mod?.Meta;
|
||||
|
||||
private void Save()
|
||||
{
|
||||
_base._plugin.ModManager.Mods.Save();
|
||||
_base._plugin.ModManager.CalculateEffectiveFileList();
|
||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||
_base._menu.EffectiveTab.RebuildFileList( _base._plugin.Configuration.ShowAdvanced );
|
||||
}
|
||||
|
||||
private void DrawAboutTab()
|
||||
{
|
||||
if( !_editMode && Meta.Description?.Length == 0 )
|
||||
return;
|
||||
|
||||
if(ImGui.BeginTabItem( LabelAboutTab ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !ImGui.BeginTabItem( LabelAboutTab ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var desc = Meta.Description;
|
||||
var flags = _editMode
|
||||
? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine
|
||||
|
|
@ -128,9 +156,12 @@ namespace Penumbra.UI
|
|||
Meta.Description = desc;
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipAboutEdit );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextWrapped( desc );
|
||||
|
|
@ -138,12 +169,15 @@ namespace Penumbra.UI
|
|||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawChangedItemsTab()
|
||||
{
|
||||
if (!_editMode && Meta.ChangedItems?.Count == 0)
|
||||
if( !_editMode && ( Meta.ChangedItems?.Count ?? 0 ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Meta.ChangedItems ??= new List< string >();
|
||||
|
||||
var flags = _editMode
|
||||
? ImGuiInputTextFlags.EnterReturnsTrue
|
||||
|
|
@ -154,8 +188,8 @@ namespace Penumbra.UI
|
|||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.ListBoxHeader( LabelChangedItemsHeader, AutoFillSize ) )
|
||||
{
|
||||
if (_changedItemsList == null)
|
||||
_changedItemsList = Meta.ChangedItems.Select( (I, index) => ($"{LabelChangedItemIdx}{index}", I) ).ToArray();
|
||||
_changedItemsList ??= Meta.ChangedItems.Select( ( I, index ) => ( $"{LabelChangedItemIdx}{index}", I ) ).ToArray();
|
||||
|
||||
for( var i = 0; i < Meta.ChangedItems.Count; ++i )
|
||||
{
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
|
|
@ -165,6 +199,7 @@ namespace Penumbra.UI
|
|||
_selector.SaveCurrentMod();
|
||||
}
|
||||
}
|
||||
|
||||
var newItem = "";
|
||||
if( _editMode )
|
||||
{
|
||||
|
|
@ -174,27 +209,42 @@ namespace Penumbra.UI
|
|||
if( newItem.Length > 0 )
|
||||
{
|
||||
if( Meta.ChangedItems == null )
|
||||
Meta.ChangedItems = new(){ newItem };
|
||||
{
|
||||
Meta.ChangedItems = new List< string >() { newItem };
|
||||
}
|
||||
else
|
||||
{
|
||||
Meta.ChangedItems.Add( newItem );
|
||||
}
|
||||
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
_changedItemsList = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawConflictTab()
|
||||
{
|
||||
if( Mod.Mod.FileConflicts.Any() )
|
||||
if( !Mod.Mod.FileConflicts.Any() )
|
||||
{
|
||||
if( ImGui.BeginTabItem( LabelConflictsTab ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if( !ImGui.BeginTabItem( LabelConflictsTab ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.ListBoxHeader( LabelConflictsHeader, AutoFillSize ) )
|
||||
{
|
||||
|
|
@ -202,29 +252,36 @@ namespace Penumbra.UI
|
|||
{
|
||||
var mod = kv.Key;
|
||||
if( ImGui.Selectable( mod ) )
|
||||
{
|
||||
_selector.SelectModByName( mod );
|
||||
}
|
||||
|
||||
ImGui.Indent( 15 );
|
||||
foreach( var file in kv.Value )
|
||||
{
|
||||
ImGui.Selectable( file );
|
||||
}
|
||||
|
||||
ImGui.Unindent( 15 );
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFileSwapTab()
|
||||
{
|
||||
if( Meta.FileSwaps.Any() )
|
||||
if( !Meta.FileSwaps.Any() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.BeginTabItem( LabelFileSwapTab ) )
|
||||
{
|
||||
if (_fileSwapOffset == null)
|
||||
_fileSwapOffset = Meta.FileSwaps.Max( P => ImGui.CalcTextSize(P.Key).X) + TextSizePadding;
|
||||
_fileSwapOffset ??= Meta.FileSwaps.Max( P => ImGui.CalcTextSize( P.Key ).X ) + TextSizePadding;
|
||||
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.ListBoxHeader( LabelFileSwapHeader, AutoFillSize ) )
|
||||
{
|
||||
|
|
@ -236,39 +293,58 @@ namespace Penumbra.UI
|
|||
ImGui.SameLine();
|
||||
ImGui.Selectable( file.Value );
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
_fileSwapOffset = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFilenameList()
|
||||
{
|
||||
if (_fullFilenameList == null)
|
||||
if( _fullFilenameList != null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var len = Mod.Mod.ModBasePath.FullName.Length;
|
||||
_fullFilenameList = Mod.Mod.ModFiles.Select( F => ( F.FullName, false, ColorGreen, "" ) ).ToArray();
|
||||
|
||||
if( Meta.Groups?.Count == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( var i = 0; i < Mod.Mod.ModFiles.Count; ++i )
|
||||
{
|
||||
_fullFilenameList[ i ].relName = _fullFilenameList[ i ].name.Substring( len ).TrimStart( '\\' );
|
||||
foreach (var Group in Meta.Groups.Values)
|
||||
if( Meta.Groups == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach( var group in Meta.Groups.Values )
|
||||
{
|
||||
var inAll = true;
|
||||
foreach (var Option in Group.Options)
|
||||
foreach( var option in group.Options )
|
||||
{
|
||||
if( option.OptionFiles.ContainsKey( _fullFilenameList[ i ].relName ) )
|
||||
{
|
||||
if (Option.OptionFiles.ContainsKey(_fullFilenameList[i].relName))
|
||||
_fullFilenameList[ i ].color = ColorYellow;
|
||||
}
|
||||
else
|
||||
{
|
||||
inAll = false;
|
||||
}
|
||||
if (inAll && Group.SelectionType == SelectType.Single)
|
||||
}
|
||||
|
||||
if( inAll && group.SelectionType == SelectType.Single )
|
||||
{
|
||||
_fullFilenameList[ i ].color = ColorGreen;
|
||||
}
|
||||
}
|
||||
|
|
@ -277,10 +353,15 @@ namespace Penumbra.UI
|
|||
|
||||
private void DrawFileListTab()
|
||||
{
|
||||
if( ImGui.BeginTabItem( LabelFileListTab ) )
|
||||
if( !ImGui.BeginTabItem( LabelFileListTab ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipFilesTab );
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize ) )
|
||||
|
|
@ -292,73 +373,86 @@ namespace Penumbra.UI
|
|||
ImGui.Selectable( file.name );
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
}
|
||||
else
|
||||
{
|
||||
_fullFilenameList = null;
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
private void HandleSelectedFilesButton( bool remove )
|
||||
{
|
||||
if( _selectedOption == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var option = ( Option )_selectedOption;
|
||||
|
||||
var gamePaths = _currentGamePaths.Split( ';' );
|
||||
if( gamePaths.Length == 0 || gamePaths[ 0 ].Length == 0 )
|
||||
{
|
||||
return;
|
||||
|
||||
int? defaultIndex = null;
|
||||
for (var i = 0; i < gamePaths.Length; ++i)
|
||||
{
|
||||
if (gamePaths[i] == TextDefaultGamePath )
|
||||
{
|
||||
defaultIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var baseLength = Mod.Mod.ModBasePath.FullName.Length;
|
||||
var defaultIndex = gamePaths.IndexOf( p => p == TextDefaultGamePath );
|
||||
var changed = false;
|
||||
for( var i = 0; i < Mod.Mod.ModFiles.Count; ++i )
|
||||
{
|
||||
if( !_fullFilenameList[ i ].selected )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var fileName = _fullFilenameList[ i ].relName;
|
||||
if (defaultIndex != null)
|
||||
if( defaultIndex >= 0 )
|
||||
{
|
||||
gamePaths[ ( int )defaultIndex ] = fileName.Replace( '\\', '/' );
|
||||
}
|
||||
|
||||
if( remove && option.OptionFiles.TryGetValue( fileName, out var setPaths ) )
|
||||
{
|
||||
if( setPaths.RemoveWhere( P => gamePaths.Contains( P ) ) > 0 )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if( setPaths.Count == 0 && option.OptionFiles.Remove( fileName ) )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(var gamePath in gamePaths)
|
||||
changed |= option.AddFile(fileName, gamePath);
|
||||
changed = gamePaths.Aggregate( changed, ( current, gamePath ) => current | option.AddFile( fileName, gamePath ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( changed )
|
||||
{
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAddToGroupButton()
|
||||
{
|
||||
if( ImGui.Button( ButtonAddToGroup ) )
|
||||
{
|
||||
HandleSelectedFilesButton( false );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawRemoveFromGroupButton()
|
||||
{
|
||||
if( ImGui.Button( ButtonRemoveFromGroup ) )
|
||||
{
|
||||
HandleSelectedFilesButton( true );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGamePathInput()
|
||||
{
|
||||
|
|
@ -367,21 +461,34 @@ namespace Penumbra.UI
|
|||
ImGui.SetNextItemWidth( -1 );
|
||||
ImGui.InputText( LabelGamePathsEditBox, ref _currentGamePaths, 128 );
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipGamePathsEdit );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGroupRow()
|
||||
{
|
||||
if( _selectedGroup == null )
|
||||
{
|
||||
SelectGroup();
|
||||
}
|
||||
|
||||
if( _selectedOption == null )
|
||||
{
|
||||
SelectOption();
|
||||
}
|
||||
|
||||
if( !DrawEditGroupSelector() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if( !DrawEditOptionSelector() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
DrawAddToGroupButton();
|
||||
ImGui.SameLine();
|
||||
|
|
@ -396,7 +503,10 @@ namespace Penumbra.UI
|
|||
{
|
||||
var loc = _fullFilenameList[ idx ].color;
|
||||
if( loc == colorNormal )
|
||||
{
|
||||
loc = colorReplace;
|
||||
}
|
||||
|
||||
ImGui.PushStyleColor( ImGuiCol.Text, loc );
|
||||
ImGui.Selectable( _fullFilenameList[ idx ].name, ref _fullFilenameList[ idx ].selected );
|
||||
ImGui.PopStyleColor();
|
||||
|
|
@ -417,48 +527,54 @@ namespace Penumbra.UI
|
|||
ImGui.Indent( indent );
|
||||
foreach( var gamePath in gamePaths )
|
||||
{
|
||||
string tmp = gamePath;
|
||||
if (ImGui.InputText($"##{fileName}_{gamePath}", ref tmp, 128, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
if (tmp != gamePath)
|
||||
var tmp = gamePath;
|
||||
if( ImGui.InputText( $"##{fileName}_{gamePath}", ref tmp, 128, ImGuiInputTextFlags.EnterReturnsTrue )
|
||||
&& tmp != gamePath )
|
||||
{
|
||||
gamePaths.Remove( gamePath );
|
||||
if( tmp.Length > 0 )
|
||||
{
|
||||
gamePaths.Add( tmp );
|
||||
}
|
||||
|
||||
_selector.SaveCurrentMod();
|
||||
_selector.ReloadCurrentMod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Unindent( indent );
|
||||
}
|
||||
else
|
||||
{
|
||||
Selectable( ColorYellow, ColorRed );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMultiSelectorCheckBox( InstallerInfo group, int idx, int flag, string label )
|
||||
{
|
||||
var opt = group.Options[ idx ];
|
||||
var enabled = ( flag & ( 1 << idx ) ) != 0;
|
||||
var oldEnabled = enabled;
|
||||
if (ImGui.Checkbox(label, ref enabled))
|
||||
if( ImGui.Checkbox( label, ref enabled ) && oldEnabled != enabled )
|
||||
{
|
||||
if (oldEnabled != enabled)
|
||||
{
|
||||
Mod.Conf[group.GroupName] ^= (1 << idx);
|
||||
Mod.Conf[ group.GroupName ] ^= 1 << idx;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMultiSelector( InstallerInfo group )
|
||||
{
|
||||
if( group.Options.Count == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiCustom.BeginFramedGroup( group.GroupName );
|
||||
for( var i = 0; i < group.Options.Count; ++i )
|
||||
DrawMultiSelectorCheckBox(group, i, Mod.Conf[group.GroupName], $"{group.Options[i].OptionName}##{group.GroupName}");
|
||||
{
|
||||
DrawMultiSelectorCheckBox( group, i, Mod.Conf[ group.GroupName ],
|
||||
$"{group.Options[ i ].OptionName}##{group.GroupName}" );
|
||||
}
|
||||
|
||||
ImGuiCustom.EndFramedGroup();
|
||||
}
|
||||
|
|
@ -466,9 +582,13 @@ namespace Penumbra.UI
|
|||
private void DrawSingleSelector( InstallerInfo group )
|
||||
{
|
||||
if( group.Options.Count < 2 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var code = Mod.Conf[ group.GroupName ];
|
||||
if( ImGui.Combo( group.GroupName, ref code, group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count ) )
|
||||
if( ImGui.Combo( group.GroupName, ref code
|
||||
, group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count ) )
|
||||
{
|
||||
Mod.Conf[ group.GroupName ] = code;
|
||||
Save();
|
||||
|
|
@ -478,23 +598,36 @@ namespace Penumbra.UI
|
|||
private void DrawGroupSelectors()
|
||||
{
|
||||
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Single ) )
|
||||
{
|
||||
DrawSingleSelector( g );
|
||||
}
|
||||
|
||||
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Multi ) )
|
||||
{
|
||||
DrawMultiSelector( g );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void DrawConfigurationTab()
|
||||
{
|
||||
if( !_editMode && !Meta.HasGroupWithConfig )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ImGui.BeginTabItem( LabelConfigurationTab ) )
|
||||
{
|
||||
if( _editMode )
|
||||
{
|
||||
DrawGroupSelectorsEdit();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawGroupSelectors();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
|
|
@ -508,9 +641,14 @@ namespace Penumbra.UI
|
|||
DrawChangedItemsTab();
|
||||
DrawConfigurationTab();
|
||||
if( _editMode )
|
||||
{
|
||||
DrawFileListTabEdit();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawFileListTab();
|
||||
}
|
||||
|
||||
DrawFileSwapTab();
|
||||
DrawConflictTab();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
|
@ -15,15 +16,20 @@ namespace Penumbra.UI
|
|||
private const string LabelNewMultiGroup = "New Multi Group";
|
||||
private const string LabelGamePathsEdit = "Game Paths";
|
||||
private const string LabelGamePathsEditBox = "##gamePathsEdit";
|
||||
private const string TextNoOptionAvailable = "[Not Available]";
|
||||
private const string ButtonAddToGroup = "Add to Group";
|
||||
private const string ButtonRemoveFromGroup = "Remove from Group";
|
||||
private const string TooltipAboutEdit = "Use Ctrl+Enter for newlines.";
|
||||
|
||||
private const string TextNoOptionAvailable = "[Not Available]";
|
||||
private const string TextDefaultGamePath = "default";
|
||||
private const char GamePathsSeparator = ';';
|
||||
private static readonly string TooltipFilesTabEdit = $"{TooltipFilesTab}\nRed Files are replaced in another group or a different option in this group, but not contained in the current option.";
|
||||
private static readonly string TooltipGamePathsEdit = $"Enter all game paths to add or remove, separated by '{GamePathsSeparator}'.\nUse '{TextDefaultGamePath}' to add the original file path.";
|
||||
|
||||
private static readonly string TooltipFilesTabEdit =
|
||||
$"{TooltipFilesTab}\n" +
|
||||
$"Red Files are replaced in another group or a different option in this group, but not contained in the current option.";
|
||||
|
||||
private static readonly string TooltipGamePathsEdit =
|
||||
$"Enter all game paths to add or remove, separated by '{GamePathsSeparator}'.\n" +
|
||||
$"Use '{TextDefaultGamePath}' to add the original file path.";
|
||||
|
||||
private const float MultiEditBoxWidth = 300f;
|
||||
|
||||
|
|
@ -35,14 +41,15 @@ namespace Penumbra.UI
|
|||
ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, TextNoOptionAvailable, 1 );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex, Meta.Groups.Values.Select( G => G.GroupName ).ToArray(), Meta.Groups.Count))
|
||||
|
||||
if( ImGui.Combo( LabelGroupSelect, ref _selectedGroupIndex
|
||||
, Meta.Groups.Values.Select( G => G.GroupName ).ToArray()
|
||||
, Meta.Groups.Count ) )
|
||||
{
|
||||
SelectGroup();
|
||||
SelectOption( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -57,8 +64,12 @@ namespace Penumbra.UI
|
|||
}
|
||||
|
||||
var group = ( InstallerInfo )_selectedGroup;
|
||||
if (ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, group.Options.Select(O => O.OptionName).ToArray(), group.Options.Count))
|
||||
if( ImGui.Combo( LabelOptionSelect, ref _selectedOptionIndex, group.Options.Select( O => O.OptionName ).ToArray(),
|
||||
group.Options.Count ) )
|
||||
{
|
||||
SelectOption();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -68,12 +79,18 @@ namespace Penumbra.UI
|
|||
{
|
||||
UpdateFilenameList();
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( _editMode ? TooltipFilesTabEdit : TooltipFilesTab );
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( -1 );
|
||||
if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize - new Vector2( 0, 1.5f * ImGui.GetTextLineHeight() ) ) )
|
||||
{
|
||||
for( var i = 0; i < Mod.Mod.ModFiles.Count; ++i )
|
||||
{
|
||||
DrawFileAndGamePaths( i );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.ListBoxFooter();
|
||||
|
||||
|
|
@ -81,8 +98,10 @@ namespace Penumbra.UI
|
|||
ImGui.EndTabItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
_fullFilenameList = null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawMultiSelectorEditBegin( InstallerInfo group )
|
||||
{
|
||||
|
|
@ -95,27 +114,30 @@ namespace Penumbra.UI
|
|||
Mod.Conf.Remove( group.GroupName );
|
||||
if( groupName.Length > 0 )
|
||||
{
|
||||
Meta.Groups[groupName] = new(){ GroupName = groupName, SelectionType = SelectType.Multi, Options = group.Options };
|
||||
Meta.Groups[ groupName ] = new InstallerInfo()
|
||||
{ GroupName = groupName, SelectionType = SelectType.Multi, Options = group.Options };
|
||||
Mod.Conf[ groupName ] = oldConf;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawMultiSelectorEditAdd( InstallerInfo group, float nameBoxStart )
|
||||
{
|
||||
var newOption = "";
|
||||
ImGui.SetCursorPosX( nameBoxStart );
|
||||
ImGui.SetNextItemWidth( MultiEditBoxWidth );
|
||||
if (ImGui.InputText($"##new_{group.GroupName}_l", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
if( ImGui.InputText( $"##new_{group.GroupName}_l", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue )
|
||||
&& newOption.Length != 0 )
|
||||
{
|
||||
if (newOption.Length != 0)
|
||||
{
|
||||
group.Options.Add(new(){ OptionName = newOption, OptionDesc = "", OptionFiles = new() });
|
||||
group.Options.Add( new Option()
|
||||
{ OptionName = newOption, OptionDesc = "", OptionFiles = new Dictionary< string, HashSet< string > >() } );
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMultiSelectorEdit( InstallerInfo group )
|
||||
{
|
||||
|
|
@ -134,7 +156,9 @@ namespace Penumbra.UI
|
|||
var newName = opt.OptionName;
|
||||
|
||||
if( nameBoxStart == CheckMarkSize )
|
||||
{
|
||||
nameBoxStart = ImGui.GetCursorPosX();
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth( MultiEditBoxWidth );
|
||||
if( ImGui.InputText( $"{label}_l", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
|
||||
|
|
@ -148,7 +172,8 @@ namespace Penumbra.UI
|
|||
}
|
||||
else if( newName != opt.OptionName )
|
||||
{
|
||||
group.Options[i] = new(){ OptionName = newName, OptionDesc = opt.OptionDesc, OptionFiles = opt.OptionFiles };
|
||||
group.Options[ i ] = new Option()
|
||||
{ OptionName = newName, OptionDesc = opt.OptionDesc, OptionFiles = opt.OptionFiles };
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
}
|
||||
|
|
@ -177,13 +202,17 @@ namespace Penumbra.UI
|
|||
Meta.Groups.Remove( group.GroupName );
|
||||
Mod.Conf.Remove( group.GroupName );
|
||||
}
|
||||
|
||||
if( groupName.Length > 0 )
|
||||
{
|
||||
Meta.Groups.Add(groupName, new InstallerInfo(){ GroupName = groupName, Options = group.Options, SelectionType = SelectType.Single } );
|
||||
Meta.Groups.Add( groupName,
|
||||
new InstallerInfo() { GroupName = groupName, Options = group.Options, SelectionType = SelectType.Single } );
|
||||
Mod.Conf[ groupName ] = oldConf;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -192,8 +221,8 @@ namespace Penumbra.UI
|
|||
var code = Mod.Conf[ group.GroupName ];
|
||||
var selectionChanged = false;
|
||||
var modChanged = false;
|
||||
var newName = "";
|
||||
if (ImGuiCustom.RenameableCombo($"##{group.GroupName}", ref code, ref newName, group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count))
|
||||
if( ImGuiCustom.RenameableCombo( $"##{group.GroupName}", ref code, out var newName,
|
||||
group.Options.Select( x => x.OptionName ).ToArray(), group.Options.Count ) )
|
||||
{
|
||||
if( code == group.Options.Count )
|
||||
{
|
||||
|
|
@ -202,7 +231,8 @@ namespace Penumbra.UI
|
|||
selectionChanged = true;
|
||||
modChanged = true;
|
||||
Mod.Conf[ group.GroupName ] = code;
|
||||
group.Options.Add(new(){ OptionName = newName, OptionDesc = "", OptionFiles = new()});
|
||||
group.Options.Add( new Option()
|
||||
{ OptionName = newName, OptionDesc = "", OptionFiles = new Dictionary< string, HashSet< string > >() } );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -212,13 +242,20 @@ namespace Penumbra.UI
|
|||
modChanged = true;
|
||||
group.Options.RemoveAt( code );
|
||||
if( code >= group.Options.Count )
|
||||
{
|
||||
code = 0;
|
||||
}
|
||||
}
|
||||
else if( newName != group.Options[ code ].OptionName )
|
||||
{
|
||||
modChanged = true;
|
||||
group.Options[code] = new Option(){ OptionName = newName, OptionDesc = group.Options[code].OptionDesc, OptionFiles = group.Options[code].OptionFiles};
|
||||
group.Options[ code ] = new Option()
|
||||
{
|
||||
OptionName = newName, OptionDesc = group.Options[ code ].OptionDesc,
|
||||
OptionFiles = group.Options[ code ].OptionFiles
|
||||
};
|
||||
}
|
||||
|
||||
if( Mod.Conf[ group.GroupName ] != code )
|
||||
{
|
||||
selectionChanged = true;
|
||||
|
|
@ -232,30 +269,36 @@ namespace Penumbra.UI
|
|||
modChanged |= DrawSingleSelectorEditGroup( group );
|
||||
|
||||
if( modChanged )
|
||||
{
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
|
||||
if( selectionChanged )
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
return labelEditPos;
|
||||
}
|
||||
|
||||
private void AddNewGroup( string newGroup, SelectType selectType )
|
||||
{
|
||||
if (!Meta.Groups.ContainsKey(newGroup) && newGroup.Length > 0)
|
||||
if( Meta.Groups.ContainsKey( newGroup ) || newGroup.Length <= 0 )
|
||||
{
|
||||
Meta.Groups[newGroup] = new ()
|
||||
return;
|
||||
}
|
||||
|
||||
Meta.Groups[ newGroup ] = new InstallerInfo()
|
||||
{
|
||||
GroupName = newGroup,
|
||||
SelectionType = selectType,
|
||||
Options = new()
|
||||
Options = new List< Option >()
|
||||
};
|
||||
|
||||
Mod.Conf[ newGroup ] = 0;
|
||||
_selector.SaveCurrentMod();
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAddSingleGroupField( float labelEditPos )
|
||||
{
|
||||
|
|
@ -265,15 +308,19 @@ namespace Penumbra.UI
|
|||
ImGui.SetCursorPosX( CheckMarkSize );
|
||||
ImGui.SetNextItemWidth( MultiEditBoxWidth );
|
||||
if( ImGui.InputText( LabelNewSingleGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
|
||||
{
|
||||
AddNewGroup( newGroup, SelectType.Single );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGuiCustom.RightJustifiedLabel( labelEditPos, LabelNewSingleGroup );
|
||||
if( ImGui.InputText( LabelNewSingleGroupEdit, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
|
||||
{
|
||||
AddNewGroup( newGroup, SelectType.Single );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAddMultiGroupField()
|
||||
{
|
||||
|
|
@ -281,18 +328,26 @@ namespace Penumbra.UI
|
|||
ImGui.SetCursorPosX( CheckMarkSize );
|
||||
ImGui.SetNextItemWidth( MultiEditBoxWidth );
|
||||
if( ImGui.InputText( LabelNewMultiGroup, ref newGroup, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
|
||||
{
|
||||
AddNewGroup( newGroup, SelectType.Multi );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGroupSelectorsEdit()
|
||||
{
|
||||
var labelEditPos = CheckMarkSize;
|
||||
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Single ) )
|
||||
{
|
||||
labelEditPos = DrawSingleSelectorEdit( g );
|
||||
}
|
||||
|
||||
DrawAddSingleGroupField( labelEditPos );
|
||||
|
||||
foreach( var g in Meta.Groups.Values.Where( g => g.SelectionType == SelectType.Multi ) )
|
||||
{
|
||||
DrawMultiSelectorEdit( g );
|
||||
}
|
||||
|
||||
DrawAddMultiGroupField();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,26 +16,29 @@ namespace Penumbra.UI
|
|||
private const string LabelEditVersion = "##editVersion";
|
||||
private const string LabelEditAuthor = "##editAuthor";
|
||||
private const string LabelEditWebsite = "##editWebsite";
|
||||
private const string ButtonOpenWebsite = "Open Website";
|
||||
private const string LabelModEnabled = "Enabled";
|
||||
private const string LabelEditingEnabled = "Enable Editing";
|
||||
private const string ButtonOpenWebsite = "Open Website";
|
||||
private const string ButtonOpenModFolder = "Open Mod Folder";
|
||||
private const string TooltipOpenModFolder = "Open the directory containing this mod in your default file explorer.";
|
||||
private const string ButtonEditJson = "Edit JSON";
|
||||
private const string TooltipEditJson = "Open the JSON configuration file in your default application for .json.";
|
||||
private const string ButtonReloadJson = "Reload JSON";
|
||||
private const string TooltipReloadJson = "Reload the configuration of all mods.";
|
||||
private const string ButtonDeduplicate = "Deduplicate";
|
||||
private const string TooltipDeduplicate = "Try to find identical files and remove duplicate occurences to reduce the mods disk size. Introduces an invisible single-option Group \"Duplicates\".";
|
||||
private const string TooltipOpenModFolder = "Open the directory containing this mod in your default file explorer.";
|
||||
private const string TooltipEditJson = "Open the JSON configuration file in your default application for .json.";
|
||||
private const string TooltipReloadJson = "Reload the configuration of all mods.";
|
||||
|
||||
private const string TooltipDeduplicate =
|
||||
"Try to find identical files and remove duplicate occurences to reduce the mods disk size.\n" +
|
||||
"Introduces an invisible single-option Group \"Duplicates\".";
|
||||
|
||||
private const float HeaderLineDistance = 10f;
|
||||
private static readonly Vector4 GreyColor = new( 1f, 1f, 1f, 0.66f );
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
private readonly Selector _selector;
|
||||
public readonly PluginDetails _details;
|
||||
public readonly PluginDetails Details;
|
||||
|
||||
private bool _editMode = false;
|
||||
private bool _editMode;
|
||||
private string _currentWebsite;
|
||||
private bool _validWebsite;
|
||||
|
||||
|
|
@ -43,12 +46,12 @@ namespace Penumbra.UI
|
|||
{
|
||||
_base = ui;
|
||||
_selector = s;
|
||||
_details = new(_base, _selector);
|
||||
Details = new PluginDetails( _base, _selector );
|
||||
_currentWebsite = Meta?.Website;
|
||||
}
|
||||
|
||||
private ModInfo Mod { get{ return _selector.Mod(); } }
|
||||
private ModMeta Meta { get{ return Mod?.Mod.Meta; } }
|
||||
private ModInfo Mod => _selector.Mod();
|
||||
private ModMeta Meta => Mod?.Mod.Meta;
|
||||
|
||||
private void DrawName()
|
||||
{
|
||||
|
|
@ -102,6 +105,7 @@ namespace Penumbra.UI
|
|||
Meta.Author = author.Length > 0 ? author : null;
|
||||
_selector.SaveCurrentMod();
|
||||
}
|
||||
|
||||
ImGui.EndGroup();
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +132,7 @@ namespace Penumbra.UI
|
|||
_validWebsite = Uri.TryCreate( Meta.Website, UriKind.Absolute, out var uriResult )
|
||||
&& ( uriResult.Scheme == Uri.UriSchemeHttps || uriResult.Scheme == Uri.UriSchemeHttp );
|
||||
}
|
||||
|
||||
if( _validWebsite )
|
||||
{
|
||||
if( ImGui.SmallButton( ButtonOpenWebsite ) )
|
||||
|
|
@ -147,8 +152,10 @@ namespace Penumbra.UI
|
|||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( Meta.Website );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextColored( GreyColor, "from" );
|
||||
|
|
@ -156,6 +163,7 @@ namespace Penumbra.UI
|
|||
ImGui.Text( Meta.Website );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndGroup();
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +186,7 @@ namespace Penumbra.UI
|
|||
Mod.Enabled = enabled;
|
||||
_base._plugin.ModManager.Mods.Save();
|
||||
_base._plugin.ModManager.CalculateEffectiveFileList();
|
||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||
_base._menu.EffectiveTab.RebuildFileList( _base._plugin.Configuration.ShowAdvanced );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,9 +201,12 @@ namespace Penumbra.UI
|
|||
{
|
||||
Process.Start( Mod.Mod.ModBasePath.FullName );
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipOpenModFolder );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawEditJsonButton()
|
||||
{
|
||||
|
|
@ -203,9 +214,12 @@ namespace Penumbra.UI
|
|||
{
|
||||
Process.Start( _selector.SaveCurrentMod() );
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipEditJson );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawReloadJsonButton()
|
||||
{
|
||||
|
|
@ -213,9 +227,12 @@ namespace Penumbra.UI
|
|||
{
|
||||
_selector.ReloadCurrentMod();
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipReloadJson );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDeduplicateButton()
|
||||
{
|
||||
|
|
@ -225,11 +242,14 @@ namespace Penumbra.UI
|
|||
_selector.SaveCurrentMod();
|
||||
Mod.Mod.RefreshModFiles();
|
||||
_base._plugin.ModManager.CalculateEffectiveFileList();
|
||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||
_base._menu.EffectiveTab.RebuildFileList( _base._plugin.Configuration.ShowAdvanced );
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipDeduplicate );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawEditLine()
|
||||
{
|
||||
|
|
@ -244,13 +264,18 @@ namespace Penumbra.UI
|
|||
|
||||
public void Draw()
|
||||
{
|
||||
if( Mod != null )
|
||||
if( Mod == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var ret = ImGui.BeginChild( LabelModPanel, AutoFillSize, true );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawHeaderLine();
|
||||
|
||||
|
|
@ -266,9 +291,11 @@ namespace Penumbra.UI
|
|||
|
||||
// Next line, if editable.
|
||||
if( _editMode )
|
||||
{
|
||||
DrawEditLine();
|
||||
}
|
||||
|
||||
_details.Draw(_editMode);
|
||||
Details.Draw( _editMode );
|
||||
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
|
@ -280,4 +307,3 @@ namespace Penumbra.UI
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,13 +32,13 @@ namespace Penumbra.UI
|
|||
private static readonly string ArrowDownString = FontAwesomeIcon.ArrowDown.ToIconString();
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
private ModCollection Mods{ get{ return _base._plugin.ModManager.Mods; } }
|
||||
private ModCollection Mods => _base._plugin.ModManager.Mods;
|
||||
|
||||
private ModInfo _mod = null;
|
||||
private int _index = 0;
|
||||
private int? _deleteIndex = null;
|
||||
private ModInfo _mod;
|
||||
private int _index;
|
||||
private int? _deleteIndex;
|
||||
private string _modFilter = "";
|
||||
private string[] _modNamesLower = null;
|
||||
private string[] _modNamesLower;
|
||||
|
||||
|
||||
public Selector( SettingsInterface ui )
|
||||
|
|
@ -94,10 +94,12 @@ namespace Penumbra.UI
|
|||
ImGui.PopFont();
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipDelete );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawModAddButton()
|
||||
private static void DrawModAddButton()
|
||||
{
|
||||
ImGui.PushFont( UiBuilder.IconFont );
|
||||
|
||||
|
|
@ -109,20 +111,25 @@ namespace Penumbra.UI
|
|||
ImGui.PopFont();
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipAdd );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawModsSelectorFilter()
|
||||
{
|
||||
ImGui.SetNextItemWidth( SelectorButtonSizes.X * 4 );
|
||||
string tmp = _modFilter;
|
||||
var tmp = _modFilter;
|
||||
if( ImGui.InputText( LabelModFilter, ref tmp, 256 ) )
|
||||
{
|
||||
_modFilter = tmp.ToLowerInvariant();
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
{
|
||||
ImGui.SetTooltip( TooltipModFilter );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawModsSelectorButtons()
|
||||
{
|
||||
|
|
@ -141,16 +148,20 @@ namespace Penumbra.UI
|
|||
ImGui.PopStyleVar( 3 );
|
||||
}
|
||||
|
||||
void DrawDeleteModal()
|
||||
private void DrawDeleteModal()
|
||||
{
|
||||
if( _deleteIndex == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.OpenPopup( DialogDeleteMod );
|
||||
|
||||
var ret = ImGui.BeginPopupModal( DialogDeleteMod );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( _mod?.Mod == null )
|
||||
{
|
||||
|
|
@ -186,7 +197,9 @@ namespace Penumbra.UI
|
|||
public void Draw()
|
||||
{
|
||||
if( Mods == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Selector pane
|
||||
ImGui.BeginGroup();
|
||||
|
|
@ -202,7 +215,9 @@ namespace Penumbra.UI
|
|||
var settings = Mods.ModSettings[ modIndex ];
|
||||
var modName = settings.Mod.Meta.Name;
|
||||
if( _modFilter.Length > 0 && !_modNamesLower[ modIndex ].Contains( _modFilter ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var changedColour = false;
|
||||
if( !settings.Enabled )
|
||||
|
|
@ -226,11 +241,15 @@ namespace Penumbra.UI
|
|||
#endif
|
||||
|
||||
if( changedColour )
|
||||
{
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
if( selected )
|
||||
{
|
||||
SetSelection( modIndex, settings );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
|
||||
|
|
@ -246,20 +265,30 @@ namespace Penumbra.UI
|
|||
{
|
||||
_mod = info;
|
||||
if( idx != _index )
|
||||
_base._menu._installedTab._modPanel._details.ResetState();
|
||||
{
|
||||
_base._menu.InstalledTab.ModPanel.Details.ResetState();
|
||||
}
|
||||
|
||||
_index = idx;
|
||||
_deleteIndex = null;
|
||||
}
|
||||
|
||||
public void SetSelection(int idx)
|
||||
private void SetSelection( int idx )
|
||||
{
|
||||
if( idx >= ( Mods?.ModSettings?.Count ?? 0 ) )
|
||||
{
|
||||
idx = -1;
|
||||
}
|
||||
|
||||
if( idx < 0 )
|
||||
{
|
||||
SetSelection( 0, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSelection( idx, Mods.ModSettings[ idx ] );
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSelection() => SetSelection( -1 );
|
||||
|
||||
|
|
@ -270,7 +299,9 @@ namespace Penumbra.UI
|
|||
var mod = Mods.ModSettings[ modIndex ];
|
||||
|
||||
if( mod.Mod.Meta.Name != name )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SetSelection( modIndex, mod );
|
||||
return;
|
||||
|
|
@ -278,11 +309,7 @@ namespace Penumbra.UI
|
|||
}
|
||||
|
||||
private string GetCurrentModMetaFile()
|
||||
{
|
||||
if( _mod == null )
|
||||
return "";
|
||||
return Path.Combine( _mod.Mod.ModBasePath.FullName, "meta.json" );
|
||||
}
|
||||
=> _mod == null ? "" : Path.Combine( _mod.Mod.ModBasePath.FullName, "meta.json" );
|
||||
|
||||
public void ReloadCurrentMod()
|
||||
{
|
||||
|
|
@ -290,11 +317,12 @@ namespace Penumbra.UI
|
|||
if( metaPath.Length > 0 && File.Exists( metaPath ) )
|
||||
{
|
||||
_mod.Mod.Meta = ModMeta.LoadFromFile( metaPath ) ?? _mod.Mod.Meta;
|
||||
_base._menu._installedTab._modPanel._details.ResetState();
|
||||
_base._menu.InstalledTab.ModPanel.Details.ResetState();
|
||||
}
|
||||
|
||||
_mod.Mod.RefreshModFiles();
|
||||
_base._plugin.ModManager.CalculateEffectiveFileList();
|
||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||
_base._menu.EffectiveTab.RebuildFileList( _base._plugin.Configuration.ShowAdvanced );
|
||||
ResetModNamesLower();
|
||||
}
|
||||
|
||||
|
|
@ -302,8 +330,11 @@ namespace Penumbra.UI
|
|||
{
|
||||
var metaPath = GetCurrentModMetaFile();
|
||||
if( metaPath.Length > 0 )
|
||||
{
|
||||
File.WriteAllText( metaPath, JsonConvert.SerializeObject( _mod.Mod.Meta, Formatting.Indented ) );
|
||||
_base._menu._installedTab._modPanel._details.ResetState();
|
||||
}
|
||||
|
||||
_base._menu.InstalledTab.ModPanel.Details.ResetState();
|
||||
return metaPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Penumbra.UI
|
|||
if( ImGui.Button( LabelRediscoverButton ) )
|
||||
{
|
||||
_base.ReloadMods();
|
||||
_base._menu._installedTab._selector.ClearSelection();
|
||||
_base._menu.InstalledTab.Selector.ClearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ namespace Penumbra.UI
|
|||
{
|
||||
_config.IsEnabled = enabled;
|
||||
_configChanged = true;
|
||||
RefreshActors.RedrawAll(_base._plugin.PluginInterface.ClientState.Actors);
|
||||
Game.RefreshActors.RedrawAll( _base._plugin.PluginInterface.ClientState.Actors );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,15 +86,17 @@ namespace Penumbra.UI
|
|||
{
|
||||
_config.ShowAdvanced = showAdvanced;
|
||||
_configChanged = true;
|
||||
_base._menu._effectiveTab.RebuildFileList(showAdvanced);
|
||||
_base._menu.EffectiveTab.RebuildFileList( showAdvanced );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLogLoadedFilesBox()
|
||||
{
|
||||
if( _base._plugin.ResourceLoader != null )
|
||||
{
|
||||
ImGui.Checkbox( LabelLogLoadedFiles, ref _base._plugin.ResourceLoader.LogAllFiles );
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDisableNotificationsBox()
|
||||
{
|
||||
|
|
@ -112,9 +114,13 @@ namespace Penumbra.UI
|
|||
if( ImGui.Checkbox( LabelEnableHttpApi, ref http ) )
|
||||
{
|
||||
if( http )
|
||||
{
|
||||
_base._plugin.CreateWebServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_base._plugin.ShutdownWebServer();
|
||||
}
|
||||
|
||||
_config.EnableHttpApi = http;
|
||||
_configChanged = true;
|
||||
|
|
@ -141,7 +147,9 @@ namespace Penumbra.UI
|
|||
{
|
||||
var ret = ImGui.BeginTabItem( LabelTab );
|
||||
if( !ret )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawRootFolder();
|
||||
|
||||
|
|
@ -159,7 +167,9 @@ namespace Penumbra.UI
|
|||
DrawShowAdvancedBox();
|
||||
|
||||
if( _config.ShowAdvanced )
|
||||
{
|
||||
DrawAdvancedSettings();
|
||||
}
|
||||
|
||||
if( _configChanged )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,19 @@ namespace Penumbra
|
|||
array[ idx2 ] = tmp;
|
||||
}
|
||||
|
||||
public static int IndexOf< T >( this T[] array, Predicate< T > match )
|
||||
{
|
||||
for( var i = 0; i < array.Length; ++i )
|
||||
{
|
||||
if( match( array[ i ] ) )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void Swap< T >( this T[] array, T lhs, T rhs )
|
||||
{
|
||||
var idx1 = Array.IndexOf( array, lhs );
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ namespace Penumbra.Util
|
|||
{
|
||||
var k = ( uint )i;
|
||||
for( var j = 0; j < 8; j++ )
|
||||
{
|
||||
k = ( k & 1 ) != 0 ? ( k >> 1 ) ^ Poly : k >> 1;
|
||||
}
|
||||
|
||||
return k;
|
||||
} ).ToArray();
|
||||
|
|
@ -40,8 +42,10 @@ namespace Penumbra.Util
|
|||
public void Update( byte[] data )
|
||||
{
|
||||
foreach( var b in data )
|
||||
{
|
||||
Update( b );
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void Update( byte b )
|
||||
|
|
|
|||
|
|
@ -5,19 +5,14 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
public class SingleOrArrayConverter< T > : JsonConverter
|
||||
{
|
||||
public override bool CanConvert( Type objectType )
|
||||
{
|
||||
return (objectType == typeof(HashSet<T>));
|
||||
}
|
||||
public override bool CanConvert( Type objectType ) => objectType == typeof( HashSet< T > );
|
||||
|
||||
public override object ReadJson( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer )
|
||||
{
|
||||
var token = JToken.Load( reader );
|
||||
if (token.Type == JTokenType.Array)
|
||||
{
|
||||
return token.ToObject<HashSet<T>>();
|
||||
}
|
||||
return new HashSet<T>{ token.ToObject<T>() };
|
||||
return token.Type == JTokenType.Array
|
||||
? token.ToObject< HashSet< T > >()
|
||||
: new HashSet< T > { token.ToObject< T >() };
|
||||
}
|
||||
|
||||
public override bool CanWrite => false;
|
||||
|
|
@ -30,10 +25,7 @@ public class SingleOrArrayConverter<T> : JsonConverter
|
|||
|
||||
public class DictSingleOrArrayConverter< T, U > : JsonConverter
|
||||
{
|
||||
public override bool CanConvert( Type objectType )
|
||||
{
|
||||
return (objectType == typeof(Dictionary<T, HashSet<U>>));
|
||||
}
|
||||
public override bool CanConvert( Type objectType ) => objectType == typeof( Dictionary< T, HashSet< U > > );
|
||||
|
||||
public override object ReadJson( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer )
|
||||
{
|
||||
|
|
@ -43,6 +35,7 @@ public class DictSingleOrArrayConverter<T,U> : JsonConverter
|
|||
{
|
||||
return token.ToObject< HashSet< T > >();
|
||||
}
|
||||
|
||||
return new HashSet< T > { token.ToObject< T >() };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,11 @@ namespace Penumbra
|
|||
public static class StringPathExtensions
|
||||
{
|
||||
private static readonly char[] _invalid = Path.GetInvalidFileNameChars();
|
||||
|
||||
public static string ReplaceInvalidPathSymbols( this string s, string replacement = "_" )
|
||||
{
|
||||
return string.Join( replacement, s.Split( _invalid ) );
|
||||
}
|
||||
=> string.Join( replacement, s.Split( _invalid ) );
|
||||
|
||||
public static string RemoveInvalidPathSymbols( this string s )
|
||||
{
|
||||
return string.Concat( s.Split( _invalid ) );
|
||||
}
|
||||
=> string.Concat( s.Split( _invalid ) );
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue