mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix the mod panels header not resetting data when a selected mod updates.
This commit is contained in:
parent
28752e2630
commit
f8331bc4d8
5 changed files with 32 additions and 10 deletions
|
|
@ -21,8 +21,11 @@ public sealed class ModDataChanged : EventWrapper<Action<ModDataChangeType, Mod,
|
|||
/// <seealso cref="Mods.Manager.ModCacheManager.OnModDataChange"/>
|
||||
ModCacheManager = 0,
|
||||
|
||||
/// <seealso cref="Mods.Manager.ModFileSystem.OnDataChange"/>
|
||||
/// <seealso cref="Mods.Manager.ModFileSystem.OnModDataChange"/>
|
||||
ModFileSystem = 0,
|
||||
|
||||
/// <seealso cref="UI.ModsTab.ModPanelHeader.OnModDataChange"/>
|
||||
ModPanelHeader = 0,
|
||||
}
|
||||
|
||||
public ModDataChanged()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public sealed class ModFileSystem : FileSystem<Mod>, IDisposable, ISavable
|
|||
Reload();
|
||||
Changed += OnChange;
|
||||
_communicator.ModDiscoveryFinished.Subscribe(Reload, ModDiscoveryFinished.Priority.ModFileSystem);
|
||||
_communicator.ModDataChanged.Subscribe(OnDataChange, ModDataChanged.Priority.ModFileSystem);
|
||||
_communicator.ModDataChanged.Subscribe(OnModDataChange, ModDataChanged.Priority.ModFileSystem);
|
||||
_communicator.ModPathChanged.Subscribe(OnModPathChange, ModPathChanged.Priority.ModFileSystem);
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ public sealed class ModFileSystem : FileSystem<Mod>, IDisposable, ISavable
|
|||
{
|
||||
_communicator.ModPathChanged.Unsubscribe(OnModPathChange);
|
||||
_communicator.ModDiscoveryFinished.Unsubscribe(Reload);
|
||||
_communicator.ModDataChanged.Unsubscribe(OnDataChange);
|
||||
_communicator.ModDataChanged.Unsubscribe(OnModDataChange);
|
||||
}
|
||||
|
||||
public struct ImportDate : ISortMode<Mod>
|
||||
|
|
@ -75,7 +75,7 @@ public sealed class ModFileSystem : FileSystem<Mod>, IDisposable, ISavable
|
|||
}
|
||||
|
||||
// Update sort order when defaulted mod names change.
|
||||
private void OnDataChange(ModDataChangeType type, Mod mod, string? oldName)
|
||||
private void OnModDataChange(ModDataChangeType type, Mod mod, string? oldName)
|
||||
{
|
||||
if (!type.HasFlag(ModDataChangeType.Name) || oldName == null || !FindLeaf(mod, out var leaf))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ public partial class ModEditWindow
|
|||
var file = tab.Mdl;
|
||||
var mesh = file.Meshes[meshIndex];
|
||||
|
||||
|
||||
// Mesh material
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
|
@ -171,7 +170,7 @@ public partial class ModEditWindow
|
|||
return ret;
|
||||
}
|
||||
|
||||
private bool DrawMaterialCombo(MdlTab tab, int meshIndex, bool disabled)
|
||||
private static bool DrawMaterialCombo(MdlTab tab, int meshIndex, bool disabled)
|
||||
{
|
||||
var mesh = tab.Mdl.Meshes[meshIndex];
|
||||
using var _ = ImRaii.Disabled(disabled);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Dalamud.Plugin;
|
||||
using Penumbra.Mods;
|
||||
using Penumbra.Services;
|
||||
using Penumbra.UI.AdvancedWindow;
|
||||
|
||||
namespace Penumbra.UI.ModsTab;
|
||||
|
|
@ -13,13 +14,13 @@ public class ModPanel : IDisposable
|
|||
private readonly ModPanelTabBar _tabs;
|
||||
|
||||
public ModPanel(DalamudPluginInterface pi, ModFileSystemSelector selector, ModEditWindow editWindow, ModPanelTabBar tabs,
|
||||
MultiModPanel multiModPanel)
|
||||
MultiModPanel multiModPanel, CommunicatorService communicator)
|
||||
{
|
||||
_selector = selector;
|
||||
_editWindow = editWindow;
|
||||
_tabs = tabs;
|
||||
_multiModPanel = multiModPanel;
|
||||
_header = new ModPanelHeader(pi);
|
||||
_header = new ModPanelHeader(pi, communicator);
|
||||
_selector.SelectionChanged += OnSelectionChange;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ using Dalamud.Plugin;
|
|||
using ImGuiNET;
|
||||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using Penumbra.Communication;
|
||||
using Penumbra.Mods;
|
||||
using Penumbra.Mods.Manager;
|
||||
using Penumbra.Services;
|
||||
using Penumbra.UI.Classes;
|
||||
|
||||
namespace Penumbra.UI.ModsTab;
|
||||
|
|
@ -13,8 +16,14 @@ public class ModPanelHeader : IDisposable
|
|||
/// <summary> We use a big, nice game font for the title. </summary>
|
||||
private readonly GameFontHandle _nameFont;
|
||||
|
||||
public ModPanelHeader(DalamudPluginInterface pi)
|
||||
=> _nameFont = pi.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
||||
private readonly CommunicatorService _communicator;
|
||||
|
||||
public ModPanelHeader(DalamudPluginInterface pi, CommunicatorService communicator)
|
||||
{
|
||||
_communicator = communicator;
|
||||
_nameFont = pi.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
||||
_communicator.ModDataChanged.Subscribe(OnModDataChange, ModDataChanged.Priority.ModPanelHeader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the header for the current mod,
|
||||
|
|
@ -76,6 +85,7 @@ public class ModPanelHeader : IDisposable
|
|||
public void Dispose()
|
||||
{
|
||||
_nameFont.Dispose();
|
||||
_communicator.ModDataChanged.Unsubscribe(OnModDataChange);
|
||||
}
|
||||
|
||||
// Header data.
|
||||
|
|
@ -218,4 +228,13 @@ public class ModPanelHeader : IDisposable
|
|||
ImGui.TextUnformatted(_modWebsite);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Just update the data when any relevant field changes. </summary>
|
||||
private void OnModDataChange(ModDataChangeType changeType, Mod mod, string? _2)
|
||||
{
|
||||
const ModDataChangeType relevantChanges =
|
||||
ModDataChangeType.Author | ModDataChangeType.Name | ModDataChangeType.Website | ModDataChangeType.Version;
|
||||
if ((changeType & relevantChanges) != 0)
|
||||
UpdateModData(mod);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue