mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Fix meta change counting and reloading on manual meta change edits.
This commit is contained in:
parent
bf355114f2
commit
1eee89ab4c
5 changed files with 23 additions and 13 deletions
|
|
@ -22,8 +22,8 @@ namespace Penumbra.Meta
|
|||
|
||||
|
||||
// Store total number of manipulations for some ease of access.
|
||||
[JsonProperty]
|
||||
public int Count { get; private set; } = 0;
|
||||
[JsonIgnore]
|
||||
internal int Count = 0;
|
||||
|
||||
|
||||
// Return an enumeration of all active meta manipulations for a given mod with given settings.
|
||||
|
|
@ -216,6 +216,12 @@ namespace Penumbra.Meta
|
|||
var collection = JsonConvert.DeserializeObject< MetaCollection >( text,
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore } );
|
||||
|
||||
if( collection != null )
|
||||
{
|
||||
collection.Count = collection.DefaultData.Count
|
||||
+ collection.GroupData.Values.SelectMany( kvp => kvp.Values ).Sum( l => l.Count );
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
catch( Exception e )
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Penumbra.Mod
|
|||
MetaManipulations.SaveToFile( MetaCollection.FileName( basePath ) );
|
||||
}
|
||||
|
||||
public void SetManipulations( ModMeta meta, DirectoryInfo basePath )
|
||||
public void SetManipulations( ModMeta meta, DirectoryInfo basePath, bool validate = true )
|
||||
{
|
||||
var newManipulations = MetaCollection.LoadFromFile( MetaCollection.FileName( basePath ) );
|
||||
if( newManipulations == null )
|
||||
|
|
@ -39,7 +39,7 @@ namespace Penumbra.Mod
|
|||
else
|
||||
{
|
||||
MetaManipulations = newManipulations;
|
||||
if( !MetaManipulations.Validate( meta ) )
|
||||
if( validate && !MetaManipulations.Validate( meta ) )
|
||||
{
|
||||
ForceManipulationsUpdate( meta, basePath );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace Penumbra.Mods
|
|||
var metaChanges = mod.Meta.RefreshFromFile( mod.MetaFile );
|
||||
var fileChanges = mod.Resources.RefreshModFiles( mod.BasePath );
|
||||
|
||||
if( !recomputeMeta && !metaChanges && fileChanges == 0 )
|
||||
if( !recomputeMeta && !reloadMeta && !metaChanges && fileChanges == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ namespace Penumbra.UI
|
|||
|
||||
private void DrawMetaManipulationsTab()
|
||||
{
|
||||
if( Mod.Data.Resources.MetaManipulations.Count == 0 )
|
||||
if( !_editMode && Mod.Data.Resources.MetaManipulations.Count == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ namespace Penumbra.UI
|
|||
{
|
||||
if( ImGui.CollapsingHeader( "Default" ) )
|
||||
{
|
||||
changes = DrawMetaManipulationsTable( "##DefaultManips", manips.DefaultData );
|
||||
changes = DrawMetaManipulationsTable( "##DefaultManips", manips.DefaultData, ref manips.Count );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -675,7 +675,7 @@ namespace Penumbra.UI
|
|||
{
|
||||
if( ImGui.CollapsingHeader( $"{group.Key} - {option.Key}" ) )
|
||||
{
|
||||
changes |= DrawMetaManipulationsTable( $"##{group.Key}{option.Key}manips", option.Value );
|
||||
changes |= DrawMetaManipulationsTable( $"##{group.Key}{option.Key}manips", option.Value, ref manips.Count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -683,6 +683,7 @@ namespace Penumbra.UI
|
|||
if( changes )
|
||||
{
|
||||
Mod.Data.Resources.MetaManipulations.SaveToFile( MetaCollection.FileName( Mod.Data.BasePath ) );
|
||||
Mod.Data.Resources.SetManipulations( Meta, Mod.Data.BasePath, false );
|
||||
_selector.ReloadCurrentMod( true, false );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ namespace Penumbra.UI
|
|||
return ret;
|
||||
}
|
||||
|
||||
private bool DrawManipulationRow( ref int manipIdx, IList< MetaManipulation > list )
|
||||
private bool DrawManipulationRow( ref int manipIdx, IList< MetaManipulation > list, ref int count )
|
||||
{
|
||||
var type = list[ manipIdx ].Type;
|
||||
|
||||
|
|
@ -549,6 +549,7 @@ namespace Penumbra.UI
|
|||
ImGui.PopFont();
|
||||
ImGui.TableNextRow();
|
||||
--manipIdx;
|
||||
--count;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -609,7 +610,7 @@ namespace Penumbra.UI
|
|||
return ( MetaType )_newManipTypeIdx;
|
||||
}
|
||||
|
||||
private bool DrawNewManipulationPopup( string popupName, IList< MetaManipulation > list )
|
||||
private bool DrawNewManipulationPopup( string popupName, IList< MetaManipulation > list, ref int count )
|
||||
{
|
||||
var change = false;
|
||||
if( ImGui.BeginPopup( popupName ) )
|
||||
|
|
@ -714,7 +715,9 @@ namespace Penumbra.UI
|
|||
};
|
||||
list.Add( manip );
|
||||
change = true;
|
||||
++count;
|
||||
}
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
|
|
@ -723,7 +726,7 @@ namespace Penumbra.UI
|
|||
return change;
|
||||
}
|
||||
|
||||
private bool DrawMetaManipulationsTable( string label, IList< MetaManipulation > list )
|
||||
private bool DrawMetaManipulationsTable( string label, IList< MetaManipulation > list, ref int count )
|
||||
{
|
||||
var numRows = _editMode ? 11 : 10;
|
||||
var changes = false;
|
||||
|
|
@ -759,7 +762,7 @@ namespace Penumbra.UI
|
|||
|
||||
for( var i = 0; i < list.Count; ++i )
|
||||
{
|
||||
changes |= DrawManipulationRow( ref i, list );
|
||||
changes |= DrawManipulationRow( ref i, list, ref count );
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
|
|
@ -768,7 +771,7 @@ namespace Penumbra.UI
|
|||
var popupName = $"##newManip{label}";
|
||||
if( _editMode )
|
||||
{
|
||||
changes |= DrawNewManipulationPopup( $"##newManip{label}", list );
|
||||
changes |= DrawNewManipulationPopup( $"##newManip{label}", list, ref count );
|
||||
if( ImGui.Button( $"Add New Manipulation##{label}", Vector2.UnitX * -1 ) )
|
||||
{
|
||||
ImGui.OpenPopup( popupName );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue