mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +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.
|
// Store total number of manipulations for some ease of access.
|
||||||
[JsonProperty]
|
[JsonIgnore]
|
||||||
public int Count { get; private set; } = 0;
|
internal int Count = 0;
|
||||||
|
|
||||||
|
|
||||||
// Return an enumeration of all active meta manipulations for a given mod with given settings.
|
// 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,
|
var collection = JsonConvert.DeserializeObject< MetaCollection >( text,
|
||||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore } );
|
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;
|
return collection;
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Penumbra.Mod
|
||||||
MetaManipulations.SaveToFile( MetaCollection.FileName( basePath ) );
|
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 ) );
|
var newManipulations = MetaCollection.LoadFromFile( MetaCollection.FileName( basePath ) );
|
||||||
if( newManipulations == null )
|
if( newManipulations == null )
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Penumbra.Mod
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MetaManipulations = newManipulations;
|
MetaManipulations = newManipulations;
|
||||||
if( !MetaManipulations.Validate( meta ) )
|
if( validate && !MetaManipulations.Validate( meta ) )
|
||||||
{
|
{
|
||||||
ForceManipulationsUpdate( meta, basePath );
|
ForceManipulationsUpdate( meta, basePath );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace Penumbra.Mods
|
||||||
var metaChanges = mod.Meta.RefreshFromFile( mod.MetaFile );
|
var metaChanges = mod.Meta.RefreshFromFile( mod.MetaFile );
|
||||||
var fileChanges = mod.Resources.RefreshModFiles( mod.BasePath );
|
var fileChanges = mod.Resources.RefreshModFiles( mod.BasePath );
|
||||||
|
|
||||||
if( !recomputeMeta && !metaChanges && fileChanges == 0 )
|
if( !recomputeMeta && !reloadMeta && !metaChanges && fileChanges == 0 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -647,7 +647,7 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
private void DrawMetaManipulationsTab()
|
private void DrawMetaManipulationsTab()
|
||||||
{
|
{
|
||||||
if( Mod.Data.Resources.MetaManipulations.Count == 0 )
|
if( !_editMode && Mod.Data.Resources.MetaManipulations.Count == 0 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -665,7 +665,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
if( ImGui.CollapsingHeader( "Default" ) )
|
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}" ) )
|
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 )
|
if( changes )
|
||||||
{
|
{
|
||||||
Mod.Data.Resources.MetaManipulations.SaveToFile( MetaCollection.FileName( Mod.Data.BasePath ) );
|
Mod.Data.Resources.MetaManipulations.SaveToFile( MetaCollection.FileName( Mod.Data.BasePath ) );
|
||||||
|
Mod.Data.Resources.SetManipulations( Meta, Mod.Data.BasePath, false );
|
||||||
_selector.ReloadCurrentMod( true, false );
|
_selector.ReloadCurrentMod( true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,7 @@ namespace Penumbra.UI
|
||||||
return ret;
|
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;
|
var type = list[ manipIdx ].Type;
|
||||||
|
|
||||||
|
|
@ -549,6 +549,7 @@ namespace Penumbra.UI
|
||||||
ImGui.PopFont();
|
ImGui.PopFont();
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
--manipIdx;
|
--manipIdx;
|
||||||
|
--count;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -609,7 +610,7 @@ namespace Penumbra.UI
|
||||||
return ( MetaType )_newManipTypeIdx;
|
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;
|
var change = false;
|
||||||
if( ImGui.BeginPopup( popupName ) )
|
if( ImGui.BeginPopup( popupName ) )
|
||||||
|
|
@ -714,7 +715,9 @@ namespace Penumbra.UI
|
||||||
};
|
};
|
||||||
list.Add( manip );
|
list.Add( manip );
|
||||||
change = true;
|
change = true;
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
|
ImGui.CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
|
|
@ -723,7 +726,7 @@ namespace Penumbra.UI
|
||||||
return change;
|
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 numRows = _editMode ? 11 : 10;
|
||||||
var changes = false;
|
var changes = false;
|
||||||
|
|
@ -759,7 +762,7 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
for( var i = 0; i < list.Count; ++i )
|
for( var i = 0; i < list.Count; ++i )
|
||||||
{
|
{
|
||||||
changes |= DrawManipulationRow( ref i, list );
|
changes |= DrawManipulationRow( ref i, list, ref count );
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTable();
|
ImGui.EndTable();
|
||||||
|
|
@ -768,7 +771,7 @@ namespace Penumbra.UI
|
||||||
var popupName = $"##newManip{label}";
|
var popupName = $"##newManip{label}";
|
||||||
if( _editMode )
|
if( _editMode )
|
||||||
{
|
{
|
||||||
changes |= DrawNewManipulationPopup( $"##newManip{label}", list );
|
changes |= DrawNewManipulationPopup( $"##newManip{label}", list, ref count );
|
||||||
if( ImGui.Button( $"Add New Manipulation##{label}", Vector2.UnitX * -1 ) )
|
if( ImGui.Button( $"Add New Manipulation##{label}", Vector2.UnitX * -1 ) )
|
||||||
{
|
{
|
||||||
ImGui.OpenPopup( popupName );
|
ImGui.OpenPopup( popupName );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue