mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Fix crashes on file selector, default mod creation for simple mods, default file edit button not working.
This commit is contained in:
parent
545536f66f
commit
60cf7e3c2e
5 changed files with 216 additions and 6 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit 6b918d67fb7370340b1b310a03dbf033b9950450
|
||||
Subproject commit a9443d8cd2b7446702d0bd6beea2a1b0ef747654
|
||||
|
|
@ -39,7 +39,7 @@ public partial class TexToolsImporter
|
|||
Mod.CreateMeta( ret, _currentModName, DefaultTexToolsData.Author, DefaultTexToolsData.Description, null, null );
|
||||
|
||||
ExtractSimpleModList( ret, modList, modData );
|
||||
|
||||
Mod.CreateDefaultFiles( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -96,6 +96,7 @@ public partial class TexToolsImporter
|
|||
: modList.Description, null, null );
|
||||
|
||||
ExtractSimpleModList( ret, modList.SimpleModsList, modData );
|
||||
Mod.CreateDefaultFiles( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,195 @@ using System.ComponentModel;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Logging;
|
||||
using Penumbra.GameData.ByteString;
|
||||
using Penumbra.Import;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
public partial class Mod
|
||||
{
|
||||
//public partial class Manager
|
||||
//{
|
||||
// public class Normalizer
|
||||
// {
|
||||
// private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Files = new();
|
||||
// private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Swaps = new();
|
||||
// private Dictionary< MetaManipulation, List< (MetaManipulation Value, IModGroup Group, ISubMod Option) > > Manips = new();
|
||||
//
|
||||
// public Normalizer( Mod mod )
|
||||
// {
|
||||
// // Default changes are irrelevant since they can only be overwritten.
|
||||
// foreach( var group in mod.Groups )
|
||||
// {
|
||||
// foreach( var option in group )
|
||||
// {
|
||||
// foreach( var (key, value) in option.Files )
|
||||
// {
|
||||
// if( !Files.TryGetValue( key, out var list ) )
|
||||
// {
|
||||
// list = new List< (FullPath Path, IModGroup Group, ISubMod Option) > { ( value, @group, option ) };
|
||||
// Files[ key ] = list;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// list.Add( ( value, @group, option ) );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Normalize a mod, this entails:
|
||||
// // - If
|
||||
// public static void Normalize( Mod mod )
|
||||
// {
|
||||
// NormalizeOptions( mod );
|
||||
// MergeSingleGroups( mod );
|
||||
// DeleteEmptyGroups( mod );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // Delete every option group that has either no options,
|
||||
// // or exclusively empty options.
|
||||
// // Triggers changes through calling ModManager.
|
||||
// private static void DeleteEmptyGroups( Mod mod )
|
||||
// {
|
||||
// for( var i = 0; i < mod.Groups.Count; ++i )
|
||||
// {
|
||||
// DeleteIdenticalOptions( mod, i );
|
||||
// var group = mod.Groups[ i ];
|
||||
// if( group.Count == 0 || group.All( o => o.FileSwaps.Count == 0 && o.Files.Count == 0 && o.Manipulations.Count == 0 ) )
|
||||
// {
|
||||
// Penumbra.ModManager.DeleteModGroup( mod, i-- );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Merge every non-optional group into the default mod.
|
||||
// // Overwrites default mod entries if necessary.
|
||||
// // Deletes the non-optional group afterwards.
|
||||
// // Triggers changes through calling ModManager.
|
||||
// private static void MergeSingleGroup( Mod mod )
|
||||
// {
|
||||
// var defaultMod = ( SubMod )mod.Default;
|
||||
// for( var i = 0; i < mod.Groups.Count; ++i )
|
||||
// {
|
||||
// var group = mod.Groups[ i ];
|
||||
// if( group.Type == SelectType.Single && group.Count == 1 )
|
||||
// {
|
||||
// defaultMod.MergeIn( group[ 0 ] );
|
||||
//
|
||||
// Penumbra.ModManager.DeleteModGroup( mod, i-- );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static void NotifyChanges( Mod mod, int groupIdx, ModOptionChangeType type, ref bool anyChanges )
|
||||
// {
|
||||
// if( anyChanges )
|
||||
// {
|
||||
// for( var i = 0; i < mod.Groups[ groupIdx ].Count; ++i )
|
||||
// {
|
||||
// Penumbra.ModManager.ModOptionChanged.Invoke( type, mod, groupIdx, i, -1 );
|
||||
// }
|
||||
//
|
||||
// anyChanges = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static void NormalizeOptions( Mod mod )
|
||||
// {
|
||||
// var defaultMod = ( SubMod )mod.Default;
|
||||
//
|
||||
// for( var i = 0; i < mod.Groups.Count; ++i )
|
||||
// {
|
||||
// var group = mod.Groups[ i ];
|
||||
// if( group.Type == SelectType.Multi || group.Count < 2 )
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// var firstOption = mod.Groups[ i ][ 0 ];
|
||||
// var anyChanges = false;
|
||||
// foreach( var (key, value) in firstOption.Files.ToList() )
|
||||
// {
|
||||
// if( group.Skip( 1 ).All( o => o.Files.TryGetValue( key, out var v ) && v.Equals( value ) ) )
|
||||
// {
|
||||
// anyChanges = true;
|
||||
// defaultMod.FileData[ key ] = value;
|
||||
// foreach( var option in group.Cast< SubMod >() )
|
||||
// {
|
||||
// option.FileData.Remove( key );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// NotifyChanges( mod, i, ModOptionChangeType.OptionFilesChanged, ref anyChanges );
|
||||
//
|
||||
// foreach( var (key, value) in firstOption.FileSwaps.ToList() )
|
||||
// {
|
||||
// if( group.Skip( 1 ).All( o => o.FileSwaps.TryGetValue( key, out var v ) && v.Equals( value ) ) )
|
||||
// {
|
||||
// anyChanges = true;
|
||||
// defaultMod.FileData[ key ] = value;
|
||||
// foreach( var option in group.Cast< SubMod >() )
|
||||
// {
|
||||
// option.FileSwapData.Remove( key );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// NotifyChanges( mod, i, ModOptionChangeType.OptionSwapsChanged, ref anyChanges );
|
||||
//
|
||||
// anyChanges = false;
|
||||
// foreach( var manip in firstOption.Manipulations.ToList() )
|
||||
// {
|
||||
// if( group.Skip( 1 ).All( o => ( ( HashSet< MetaManipulation > )o.Manipulations ).TryGetValue( manip, out var m )
|
||||
// && manip.EntryEquals( m ) ) )
|
||||
// {
|
||||
// anyChanges = true;
|
||||
// defaultMod.ManipulationData.Remove( manip );
|
||||
// defaultMod.ManipulationData.Add( manip );
|
||||
// foreach( var option in group.Cast< SubMod >() )
|
||||
// {
|
||||
// option.ManipulationData.Remove( manip );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// NotifyChanges( mod, i, ModOptionChangeType.OptionMetaChanged, ref anyChanges );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // Delete all options that are entirely identical.
|
||||
// // Deletes the later occurring option.
|
||||
// private static void DeleteIdenticalOptions( Mod mod, int groupIdx )
|
||||
// {
|
||||
// var group = mod.Groups[ groupIdx ];
|
||||
// for( var i = 0; i < group.Count; ++i )
|
||||
// {
|
||||
// var option = group[ i ];
|
||||
// for( var j = i + 1; j < group.Count; ++j )
|
||||
// {
|
||||
// var option2 = group[ j ];
|
||||
// if( option.Files.SetEquals( option2.Files )
|
||||
// && option.FileSwaps.SetEquals( option2.FileSwaps )
|
||||
// && option.Manipulations.SetEquals( option2.Manipulations ) )
|
||||
// {
|
||||
// Penumbra.ModManager.DeleteOption( mod, groupIdx, j-- );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
// TODO Everything
|
||||
//ublic class ModCleanup
|
||||
//
|
||||
|
|
|
|||
|
|
@ -82,6 +82,27 @@ public partial class Mod
|
|||
public IReadOnlySet< MetaManipulation > Manipulations
|
||||
=> ManipulationData;
|
||||
|
||||
// Insert all changes from the other submod.
|
||||
// Overwrites already existing changes in this mod.
|
||||
public void MergeIn( ISubMod other )
|
||||
{
|
||||
foreach( var (key, value) in other.Files )
|
||||
{
|
||||
FileData[ key ] = value;
|
||||
}
|
||||
|
||||
foreach( var (key, value) in other.FileSwaps )
|
||||
{
|
||||
FileSwapData[ key ] = value;
|
||||
}
|
||||
|
||||
foreach( var manip in other.Manipulations )
|
||||
{
|
||||
ManipulationData.Remove( manip );
|
||||
ManipulationData.Add( manip );
|
||||
}
|
||||
}
|
||||
|
||||
public void Load( DirectoryInfo basePath, JToken json, out int priority )
|
||||
{
|
||||
FileData.Clear();
|
||||
|
|
@ -148,6 +169,7 @@ public partial class Mod
|
|||
{
|
||||
File.Delete( file.FullName );
|
||||
}
|
||||
|
||||
ManipulationData.UnionWith( meta.MetaManipulations );
|
||||
|
||||
break;
|
||||
|
|
@ -163,6 +185,7 @@ public partial class Mod
|
|||
{
|
||||
File.Delete( file.FullName );
|
||||
}
|
||||
|
||||
ManipulationData.UnionWith( rgsp.MetaManipulations );
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public partial class ConfigWindow
|
|||
Process.Start( new ProcessStartInfo( _mod.BasePath.FullName ) { UseShellExecute = true } );
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiUtil.DrawDisabledButton( "Rename Mod Directory", buttonSize, "Not implemented yet", true );
|
||||
ImGui.SameLine();
|
||||
|
|
@ -136,8 +136,10 @@ public partial class ConfigWindow
|
|||
Penumbra.ModManager.ChangeModWebsite( _mod.Index, newWebsite );
|
||||
}
|
||||
|
||||
var reducedSize = new Vector2( _window._inputTextWidth.X - _window._iconButtonSize.X - ImGui.GetStyle().ItemSpacing.X, 0 );
|
||||
var spacing = new Vector2( 3 * ImGuiHelpers.GlobalScale );
|
||||
using var style = ImRaii.PushStyle( ImGuiStyleVar.ItemSpacing, spacing );
|
||||
|
||||
var reducedSize = new Vector2( _window._inputTextWidth.X - _window._iconButtonSize.X - spacing.X, 0 );
|
||||
if( ImGui.Button( "Edit Description", reducedSize ) )
|
||||
{
|
||||
_delayedActions.Enqueue( () => OpenEditDescriptionPopup( DescriptionFieldIdx ) );
|
||||
|
|
@ -148,7 +150,8 @@ public partial class ConfigWindow
|
|||
var tt = fileExists
|
||||
? "Open the metadata json file in the text editor of your choice."
|
||||
: "The metadata json file does not exist.";
|
||||
if( ImGuiUtil.DrawDisabledButton( FontAwesomeIcon.FileExport.ToIconString(), _window._iconButtonSize, tt, !fileExists, true ) )
|
||||
if( ImGuiUtil.DrawDisabledButton( $"{FontAwesomeIcon.FileExport.ToIconString()}##metaFile", _window._iconButtonSize, tt,
|
||||
!fileExists, true ) )
|
||||
{
|
||||
Process.Start( new ProcessStartInfo( _mod.MetaFile.FullName ) { UseShellExecute = true } );
|
||||
}
|
||||
|
|
@ -163,7 +166,8 @@ public partial class ConfigWindow
|
|||
tt = fileExists
|
||||
? "Open the default option json file in the text editor of your choice."
|
||||
: "The default option json file does not exist.";
|
||||
if( ImGuiUtil.DrawDisabledButton( FontAwesomeIcon.FileExport.ToIconString(), _window._iconButtonSize, tt, !fileExists, true ) )
|
||||
if( ImGuiUtil.DrawDisabledButton( $"{FontAwesomeIcon.FileExport.ToIconString()}##defaultFile", _window._iconButtonSize, tt,
|
||||
!fileExists, true ) )
|
||||
{
|
||||
Process.Start( new ProcessStartInfo( _mod.DefaultFile ) { UseShellExecute = true } );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue